This commit is contained in:
gnembon committed 2020-05-10 01:42:19 -03:00
1 parent 566515d0c3
commit ae0975d626
20 files changed
+130 -134

No files matched your search

+1 -1
View File
@@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx1G
# check these on https://fabricmc.net/use # check these on https://fabricmc.net/use
# or better: https://modmuss50.me/fabric.html # or better: https://modmuss50.me/fabric.html
minecraft_version=20w19a minecraft_version=20w19a
yarn_mappings=20w19a+build.1 yarn_mappings=20w19a+build.9
loader_version=0.8.2+build.194 loader_version=0.8.2+build.194
# Mod Properties # Mod Properties
+13 -13
View File
@@ -13,7 +13,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import net.minecraft.command.arguments.BlockPosArgumentType; import net.minecraft.command.arguments.BlockPosArgumentType;
import net.minecraft.command.arguments.DimensionArgumentType; 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.entity.player.PlayerEntity;
import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.util.DyeColor; import net.minecraft.util.DyeColor;
@@ -57,7 +57,7 @@ public class SpawnCommand
then(literal("stop"). then(literal("stop").
executes( (c) -> stopTracking(c.getSource()))). executes( (c) -> stopTracking(c.getSource()))).
then(argument("type", word()). 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"))))). executes( (c) -> recentSpawnsForType(c.getSource(), getString(c, "type"))))).
then(literal("test"). then(literal("test").
executes( (c)-> runTest(c.getSource(), 72000, null)). executes( (c)-> runTest(c.getSource(), 72000, null)).
@@ -80,7 +80,7 @@ public class SpawnCommand
then(literal("reset"). then(literal("reset").
executes( (c) -> resetSpawnRates(c.getSource()))). executes( (c) -> resetSpawnRates(c.getSource()))).
then(argument("type", word()). 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)). then(argument("rounds", integer(0)).
suggests( (c, b) -> suggestMatching(new String[]{"1"},b)). suggests( (c, b) -> suggestMatching(new String[]{"1"},b)).
executes( (c) -> setSpawnRates( executes( (c) -> setSpawnRates(
@@ -97,19 +97,19 @@ public class SpawnCommand
then(literal("entities"). then(literal("entities").
executes( (c) -> generalMobcaps(c.getSource()) ). executes( (c) -> generalMobcaps(c.getSource()) ).
then(argument("type", string()). 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"))))); executes( (c) -> listEntitiesOfType(c.getSource(), getString(c, "type")))));
dispatcher.register(literalargumentbuilder); 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 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)); Messenger.send(source, SpawnReporter.recent_spawns(source.getWorld(), cat));
return 1; return 1;
} }
@@ -231,7 +231,7 @@ public class SpawnCommand
private static int resetSpawnRates(ServerCommandSource source) 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); 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 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); SpawnReporter.spawn_tries.put(cat, rounds);
Messenger.m(source, "gi "+mobtype+" mobs will now spawn "+rounds+" times per tick"); Messenger.m(source, "gi "+mobtype+" mobs will now spawn "+rounds+" times per tick");
return 1; return 1;
@@ -250,7 +250,7 @@ public class SpawnCommand
private static int setMobcaps(ServerCommandSource source, int hostile_cap) 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); 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)); Messenger.m(source, String.format("gi Mobcaps for hostile mobs changed to %d, other groups will follow", hostile_cap));
return 1; return 1;
@@ -264,7 +264,7 @@ public class SpawnCommand
private static int listEntitiesOfType(ServerCommandSource source, String mobtype) throws CommandSyntaxException 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())); Messenger.send(source, SpawnReporter.printEntitiesByType(cat, source.getWorld()));
return 1; return 1;
} }
@@ -36,7 +36,7 @@ public abstract class EntityNavigation_pathfindingMixin
Path path = findPathToAny(set_1, int_1, boolean_1, int_2); Path path = findPathToAny(set_1, int_1, boolean_1, int_2);
long finish = System.nanoTime(); long finish = System.nanoTime();
float duration = (1.0F*((finish - start)/1000))/1000; 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; return path;
} }
@@ -52,7 +52,7 @@ public abstract class EntityNavigation_pathfindingMixin
Path path = findPathToAny(set_1, int_1, boolean_1, int_2); Path path = findPathToAny(set_1, int_1, boolean_1, int_2);
long finish = System.nanoTime(); long finish = System.nanoTime();
float duration = (1.0F*((finish - start)/1000))/1000; 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; return path;
} }
} }
@@ -2,7 +2,7 @@ package carpet.mixins;
import carpet.CarpetSettings; import carpet.CarpetSettings;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.entity.EntityCategory; import net.minecraft.entity.SpawnGroup;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld; import net.minecraft.world.IWorld;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
@@ -25,23 +25,23 @@ public abstract class FlatChunkGeneratorMixin extends ChunkGenerator<FlatChunkGe
} }
@Override @Override
public List<Biome.SpawnEntry> getEntitySpawnList(StructureAccessor arg, EntityCategory category, BlockPos pos) public List<Biome.SpawnEntry> getEntitySpawnList(StructureAccessor arg, SpawnGroup category, BlockPos pos)
{ {
if (CarpetSettings.flatWorldStructureSpawning) if (CarpetSettings.flatWorldStructureSpawning)
{ {
if (Feature.SWAMP_HUT.method_14029(this.world, arg, pos)) if (Feature.SWAMP_HUT.method_14029(this.world, arg, pos))
{ {
if (category == EntityCategory.MONSTER) if (category == SpawnGroup.MONSTER)
{ {
return Feature.SWAMP_HUT.getMonsterSpawns(); return Feature.SWAMP_HUT.getMonsterSpawns();
} }
if (category == EntityCategory.CREATURE) if (category == SpawnGroup.CREATURE)
{ {
return Feature.SWAMP_HUT.getCreatureSpawns(); return Feature.SWAMP_HUT.getCreatureSpawns();
} }
} }
else if (category == EntityCategory.MONSTER) else if (category == SpawnGroup.MONSTER)
{ {
if (Feature.PILLAGER_OUTPOST.isApproximatelyInsideStructure(this.world, arg, pos)) if (Feature.PILLAGER_OUTPOST.isApproximatelyInsideStructure(this.world, arg, pos))
{ {
@@ -1,7 +1,7 @@
package carpet.mixins; package carpet.mixins;
import carpet.CarpetSettings; import carpet.CarpetSettings;
import net.minecraft.entity.EntityCategory; import net.minecraft.entity.SpawnGroup;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld; import net.minecraft.world.IWorld;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
@@ -24,9 +24,9 @@ public abstract class FloatingIslandsChunkGeneratorMixin extends SurfaceChunkGen
} }
@Override @Override
public List<Biome.SpawnEntry> getEntitySpawnList(StructureAccessor arg, EntityCategory category, BlockPos pos) public List<Biome.SpawnEntry> 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)) if (Feature.END_CITY.isInsideStructure(this.world, arg, pos))
{ {
@@ -4,7 +4,7 @@ import carpet.CarpetSettings;
import net.minecraft.entity.EntityData; import net.minecraft.entity.EntityData;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
import net.minecraft.entity.LightningEntity; 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.ElderGuardianEntity;
import net.minecraft.entity.mob.GuardianEntity; import net.minecraft.entity.mob.GuardianEntity;
import net.minecraft.entity.mob.HostileEntity; 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); ElderGuardianEntity elderGuardian = new ElderGuardianEntity(EntityType.ELDER_GUARDIAN ,this.world);
elderGuardian.refreshPositionAndAngles(this.getX(), this.getY(), this.getZ(), this.yaw, this.pitch); 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()); elderGuardian.setAiDisabled(this.isAiDisabled());
if (this.hasCustomName()) if (this.hasCustomName())
@@ -1,7 +1,7 @@
package carpet.mixins; package carpet.mixins;
import carpet.CarpetSettings; import carpet.CarpetSettings;
import net.minecraft.entity.EntityCategory; import net.minecraft.entity.SpawnGroup;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld; import net.minecraft.world.IWorld;
import net.minecraft.world.biome.Biome; 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, @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"), 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) cancellable = true)
private void onGetEntitySpawnList(StructureAccessor arg, EntityCategory entityCategory, BlockPos blockPos, CallbackInfoReturnable<List<Biome.SpawnEntry>> cir) private void onGetEntitySpawnList(StructureAccessor arg, SpawnGroup entityCategory, BlockPos blockPos, CallbackInfoReturnable<List<Biome.SpawnEntry>> cir)
{ {
if (CarpetSettings.huskSpawningInTemples) if (CarpetSettings.huskSpawningInTemples)
{ {
@@ -4,7 +4,7 @@ import carpet.fakes.ServerChunkManagerInterface;
import carpet.utils.SpawnReporter; import carpet.utils.SpawnReporter;
import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntMap;
import net.minecraft.class_5217; 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.ChunkTicketManager;
import net.minecraft.server.world.ServerChunkManager; import net.minecraft.server.world.ServerChunkManager;
import net.minecraft.server.world.ServerWorld; 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 //local spawns now need to be tracked globally cause each calll is just for chunk
SpawnReporter.local_spawns = new HashMap<>(); SpawnReporter.local_spawns = new HashMap<>();
SpawnReporter.first_chunk_marker = new HashSet<>(); SpawnReporter.first_chunk_marker = new HashSet<>();
for (EntityCategory cat : EntityCategory.values()) for (SpawnGroup cat : SpawnGroup.values())
{ {
Pair key = Pair.of(dim, cat); Pair key = Pair.of(dim, cat);
SpawnReporter.overall_spawn_ticks.put(key, SpawnReporter.overall_spawn_ticks.put(key,
@@ -75,7 +75,7 @@ public abstract class ServerChunkManagerMixin implements ServerChunkManagerInter
boolean boolean_3 = levelProperties_1.getTime() % 400L == 0L; boolean boolean_3 = levelProperties_1.getTime() % 400L == 0L;
if (SpawnReporter.track_spawns > 0L && SpawnReporter.local_spawns != null) if (SpawnReporter.track_spawns > 0L && SpawnReporter.local_spawns != null)
{ {
for (EntityCategory cat: EntityCategory.values()) for (SpawnGroup cat: SpawnGroup.values())
{ {
DimensionType dim = world.dimension.getType(); DimensionType dim = world.dimension.getType();
Pair key = Pair.of(world.dimension.getType(), cat); Pair key = Pair.of(world.dimension.getType(), cat);
@@ -4,7 +4,7 @@ import carpet.fakes.SpawnHelperInnerInterface;
import carpet.utils.SpawnReporter; import carpet.utils.SpawnReporter;
import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; 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.util.math.GravityField;
import net.minecraft.world.SpawnHelper; import net.minecraft.world.SpawnHelper;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
@@ -19,25 +19,18 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(SpawnHelper.Info.class) @Mixin(SpawnHelper.Info.class)
public class SpawnHelperInnerMixin implements SpawnHelperInnerInterface public class SpawnHelperInnerMixin implements SpawnHelperInnerInterface
{ {
//@Shadow @Final private int field_24394;
//@Shadow @Final private Object2IntMap<EntityCategory> field_24395;
//@Shadow @Final private class_5263 field_24396;
@Shadow @Final private int spawningChunkCount; @Shadow @Final private int spawningChunkCount;
@Shadow @Final private Object2IntOpenHashMap<EntityCategory> categoryToCount;
@Shadow @Final private GravityField densityField; @Shadow @Final private GravityField densityField;
@Shadow @Final private Object2IntOpenHashMap<SpawnGroup> groupToCount;
@Inject(method = "isBelowCap", at = @At("HEAD"), cancellable = true) @Inject(method = "isBelowCap", at = @At("HEAD"), cancellable = true)
private void changeMobCaps(EntityCategory entityCategory, CallbackInfoReturnable<Boolean> cir) private void changeMobCaps(SpawnGroup entityCategory, CallbackInfoReturnable<Boolean> 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); int i = newCap * spawningChunkCount / (int)Math.pow(17.0D, 2.0D);
cir.setReturnValue(categoryToCount.getInt(entityCategory) < i); cir.setReturnValue(groupToCount.getInt(entityCategory) < i);
} }
@Override @Override
@@ -7,10 +7,10 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.FenceGateBlock; import net.minecraft.block.FenceGateBlock;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCategory; import net.minecraft.entity.SpawnGroup;
import net.minecraft.entity.EntityData; import net.minecraft.entity.EntityData;
import net.minecraft.entity.EntityType; 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.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
@@ -44,9 +44,9 @@ public class SpawnHelperMixin
{ {
@Shadow @Final private static int CHUNK_AREA; @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", value = "INVOKE",
target = "Lnet/minecraft/server/world/ServerWorld;doesNotCollide(Lnet/minecraft/util/math/Box;)Z" 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); 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", value = "INVOKE",
target = "Lnet/minecraft/server/world/ServerWorld;spawnEntity(Lnet/minecraft/entity/Entity;)Z" target = "Lnet/minecraft/server/world/ServerWorld;spawnEntity(Lnet/minecraft/entity/Entity;)Z"
)) ))
@@ -164,7 +164,7 @@ public class SpawnHelperMixin
SpawnReporter.registerSpawn( SpawnReporter.registerSpawn(
world.dimension.getType(), world.dimension.getType(),
(MobEntity) entity_1, (MobEntity) entity_1,
entity_1.getType().getCategory(), entity_1.getType().getSpawnGroup(),
entity_1.getBlockPos()); entity_1.getBlockPos());
} }
if (!SpawnReporter.mock_spawns) if (!SpawnReporter.mock_spawns)
@@ -172,26 +172,26 @@ public class SpawnHelperMixin
return false; 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", 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) if (!SpawnReporter.mock_spawns)
return mobEntity.initialize(iWorld_1, localDifficulty_1, spawnType_1, entityData_1, compoundTag_1); return mobEntity.initialize(iWorld_1, localDifficulty_1, spawnType_1, entityData_1, compoundTag_1);
return null; 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", value = "INVOKE",
target = "Lnet/minecraft/entity/player/PlayerEntity;squaredDistanceTo(DDD)D" target = "Lnet/minecraft/entity/player/PlayerEntity;squaredDistanceTo(DDD)D"
)) ))
private static double getSqDistanceTo(PlayerEntity playerEntity, double double_1, double double_2, double double_3, 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); 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 0.0;
return distanceTo; return distanceTo;
} }
@@ -202,10 +202,10 @@ public class SpawnHelperMixin
@Redirect(method = "spawn", at = @At( @Redirect(method = "spawn", at = @At(
value = "INVOKE", 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. // 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++) for (int i = 0; i < SpawnReporter.spawn_tries.get(category); i++)
{ {
@@ -217,11 +217,11 @@ public class SpawnHelperMixin
/* /*
@Redirect(method = "spawn", at = @At( @Redirect(method = "spawn", at = @At(
value = "INVOKE", 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. // allows to change mobcaps and captures each category try per dimension before it fails due to full mobcaps.
private static boolean changeMobcaps( 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 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) if (SpawnReporter.track_spawns > 0L)
{ {
EntityCategory[] var6 = SPAWNABLE_CATEGORIES; SpawnGroup[] var6 = SPAWNABLE_GROUPS;
int var7 = var6.length; int var7 = var6.length;
for(int var8 = 0; var8 < var7; ++var8) { 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()) ) if ((spawnAnimals || !entityCategory.isPeaceful()) && (spawnMonsters || entityCategory.isPeaceful()) && (shouldSpawnAnimals || !entityCategory.isAnimal()) )
{ {
DimensionType dim = world.dimension.getType(); 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_2 = SpawnReporter.chunkCounts.get(dim); // eligible chunks for spawning
int int_3 = newCap * int_2 / CHUNK_AREA; //current spawning limits 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)) if (SpawnReporter.track_spawns > 0L && !SpawnReporter.first_chunk_marker.contains(entityCategory))
{ {
@@ -128,7 +128,7 @@ public abstract class VillagerEntity_aiMixin extends AbstractTraderEntity
else 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) 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()); 48, PointOfInterestStorage.OccupationStatus.ANY).collect(Collectors.toList());
for (PointOfInterest poi : list_1) for (PointOfInterest poi : list_1)
{ {
Vec3d pv = Vec3d.method_24953(poi.getPos()); Vec3d pv = Vec3d.ofCenter(poi.getPos());
if (!poi.hasSpace()) if (!poi.hasSpace())
{ {
((ServerWorld) getEntityWorld()).spawnParticles(ParticleTypes.HAPPY_VILLAGER, ((ServerWorld) getEntityWorld()).spawnParticles(ParticleTypes.HAPPY_VILLAGER,
@@ -71,7 +71,7 @@ import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.ItemEntity; import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.LightningEntity; import net.minecraft.entity.LightningEntity;
import net.minecraft.entity.LivingEntity; 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.decoration.ArmorStandEntity;
import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
@@ -1765,7 +1765,7 @@ public class CarpetExpression
} }
else 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 = new ItemEntity(cc.s.getWorld(), point.x, point.y, point.z, droppedStack);
item.setToDefaultPickupDelay(); item.setToDefaultPickupDelay();
cc.s.getWorld().spawnEntity(item); cc.s.getWorld().spawnEntity(item);
@@ -1907,7 +1907,7 @@ public class CarpetExpression
return LazyValue.NULL; return LazyValue.NULL;
} else { } else {
if (!hasTag && entity_1 instanceof MobEntity) { 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); Value res = new EntityValue(entity_1);
return (_c, _t) -> res; return (_c, _t) -> res;
@@ -52,7 +52,7 @@ public class Vector3Argument extends Argument
if (v1 instanceof BlockValue) if (v1 instanceof BlockValue)
{ {
// pos + 0.5v // 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) if (v1 instanceof ListValue)
{ {
@@ -235,7 +235,7 @@ public class BlockValue extends Value
SpecificDirection dir = SpecificDirection.DIRECTION_MAP.get(direction); SpecificDirection dir = SpecificDirection.DIRECTION_MAP.get(direction);
if (dir == null) if (dir == null)
throw new InternalExpressionException("unknown block placement direction: "+direction); 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); return new PlacementContext(world, dir.facing, sneakPlace, itemStack, hitres);
} }
private PlacementContext(World world_1, Direction direction_1, boolean sneakPlace, ItemStack itemStack_1, BlockHitResult hitres) { private PlacementContext(World world_1, Direction direction_1, boolean sneakPlace, ItemStack itemStack_1, BlockHitResult hitres) {
@@ -484,7 +484,7 @@ public class EntityValue extends Value
return new NBTSerializableValue(nbttagcompound).get(a); 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) public void set(String what, Value toWhat)
+7 -4
View File
@@ -1,8 +1,11 @@
package carpet.utils; 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.EntityType;
import net.minecraft.entity.SpawnType; import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.ai.TargetFinder; import net.minecraft.entity.ai.TargetFinder;
import net.minecraft.entity.ai.goal.WanderAroundGoal; import net.minecraft.entity.ai.goal.WanderAroundGoal;
import net.minecraft.entity.ai.pathing.NavigationType; import net.minecraft.entity.ai.pathing.NavigationType;
@@ -57,7 +60,7 @@ public class BlockInfo
put(BlockSoundGroup.BASALT, "basalt"); put(BlockSoundGroup.BASALT, "basalt");
put(BlockSoundGroup.WART_BLOCK, "wart"); put(BlockSoundGroup.WART_BLOCK, "wart");
put(BlockSoundGroup.NETHERRACK, "netherrack"); 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_SPROUTS, "nether_sprouts");
put(BlockSoundGroup.NETHER_ORE, "nether_ore"); put(BlockSoundGroup.NETHER_ORE, "nether_ore");
put(BlockSoundGroup.BONE, "bone"); put(BlockSoundGroup.BONE, "bone");
@@ -220,7 +223,7 @@ public class BlockInfo
private static BaseText wander_chances(BlockPos pos, World worldIn) private static BaseText wander_chances(BlockPos pos, World worldIn)
{ {
MobEntityWithAi creature = new ZombifiedPiglinEntity(EntityType.ZOMBIFIED_PIGLIN, 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); creature.refreshPositionAndAngles(pos, 0.0F, 0.0F);
WanderAroundGoal wander = new WanderAroundGoal(creature, 0.8D); WanderAroundGoal wander = new WanderAroundGoal(creature, 0.8D);
int success = 0; int success = 0;
+2 -2
View File
@@ -1,7 +1,7 @@
package carpet.utils; package carpet.utils;
import net.minecraft.server.command.ServerCommandSource; 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.entity.player.PlayerEntity;
import net.minecraft.text.BaseText; import net.minecraft.text.BaseText;
import net.minecraft.text.ClickEvent; import net.minecraft.text.ClickEvent;
@@ -100,7 +100,7 @@ public class Messenger
if (actual > reference) color = "m"; if (actual > reference) color = "m";
return color; return color;
} }
public static String creatureTypeColor(EntityCategory type) public static String creatureTypeColor(SpawnGroup type)
{ {
switch (type) switch (type)
{ {
@@ -4,9 +4,9 @@ import net.minecraft.block.Block;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.EntityCategory; import net.minecraft.entity.SpawnGroup;
import net.minecraft.entity.SpawnRestriction; 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.WaterCreatureEntity;
import net.minecraft.entity.mob.AmbientEntity; import net.minecraft.entity.mob.AmbientEntity;
import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.mob.MobEntity;
@@ -35,9 +35,9 @@ public class PerimeterDiagnostics
} }
private Biome.SpawnEntry sle; private Biome.SpawnEntry sle;
private ServerWorld worldServer; private ServerWorld worldServer;
private EntityCategory ctype; private SpawnGroup ctype;
private MobEntity el; private MobEntity el;
private PerimeterDiagnostics(ServerWorld server, EntityCategory ctype, MobEntity el) private PerimeterDiagnostics(ServerWorld server, SpawnGroup ctype, MobEntity el)
{ {
this.sle = null; this.sle = null;
this.worldServer = server; this.worldServer = server;
@@ -60,28 +60,28 @@ public class PerimeterDiagnostics
//int specific_spawns = 0; //int specific_spawns = 0;
boolean add_water = false; boolean add_water = false;
boolean add_ground = false; boolean add_ground = false;
EntityCategory ctype = null; SpawnGroup ctype = null;
if (el != null) if (el != null)
{ {
if (el instanceof WaterCreatureEntity) if (el instanceof WaterCreatureEntity)
{ {
add_water = true; add_water = true;
ctype = EntityCategory.WATER_CREATURE; ctype = SpawnGroup.WATER_CREATURE;
} }
else if (el instanceof PassiveEntity) else if (el instanceof PassiveEntity)
{ {
add_ground = true; add_ground = true;
ctype = EntityCategory.CREATURE; ctype = SpawnGroup.CREATURE;
} }
else if (el instanceof Monster) else if (el instanceof Monster)
{ {
add_ground = true; add_ground = true;
ctype = EntityCategory.MONSTER; ctype = SpawnGroup.MONSTER;
} }
else if (el instanceof AmbientEntity) else if (el instanceof AmbientEntity)
{ {
ctype = EntityCategory.AMBIENT; ctype = SpawnGroup.AMBIENT;
} }
} }
PerimeterDiagnostics diagnostic = new PerimeterDiagnostics(worldserver,ctype,el); PerimeterDiagnostics diagnostic = new PerimeterDiagnostics(worldserver,ctype,el);
@@ -177,8 +177,8 @@ public class PerimeterDiagnostics
if (SpawnHelper.canSpawn(spt, worldServer, pos, sle.type)) 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); 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) && return el.canSpawn(worldServer) && el.canSpawn(worldServer, SpawnReason.NATURAL) &&
SpawnRestriction.canSpawn(el.getType(),el.getEntityWorld(), SpawnType.NATURAL, el.getBlockPos(), el.getEntityWorld().random) && 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 worldServer.doesNotCollide(el); // check collision rules once they stop fiddling with them after 1.14.1
} }
return false; return false;
+44 -44
View File
@@ -6,11 +6,11 @@ import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2LongMap; import it.unimi.dsi.fastutil.objects.Object2LongMap;
import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCategory; import net.minecraft.entity.SpawnGroup;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.SpawnRestriction; 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.mob.MobEntity;
import net.minecraft.entity.passive.OcelotEntity; import net.minecraft.entity.passive.OcelotEntity;
import net.minecraft.text.BaseText; import net.minecraft.text.BaseText;
@@ -39,29 +39,29 @@ public class SpawnReporter
public static Long track_spawns = 0L; public static Long track_spawns = 0L;
public static final HashMap<DimensionType, Integer> chunkCounts = new HashMap<>(); public static final HashMap<DimensionType, Integer> chunkCounts = new HashMap<>();
public static final HashMap<Pair<DimensionType, EntityCategory>, Object2LongMap<EntityType>> spawn_stats = new HashMap<>(); public static final HashMap<Pair<DimensionType, SpawnGroup>, Object2LongMap<EntityType>> spawn_stats = new HashMap<>();
public static double mobcap_exponent = 0.0D; public static double mobcap_exponent = 0.0D;
public static final HashMap<Pair<DimensionType, EntityCategory>, Long> spawn_attempts = new HashMap<>(); public static final HashMap<Pair<DimensionType, SpawnGroup>, Long> spawn_attempts = new HashMap<>();
public static final HashMap<Pair<DimensionType, EntityCategory>, Long> overall_spawn_ticks = new HashMap<>(); public static final HashMap<Pair<DimensionType, SpawnGroup>, Long> overall_spawn_ticks = new HashMap<>();
public static final HashMap<Pair<DimensionType, EntityCategory>, Long> spawn_ticks_full = new HashMap<>(); public static final HashMap<Pair<DimensionType, SpawnGroup>, Long> spawn_ticks_full = new HashMap<>();
public static final HashMap<Pair<DimensionType, EntityCategory>, Long> spawn_ticks_fail = new HashMap<>(); public static final HashMap<Pair<DimensionType, SpawnGroup>, Long> spawn_ticks_fail = new HashMap<>();
public static final HashMap<Pair<DimensionType, EntityCategory>, Long> spawn_ticks_succ = new HashMap<>(); public static final HashMap<Pair<DimensionType, SpawnGroup>, Long> spawn_ticks_succ = new HashMap<>();
public static final HashMap<Pair<DimensionType, EntityCategory>, Long> spawn_ticks_spawns = new HashMap<>(); public static final HashMap<Pair<DimensionType, SpawnGroup>, Long> spawn_ticks_spawns = new HashMap<>();
public static final HashMap<Pair<DimensionType, EntityCategory>, Long> spawn_cap_count = new HashMap<>(); public static final HashMap<Pair<DimensionType, SpawnGroup>, Long> spawn_cap_count = new HashMap<>();
public static final HashMap<Pair<DimensionType, EntityCategory>, EvictingQueue<Pair<EntityType, BlockPos>>> spawned_mobs = new HashMap<>(); public static final HashMap<Pair<DimensionType, SpawnGroup>, EvictingQueue<Pair<EntityType, BlockPos>>> spawned_mobs = new HashMap<>();
public static final HashMap<EntityCategory, Integer> spawn_tries = new HashMap<>(); public static final HashMap<SpawnGroup, Integer> spawn_tries = new HashMap<>();
public static BlockPos lower_spawning_limit = null; public static BlockPos lower_spawning_limit = null;
public static BlockPos upper_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. // in case game gets each thread for each world - these need to belong to workd.
public static HashMap<EntityCategory, Long> local_spawns = null; // per world public static HashMap<SpawnGroup, Long> local_spawns = null; // per world
public static HashSet<EntityCategory> first_chunk_marker = null; public static HashSet<SpawnGroup> first_chunk_marker = null;
static { static {
reset_spawn_stats(true); 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) if (lower_spawning_limit != null)
{ {
@@ -73,7 +73,7 @@ public class SpawnReporter
return; return;
} }
} }
Pair<DimensionType, EntityCategory> key = Pair.of(mob.dimension, cat); Pair<DimensionType, SpawnGroup> key = Pair.of(mob.dimension, cat);
long count = spawn_stats.get(key).getOrDefault(mob.getType(), 0L); long count = spawn_stats.get(key).getOrDefault(mob.getType(), 0L);
spawn_stats.get(key).put(mob.getType(), count + 1); spawn_stats.get(key).put(mob.getType(), count + 1);
spawned_mobs.get(key).put(Pair.of(mob.getType(), pos)); spawned_mobs.get(key).put(Pair.of(mob.getType(), pos));
@@ -89,7 +89,7 @@ public class SpawnReporter
if (multiline) if (multiline)
lst.add(Messenger.s(String.format("Mobcaps for %s:",name))); lst.add(Messenger.s(String.format("Mobcaps for %s:",name)));
SpawnHelper.Info lastSpawner = world.getChunkManager().getSpawnInfo(); SpawnHelper.Info lastSpawner = world.getChunkManager().getSpawnInfo();
Object2IntMap<EntityCategory> dimCounts = lastSpawner.getCategoryToCount(); Object2IntMap<SpawnGroup> dimCounts = lastSpawner.getGroupToCount();
int chunkcount = chunkCounts.getOrDefault(dim, -1); int chunkcount = chunkCounts.getOrDefault(dim, -1);
if (dimCounts == null || chunkcount < 0) if (dimCounts == null || chunkcount < 0)
{ {
@@ -98,10 +98,10 @@ public class SpawnReporter
} }
List<String> shortCodes = new ArrayList<>(); List<String> shortCodes = new ArrayList<>();
for (EntityCategory enumcreaturetype : EntityCategory.values()) for (SpawnGroup enumcreaturetype : SpawnGroup.values())
{ {
int cur = dimCounts.getOrDefault(enumcreaturetype, -1); 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 color = Messenger.heatmap_color(cur, max);
String mobColor = Messenger.creatureTypeColor(enumcreaturetype); String mobColor = Messenger.creatureTypeColor(enumcreaturetype);
if (multiline) if (multiline)
@@ -136,7 +136,7 @@ public class SpawnReporter
return lst; return lst;
} }
public static List<BaseText> recent_spawns(World world, EntityCategory creature_type) public static List<BaseText> recent_spawns(World world, SpawnGroup creature_type)
{ {
List<BaseText> lst = new ArrayList<>(); List<BaseText> lst = new ArrayList<>();
if ((track_spawns == 0L)) if ((track_spawns == 0L))
@@ -178,7 +178,7 @@ public class SpawnReporter
return printMobcapsForDimension(worldIn, true ); 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 (creature_type != null)
{ {
if (track_spawns > 0L) 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) switch (color)
{ {
case RED: case RED:
return EntityCategory.MONSTER; return SpawnGroup.MONSTER;
case GREEN: case GREEN:
return EntityCategory.CREATURE; return SpawnGroup.CREATURE;
case BLUE: case BLUE:
return EntityCategory.WATER_CREATURE; return SpawnGroup.WATER_CREATURE;
case BROWN: case BROWN:
return EntityCategory.AMBIENT; return SpawnGroup.AMBIENT;
case CYAN: case CYAN:
return EntityCategory.WATER_AMBIENT; return SpawnGroup.WATER_AMBIENT;
} }
return null; 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)) if ("hostile".equalsIgnoreCase(type_code))
{ {
return EntityCategory.MONSTER; return SpawnGroup.MONSTER;
} }
else if ("passive".equalsIgnoreCase(type_code)) else if ("passive".equalsIgnoreCase(type_code))
{ {
return EntityCategory.CREATURE; return SpawnGroup.CREATURE;
} }
else if ("water".equalsIgnoreCase(type_code)) else if ("water".equalsIgnoreCase(type_code))
{ {
return EntityCategory.WATER_CREATURE; return SpawnGroup.WATER_CREATURE;
} }
else if ("fish".equalsIgnoreCase(type_code)) else if ("fish".equalsIgnoreCase(type_code))
{ {
return EntityCategory.WATER_AMBIENT; return SpawnGroup.WATER_AMBIENT;
} }
else if ("ambient".equalsIgnoreCase(type_code)) else if ("ambient".equalsIgnoreCase(type_code))
{ {
return EntityCategory.AMBIENT; return SpawnGroup.AMBIENT;
} }
return null; return null;
} }
public static String get_type_string(EntityCategory type) public static String get_type_string(SpawnGroup type)
{ {
return String.format("%s", type); return String.format("%s", type);
} }
@@ -257,11 +257,11 @@ public class SpawnReporter
return get_type_string(get_creature_type_from_code(str)); return get_type_string(get_creature_type_from_code(str));
} }
public static List<BaseText> printEntitiesByType(EntityCategory cat, World worldIn) //Class<?> entityType) public static List<BaseText> printEntitiesByType(SpawnGroup cat, World worldIn) //Class<?> entityType)
{ {
List<BaseText> lst = new ArrayList<>(); List<BaseText> lst = new ArrayList<>();
lst.add( Messenger.s(String.format("Loaded entities for %s class:", get_type_string(cat)))); 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()) if (!(entity instanceof MobEntity) || !((MobEntity)entity).isPersistent())
{ {
@@ -295,7 +295,7 @@ public class SpawnReporter
spawn_stats.clear(); spawn_stats.clear();
spawned_mobs.clear(); spawned_mobs.clear();
for (EntityCategory enumcreaturetype : EntityCategory.values()) for (SpawnGroup enumcreaturetype : SpawnGroup.values())
{ {
if (full) if (full)
{ {
@@ -303,7 +303,7 @@ public class SpawnReporter
} }
for (DimensionType dim : DimensionType.getAll()) for (DimensionType dim : DimensionType.getAll())
{ {
Pair<DimensionType, EntityCategory> key = Pair.of(dim, enumcreaturetype); Pair<DimensionType, SpawnGroup> key = Pair.of(dim, enumcreaturetype);
overall_spawn_ticks.put(key, 0L); overall_spawn_ticks.put(key, 0L);
spawn_attempts.put(key, 0L); spawn_attempts.put(key, 0L);
spawn_ticks_full.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(), lower_spawning_limit.getX(),lower_spawning_limit.getY(),lower_spawning_limit.getZ(),
upper_spawning_limit.getX(),upper_spawning_limit.getY(),upper_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))); 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); //String type_code = String.format("%s", enumcreaturetype);
boolean there_are_mobs_to_list = false; boolean there_are_mobs_to_list = false;
for (DimensionType dim: DimensionType.getAll()) //String world_code: new String[] {"", " (N)", " (E)"}) for (DimensionType dim: DimensionType.getAll()) //String world_code: new String[] {"", " (N)", " (E)"})
{ {
Pair<DimensionType, EntityCategory> code = Pair.of(dim, enumcreaturetype); Pair<DimensionType, SpawnGroup> code = Pair.of(dim, enumcreaturetype);
if (spawn_ticks_spawns.get(code) > 0L) if (spawn_ticks_spawns.get(code) > 0L)
{ {
there_are_mobs_to_list = true; there_are_mobs_to_list = true;
@@ -405,7 +405,7 @@ public class SpawnReporter
if (y == lc) where = "right at it."; 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(String.format("Maximum spawn Y value for (%+d, %+d) is %d. You are "+where, x, z, lc )));
rep.add(Messenger.s("Spawns:")); 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); String type_code = String.format("%s", enumcreaturetype).substring(0, 3);
List<Biome.SpawnEntry> lst = ((ChunkGenerator)worldIn.getChunkManager().getChunkGenerator()).getEntitySpawnList(worldIn.getStructureAccessor(), enumcreaturetype, pos); List<Biome.SpawnEntry> lst = ((ChunkGenerator)worldIn.getChunkManager().getChunkGenerator()).getEntitySpawnList(worldIn.getStructureAccessor(), enumcreaturetype, pos);
@@ -448,15 +448,15 @@ public class SpawnReporter
for (int i = 0; i < 20; ++i) for (int i = 0; i < 20; ++i)
{ {
if ( 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) && 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; 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 // the code invokes onInitialSpawn after getCanSpawHere
fits = fits1 && worldIn.doesNotCollide(mob); fits = fits1 && worldIn.doesNotCollide(mob);
if (fits) if (fits)
+2 -2
View File
@@ -51,10 +51,10 @@ public class WoolTool
{ {
ServerCommandSource source = placer.getCommandSource(); ServerCommandSource source = placer.getCommandSource();
if (!DistanceCalculator.hasStartingPoint(source) || placer.isSneaking()) { 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 { else {
DistanceCalculator.setEnd(source, Vec3d.method_24954(pos)); DistanceCalculator.setEnd(source, Vec3d.of(pos));
} }
} }
break; break;