mirror of
https://github.com/PaperMC/Paper.git
synced 2025-05-19 05:30:23 -07:00
Add support for bonus chest configuration in WorldCreator (#12344)
This commit is contained in:
parent
de410d13ef
commit
33e8928f53
@ -2870,6 +2870,13 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
|
||||
*/
|
||||
public boolean canGenerateStructures();
|
||||
|
||||
/**
|
||||
* Checks if the bonus chest is enabled.
|
||||
*
|
||||
* @return {@code true} if the bonus chest is enabled, {@code false} otherwise
|
||||
*/
|
||||
boolean hasBonusChest();
|
||||
|
||||
/**
|
||||
* Gets whether the world is hardcore or not.
|
||||
*
|
||||
|
@ -23,6 +23,7 @@ public class WorldCreator {
|
||||
private boolean generateStructures = true;
|
||||
private String generatorSettings = "";
|
||||
private boolean hardcore = false;
|
||||
private boolean bonusChest = false;
|
||||
private net.kyori.adventure.util.TriState keepSpawnLoaded = net.kyori.adventure.util.TriState.NOT_SET; // Paper
|
||||
|
||||
/**
|
||||
@ -123,6 +124,7 @@ public class WorldCreator {
|
||||
type = world.getWorldType();
|
||||
generateStructures = world.canGenerateStructures();
|
||||
hardcore = world.isHardcore();
|
||||
bonusChest = world.hasBonusChest();
|
||||
this.keepSpawnLoaded = net.kyori.adventure.util.TriState.byBoolean(world.getKeepSpawnInMemory()); // Paper
|
||||
|
||||
return this;
|
||||
@ -146,6 +148,7 @@ public class WorldCreator {
|
||||
generateStructures = creator.generateStructures();
|
||||
generatorSettings = creator.generatorSettings();
|
||||
hardcore = creator.hardcore();
|
||||
bonusChest = creator.bonusChest();
|
||||
keepSpawnLoaded = creator.keepSpawnLoaded(); // Paper
|
||||
|
||||
return this;
|
||||
@ -451,7 +454,7 @@ public class WorldCreator {
|
||||
|
||||
/**
|
||||
* Gets whether the world will be hardcore or not.
|
||||
*
|
||||
* <p>
|
||||
* In a hardcore world the difficulty will be locked to hard.
|
||||
*
|
||||
* @return hardcore status
|
||||
@ -460,6 +463,27 @@ public class WorldCreator {
|
||||
return hardcore;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether a bonus chest should be generated or not.
|
||||
*
|
||||
* @param bonusChest indicating whether the bonus chest should be generated
|
||||
* @return This object, for chaining
|
||||
*/
|
||||
@NotNull
|
||||
public WorldCreator bonusChest(final boolean bonusChest) {
|
||||
this.bonusChest = bonusChest;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether the bonus chest feature is enabled.
|
||||
*
|
||||
* @return true if the bonus chest is enabled, false otherwise.
|
||||
*/
|
||||
public boolean bonusChest() {
|
||||
return bonusChest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the spawn chunks will be kept loaded. <br>
|
||||
* Setting this to false will also stop the spawn chunks from being generated
|
||||
|
@ -250,7 +250,7 @@
|
||||
+ // Paper start - expose FeatureElement wrapper for GameRules.Type.
|
||||
+ // Chosen over simply adding this to the inheritance to avoid reobf issues with spigot...
|
||||
+ public net.minecraft.world.flag.FeatureElement asFeatureElement() {
|
||||
+ return net.minecraft.world.level.GameRules.Type.this::requiredFeatures;
|
||||
+ return GameRules.Type.this::requiredFeatures;
|
||||
+ }
|
||||
+ // Paper end - expose FeatureElement wrapper for GameRules.Type.
|
||||
}
|
||||
|
@ -1345,7 +1345,7 @@ public final class CraftServer implements Server {
|
||||
registryAccess = levelDataAndDimensions.dimensions().dimensionsRegistryAccess();
|
||||
} else {
|
||||
LevelSettings levelSettings;
|
||||
WorldOptions worldOptions = new WorldOptions(creator.seed(), creator.generateStructures(), false);
|
||||
WorldOptions worldOptions = new WorldOptions(creator.seed(), creator.generateStructures(), creator.bonusChest());
|
||||
WorldDimensions worldDimensions;
|
||||
|
||||
DedicatedServerProperties.WorldDimensionData properties = new DedicatedServerProperties.WorldDimensionData(GsonHelper.parse((creator.generatorSettings().isEmpty()) ? "{}" : creator.generatorSettings()), creator.type().name().toLowerCase(Locale.ROOT));
|
||||
|
@ -1620,6 +1620,11 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
return this.world.serverLevelData.worldGenOptions().generateStructures();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBonusChest() {
|
||||
return this.world.serverLevelData.worldGenOptions().generateBonusChest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHardcore() {
|
||||
return this.world.getLevelData().isHardcore();
|
||||
|
Loading…
x
Reference in New Issue
Block a user