This commit is contained in:
gnembon committed 2020-07-29 17:23:53 -03:00
1 parent dc3881f6d2
commit 28857815e0
14 files changed
+53 -59

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=20w30a minecraft_version=20w30a
yarn_mappings=20w30a+build.11 yarn_mappings=20w30a+build.26
loader_version=0.9.0+build.204 loader_version=0.9.0+build.204
# Mod Properties # Mod Properties
@@ -30,8 +30,8 @@ public abstract class BlockLightStorage_scarpetChunkCreationMixin extends LightS
for (int y = -1; y < 17; ++y) for (int y = -1; y < 17; ++y)
{ {
final long sectionPos = ChunkSectionPos.asLong(ChunkSectionPos.getX(cPos), y, ChunkSectionPos.getZ(cPos)); final long sectionPos = ChunkSectionPos.asLong(ChunkSectionPos.unpackX(cPos), y, ChunkSectionPos.unpackZ(cPos));
final long pos = BlockPos.asLong(ChunkSectionPos.getBlockCoord(ChunkSectionPos.getX(sectionPos)), ChunkSectionPos.getBlockCoord(y), ChunkSectionPos.getBlockCoord(ChunkSectionPos.getZ(sectionPos))); final long pos = BlockPos.asLong(ChunkSectionPos.getBlockCoord(ChunkSectionPos.unpackX(sectionPos)), ChunkSectionPos.getBlockCoord(y), ChunkSectionPos.getBlockCoord(ChunkSectionPos.unpackZ(sectionPos)));
if (!this.hasSection(sectionPos)) if (!this.hasSection(sectionPos))
continue; continue;
@@ -19,7 +19,7 @@ import java.util.concurrent.atomic.AtomicReferenceArray;
@Mixin(ChunkHolder.class) @Mixin(ChunkHolder.class)
public abstract class ChunkHolder_scarpetChunkCreationMixin implements ChunkHolderInterface public abstract class ChunkHolder_scarpetChunkCreationMixin implements ChunkHolderInterface
{ {
@Shadow protected abstract void updateFuture(CompletableFuture<? extends Either<? extends Chunk, ChunkHolder.Unloaded>> newChunkFuture); @Shadow protected abstract void combineSavingFuture(CompletableFuture<? extends Either<? extends Chunk, ChunkHolder.Unloaded>> newChunkFuture);
@Shadow @Final private AtomicReferenceArray<CompletableFuture<Either<Chunk, ChunkHolder.Unloaded>>> futuresByStatus; @Shadow @Final private AtomicReferenceArray<CompletableFuture<Either<Chunk, ChunkHolder.Unloaded>>> futuresByStatus;
@@ -31,7 +31,7 @@ public abstract class ChunkHolder_scarpetChunkCreationMixin implements ChunkHold
() -> Either.left(new ProtoChunk(chpos, UpgradeData.NO_UPGRADE_DATA)), () -> Either.left(new ProtoChunk(chpos, UpgradeData.NO_UPGRADE_DATA)),
executor executor
); );
updateFuture(completableFuture2); combineSavingFuture(completableFuture2);
futuresByStatus.set(i, completableFuture2); futuresByStatus.set(i, completableFuture2);
return completableFuture2; return completableFuture2;
} }
@@ -33,7 +33,7 @@ public abstract class FlatChunkGeneratorMixin extends ChunkGenerator
{ {
if (CarpetSettings.flatWorldStructureSpawning) if (CarpetSettings.flatWorldStructureSpawning)
{ {
if (accessor.method_28388(pos, true, StructureFeature.SWAMP_HUT).hasChildren()) if (accessor.getStructureAt(pos, true, StructureFeature.SWAMP_HUT).hasChildren())
{ //swamp hut { //swamp hut
if (group == SpawnGroup.MONSTER) if (group == SpawnGroup.MONSTER)
{ {
@@ -48,32 +48,32 @@ public abstract class FlatChunkGeneratorMixin extends ChunkGenerator
if (group == SpawnGroup.MONSTER) if (group == SpawnGroup.MONSTER)
{ {
if (accessor.method_28388(pos, false, StructureFeature.PILLAGER_OUTPOST).hasChildren()) if (accessor.getStructureAt(pos, false, StructureFeature.PILLAGER_OUTPOST).hasChildren())
{ {
return StructureFeature.PILLAGER_OUTPOST.getMonsterSpawns(); return StructureFeature.PILLAGER_OUTPOST.getMonsterSpawns();
} }
if (CarpetSettings.huskSpawningInTemples) if (CarpetSettings.huskSpawningInTemples)
{ {
if (accessor.method_28388(pos, true, StructureFeature.DESERT_PYRAMID).hasChildren()) if (accessor.getStructureAt(pos, true, StructureFeature.DESERT_PYRAMID).hasChildren())
{ {
return StructureFeature.DESERT_PYRAMID.getMonsterSpawns(); return StructureFeature.DESERT_PYRAMID.getMonsterSpawns();
} }
} }
if (accessor.method_28388(pos, false, StructureFeature.MONUMENT).hasChildren()) if (accessor.getStructureAt(pos, false, StructureFeature.MONUMENT).hasChildren())
{ {
return StructureFeature.MONUMENT.getMonsterSpawns(); return StructureFeature.MONUMENT.getMonsterSpawns();
} }
if (accessor.method_28388(pos, true, StructureFeature.FORTRESS).hasChildren()) if (accessor.getStructureAt(pos, true, StructureFeature.FORTRESS).hasChildren())
{ {
return StructureFeature.FORTRESS.getMonsterSpawns(); return StructureFeature.FORTRESS.getMonsterSpawns();
} }
if (CarpetSettings.shulkerSpawningInEndCities) if (CarpetSettings.shulkerSpawningInEndCities)
{ {
if (accessor.method_28388(pos, true, StructureFeature.END_CITY).hasChildren()) if (accessor.getStructureAt(pos, true, StructureFeature.END_CITY).hasChildren())
{ {
return StructureFeature.END_CITY.getMonsterSpawns(); return StructureFeature.END_CITY.getMonsterSpawns();
} }
@@ -1,12 +1,10 @@
package carpet.mixins; package carpet.mixins;
import carpet.CarpetSettings; import carpet.CarpetSettings;
import net.minecraft.class_5425;
import net.minecraft.entity.mob.HuskEntity; import net.minecraft.entity.mob.HuskEntity;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldAccess; import net.minecraft.world.ServerWorldAccess;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.StructureFeature; import net.minecraft.world.gen.feature.StructureFeature;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
@@ -15,10 +13,10 @@ import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(HuskEntity.class) @Mixin(HuskEntity.class)
public class HuskEntityMixin public class HuskEntityMixin
{ {
@Redirect(method = "canSpawn", at = @At(value = "INVOKE", target="Lnet/minecraft/class_5425;isSkyVisible(Lnet/minecraft/util/math/BlockPos;)Z")) @Redirect(method = "canSpawn", at = @At(value = "INVOKE", target="Lnet/minecraft/world/ServerWorldAccess;isSkyVisible(Lnet/minecraft/util/math/BlockPos;)Z"))
private static boolean isSkylightOrTempleVisible(class_5425 class_5425, BlockPos pos) private static boolean isSkylightOrTempleVisible(ServerWorldAccess serverWorldAccess, BlockPos pos)
{ {
return class_5425.isSkyVisible(pos) || return serverWorldAccess.isSkyVisible(pos) ||
(CarpetSettings.huskSpawningInTemples && (((ServerWorld)class_5425).getStructureAccessor().method_28388(pos, false, StructureFeature.DESERT_PYRAMID).hasChildren())); (CarpetSettings.huskSpawningInTemples && (((ServerWorld)serverWorldAccess).getStructureAccessor().getStructureAt(pos, false, StructureFeature.DESERT_PYRAMID).hasChildren()));
} }
} }
@@ -75,7 +75,7 @@ public abstract class LightStorage_scarpetChunkCreationMixin implements LightSto
{ {
for (int y = -1; y < 17; ++y) for (int y = -1; y < 17; ++y)
{ {
final long sectionPos = ChunkSectionPos.asLong(ChunkSectionPos.getX(cPos), y, ChunkSectionPos.getZ(cPos)); final long sectionPos = ChunkSectionPos.asLong(ChunkSectionPos.unpackX(cPos), y, ChunkSectionPos.unpackZ(cPos));
this.queuedSections.remove(sectionPos); this.queuedSections.remove(sectionPos);
@@ -48,7 +48,7 @@ public abstract class ServerLightingProvider_scarpetChunkCreationMixin extends L
this.enqueue(pos.x, pos.z, () -> 0, ServerLightingProvider.Stage.PRE_UPDATE, Util.debugRunnable(() -> { this.enqueue(pos.x, pos.z, () -> 0, ServerLightingProvider.Stage.PRE_UPDATE, Util.debugRunnable(() -> {
super.setColumnEnabled(pos, false); super.setColumnEnabled(pos, false);
((Lighting_scarpetChunkCreationInterface) this).removeLightData(ChunkSectionPos.withZeroZ(ChunkSectionPos.asLong(pos.x, 0, pos.z))); ((Lighting_scarpetChunkCreationInterface) this).removeLightData(ChunkSectionPos.withZeroY(ChunkSectionPos.asLong(pos.x, 0, pos.z)));
}, },
() -> "Remove light data " + pos () -> "Remove light data " + pos
)); ));
@@ -66,7 +66,7 @@ public abstract class ServerLightingProvider_scarpetChunkCreationMixin extends L
blockPos -> super.addLightSource(blockPos, chunk.getLuminance(blockPos)) blockPos -> super.addLightSource(blockPos, chunk.getLuminance(blockPos))
); );
((Lighting_scarpetChunkCreationInterface) this).relight(ChunkSectionPos.withZeroZ(ChunkSectionPos.asLong(pos.x, 0, pos.z))); ((Lighting_scarpetChunkCreationInterface) this).relight(ChunkSectionPos.withZeroY(ChunkSectionPos.asLong(pos.x, 0, pos.z)));
}, },
() -> "Relight chunk " + pos () -> "Relight chunk " + pos
)); ));
@@ -47,7 +47,7 @@ public abstract class SkyLightStorage_scarpetChunkCreationMixin extends LightSto
{ {
for (int y = -1; y < 17; ++y) for (int y = -1; y < 17; ++y)
{ {
final long sectionPos = ChunkSectionPos.asLong(ChunkSectionPos.getX(cPos), y, ChunkSectionPos.getZ(cPos)); final long sectionPos = ChunkSectionPos.asLong(ChunkSectionPos.unpackX(cPos), y, ChunkSectionPos.unpackZ(cPos));
this.sectionsToUpdate.remove(sectionPos); this.sectionsToUpdate.remove(sectionPos);
this.sectionsToRemove.remove(sectionPos); this.sectionsToRemove.remove(sectionPos);
@@ -63,8 +63,8 @@ public abstract class SkyLightStorage_scarpetChunkCreationMixin extends LightSto
for (int y = -1; y < 17; ++y) for (int y = -1; y < 17; ++y)
{ {
final long sectionPos = ChunkSectionPos.asLong(ChunkSectionPos.getX(cPos), y, ChunkSectionPos.getZ(cPos)); final long sectionPos = ChunkSectionPos.asLong(ChunkSectionPos.unpackX(cPos), y, ChunkSectionPos.unpackZ(cPos));
final long pos = BlockPos.asLong(ChunkSectionPos.getBlockCoord(ChunkSectionPos.getX(sectionPos)), ChunkSectionPos.getBlockCoord(y), ChunkSectionPos.getBlockCoord(ChunkSectionPos.getZ(sectionPos))); final long pos = BlockPos.asLong(ChunkSectionPos.getBlockCoord(ChunkSectionPos.unpackX(sectionPos)), ChunkSectionPos.getBlockCoord(y), ChunkSectionPos.getBlockCoord(ChunkSectionPos.unpackZ(sectionPos)));
if (!this.hasSection(sectionPos)) if (!this.hasSection(sectionPos))
continue; continue;
@@ -95,11 +95,11 @@ public abstract class SkyLightStorage_scarpetChunkCreationMixin extends LightSto
long src = BlockPos.offset(dst, dir); long src = BlockPos.offset(dst, dir);
if (neighborLightArray == null) if (neighborLightArray == null)
src = BlockPos.asLong(BlockPos.unpackLongX(src), ChunkSectionPos.getBlockCoord(ChunkSectionPos.getY(neighborCeilingSectionPos)), BlockPos.unpackLongZ(src)); src = BlockPos.asLong(BlockPos.unpackLongX(src), ChunkSectionPos.getBlockCoord(ChunkSectionPos.unpackY(neighborCeilingSectionPos)), BlockPos.unpackLongZ(src));
final int srcLevel = neighborCeilingLightArray != null ? final int srcLevel = neighborCeilingLightArray != null ?
((ChunkLightProviderInterface) lightProvider).callGetCurrentLevelFromSection(neighborCeilingLightArray, src) ((ChunkLightProviderInterface) lightProvider).callGetCurrentLevelFromSection(neighborCeilingLightArray, src)
: this.isSectionEnabled(ChunkSectionPos.withZeroZ(neighborCeilingSectionPos)) ? 0 : 15; : this.isSectionEnabled(ChunkSectionPos.withZeroY(neighborCeilingSectionPos)) ? 0 : 15;
levelPropagator.invokeUpdateLevel(src, dst, levelPropagator.callGetPropagatedLevel(src, dst, srcLevel), true); levelPropagator.invokeUpdateLevel(src, dst, levelPropagator.callGetPropagatedLevel(src, dst, srcLevel), true);
} }
@@ -6,7 +6,6 @@ import carpet.utils.SpawnReporter;
import net.minecraft.block.Block; 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.class_5425;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.SpawnGroup; import net.minecraft.entity.SpawnGroup;
import net.minecraft.entity.EntityData; import net.minecraft.entity.EntityData;
@@ -23,13 +22,12 @@ import net.minecraft.util.math.MathHelper;
import net.minecraft.util.registry.RegistryKey; import net.minecraft.util.registry.RegistryKey;
import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes; import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.WorldAccess; import net.minecraft.world.ServerWorldAccess;
import net.minecraft.world.LocalDifficulty; import net.minecraft.world.LocalDifficulty;
import net.minecraft.world.SpawnHelper; import net.minecraft.world.SpawnHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.WorldChunk; import net.minecraft.world.chunk.WorldChunk;
import net.minecraft.world.dimension.DimensionType;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@@ -153,7 +151,7 @@ public class SpawnHelperMixin
@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( @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;method_30771(Lnet/minecraft/entity/Entity;)V"//"Lnet/minecraft/server/world/ServerWorld;spawnEntity(Lnet/minecraft/entity/Entity;)Z" target = "Lnet/minecraft/server/world/ServerWorld;spawnEntityAndPassengers(Lnet/minecraft/entity/Entity;)V"//"Lnet/minecraft/server/world/ServerWorld;spawnEntity(Lnet/minecraft/entity/Entity;)Z"
)) ))
private static void spawnEntity(ServerWorld world, Entity entity_1) private static void spawnEntity(ServerWorld world, Entity entity_1)
{ {
@@ -170,18 +168,18 @@ public class SpawnHelperMixin
entity_1.getBlockPos()); entity_1.getBlockPos());
} }
if (!SpawnReporter.mock_spawns) if (!SpawnReporter.mock_spawns)
world.method_30771(entity_1); world.spawnEntityAndPassengers(entity_1);
//world.spawnEntity(entity_1); //world.spawnEntity(entity_1);
} }
@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( @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/class_5425;Lnet/minecraft/world/LocalDifficulty;Lnet/minecraft/entity/SpawnReason;Lnet/minecraft/entity/EntityData;Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/entity/EntityData;" target = "Lnet/minecraft/entity/mob/MobEntity;initialize(Lnet/minecraft/world/ServerWorldAccess;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, class_5425 foo, LocalDifficulty localDifficulty_1, SpawnReason spawnType_1, EntityData entityData_1, CompoundTag compoundTag_1) private static EntityData spawnEntity(MobEntity mobEntity, ServerWorldAccess serverWorldAccess, LocalDifficulty difficulty, SpawnReason spawnReason, EntityData entityData, CompoundTag entityTag)
{ {
if (!SpawnReporter.mock_spawns) // WorldAccess if (!SpawnReporter.mock_spawns) // WorldAccess
return mobEntity.initialize(foo, localDifficulty_1, spawnType_1, entityData_1, compoundTag_1); return mobEntity.initialize(serverWorldAccess, difficulty, spawnReason, entityData, entityTag);
return null; return null;
} }
@@ -2,11 +2,10 @@ package carpet.mixins;
import carpet.CarpetSettings; import carpet.CarpetSettings;
import net.minecraft.block.entity.StructureBlockBlockEntity; import net.minecraft.block.entity.StructureBlockBlockEntity;
import net.minecraft.class_5425;
import net.minecraft.structure.Structure; import net.minecraft.structure.Structure;
import net.minecraft.structure.StructurePlacementData; import net.minecraft.structure.StructurePlacementData;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldAccess; import net.minecraft.world.ServerWorldAccess;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.Redirect;
@@ -18,15 +17,15 @@ public abstract class StructureBlockBlockEntity_fillUpdatesMixin
{ {
@Redirect(method = "place", at = @At( @Redirect(method = "place", at = @At(
value = "INVOKE", value = "INVOKE",
target = "Lnet/minecraft/structure/Structure;place(Lnet/minecraft/class_5425;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/structure/StructurePlacementData;Ljava/util/Random;)V" target = "Lnet/minecraft/structure/Structure;place(Lnet/minecraft/world/ServerWorldAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/structure/StructurePlacementData;Ljava/util/Random;)V"
)) ))
private void onStructurePlacen(Structure structure, class_5425 world, BlockPos pos, StructurePlacementData placementData, Random random) private void onStructurePlacen(Structure structure, ServerWorldAccess serverWorldAccess, BlockPos pos, StructurePlacementData placementData, Random random)
{ {
if(!CarpetSettings.fillUpdates) if(!CarpetSettings.fillUpdates)
CarpetSettings.impendingFillSkipUpdates = true; CarpetSettings.impendingFillSkipUpdates = true;
try try
{ {
structure.place(world, pos, placementData, random); structure.place(serverWorldAccess, pos, placementData, random);
} }
finally finally
{ {
@@ -2,11 +2,10 @@ package carpet.mixins;
import carpet.CarpetSettings; import carpet.CarpetSettings;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.class_5425;
import net.minecraft.structure.Structure; import net.minecraft.structure.Structure;
import net.minecraft.structure.StructurePlacementData; import net.minecraft.structure.StructurePlacementData;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldAccess; import net.minecraft.world.ServerWorldAccess;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.Redirect;
@@ -14,17 +13,17 @@ import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(Structure.class) @Mixin(Structure.class)
public class Structure_fillUpdatesMixin public class Structure_fillUpdatesMixin
{ {
@Redirect( method = "place(Lnet/minecraft/class_5425;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/structure/StructurePlacementData;Ljava/util/Random;I)Z", at = @At( @Redirect( method = "place(Lnet/minecraft/world/ServerWorldAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/structure/StructurePlacementData;Ljava/util/Random;I)Z", at = @At(
value = "INVOKE", value = "INVOKE",
target = "Lnet/minecraft/class_5425;updateNeighbors(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/Block;)V" target = "Lnet/minecraft/world/ServerWorldAccess;updateNeighbors(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/Block;)V"
)) ))
private void skipUpdateNeighbours(class_5425 class_5425, BlockPos pos, Block block) private void skipUpdateNeighbours(ServerWorldAccess serverWorldAccess, BlockPos pos, Block block)
{ {
if (!CarpetSettings.impendingFillSkipUpdates) if (!CarpetSettings.impendingFillSkipUpdates)
class_5425.updateNeighbors(pos, block); serverWorldAccess.updateNeighbors(pos, block);
} }
@Redirect(method = "place(Lnet/minecraft/class_5425;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/structure/StructurePlacementData;Ljava/util/Random;I)Z", at = @At( @Redirect(method = "place(Lnet/minecraft/world/ServerWorldAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/structure/StructurePlacementData;Ljava/util/Random;I)Z", at = @At(
value = "INVOKE", value = "INVOKE",
target = "Lnet/minecraft/structure/StructurePlacementData;shouldUpdateNeighbors()Z" target = "Lnet/minecraft/structure/StructurePlacementData;shouldUpdateNeighbors()Z"
)) ))
@@ -32,14 +32,14 @@ public abstract class SurfaceChunkGenerator_husksSpawnMixin extends ChunkGenerat
{ {
if (CarpetSettings.huskSpawningInTemples && group == SpawnGroup.MONSTER) if (CarpetSettings.huskSpawningInTemples && group == SpawnGroup.MONSTER)
{ {
if (accessor.method_28388(pos, true, StructureFeature.DESERT_PYRAMID).hasChildren()) if (accessor.getStructureAt(pos, true, StructureFeature.DESERT_PYRAMID).hasChildren())
{ {
cir.setReturnValue(StructureFeature.DESERT_PYRAMID.getMonsterSpawns()); cir.setReturnValue(StructureFeature.DESERT_PYRAMID.getMonsterSpawns());
} }
} }
if (CarpetSettings.shulkerSpawningInEndCities && SpawnGroup.MONSTER == group) if (CarpetSettings.shulkerSpawningInEndCities && SpawnGroup.MONSTER == group)
{ {
if (accessor.method_28388(pos, true, StructureFeature.END_CITY).hasChildren()) if (accessor.getStructureAt(pos, true, StructureFeature.END_CITY).hasChildren())
{ {
cir.setReturnValue(StructureFeature.END_CITY.getMonsterSpawns()); cir.setReturnValue(StructureFeature.END_CITY.getMonsterSpawns());
} }
@@ -93,7 +93,7 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
protected abstract boolean updateHolderMap(); protected abstract boolean updateHolderMap();
@Shadow @Shadow
protected abstract CompletableFuture<Either<List<Chunk>, Unloaded>> createChunkRegionFuture(final ChunkPos centerChunk, final int margin, final IntFunction<ChunkStatus> distanceToStatus); protected abstract CompletableFuture<Either<List<Chunk>, Unloaded>> getRegion (final ChunkPos centerChunk, final int margin, final IntFunction<ChunkStatus> distanceToStatus);
//in method_20617 //in method_20617
//method_19534(Lnet/minecraft/server/world/ChunkHolder;Lnet/minecraft/world/chunk/Chunk;)Ljava/util/concurrent/CompletableFuture; //method_19534(Lnet/minecraft/server/world/ChunkHolder;Lnet/minecraft/world/chunk/Chunk;)Ljava/util/concurrent/CompletableFuture;
@@ -114,7 +114,7 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
@Unique @Unique
private void addTicket(final ChunkPos pos, final ChunkStatus status) private void addTicket(final ChunkPos pos, final ChunkStatus status)
{ // UNKNOWN { // UNKNOWN
this.ticketManager.addTicketWithLevel(ChunkTicketType.field_14032, pos, 33 + ChunkStatus.getTargetGenerationRadius(status), pos); this.ticketManager.addTicketWithLevel(ChunkTicketType.field_14032, pos, 33 + ChunkStatus.getDistanceFromFull(status), pos);
} }
@Unique @Unique
@@ -162,7 +162,7 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
{ {
final Set<ChunkPos> existingChunks = this.getExistingChunks(requestedChunks); final Set<ChunkPos> existingChunks = this.getExistingChunks(requestedChunks);
for (final ChunkPos pos : existingChunks) for (final ChunkPos pos : existingChunks)
this.currentChunkHolders.get(pos.toLong()).createFuture(ChunkStatus.EMPTY, (ThreadedAnvilChunkStorage) (Object) this); this.currentChunkHolders.get(pos.toLong()).getChunkAt(ChunkStatus.EMPTY, (ThreadedAnvilChunkStorage) (Object) this);
return existingChunks; return existingChunks;
} }
@@ -184,7 +184,7 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
// Fetch all currently loaded chunks // Fetch all currently loaded chunks
final Set<ChunkPos> loadedChunks = requestedChunks.stream().filter( final Set<ChunkPos> loadedChunks = requestedChunks.stream().filter(
pos -> this.currentChunkHolders.get(pos.toLong()).getCompletedChunk() != null // all relevant ChunkHolders exist pos -> this.currentChunkHolders.get(pos.toLong()).getCurrentChunk() != null // all relevant ChunkHolders exist
).collect(Collectors.toSet()); ).collect(Collectors.toSet());
if (report != null) if (report != null)
@@ -223,7 +223,7 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
@Unique @Unique
private Chunk getCurrentChunk(final ChunkPos pos) private Chunk getCurrentChunk(final ChunkPos pos)
{ {
final CompletableFuture<Chunk> future = this.currentChunkHolders.get(pos.toLong()).getFuture(); final CompletableFuture<Chunk> future = this.currentChunkHolders.get(pos.toLong()).getSavingFuture();
this.waitFor(future); this.waitFor(future);
return future.join(); return future.join();
@@ -234,14 +234,14 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
{ {
this.addTicket(pos); this.addTicket(pos);
this.tickTicketManager(); this.tickTicketManager();
if (this.currentChunkHolders.get(pos.toLong()).getCompletedChunk() == null) // chunk unloaded if (this.currentChunkHolders.get(pos.toLong()).getCurrentChunk() == null) // chunk unloaded
if (WorldTools.canHasChunk(this.world, pos, null, true)) if (WorldTools.canHasChunk(this.world, pos, null, true))
this.currentChunkHolders.get(pos.toLong()).createFuture(ChunkStatus.EMPTY, (ThreadedAnvilChunkStorage) (Object) this); this.currentChunkHolders.get(pos.toLong()).getChunkAt(ChunkStatus.EMPTY, (ThreadedAnvilChunkStorage) (Object) this);
final Chunk chunk = this.getCurrentChunk(pos); final Chunk chunk = this.getCurrentChunk(pos);
if (!(chunk.getStatus().isAtLeast(ChunkStatus.LIGHT.getPrevious()))) return; if (!(chunk.getStatus().isAtLeast(ChunkStatus.LIGHT.getPrevious()))) return;
((ServerLightingProviderInterface) this.serverLightingProvider).removeLightData(chunk); ((ServerLightingProviderInterface) this.serverLightingProvider).removeLightData(chunk);
this.addRelightTicket(pos); this.addRelightTicket(pos);
final CompletableFuture<?> lightFuture = this.createChunkRegionFuture(pos, 1, (pos_) -> ChunkStatus.LIGHT) final CompletableFuture<?> lightFuture = this.getRegion (pos, 1, (pos_) -> ChunkStatus.LIGHT)
.thenCompose( .thenCompose(
either -> either.map( either -> either.map(
list -> ((ServerLightingProviderInterface) this.serverLightingProvider).relight(chunk), list -> ((ServerLightingProviderInterface) this.serverLightingProvider).relight(chunk),
@@ -360,7 +360,7 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
{ {
final ChunkPos pos = chunk.getPos(); final ChunkPos pos = chunk.getPos();
lightFutures.add(this.createChunkRegionFuture(pos, 1, (pos_) -> ChunkStatus.LIGHT).thenCompose( lightFutures.add(this.getRegion (pos, 1, (pos_) -> ChunkStatus.LIGHT).thenCompose(
either -> either.map( either -> either.map(
list -> ((ServerLightingProviderInterface) this.serverLightingProvider).relight(chunk), list -> ((ServerLightingProviderInterface) this.serverLightingProvider).relight(chunk),
unloaded -> { unloaded -> {
@@ -389,7 +389,7 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
for (final Entry<ChunkPos, ChunkStatus> entry : targetGenerationStatus.entrySet()) for (final Entry<ChunkPos, ChunkStatus> entry : targetGenerationStatus.entrySet())
targetGenerationFutures.add(Pair.of( targetGenerationFutures.add(Pair.of(
entry.getValue(), entry.getValue(),
this.currentChunkHolders.get(entry.getKey().toLong()).createFuture(entry.getValue(), (ThreadedAnvilChunkStorage) (Object) this) this.currentChunkHolders.get(entry.getKey().toLong()).getChunkAt(entry.getValue(), (ThreadedAnvilChunkStorage) (Object) this)
)); ));
final Map<ChunkStatus, List<CompletableFuture<?>>> targetGenerationFuturesGrouped = targetGenerationFutures.stream().collect( final Map<ChunkStatus, List<CompletableFuture<?>>> targetGenerationFuturesGrouped = targetGenerationFutures.stream().collect(
@@ -416,7 +416,7 @@ public class SpawnReporter
// yeeted from SpawnHelper - temporary fix // yeeted from SpawnHelper - temporary fix
private static List<Biome.SpawnEntry> method_29950(ServerWorld serverWorld, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator, SpawnGroup spawnGroup, BlockPos blockPos, /*@Nullable*/ Biome biome) { private static List<Biome.SpawnEntry> method_29950(ServerWorld serverWorld, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator, SpawnGroup spawnGroup, BlockPos blockPos, /*@Nullable*/ Biome biome) {
return spawnGroup == SpawnGroup.MONSTER && serverWorld.getBlockState(blockPos.down()).getBlock() == Blocks.NETHER_BRICKS && structureAccessor.method_28388(blockPos, false, StructureFeature.FORTRESS).hasChildren() ? StructureFeature.FORTRESS.getMonsterSpawns() : chunkGenerator.getEntitySpawnList(biome != null ? biome : serverWorld.getBiome(blockPos), structureAccessor, spawnGroup, blockPos); return spawnGroup == SpawnGroup.MONSTER && serverWorld.getBlockState(blockPos.down()).getBlock() == Blocks.NETHER_BRICKS && structureAccessor.getStructureAt(blockPos, false, StructureFeature.FORTRESS).hasChildren() ? StructureFeature.FORTRESS.getMonsterSpawns() : chunkGenerator.getEntitySpawnList(biome != null ? biome : serverWorld.getBiome(blockPos), structureAccessor, spawnGroup, blockPos);
} }
public static List<BaseText> report(BlockPos pos, ServerWorld worldIn) public static List<BaseText> report(BlockPos pos, ServerWorld worldIn)