just to change from disabling spawn chunks to control over its size. Removes disableSpawnChunks, adds spawnChunksSize. Fixes #192

This commit is contained in:
gnembon committed 2020-04-13 00:59:55 -03:00
1 parent 19a01bee1b
commit 2a1d5542f1
12 files changed
+178 -75

No files matched your search

+27 -53
View File
@@ -5,13 +5,11 @@ import carpet.settings.Rule;
import carpet.settings.SettingsManager;
import carpet.settings.Validator;
import carpet.utils.Messenger;
import carpet.utils.SpawnChunks;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.dedicated.DedicatedServer;
import net.minecraft.server.world.ChunkTicketType;
import net.minecraft.server.world.ServerChunkManager;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Unit;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.ChunkPos;
@@ -236,13 +234,6 @@ public class CarpetSettings
@Rule( desc = "Pistons can push block entities, like hoppers, chests etc.", category = {EXPERIMENTAL, FEATURE} )
public static boolean movableBlockEntities = false;
/*@Rule(
desc = "Orange stained glass behaves like slime, but doesn't stick to it",
extra = "Only available for 1.14. in 1.15 use honey instead",
category = {EXPERIMENTAL, FEATURE}
)
public static boolean honeySlime = false;*/
@Rule( desc = "Saplings turn into dead shrubs in hot climates and no water access", category = FEATURE )
public static boolean desertShrubs = false;
@@ -356,9 +347,6 @@ public class CarpetSettings
@Rule(desc = "Pistons, Glass and Sponge can be broken faster with their appropriate tools", category = SURVIVAL)
public static boolean missingTools = false;
//@Rule(desc = "Alternative, persistent caching strategy for nether portals", category = {SURVIVAL, CREATIVE})
//public static boolean portalCaching = false; // ineffective in 1.15
@Rule(desc = "fill/clone/setblock and structure blocks cause block updates", category = CREATIVE)
public static boolean fillUpdates = true;
@@ -509,13 +497,9 @@ public class CarpetSettings
)
public static int viewDistance = 0;
private static class DisableSpawnChunksValidator extends Validator<Boolean> {
@Override public Boolean validate(ServerCommandSource source, ParsedRule<Boolean> currentRule, Boolean newValue, String string) {
if (currentRule.get().booleanValue() == newValue.booleanValue())
{
//must been some startup thing
return newValue;
}
public static class ChangeSpawnChunksValidator extends Validator<Integer> {
public static void changeSpawnSize(int size)
{
ServerWorld overworld = CarpetServer.minecraft_server.getWorld(DimensionType.OVERWORLD);
if (overworld != null) {
ChunkPos centerChunk = new ChunkPos(new BlockPos(
@@ -523,40 +507,37 @@ public class CarpetSettings
overworld.getLevelProperties().getSpawnY(),
overworld.getLevelProperties().getSpawnZ()
));
ServerChunkManager chunkManager = (ServerChunkManager) overworld.getChunkManager();
chunkManager.removeTicket(ChunkTicketType.START, centerChunk, 11, Unit.INSTANCE);
if (!newValue)
{
chunkManager.addTicket(ChunkTicketType.START, centerChunk, 11, Unit.INSTANCE);
}
SpawnChunks.changeSpawnChunks(overworld.getChunkManager(), centerChunk, size);
}
}
@Override public Integer validate(ServerCommandSource source, ParsedRule<Integer> currentRule, Integer newValue, String string) {
if (newValue < 0 || newValue > 32)
{
Messenger.m(source, "r spawn chunk size has to be between 0 and 32");
return null;
}
if (currentRule.get().intValue() == newValue.intValue())
{
//must been some startup thing
return newValue;
}
ServerWorld currentOverworld = CarpetServer.minecraft_server.getWorld(DimensionType.OVERWORLD);
if (currentOverworld != null)
{
changeSpawnSize(newValue);
}
return newValue;
}
}
@Rule(
desc = "Allows spawn chunks to unload",
desc = "Changes size of spawn chunks",
extra = {"Defines new radius", "setting it to 0 - disables spawn chunks"},
category = CREATIVE,
validate = DisableSpawnChunksValidator.class
)
public static boolean disableSpawnChunks = false;
/*private static class KelpLimit extends Validator<Integer>
{
@Override public Integer validate(ServerCommandSource source, ParsedRule<Integer> currentRule, Integer newValue, String string) {
return (newValue>=0 && newValue <=25)?newValue:null;
}
@Override
public String description() { return "You must choose a value from 0 to 25. 25 and all natural kelp can grow 25 blocks, choose 0 to make all generated kelp not to grow";}
}
@Rule(
desc = "limits growth limit of newly naturally generated kelp to this amount of blocks",
options = {"0", "2", "25"},
category = FEATURE,
strict = false,
validate = KelpLimit.class
options = {"0", "11"},
validate = ChangeSpawnChunksValidator.class
)
public static int kelpGenerationGrowthLimit = 25;*/
public static int spawnChunksSize = 11;
@Rule(desc = "Coral structures will grow with bonemeal from coral plants", category = FEATURE)
public static boolean renewableCoral = false;
@@ -573,13 +554,6 @@ public class CarpetSettings
@Rule(desc = "Spawning requires much less CPU and Memory", category = OPTIMIZATION)
public static boolean lagFreeSpawning = false;
//@Rule(
// desc = "Prevents horses and other mobs to wander into the distance after dismounting",
// extra = "Fixes issues with various Joergens wandering off and disappearing client-side",
// category = BUGFIX
//)
//public static boolean horseWanderingFix = false;
@Rule(
desc = "Allows structure mobs to spawn in flat worlds",