From ae0975d626317bf1cb16f3e413c5ed9d3db811e7 Mon Sep 17 00:00:00 2001 From: gnembon Date: Sun, 10 May 2020 01:42:19 -0300 Subject: [PATCH] mappings --- gradle.properties | 2 +- .../java/carpet/commands/SpawnCommand.java | 26 +++--- .../EntityNavigation_pathfindingMixin.java | 4 +- .../mixins/FlatChunkGeneratorMixin.java | 10 +-- .../FloatingIslandsChunkGeneratorMixin.java | 6 +- .../carpet/mixins/GuardianEntityMixin.java | 4 +- .../mixins/OverworldChunkGeneratorMixin.java | 4 +- .../mixins/ServerChunkManagerMixin.java | 6 +- .../carpet/mixins/SpawnHelperInnerMixin.java | 17 ++-- .../java/carpet/mixins/SpawnHelperMixin.java | 40 ++++----- .../carpet/mixins/VillagerEntity_aiMixin.java | 4 +- .../java/carpet/script/CarpetExpression.java | 6 +- .../script/argument/Vector3Argument.java | 2 +- .../java/carpet/script/value/BlockValue.java | 2 +- .../java/carpet/script/value/EntityValue.java | 2 +- src/main/java/carpet/utils/BlockInfo.java | 11 ++- src/main/java/carpet/utils/Messenger.java | 4 +- .../carpet/utils/PerimeterDiagnostics.java | 22 ++--- src/main/java/carpet/utils/SpawnReporter.java | 88 +++++++++---------- src/main/java/carpet/utils/WoolTool.java | 4 +- 20 files changed, 130 insertions(+), 134 deletions(-) diff --git a/gradle.properties b/gradle.properties index 5027ae3b..01d02784 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx1G # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html minecraft_version=20w19a - yarn_mappings=20w19a+build.1 + yarn_mappings=20w19a+build.9 loader_version=0.8.2+build.194 # Mod Properties diff --git a/src/main/java/carpet/commands/SpawnCommand.java b/src/main/java/carpet/commands/SpawnCommand.java index 86aa9375..c15ccfb5 100644 --- a/src/main/java/carpet/commands/SpawnCommand.java +++ b/src/main/java/carpet/commands/SpawnCommand.java @@ -13,7 +13,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; import net.minecraft.command.arguments.BlockPosArgumentType; import net.minecraft.command.arguments.DimensionArgumentType; -import net.minecraft.entity.EntityCategory; +import net.minecraft.entity.SpawnGroup; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.util.DyeColor; @@ -57,7 +57,7 @@ public class SpawnCommand then(literal("stop"). executes( (c) -> stopTracking(c.getSource()))). then(argument("type", word()). - suggests( (c, b) -> suggestMatching(Arrays.stream(EntityCategory.values()).map(EntityCategory::getName),b)). + suggests( (c, b) -> suggestMatching(Arrays.stream(SpawnGroup.values()).map(SpawnGroup::getName),b)). executes( (c) -> recentSpawnsForType(c.getSource(), getString(c, "type"))))). then(literal("test"). executes( (c)-> runTest(c.getSource(), 72000, null)). @@ -80,7 +80,7 @@ public class SpawnCommand then(literal("reset"). executes( (c) -> resetSpawnRates(c.getSource()))). then(argument("type", word()). - suggests( (c, b) -> suggestMatching(Arrays.stream(EntityCategory.values()).map(EntityCategory::getName),b)). + suggests( (c, b) -> suggestMatching(Arrays.stream(SpawnGroup.values()).map(SpawnGroup::getName),b)). then(argument("rounds", integer(0)). suggests( (c, b) -> suggestMatching(new String[]{"1"},b)). executes( (c) -> setSpawnRates( @@ -97,19 +97,19 @@ public class SpawnCommand then(literal("entities"). executes( (c) -> generalMobcaps(c.getSource()) ). then(argument("type", string()). - suggests( (c, b)->suggestMatching(Arrays.stream(EntityCategory.values()).map(EntityCategory::getName), b)). + suggests( (c, b)->suggestMatching(Arrays.stream(SpawnGroup.values()).map(SpawnGroup::getName), b)). executes( (c) -> listEntitiesOfType(c.getSource(), getString(c, "type"))))); dispatcher.register(literalargumentbuilder); } - private static EntityCategory getCategory(String string) throws CommandSyntaxException + private static SpawnGroup getCategory(String string) throws CommandSyntaxException { - if (!Arrays.stream(EntityCategory.values()).map(EntityCategory::getName).collect(Collectors.toSet()).contains(string)) + if (!Arrays.stream(SpawnGroup.values()).map(SpawnGroup::getName).collect(Collectors.toSet()).contains(string)) { - throw new SimpleCommandExceptionType(Messenger.c("r Wrong mob type: "+string+" should be "+ Arrays.stream(EntityCategory.values()).map(EntityCategory::getName).collect(Collectors.joining(", ")))).create(); + throw new SimpleCommandExceptionType(Messenger.c("r Wrong mob type: "+string+" should be "+ Arrays.stream(SpawnGroup.values()).map(SpawnGroup::getName).collect(Collectors.joining(", ")))).create(); } - return EntityCategory.valueOf(string.toUpperCase()); + return SpawnGroup.valueOf(string.toUpperCase()); } @@ -166,7 +166,7 @@ public class SpawnCommand private static int recentSpawnsForType(ServerCommandSource source, String mob_type) throws CommandSyntaxException { - EntityCategory cat = getCategory(mob_type); + SpawnGroup cat = getCategory(mob_type); Messenger.send(source, SpawnReporter.recent_spawns(source.getWorld(), cat)); return 1; } @@ -231,7 +231,7 @@ public class SpawnCommand private static int resetSpawnRates(ServerCommandSource source) { - for (EntityCategory s: SpawnReporter.spawn_tries.keySet()) + for (SpawnGroup s: SpawnReporter.spawn_tries.keySet()) { SpawnReporter.spawn_tries.put(s,1); } @@ -242,7 +242,7 @@ public class SpawnCommand private static int setSpawnRates(ServerCommandSource source, String mobtype, int rounds) throws CommandSyntaxException { - EntityCategory cat = getCategory(mobtype); + SpawnGroup cat = getCategory(mobtype); SpawnReporter.spawn_tries.put(cat, rounds); Messenger.m(source, "gi "+mobtype+" mobs will now spawn "+rounds+" times per tick"); return 1; @@ -250,7 +250,7 @@ public class SpawnCommand private static int setMobcaps(ServerCommandSource source, int hostile_cap) { - double desired_ratio = (double)hostile_cap/ EntityCategory.MONSTER.getSpawnCap(); + double desired_ratio = (double)hostile_cap/ SpawnGroup.MONSTER.getCapacity(); SpawnReporter.mobcap_exponent = 4.0*Math.log(desired_ratio)/Math.log(2.0); Messenger.m(source, String.format("gi Mobcaps for hostile mobs changed to %d, other groups will follow", hostile_cap)); return 1; @@ -264,7 +264,7 @@ public class SpawnCommand private static int listEntitiesOfType(ServerCommandSource source, String mobtype) throws CommandSyntaxException { - EntityCategory cat = getCategory(mobtype); + SpawnGroup cat = getCategory(mobtype); Messenger.send(source, SpawnReporter.printEntitiesByType(cat, source.getWorld())); return 1; } diff --git a/src/main/java/carpet/mixins/EntityNavigation_pathfindingMixin.java b/src/main/java/carpet/mixins/EntityNavigation_pathfindingMixin.java index 56bf184a..b819f013 100644 --- a/src/main/java/carpet/mixins/EntityNavigation_pathfindingMixin.java +++ b/src/main/java/carpet/mixins/EntityNavigation_pathfindingMixin.java @@ -36,7 +36,7 @@ public abstract class EntityNavigation_pathfindingMixin Path path = findPathToAny(set_1, int_1, boolean_1, int_2); long finish = System.nanoTime(); float duration = (1.0F*((finish - start)/1000))/1000; - set_1.forEach(b -> PathfindingVisualizer.slowPath(entity, Vec3d.method_24955(b), duration, path != null)); // ground centered position + set_1.forEach(b -> PathfindingVisualizer.slowPath(entity, Vec3d.ofBottomCenter(b), duration, path != null)); // ground centered position return path; } @@ -52,7 +52,7 @@ public abstract class EntityNavigation_pathfindingMixin Path path = findPathToAny(set_1, int_1, boolean_1, int_2); long finish = System.nanoTime(); float duration = (1.0F*((finish - start)/1000))/1000; - set_1.forEach(b -> PathfindingVisualizer.slowPath(entity, Vec3d.method_24955(b), duration, path != null)); + set_1.forEach(b -> PathfindingVisualizer.slowPath(entity, Vec3d.ofBottomCenter(b), duration, path != null)); return path; } } diff --git a/src/main/java/carpet/mixins/FlatChunkGeneratorMixin.java b/src/main/java/carpet/mixins/FlatChunkGeneratorMixin.java index af98fd14..74e0ad8e 100644 --- a/src/main/java/carpet/mixins/FlatChunkGeneratorMixin.java +++ b/src/main/java/carpet/mixins/FlatChunkGeneratorMixin.java @@ -2,7 +2,7 @@ package carpet.mixins; import carpet.CarpetSettings; import net.minecraft.block.Blocks; -import net.minecraft.entity.EntityCategory; +import net.minecraft.entity.SpawnGroup; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; import net.minecraft.world.biome.Biome; @@ -25,23 +25,23 @@ public abstract class FlatChunkGeneratorMixin extends ChunkGenerator getEntitySpawnList(StructureAccessor arg, EntityCategory category, BlockPos pos) + public List getEntitySpawnList(StructureAccessor arg, SpawnGroup category, BlockPos pos) { if (CarpetSettings.flatWorldStructureSpawning) { if (Feature.SWAMP_HUT.method_14029(this.world, arg, pos)) { - if (category == EntityCategory.MONSTER) + if (category == SpawnGroup.MONSTER) { return Feature.SWAMP_HUT.getMonsterSpawns(); } - if (category == EntityCategory.CREATURE) + if (category == SpawnGroup.CREATURE) { return Feature.SWAMP_HUT.getCreatureSpawns(); } } - else if (category == EntityCategory.MONSTER) + else if (category == SpawnGroup.MONSTER) { if (Feature.PILLAGER_OUTPOST.isApproximatelyInsideStructure(this.world, arg, pos)) { diff --git a/src/main/java/carpet/mixins/FloatingIslandsChunkGeneratorMixin.java b/src/main/java/carpet/mixins/FloatingIslandsChunkGeneratorMixin.java index 045d62eb..2f1e6967 100644 --- a/src/main/java/carpet/mixins/FloatingIslandsChunkGeneratorMixin.java +++ b/src/main/java/carpet/mixins/FloatingIslandsChunkGeneratorMixin.java @@ -1,7 +1,7 @@ package carpet.mixins; import carpet.CarpetSettings; -import net.minecraft.entity.EntityCategory; +import net.minecraft.entity.SpawnGroup; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; import net.minecraft.world.biome.Biome; @@ -24,9 +24,9 @@ public abstract class FloatingIslandsChunkGeneratorMixin extends SurfaceChunkGen } @Override - public List getEntitySpawnList(StructureAccessor arg, EntityCategory category, BlockPos pos) + public List getEntitySpawnList(StructureAccessor arg, SpawnGroup category, BlockPos pos) { - if (CarpetSettings.shulkerSpawningInEndCities && EntityCategory.MONSTER == category) + if (CarpetSettings.shulkerSpawningInEndCities && SpawnGroup.MONSTER == category) { if (Feature.END_CITY.isInsideStructure(this.world, arg, pos)) { diff --git a/src/main/java/carpet/mixins/GuardianEntityMixin.java b/src/main/java/carpet/mixins/GuardianEntityMixin.java index 62c504f7..7c909804 100644 --- a/src/main/java/carpet/mixins/GuardianEntityMixin.java +++ b/src/main/java/carpet/mixins/GuardianEntityMixin.java @@ -4,7 +4,7 @@ import carpet.CarpetSettings; import net.minecraft.entity.EntityData; import net.minecraft.entity.EntityType; import net.minecraft.entity.LightningEntity; -import net.minecraft.entity.SpawnType; +import net.minecraft.entity.SpawnReason; import net.minecraft.entity.mob.ElderGuardianEntity; import net.minecraft.entity.mob.GuardianEntity; import net.minecraft.entity.mob.HostileEntity; @@ -28,7 +28,7 @@ public abstract class GuardianEntityMixin extends HostileEntity { ElderGuardianEntity elderGuardian = new ElderGuardianEntity(EntityType.ELDER_GUARDIAN ,this.world); elderGuardian.refreshPositionAndAngles(this.getX(), this.getY(), this.getZ(), this.yaw, this.pitch); - elderGuardian.initialize(this.world ,this.world.getLocalDifficulty(elderGuardian.getBlockPos()), SpawnType.CONVERSION, (EntityData)null, (CompoundTag)null); + elderGuardian.initialize(this.world ,this.world.getLocalDifficulty(elderGuardian.getBlockPos()), SpawnReason.CONVERSION, (EntityData)null, (CompoundTag)null); elderGuardian.setAiDisabled(this.isAiDisabled()); if (this.hasCustomName()) diff --git a/src/main/java/carpet/mixins/OverworldChunkGeneratorMixin.java b/src/main/java/carpet/mixins/OverworldChunkGeneratorMixin.java index 709cc45e..619b33b1 100644 --- a/src/main/java/carpet/mixins/OverworldChunkGeneratorMixin.java +++ b/src/main/java/carpet/mixins/OverworldChunkGeneratorMixin.java @@ -1,7 +1,7 @@ package carpet.mixins; import carpet.CarpetSettings; -import net.minecraft.entity.EntityCategory; +import net.minecraft.entity.SpawnGroup; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; import net.minecraft.world.biome.Biome; @@ -29,7 +29,7 @@ public abstract class OverworldChunkGeneratorMixin extends SurfaceChunkGenerator @Inject(method = "getEntitySpawnList", at = @At(value = "INVOKE", ordinal = 1, shift = At.Shift.BEFORE, target = "Lnet/minecraft/world/gen/feature/StructureFeature;isApproximatelyInsideStructure(Lnet/minecraft/world/IWorld;Lnet/minecraft/world/gen/StructureAccessor;Lnet/minecraft/util/math/BlockPos;)Z"), cancellable = true) - private void onGetEntitySpawnList(StructureAccessor arg, EntityCategory entityCategory, BlockPos blockPos, CallbackInfoReturnable> cir) + private void onGetEntitySpawnList(StructureAccessor arg, SpawnGroup entityCategory, BlockPos blockPos, CallbackInfoReturnable> cir) { if (CarpetSettings.huskSpawningInTemples) { diff --git a/src/main/java/carpet/mixins/ServerChunkManagerMixin.java b/src/main/java/carpet/mixins/ServerChunkManagerMixin.java index d86941f1..83bd1774 100644 --- a/src/main/java/carpet/mixins/ServerChunkManagerMixin.java +++ b/src/main/java/carpet/mixins/ServerChunkManagerMixin.java @@ -4,7 +4,7 @@ import carpet.fakes.ServerChunkManagerInterface; import carpet.utils.SpawnReporter; import it.unimi.dsi.fastutil.objects.Object2IntMap; import net.minecraft.class_5217; -import net.minecraft.entity.EntityCategory; +import net.minecraft.entity.SpawnGroup; import net.minecraft.server.world.ChunkTicketManager; import net.minecraft.server.world.ServerChunkManager; import net.minecraft.server.world.ServerWorld; @@ -56,7 +56,7 @@ public abstract class ServerChunkManagerMixin implements ServerChunkManagerInter //local spawns now need to be tracked globally cause each calll is just for chunk SpawnReporter.local_spawns = new HashMap<>(); SpawnReporter.first_chunk_marker = new HashSet<>(); - for (EntityCategory cat : EntityCategory.values()) + for (SpawnGroup cat : SpawnGroup.values()) { Pair key = Pair.of(dim, cat); SpawnReporter.overall_spawn_ticks.put(key, @@ -75,7 +75,7 @@ public abstract class ServerChunkManagerMixin implements ServerChunkManagerInter boolean boolean_3 = levelProperties_1.getTime() % 400L == 0L; if (SpawnReporter.track_spawns > 0L && SpawnReporter.local_spawns != null) { - for (EntityCategory cat: EntityCategory.values()) + for (SpawnGroup cat: SpawnGroup.values()) { DimensionType dim = world.dimension.getType(); Pair key = Pair.of(world.dimension.getType(), cat); diff --git a/src/main/java/carpet/mixins/SpawnHelperInnerMixin.java b/src/main/java/carpet/mixins/SpawnHelperInnerMixin.java index 6d620e2e..f2f48e1c 100644 --- a/src/main/java/carpet/mixins/SpawnHelperInnerMixin.java +++ b/src/main/java/carpet/mixins/SpawnHelperInnerMixin.java @@ -4,7 +4,7 @@ import carpet.fakes.SpawnHelperInnerInterface; import carpet.utils.SpawnReporter; import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; -import net.minecraft.entity.EntityCategory; +import net.minecraft.entity.SpawnGroup; import net.minecraft.util.math.GravityField; import net.minecraft.world.SpawnHelper; import org.spongepowered.asm.mixin.Final; @@ -19,25 +19,18 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(SpawnHelper.Info.class) public class SpawnHelperInnerMixin implements SpawnHelperInnerInterface { - //@Shadow @Final private int field_24394; - - //@Shadow @Final private Object2IntMap field_24395; - - //@Shadow @Final private class_5263 field_24396; - @Shadow @Final private int spawningChunkCount; - @Shadow @Final private Object2IntOpenHashMap categoryToCount; - @Shadow @Final private GravityField densityField; + @Shadow @Final private Object2IntOpenHashMap groupToCount; @Inject(method = "isBelowCap", at = @At("HEAD"), cancellable = true) - private void changeMobCaps(EntityCategory entityCategory, CallbackInfoReturnable cir) + private void changeMobCaps(SpawnGroup entityCategory, CallbackInfoReturnable cir) { - int newCap = (int) ((double)entityCategory.getSpawnCap()*(Math.pow(2.0,(SpawnReporter.mobcap_exponent/4)))); + int newCap = (int) ((double)entityCategory.getCapacity()*(Math.pow(2.0,(SpawnReporter.mobcap_exponent/4)))); int i = newCap * spawningChunkCount / (int)Math.pow(17.0D, 2.0D); - cir.setReturnValue(categoryToCount.getInt(entityCategory) < i); + cir.setReturnValue(groupToCount.getInt(entityCategory) < i); } @Override diff --git a/src/main/java/carpet/mixins/SpawnHelperMixin.java b/src/main/java/carpet/mixins/SpawnHelperMixin.java index 4a3eb7cd..51021460 100644 --- a/src/main/java/carpet/mixins/SpawnHelperMixin.java +++ b/src/main/java/carpet/mixins/SpawnHelperMixin.java @@ -7,10 +7,10 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.FenceGateBlock; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityCategory; +import net.minecraft.entity.SpawnGroup; import net.minecraft.entity.EntityData; import net.minecraft.entity.EntityType; -import net.minecraft.entity.SpawnType; +import net.minecraft.entity.SpawnReason; import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.CompoundTag; @@ -44,9 +44,9 @@ public class SpawnHelperMixin { @Shadow @Final private static int CHUNK_AREA; - @Shadow @Final private static EntityCategory[] SPAWNABLE_CATEGORIES; + @Shadow @Final private static SpawnGroup[] SPAWNABLE_GROUPS; - @Redirect(method = "canSpawn(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/entity/EntityCategory;Lnet/minecraft/world/gen/StructureAccessor;Lnet/minecraft/world/gen/chunk/ChunkGenerator;Lnet/minecraft/world/biome/Biome$SpawnEntry;Lnet/minecraft/util/math/BlockPos$Mutable;D)Z", at = @At( + @Redirect(method = "canSpawn(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/entity/SpawnGroup;Lnet/minecraft/world/gen/StructureAccessor;Lnet/minecraft/world/gen/chunk/ChunkGenerator;Lnet/minecraft/world/biome/Biome$SpawnEntry;Lnet/minecraft/util/math/BlockPos$Mutable;D)Z", at = @At( value = "INVOKE", target = "Lnet/minecraft/server/world/ServerWorld;doesNotCollide(Lnet/minecraft/util/math/Box;)Z" )) @@ -149,7 +149,7 @@ public class SpawnHelperMixin return entityType.create(world_1); } - @Redirect(method = "spawnEntitiesInChunk(Lnet/minecraft/entity/EntityCategory;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/chunk/Chunk;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/SpawnHelper$Checker;Lnet/minecraft/world/SpawnHelper$Runner;)V", at = @At( + @Redirect(method = "spawnEntitiesInChunk(Lnet/minecraft/entity/SpawnGroup;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/chunk/Chunk;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/SpawnHelper$Checker;Lnet/minecraft/world/SpawnHelper$Runner;)V", at = @At( value = "INVOKE", target = "Lnet/minecraft/server/world/ServerWorld;spawnEntity(Lnet/minecraft/entity/Entity;)Z" )) @@ -164,7 +164,7 @@ public class SpawnHelperMixin SpawnReporter.registerSpawn( world.dimension.getType(), (MobEntity) entity_1, - entity_1.getType().getCategory(), + entity_1.getType().getSpawnGroup(), entity_1.getBlockPos()); } if (!SpawnReporter.mock_spawns) @@ -172,26 +172,26 @@ public class SpawnHelperMixin return false; } - @Redirect(method = "spawnEntitiesInChunk(Lnet/minecraft/entity/EntityCategory;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/chunk/Chunk;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/SpawnHelper$Checker;Lnet/minecraft/world/SpawnHelper$Runner;)V", at = @At( + @Redirect(method = "spawnEntitiesInChunk(Lnet/minecraft/entity/SpawnGroup;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/chunk/Chunk;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/SpawnHelper$Checker;Lnet/minecraft/world/SpawnHelper$Runner;)V", at = @At( value = "INVOKE", - target = "Lnet/minecraft/entity/mob/MobEntity;initialize(Lnet/minecraft/world/IWorld;Lnet/minecraft/world/LocalDifficulty;Lnet/minecraft/entity/SpawnType;Lnet/minecraft/entity/EntityData;Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/entity/EntityData;" + target = "Lnet/minecraft/entity/mob/MobEntity;initialize(Lnet/minecraft/world/IWorld;Lnet/minecraft/world/LocalDifficulty;Lnet/minecraft/entity/SpawnReason;Lnet/minecraft/entity/EntityData;Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/entity/EntityData;" )) - private static EntityData spawnEntity(MobEntity mobEntity, IWorld iWorld_1, LocalDifficulty localDifficulty_1, SpawnType spawnType_1, EntityData entityData_1, CompoundTag compoundTag_1) + private static EntityData spawnEntity(MobEntity mobEntity, IWorld iWorld_1, LocalDifficulty localDifficulty_1, SpawnReason spawnType_1, EntityData entityData_1, CompoundTag compoundTag_1) { if (!SpawnReporter.mock_spawns) return mobEntity.initialize(iWorld_1, localDifficulty_1, spawnType_1, entityData_1, compoundTag_1); return null; } - @Redirect(method = "spawnEntitiesInChunk(Lnet/minecraft/entity/EntityCategory;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/chunk/Chunk;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/SpawnHelper$Checker;Lnet/minecraft/world/SpawnHelper$Runner;)V", at = @At( + @Redirect(method = "spawnEntitiesInChunk(Lnet/minecraft/entity/SpawnGroup;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/chunk/Chunk;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/SpawnHelper$Checker;Lnet/minecraft/world/SpawnHelper$Runner;)V", at = @At( value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;squaredDistanceTo(DDD)D" )) private static double getSqDistanceTo(PlayerEntity playerEntity, double double_1, double double_2, double double_3, - EntityCategory entityCategory, ServerWorld serverWorld, Chunk chunk, BlockPos blockPos) + SpawnGroup entityCategory, ServerWorld serverWorld, Chunk chunk, BlockPos blockPos) { double distanceTo = playerEntity.squaredDistanceTo(double_1, double_2, double_3); - if (CarpetSettings.lagFreeSpawning && distanceTo > 16384.0D && entityCategory != EntityCategory.CREATURE) + if (CarpetSettings.lagFreeSpawning && distanceTo > 16384.0D && entityCategory != SpawnGroup.CREATURE) return 0.0; return distanceTo; } @@ -202,10 +202,10 @@ public class SpawnHelperMixin @Redirect(method = "spawn", at = @At( value = "INVOKE", - target = "Lnet/minecraft/world/SpawnHelper;spawnEntitiesInChunk(Lnet/minecraft/entity/EntityCategory;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/chunk/WorldChunk;Lnet/minecraft/world/SpawnHelper$Checker;Lnet/minecraft/world/SpawnHelper$Runner;)V" + target = "Lnet/minecraft/world/SpawnHelper;spawnEntitiesInChunk(Lnet/minecraft/entity/SpawnGroup;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/chunk/WorldChunk;Lnet/minecraft/world/SpawnHelper$Checker;Lnet/minecraft/world/SpawnHelper$Runner;)V" )) // inject our repeat of spawns if more spawn ticks per tick are chosen. - private static void spawnMultipleTimes(EntityCategory category, ServerWorld world, WorldChunk chunk, SpawnHelper.Checker checker, SpawnHelper.Runner runner) + private static void spawnMultipleTimes(SpawnGroup category, ServerWorld world, WorldChunk chunk, SpawnHelper.Checker checker, SpawnHelper.Runner runner) { for (int i = 0; i < SpawnReporter.spawn_tries.get(category); i++) { @@ -217,11 +217,11 @@ public class SpawnHelperMixin /* @Redirect(method = "spawn", at = @At( value = "INVOKE", - target = "Lnet/minecraft/world/SpawnHelper$Info;isBelowCap(Lnet/minecraft/entity/EntityCategory;)Z" + target = "Lnet/minecraft/world/SpawnHelper$Info;isBelowCap(Lnet/minecraft/entity/SpawnGroup;)Z" )) // allows to change mobcaps and captures each category try per dimension before it fails due to full mobcaps. private static boolean changeMobcaps( - SpawnHelper.Info info, EntityCategory entityCategory, + SpawnHelper.Info info, SpawnGroup entityCategory, ServerWorld serverWorld, WorldChunk chunk, SpawnHelper.Info info_outer, boolean spawnAnimals, boolean spawnMonsters, boolean shouldSpawnAnimals ) { @@ -273,18 +273,18 @@ public class SpawnHelperMixin { if (SpawnReporter.track_spawns > 0L) { - EntityCategory[] var6 = SPAWNABLE_CATEGORIES; + SpawnGroup[] var6 = SPAWNABLE_GROUPS; int var7 = var6.length; for(int var8 = 0; var8 < var7; ++var8) { - EntityCategory entityCategory = var6[var8]; + SpawnGroup entityCategory = var6[var8]; if ((spawnAnimals || !entityCategory.isPeaceful()) && (spawnMonsters || entityCategory.isPeaceful()) && (shouldSpawnAnimals || !entityCategory.isAnimal()) ) { DimensionType dim = world.dimension.getType(); - int newCap = (int) ((double)entityCategory.getSpawnCap()*(Math.pow(2.0,(SpawnReporter.mobcap_exponent/4)))); + int newCap = (int) ((double)entityCategory.getCapacity()*(Math.pow(2.0,(SpawnReporter.mobcap_exponent/4)))); int int_2 = SpawnReporter.chunkCounts.get(dim); // eligible chunks for spawning int int_3 = newCap * int_2 / CHUNK_AREA; //current spawning limits - int mobCount = info.getCategoryToCount().getInt(entityCategory); + int mobCount = info.getGroupToCount().getInt(entityCategory); if (SpawnReporter.track_spawns > 0L && !SpawnReporter.first_chunk_marker.contains(entityCategory)) { diff --git a/src/main/java/carpet/mixins/VillagerEntity_aiMixin.java b/src/main/java/carpet/mixins/VillagerEntity_aiMixin.java index 3f06977f..16c53eb8 100644 --- a/src/main/java/carpet/mixins/VillagerEntity_aiMixin.java +++ b/src/main/java/carpet/mixins/VillagerEntity_aiMixin.java @@ -128,7 +128,7 @@ public abstract class VillagerEntity_aiMixin extends AbstractTraderEntity else { - ParticleDisplay.drawParticleLine((ServerPlayerEntity) playerEntity_1, getPos(), Vec3d.method_24953(bedPos.getPos()), "dust 0 0 0 1", "happy_villager", 100, 0.2); // pos+0.5v + ParticleDisplay.drawParticleLine((ServerPlayerEntity) playerEntity_1, getPos(), Vec3d.ofCenter(bedPos.getPos()), "dust 0 0 0 1", "happy_villager", 100, 0.2); // pos+0.5v } } else if (itemStack_1.getItem() == Items.ROTTEN_FLESH) @@ -144,7 +144,7 @@ public abstract class VillagerEntity_aiMixin extends AbstractTraderEntity 48, PointOfInterestStorage.OccupationStatus.ANY).collect(Collectors.toList()); for (PointOfInterest poi : list_1) { - Vec3d pv = Vec3d.method_24953(poi.getPos()); + Vec3d pv = Vec3d.ofCenter(poi.getPos()); if (!poi.hasSpace()) { ((ServerWorld) getEntityWorld()).spawnParticles(ParticleTypes.HAPPY_VILLAGER, diff --git a/src/main/java/carpet/script/CarpetExpression.java b/src/main/java/carpet/script/CarpetExpression.java index 466f104a..48d55528 100644 --- a/src/main/java/carpet/script/CarpetExpression.java +++ b/src/main/java/carpet/script/CarpetExpression.java @@ -71,7 +71,7 @@ import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.ItemEntity; import net.minecraft.entity.LightningEntity; import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.SpawnType; +import net.minecraft.entity.SpawnReason; import net.minecraft.entity.decoration.ArmorStandEntity; import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.player.PlayerEntity; @@ -1765,7 +1765,7 @@ public class CarpetExpression } else { - Vec3d point = Vec3d.method_24953(inventoryLocator.position); //pos+0.5v + Vec3d point = Vec3d.ofCenter(inventoryLocator.position); //pos+0.5v item = new ItemEntity(cc.s.getWorld(), point.x, point.y, point.z, droppedStack); item.setToDefaultPickupDelay(); cc.s.getWorld().spawnEntity(item); @@ -1907,7 +1907,7 @@ public class CarpetExpression return LazyValue.NULL; } else { if (!hasTag && entity_1 instanceof MobEntity) { - ((MobEntity)entity_1).initialize(serverWorld, serverWorld.getLocalDifficulty(entity_1.getBlockPos()), SpawnType.COMMAND, null, null); + ((MobEntity)entity_1).initialize(serverWorld, serverWorld.getLocalDifficulty(entity_1.getBlockPos()), SpawnReason.COMMAND, null, null); } Value res = new EntityValue(entity_1); return (_c, _t) -> res; diff --git a/src/main/java/carpet/script/argument/Vector3Argument.java b/src/main/java/carpet/script/argument/Vector3Argument.java index e581b6d3..bb35eac8 100644 --- a/src/main/java/carpet/script/argument/Vector3Argument.java +++ b/src/main/java/carpet/script/argument/Vector3Argument.java @@ -52,7 +52,7 @@ public class Vector3Argument extends Argument if (v1 instanceof BlockValue) { // pos + 0.5v - return (new Vector3Argument(Vec3d.method_24953(((BlockValue) v1).getPos()), 1+offset)).fromBlock(); + return (new Vector3Argument(Vec3d.ofCenter(((BlockValue) v1).getPos()), 1+offset)).fromBlock(); } if (v1 instanceof ListValue) { diff --git a/src/main/java/carpet/script/value/BlockValue.java b/src/main/java/carpet/script/value/BlockValue.java index f117578f..be8354f9 100644 --- a/src/main/java/carpet/script/value/BlockValue.java +++ b/src/main/java/carpet/script/value/BlockValue.java @@ -235,7 +235,7 @@ public class BlockValue extends Value SpecificDirection dir = SpecificDirection.DIRECTION_MAP.get(direction); if (dir == null) throw new InternalExpressionException("unknown block placement direction: "+direction); - BlockHitResult hitres = new BlockHitResult(Vec3d.method_24954(pos).add(dir.hitOffset), dir.facing, pos, false); + BlockHitResult hitres = new BlockHitResult(Vec3d.of(pos).add(dir.hitOffset), dir.facing, pos, false); return new PlacementContext(world, dir.facing, sneakPlace, itemStack, hitres); } private PlacementContext(World world_1, Direction direction_1, boolean sneakPlace, ItemStack itemStack_1, BlockHitResult hitres) { diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index 525fd55f..224d356a 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -484,7 +484,7 @@ public class EntityValue extends Value return new NBTSerializableValue(nbttagcompound).get(a); }); - put("category",(e,a)->{return new StringValue(e.getType().getCategory().toString().toLowerCase(Locale.ROOT));}); + put("category",(e,a)->{return new StringValue(e.getType().getSpawnGroup().toString().toLowerCase(Locale.ROOT));}); }}; public void set(String what, Value toWhat) diff --git a/src/main/java/carpet/utils/BlockInfo.java b/src/main/java/carpet/utils/BlockInfo.java index bb32b550..2fa464fd 100644 --- a/src/main/java/carpet/utils/BlockInfo.java +++ b/src/main/java/carpet/utils/BlockInfo.java @@ -1,8 +1,11 @@ package carpet.utils; -import net.minecraft.block.*; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Material; +import net.minecraft.block.MaterialColor; import net.minecraft.entity.EntityType; -import net.minecraft.entity.SpawnType; +import net.minecraft.entity.SpawnReason; import net.minecraft.entity.ai.TargetFinder; import net.minecraft.entity.ai.goal.WanderAroundGoal; import net.minecraft.entity.ai.pathing.NavigationType; @@ -57,7 +60,7 @@ public class BlockInfo put(BlockSoundGroup.BASALT, "basalt"); put(BlockSoundGroup.WART_BLOCK, "wart"); put(BlockSoundGroup.NETHERRACK, "netherrack"); - put(BlockSoundGroup.NETHER_BRICK, "nether_bricks"); + put(BlockSoundGroup.NETHER_BRICKS, "nether_bricks"); put(BlockSoundGroup.NETHER_SPROUTS, "nether_sprouts"); put(BlockSoundGroup.NETHER_ORE, "nether_ore"); put(BlockSoundGroup.BONE, "bone"); @@ -220,7 +223,7 @@ public class BlockInfo private static BaseText wander_chances(BlockPos pos, World worldIn) { MobEntityWithAi creature = new ZombifiedPiglinEntity(EntityType.ZOMBIFIED_PIGLIN, worldIn); - creature.initialize(worldIn, worldIn.getLocalDifficulty(pos), SpawnType.NATURAL, null, null); + creature.initialize(worldIn, worldIn.getLocalDifficulty(pos), SpawnReason.NATURAL, null, null); creature.refreshPositionAndAngles(pos, 0.0F, 0.0F); WanderAroundGoal wander = new WanderAroundGoal(creature, 0.8D); int success = 0; diff --git a/src/main/java/carpet/utils/Messenger.java b/src/main/java/carpet/utils/Messenger.java index 59ea3b4a..ff6de29a 100644 --- a/src/main/java/carpet/utils/Messenger.java +++ b/src/main/java/carpet/utils/Messenger.java @@ -1,7 +1,7 @@ package carpet.utils; import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.entity.EntityCategory; +import net.minecraft.entity.SpawnGroup; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.text.BaseText; import net.minecraft.text.ClickEvent; @@ -100,7 +100,7 @@ public class Messenger if (actual > reference) color = "m"; return color; } - public static String creatureTypeColor(EntityCategory type) + public static String creatureTypeColor(SpawnGroup type) { switch (type) { diff --git a/src/main/java/carpet/utils/PerimeterDiagnostics.java b/src/main/java/carpet/utils/PerimeterDiagnostics.java index f424df8e..ae7477f1 100644 --- a/src/main/java/carpet/utils/PerimeterDiagnostics.java +++ b/src/main/java/carpet/utils/PerimeterDiagnostics.java @@ -4,9 +4,9 @@ import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.block.Material; import net.minecraft.block.BlockState; -import net.minecraft.entity.EntityCategory; +import net.minecraft.entity.SpawnGroup; import net.minecraft.entity.SpawnRestriction; -import net.minecraft.entity.SpawnType; +import net.minecraft.entity.SpawnReason; import net.minecraft.entity.mob.WaterCreatureEntity; import net.minecraft.entity.mob.AmbientEntity; import net.minecraft.entity.mob.MobEntity; @@ -35,9 +35,9 @@ public class PerimeterDiagnostics } private Biome.SpawnEntry sle; private ServerWorld worldServer; - private EntityCategory ctype; + private SpawnGroup ctype; private MobEntity el; - private PerimeterDiagnostics(ServerWorld server, EntityCategory ctype, MobEntity el) + private PerimeterDiagnostics(ServerWorld server, SpawnGroup ctype, MobEntity el) { this.sle = null; this.worldServer = server; @@ -60,28 +60,28 @@ public class PerimeterDiagnostics //int specific_spawns = 0; boolean add_water = false; boolean add_ground = false; - EntityCategory ctype = null; + SpawnGroup ctype = null; if (el != null) { if (el instanceof WaterCreatureEntity) { add_water = true; - ctype = EntityCategory.WATER_CREATURE; + ctype = SpawnGroup.WATER_CREATURE; } else if (el instanceof PassiveEntity) { add_ground = true; - ctype = EntityCategory.CREATURE; + ctype = SpawnGroup.CREATURE; } else if (el instanceof Monster) { add_ground = true; - ctype = EntityCategory.MONSTER; + ctype = SpawnGroup.MONSTER; } else if (el instanceof AmbientEntity) { - ctype = EntityCategory.AMBIENT; + ctype = SpawnGroup.AMBIENT; } } PerimeterDiagnostics diagnostic = new PerimeterDiagnostics(worldserver,ctype,el); @@ -177,8 +177,8 @@ public class PerimeterDiagnostics if (SpawnHelper.canSpawn(spt, worldServer, pos, sle.type)) { el.refreshPositionAndAngles((float)pos.getX() + 0.5F, (float)pos.getY(), (float)pos.getZ()+0.5F, 0.0F, 0.0F); - return el.canSpawn(worldServer) && el.canSpawn(worldServer, SpawnType.NATURAL) && - SpawnRestriction.canSpawn(el.getType(),el.getEntityWorld(), SpawnType.NATURAL, el.getBlockPos(), el.getEntityWorld().random) && + return el.canSpawn(worldServer) && el.canSpawn(worldServer, SpawnReason.NATURAL) && + SpawnRestriction.canSpawn(el.getType(),el.getEntityWorld(), SpawnReason.NATURAL, el.getBlockPos(), el.getEntityWorld().random) && worldServer.doesNotCollide(el); // check collision rules once they stop fiddling with them after 1.14.1 } return false; diff --git a/src/main/java/carpet/utils/SpawnReporter.java b/src/main/java/carpet/utils/SpawnReporter.java index 62c406d9..45ac76b9 100644 --- a/src/main/java/carpet/utils/SpawnReporter.java +++ b/src/main/java/carpet/utils/SpawnReporter.java @@ -6,11 +6,11 @@ import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2LongMap; import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityCategory; +import net.minecraft.entity.SpawnGroup; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.SpawnRestriction; -import net.minecraft.entity.SpawnType; +import net.minecraft.entity.SpawnReason; import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.passive.OcelotEntity; import net.minecraft.text.BaseText; @@ -39,29 +39,29 @@ public class SpawnReporter public static Long track_spawns = 0L; public static final HashMap chunkCounts = new HashMap<>(); - public static final HashMap, Object2LongMap> spawn_stats = new HashMap<>(); + public static final HashMap, Object2LongMap> spawn_stats = new HashMap<>(); public static double mobcap_exponent = 0.0D; - public static final HashMap, Long> spawn_attempts = new HashMap<>(); - public static final HashMap, Long> overall_spawn_ticks = new HashMap<>(); - public static final HashMap, Long> spawn_ticks_full = new HashMap<>(); - public static final HashMap, Long> spawn_ticks_fail = new HashMap<>(); - public static final HashMap, Long> spawn_ticks_succ = new HashMap<>(); - public static final HashMap, Long> spawn_ticks_spawns = new HashMap<>(); - public static final HashMap, Long> spawn_cap_count = new HashMap<>(); - public static final HashMap, EvictingQueue>> spawned_mobs = new HashMap<>(); - public static final HashMap spawn_tries = new HashMap<>(); + public static final HashMap, Long> spawn_attempts = new HashMap<>(); + public static final HashMap, Long> overall_spawn_ticks = new HashMap<>(); + public static final HashMap, Long> spawn_ticks_full = new HashMap<>(); + public static final HashMap, Long> spawn_ticks_fail = new HashMap<>(); + public static final HashMap, Long> spawn_ticks_succ = new HashMap<>(); + public static final HashMap, Long> spawn_ticks_spawns = new HashMap<>(); + public static final HashMap, Long> spawn_cap_count = new HashMap<>(); + public static final HashMap, EvictingQueue>> spawned_mobs = new HashMap<>(); + public static final HashMap spawn_tries = new HashMap<>(); public static BlockPos lower_spawning_limit = null; public static BlockPos upper_spawning_limit = null; // in case game gets each thread for each world - these need to belong to workd. - public static HashMap local_spawns = null; // per world - public static HashSet first_chunk_marker = null; + public static HashMap local_spawns = null; // per world + public static HashSet first_chunk_marker = null; static { reset_spawn_stats(true); } - public static void registerSpawn(DimensionType dim, MobEntity mob, EntityCategory cat, BlockPos pos) + public static void registerSpawn(DimensionType dim, MobEntity mob, SpawnGroup cat, BlockPos pos) { if (lower_spawning_limit != null) { @@ -73,7 +73,7 @@ public class SpawnReporter return; } } - Pair key = Pair.of(mob.dimension, cat); + Pair key = Pair.of(mob.dimension, cat); long count = spawn_stats.get(key).getOrDefault(mob.getType(), 0L); spawn_stats.get(key).put(mob.getType(), count + 1); spawned_mobs.get(key).put(Pair.of(mob.getType(), pos)); @@ -89,7 +89,7 @@ public class SpawnReporter if (multiline) lst.add(Messenger.s(String.format("Mobcaps for %s:",name))); SpawnHelper.Info lastSpawner = world.getChunkManager().getSpawnInfo(); - Object2IntMap dimCounts = lastSpawner.getCategoryToCount(); + Object2IntMap dimCounts = lastSpawner.getGroupToCount(); int chunkcount = chunkCounts.getOrDefault(dim, -1); if (dimCounts == null || chunkcount < 0) { @@ -98,10 +98,10 @@ public class SpawnReporter } List shortCodes = new ArrayList<>(); - for (EntityCategory enumcreaturetype : EntityCategory.values()) + for (SpawnGroup enumcreaturetype : SpawnGroup.values()) { int cur = dimCounts.getOrDefault(enumcreaturetype, -1); - int max = chunkcount * (int)((double)enumcreaturetype.getSpawnCap() * (Math.pow(2.0,(SpawnReporter.mobcap_exponent/4)))) / (int)Math.pow(17.0D, 2.0D); // from ServerChunkManager.CHUNKS_ELIGIBLE_FOR_SPAWNING + int max = chunkcount * (int)((double)enumcreaturetype.getCapacity() * (Math.pow(2.0,(SpawnReporter.mobcap_exponent/4)))) / (int)Math.pow(17.0D, 2.0D); // from ServerChunkManager.CHUNKS_ELIGIBLE_FOR_SPAWNING String color = Messenger.heatmap_color(cur, max); String mobColor = Messenger.creatureTypeColor(enumcreaturetype); if (multiline) @@ -136,7 +136,7 @@ public class SpawnReporter return lst; } - public static List recent_spawns(World world, EntityCategory creature_type) + public static List recent_spawns(World world, SpawnGroup creature_type) { List lst = new ArrayList<>(); if ((track_spawns == 0L)) @@ -178,7 +178,7 @@ public class SpawnReporter return printMobcapsForDimension(worldIn, true ); } } - EntityCategory creature_type = get_type_code_from_wool_code(under); + SpawnGroup creature_type = get_type_code_from_wool_code(under); if (creature_type != null) { if (track_spawns > 0L) @@ -203,51 +203,51 @@ public class SpawnReporter } - public static EntityCategory get_type_code_from_wool_code(DyeColor color) + public static SpawnGroup get_type_code_from_wool_code(DyeColor color) { switch (color) { case RED: - return EntityCategory.MONSTER; + return SpawnGroup.MONSTER; case GREEN: - return EntityCategory.CREATURE; + return SpawnGroup.CREATURE; case BLUE: - return EntityCategory.WATER_CREATURE; + return SpawnGroup.WATER_CREATURE; case BROWN: - return EntityCategory.AMBIENT; + return SpawnGroup.AMBIENT; case CYAN: - return EntityCategory.WATER_AMBIENT; + return SpawnGroup.WATER_AMBIENT; } return null; } - public static EntityCategory get_creature_type_from_code(String type_code) + public static SpawnGroup get_creature_type_from_code(String type_code) { if ("hostile".equalsIgnoreCase(type_code)) { - return EntityCategory.MONSTER; + return SpawnGroup.MONSTER; } else if ("passive".equalsIgnoreCase(type_code)) { - return EntityCategory.CREATURE; + return SpawnGroup.CREATURE; } else if ("water".equalsIgnoreCase(type_code)) { - return EntityCategory.WATER_CREATURE; + return SpawnGroup.WATER_CREATURE; } else if ("fish".equalsIgnoreCase(type_code)) { - return EntityCategory.WATER_AMBIENT; + return SpawnGroup.WATER_AMBIENT; } else if ("ambient".equalsIgnoreCase(type_code)) { - return EntityCategory.AMBIENT; + return SpawnGroup.AMBIENT; } return null; } - public static String get_type_string(EntityCategory type) + public static String get_type_string(SpawnGroup type) { return String.format("%s", type); } @@ -257,11 +257,11 @@ public class SpawnReporter return get_type_string(get_creature_type_from_code(str)); } - public static List printEntitiesByType(EntityCategory cat, World worldIn) //Class entityType) + public static List printEntitiesByType(SpawnGroup cat, World worldIn) //Class entityType) { List lst = new ArrayList<>(); lst.add( Messenger.s(String.format("Loaded entities for %s class:", get_type_string(cat)))); - for (Entity entity : ((ServerWorld)worldIn).getEntities(null, (e) -> e.getType().getCategory()==cat)) + for (Entity entity : ((ServerWorld)worldIn).getEntities(null, (e) -> e.getType().getSpawnGroup()==cat)) { if (!(entity instanceof MobEntity) || !((MobEntity)entity).isPersistent()) { @@ -295,7 +295,7 @@ public class SpawnReporter spawn_stats.clear(); spawned_mobs.clear(); - for (EntityCategory enumcreaturetype : EntityCategory.values()) + for (SpawnGroup enumcreaturetype : SpawnGroup.values()) { if (full) { @@ -303,7 +303,7 @@ public class SpawnReporter } for (DimensionType dim : DimensionType.getAll()) { - Pair key = Pair.of(dim, enumcreaturetype); + Pair key = Pair.of(dim, enumcreaturetype); overall_spawn_ticks.put(key, 0L); spawn_attempts.put(key, 0L); spawn_ticks_full.put(key, 0L); @@ -337,13 +337,13 @@ public class SpawnReporter lower_spawning_limit.getX(),lower_spawning_limit.getY(),lower_spawning_limit.getZ(), upper_spawning_limit.getX(),upper_spawning_limit.getY(),upper_spawning_limit.getZ() ):""; report.add(Messenger.s(String.format("%sSpawn statistics %s: for %.1f min", simulated, location, (duration/72000.0)*60))); - for (EntityCategory enumcreaturetype : EntityCategory.values()) + for (SpawnGroup enumcreaturetype : SpawnGroup.values()) { //String type_code = String.format("%s", enumcreaturetype); boolean there_are_mobs_to_list = false; for (DimensionType dim: DimensionType.getAll()) //String world_code: new String[] {"", " (N)", " (E)"}) { - Pair code = Pair.of(dim, enumcreaturetype); + Pair code = Pair.of(dim, enumcreaturetype); if (spawn_ticks_spawns.get(code) > 0L) { there_are_mobs_to_list = true; @@ -405,7 +405,7 @@ public class SpawnReporter if (y == lc) where = "right at it."; rep.add(Messenger.s(String.format("Maximum spawn Y value for (%+d, %+d) is %d. You are "+where, x, z, lc ))); rep.add(Messenger.s("Spawns:")); - for (EntityCategory enumcreaturetype : EntityCategory.values()) + for (SpawnGroup enumcreaturetype : SpawnGroup.values()) { String type_code = String.format("%s", enumcreaturetype).substring(0, 3); List lst = ((ChunkGenerator)worldIn.getChunkManager().getChunkGenerator()).getEntitySpawnList(worldIn.getStructureAccessor(), enumcreaturetype, pos); @@ -448,15 +448,15 @@ public class SpawnReporter for (int i = 0; i < 20; ++i) { if ( - SpawnRestriction.canSpawn(etype,worldIn, SpawnType.NATURAL, pos, worldIn.random) && + SpawnRestriction.canSpawn(etype,worldIn, SpawnReason.NATURAL, pos, worldIn.random) && SpawnHelper.canSpawn(SpawnRestriction.getLocation(etype), worldIn, pos, etype) && - mob.canSpawn(worldIn, SpawnType.NATURAL) // && mob.canSpawn(worldIn) // entity collisions + mob.canSpawn(worldIn, SpawnReason.NATURAL) // && mob.canSpawn(worldIn) // entity collisions ) { will_spawn += 1; } } - mob.initialize(worldIn, worldIn.getLocalDifficulty(mob.getBlockPos()), SpawnType.NATURAL, null, null); + mob.initialize(worldIn, worldIn.getLocalDifficulty(mob.getBlockPos()), SpawnReason.NATURAL, null, null); // the code invokes onInitialSpawn after getCanSpawHere fits = fits1 && worldIn.doesNotCollide(mob); if (fits) diff --git a/src/main/java/carpet/utils/WoolTool.java b/src/main/java/carpet/utils/WoolTool.java index fe80e357..832d4b3b 100644 --- a/src/main/java/carpet/utils/WoolTool.java +++ b/src/main/java/carpet/utils/WoolTool.java @@ -51,10 +51,10 @@ public class WoolTool { ServerCommandSource source = placer.getCommandSource(); if (!DistanceCalculator.hasStartingPoint(source) || placer.isSneaking()) { - DistanceCalculator.setStart(source, Vec3d.method_24954(pos) ); // zero padded pos + DistanceCalculator.setStart(source, Vec3d.of(pos) ); // zero padded pos } else { - DistanceCalculator.setEnd(source, Vec3d.method_24954(pos)); + DistanceCalculator.setEnd(source, Vec3d.of(pos)); } } break;