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

@@ -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;
}
}
@@ -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<FlatChunkGe
}
@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 (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))
{
@@ -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<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))
{
@@ -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())
@@ -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<List<Biome.SpawnEntry>> cir)
private void onGetEntitySpawnList(StructureAccessor arg, SpawnGroup entityCategory, BlockPos blockPos, CallbackInfoReturnable<List<Biome.SpawnEntry>> cir)
{
if (CarpetSettings.huskSpawningInTemples)
{
@@ -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);
@@ -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<EntityCategory> field_24395;
//@Shadow @Final private class_5263 field_24396;
@Shadow @Final private int spawningChunkCount;
@Shadow @Final private Object2IntOpenHashMap<EntityCategory> categoryToCount;
@Shadow @Final private GravityField densityField;
@Shadow @Final private Object2IntOpenHashMap<SpawnGroup> groupToCount;
@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);
cir.setReturnValue(categoryToCount.getInt(entityCategory) < i);
cir.setReturnValue(groupToCount.getInt(entityCategory) < i);
}
@Override
@@ -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))
{
@@ -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,