diff --git a/gradle.properties b/gradle.properties index 6695c608..f726a05b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,8 +4,8 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html - minecraft_version=20w21a - yarn_mappings=20w21a+build.16 + minecraft_version=20w22a + yarn_mappings=20w22a+build.1 loader_version=0.8.4+build.198 # Mod Properties diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index 963fe7db..28e54b95 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -15,6 +15,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Box; import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; import net.minecraft.world.dimension.DimensionType; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -523,7 +524,7 @@ public class CarpetSettings public static class ChangeSpawnChunksValidator extends Validator { public static void changeSpawnSize(int size) { - ServerWorld overworld = CarpetServer.minecraft_server.getWorld(DimensionType.OVERWORLD_REGISTRY_KEY); // OW + ServerWorld overworld = CarpetServer.minecraft_server.getWorld(World.field_25179); // OW if (overworld != null) { ChunkPos centerChunk = new ChunkPos(new BlockPos( overworld.getLevelProperties().getSpawnX(), @@ -544,7 +545,7 @@ public class CarpetSettings //must been some startup thing return newValue; } - ServerWorld currentOverworld = CarpetServer.minecraft_server.getWorld(DimensionType.OVERWORLD_REGISTRY_KEY); // OW + ServerWorld currentOverworld = CarpetServer.minecraft_server.getWorld(World.field_25179); // OW if (currentOverworld != null) { changeSpawnSize(newValue); diff --git a/src/main/java/carpet/commands/PlayerCommand.java b/src/main/java/carpet/commands/PlayerCommand.java index ee81c3ef..d894f53c 100644 --- a/src/main/java/carpet/commands/PlayerCommand.java +++ b/src/main/java/carpet/commands/PlayerCommand.java @@ -28,6 +28,7 @@ import net.minecraft.util.math.Vec2f; import net.minecraft.util.math.Vec3d; import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.GameMode; +import net.minecraft.world.World; import net.minecraft.world.dimension.DimensionType; import java.util.Arrays; @@ -235,7 +236,7 @@ public class PlayerCommand () -> RotationArgumentType.getRotation(context, "direction").toAbsoluteRotation(context.getSource()), source::getRotation ); - RegistryKey dimType = tryGetArg( + RegistryKey dimType = tryGetArg( () -> DimensionArgumentType.getDimensionArgument(context, "dimension"), () -> source.getWorld().method_27983() // dimension.getType() ); diff --git a/src/main/java/carpet/commands/SpawnCommand.java b/src/main/java/carpet/commands/SpawnCommand.java index 90ca891c..63ba9752 100644 --- a/src/main/java/carpet/commands/SpawnCommand.java +++ b/src/main/java/carpet/commands/SpawnCommand.java @@ -19,6 +19,7 @@ import net.minecraft.server.command.ServerCommandSource; import net.minecraft.util.DyeColor; import net.minecraft.util.math.BlockPos; import net.minecraft.util.registry.RegistryKey; +import net.minecraft.world.World; import net.minecraft.world.dimension.DimensionType; import java.util.Arrays; @@ -258,7 +259,7 @@ public class SpawnCommand return 1; } - private static int mobcapsForDimension(ServerCommandSource source, RegistryKey dim) + private static int mobcapsForDimension(ServerCommandSource source, RegistryKey dim) { Messenger.send(source, SpawnReporter.printMobcapsForDimension(source.getMinecraftServer().getWorld(dim), true)); return 1; diff --git a/src/main/java/carpet/helpers/FeatureGenerator.java b/src/main/java/carpet/helpers/FeatureGenerator.java index c93c3114..c788e084 100644 --- a/src/main/java/carpet/helpers/FeatureGenerator.java +++ b/src/main/java/carpet/helpers/FeatureGenerator.java @@ -61,11 +61,6 @@ import static net.minecraft.world.biome.DefaultBiomeFeatures.OAK_TREE_CONFIG; public class FeatureGenerator { - public static String fix(String key) - { - return key.toLowerCase(Locale.ROOT); - } - @FunctionalInterface private interface Thing { @@ -156,28 +151,28 @@ public class FeatureGenerator } - public static final Map> structureToFeature = new HashMap<>(); - public static final Map featureToStructure = new HashMap<>(); + public static final Map, List> structureToFeature = new HashMap<>(); + public static final Map> featureToStructure = new HashMap<>(); static { - structureToFeature.put(StructureFeature.MONUMENT.getName(), Collections.singletonList("monument")); - structureToFeature.put(StructureFeature.END_CITY.getName(), Collections.singletonList("end_city")); - structureToFeature.put(StructureFeature.OCEAN_RUIN.getName(), Arrays.asList("ocean_ruin", "ocean_ruin_warm", "ocean_ruin_small", "ocean_ruin_warm_small", "ocean_ruin_tall", "ocean_ruin_warm_tall")); - structureToFeature.put(StructureFeature.VILLAGE.getName(), Arrays.asList("village", "village_desert", "village_savanna", "village_taiga", "village_snowy")); - structureToFeature.put(StructureFeature.MANSION.getName(), Collections.singletonList("mansion")); - structureToFeature.put(StructureFeature.BURIED_TREASURE.getName(), Collections.singletonList("treasure")); - structureToFeature.put(StructureFeature.field_24851.getName(), Collections.singletonList("witch_hut")); - structureToFeature.put(StructureFeature.STRONGHOLD.getName(), Collections.singletonList("stronghold")); - structureToFeature.put(StructureFeature.DESERT_PYRAMID.getName(), Collections.singletonList("desert_temple")); - structureToFeature.put(StructureFeature.JUNGLE_PYRAMID.getName(), Collections.singletonList("jungle_temple")); - structureToFeature.put(StructureFeature.SHIPWRECK.getName(), Arrays.asList("shipwreck", "shipwreck2")); - structureToFeature.put(StructureFeature.PILLAGER_OUTPOST.getName(), Collections.singletonList("pillager_outpost")); - structureToFeature.put(StructureFeature.MINESHAFT.getName(), Arrays.asList("mineshaft", "mineshaft_mesa")); - structureToFeature.put(StructureFeature.IGLOO.getName(), Collections.singletonList("igloo")); - structureToFeature.put(StructureFeature.FORTRESS.getName(), Collections.singletonList("fortress")); - structureToFeature.put(StructureFeature.NETHER_FOSSIL.getName(), Collections.singletonList("nether_fossil")); - structureToFeature.put(StructureFeature.BASTION_REMNANT.getName(), Arrays.asList("bastion_remnant", "bastion_remnant_housing", "bastion_remnant_stable", "bastion_remnant_treasure", "bastion_remnant_bridge")); - structureToFeature.put(StructureFeature.RUINED_PORTAL.getName(), Collections.singletonList("ruined_portal")); + structureToFeature.put(StructureFeature.MONUMENT, Collections.singletonList("monument")); + structureToFeature.put(StructureFeature.END_CITY, Collections.singletonList("end_city")); + structureToFeature.put(StructureFeature.OCEAN_RUIN, Arrays.asList("ocean_ruin", "ocean_ruin_warm", "ocean_ruin_small", "ocean_ruin_warm_small", "ocean_ruin_tall", "ocean_ruin_warm_tall")); + structureToFeature.put(StructureFeature.VILLAGE, Arrays.asList("village", "village_desert", "village_savanna", "village_taiga", "village_snowy")); + structureToFeature.put(StructureFeature.MANSION, Collections.singletonList("mansion")); + structureToFeature.put(StructureFeature.BURIED_TREASURE, Collections.singletonList("treasure")); + structureToFeature.put(StructureFeature.field_24851, Collections.singletonList("witch_hut")); + structureToFeature.put(StructureFeature.STRONGHOLD, Collections.singletonList("stronghold")); + structureToFeature.put(StructureFeature.DESERT_PYRAMID, Collections.singletonList("desert_temple")); + structureToFeature.put(StructureFeature.JUNGLE_PYRAMID, Collections.singletonList("jungle_temple")); + structureToFeature.put(StructureFeature.SHIPWRECK, Arrays.asList("shipwreck", "shipwreck2")); + structureToFeature.put(StructureFeature.PILLAGER_OUTPOST, Collections.singletonList("pillager_outpost")); + structureToFeature.put(StructureFeature.MINESHAFT, Arrays.asList("mineshaft", "mineshaft_mesa")); + structureToFeature.put(StructureFeature.IGLOO, Collections.singletonList("igloo")); + structureToFeature.put(StructureFeature.FORTRESS, Collections.singletonList("fortress")); + structureToFeature.put(StructureFeature.NETHER_FOSSIL, Collections.singletonList("nether_fossil")); + structureToFeature.put(StructureFeature.BASTION_REMNANT, Arrays.asList("bastion_remnant", "bastion_remnant_housing", "bastion_remnant_stable", "bastion_remnant_treasure", "bastion_remnant_bridge")); + structureToFeature.put(StructureFeature.RUINED_PORTAL, Collections.singletonList("ruined_portal")); structureToFeature.forEach((key, value) -> value.forEach(el -> featureToStructure.put(el, key))); } diff --git a/src/main/java/carpet/helpers/HopperCounter.java b/src/main/java/carpet/helpers/HopperCounter.java index 66660917..a409126f 100644 --- a/src/main/java/carpet/helpers/HopperCounter.java +++ b/src/main/java/carpet/helpers/HopperCounter.java @@ -10,6 +10,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.text.BaseText; import net.minecraft.text.TranslatableText; import net.minecraft.server.MinecraftServer; +import net.minecraft.world.World; import net.minecraft.world.dimension.DimensionType; import java.util.ArrayList; @@ -50,7 +51,7 @@ public class HopperCounter { if (startTick == 0) { - startTick = server.getWorld(DimensionType.OVERWORLD_REGISTRY_KEY).getTime(); //OW + startTick = server.getWorld(World.field_25179).getTime(); //OW startMillis = System.currentTimeMillis(); } Item item = stack.getItem(); @@ -61,7 +62,7 @@ public class HopperCounter public void reset(MinecraftServer server) { counter.clear(); - startTick = server.getWorld(DimensionType.OVERWORLD_REGISTRY_KEY).getTime(); //OW + startTick = server.getWorld(World.field_25179).getTime(); //OW startMillis = System.currentTimeMillis(); // pubSubProvider.publish(); } @@ -105,7 +106,7 @@ public class HopperCounter return Collections.singletonList(Messenger.s(String.format("No items for %s yet", color.getName()))); } long total = getTotalItems(); - long ticks = Math.max(realTime ? (System.currentTimeMillis() - startMillis) / 50 : server.getWorld(DimensionType.OVERWORLD_REGISTRY_KEY).getTime() - startTick, 1); //OW + long ticks = Math.max(realTime ? (System.currentTimeMillis() - startMillis) / 50 : server.getWorld(World.field_25179).getTime() - startTick, 1); //OW if (total == 0) { if (brief) diff --git a/src/main/java/carpet/mixins/PistonBlock_movableTEMixin.java b/src/main/java/carpet/mixins/PistonBlock_movableTEMixin.java index 28ef596a..a5750724 100644 --- a/src/main/java/carpet/mixins/PistonBlock_movableTEMixin.java +++ b/src/main/java/carpet/mixins/PistonBlock_movableTEMixin.java @@ -66,8 +66,8 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock target = "Ljava/util/List;size()I", ordinal = 4),locals = LocalCapture.CAPTURE_FAILHARD) private void onMove(World world_1, BlockPos blockPos_1, Direction direction_1, boolean boolean_1, CallbackInfoReturnable cir, BlockPos blockPos_2, PistonHandler pistonHandler_1, Map map_1, - List list_1, List list_2, List list_3, int int_2, BlockState[] blockStates_1, - Direction direction_2) + List list_1, List list_2, List list_3, BlockState[] blockStates_1, + Direction direction_2, int int_2) { //Get the blockEntities and remove them from the world before any magic starts to happen if (CarpetSettings.movableBlockEntities) @@ -95,7 +95,7 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock locals = LocalCapture.CAPTURE_FAILHARD) private void setBlockEntityWithCarried(World world_1, BlockPos blockPos_1, Direction direction_1, boolean boolean_1, CallbackInfoReturnable cir, BlockPos blockPos_2, PistonHandler pistonHandler_1, Map map_1, List list_1, - List list_2, List list_3, int int_2, BlockState[] blockStates_1, Direction direction_2, + List list_2, List list_3, BlockState[] blockStates_1, Direction direction_2, int int_2, int int_3, BlockPos blockPos_4, BlockState blockState_1) { BlockEntity blockEntityPiston = PistonExtensionBlock.createBlockEntityPiston((BlockState) list_2.get(int_3), diff --git a/src/main/java/carpet/mixins/ServerChunkManagerMixin.java b/src/main/java/carpet/mixins/ServerChunkManagerMixin.java index 5f9d11f0..740d5836 100644 --- a/src/main/java/carpet/mixins/ServerChunkManagerMixin.java +++ b/src/main/java/carpet/mixins/ServerChunkManagerMixin.java @@ -10,6 +10,7 @@ import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.SpawnHelper; +import net.minecraft.world.World; import net.minecraft.world.WorldProperties; import net.minecraft.world.chunk.WorldChunk; import net.minecraft.world.dimension.DimensionType; @@ -48,7 +49,7 @@ public abstract class ServerChunkManagerMixin implements ServerChunkManagerInter private int setupTracking(ChunkTicketManager chunkTicketManager) { int j = chunkTicketManager.getSpawningChunkCount(); - RegistryKey dim = this.world.method_27983(); // getDimensionType; + RegistryKey dim = this.world.method_27983(); // getDimensionType; //((WorldInterface)world).getPrecookedMobs().clear(); not needed because mobs are compared with predefined BBs SpawnReporter.chunkCounts.put(dim, j); @@ -78,7 +79,7 @@ public abstract class ServerChunkManagerMixin implements ServerChunkManagerInter { for (SpawnGroup cat: SpawnGroup.values()) { - RegistryKey dim = world.method_27983(); // getDimensionType; + RegistryKey dim = world.method_27983(); // getDimensionType; Pair key = Pair.of(dim, cat); int spawnTries = SpawnReporter.spawn_tries.get(cat); if (!SpawnReporter.local_spawns.containsKey(cat)) diff --git a/src/main/java/carpet/mixins/ServerPlayerEntity_scarpetEventMixin.java b/src/main/java/carpet/mixins/ServerPlayerEntity_scarpetEventMixin.java index 639c9f87..b3b9cee9 100644 --- a/src/main/java/carpet/mixins/ServerPlayerEntity_scarpetEventMixin.java +++ b/src/main/java/carpet/mixins/ServerPlayerEntity_scarpetEventMixin.java @@ -89,7 +89,7 @@ public abstract class ServerPlayerEntity_scarpetEventMixin extends PlayerEntity } private Vec3d previousLocation; - private RegistryKey previousDimension; + private RegistryKey previousDimension; @Inject(method = "changeDimension", at = @At("HEAD")) private void logPreviousCoordinates(RegistryKey newDimension, CallbackInfoReturnable cir) @@ -99,13 +99,13 @@ public abstract class ServerPlayerEntity_scarpetEventMixin extends PlayerEntity } @Inject(method = "changeDimension", at = @At("RETURN")) - private void atChangeDimension(RegistryKey newDimension, CallbackInfoReturnable cir) + private void atChangeDimension(RegistryKey newDimension, CallbackInfoReturnable cir) { if (PLAYER_CHANGES_DIMENSION.isNeeded()) { ServerPlayerEntity player = (ServerPlayerEntity) (Object)this; Vec3d to = null; - if (!notInAnyWorld || previousDimension != DimensionType.THE_END_REGISTRY_KEY || newDimension != DimensionType.OVERWORLD_REGISTRY_KEY) // end ow + if (!notInAnyWorld || previousDimension != World.field_25181 || newDimension != World.field_25179) // end ow { to = getPos(); } diff --git a/src/main/java/carpet/mixins/ServerWorld_tickMixin.java b/src/main/java/carpet/mixins/ServerWorld_tickMixin.java index b673f1c3..608bc0d9 100644 --- a/src/main/java/carpet/mixins/ServerWorld_tickMixin.java +++ b/src/main/java/carpet/mixins/ServerWorld_tickMixin.java @@ -5,6 +5,7 @@ import carpet.utils.CarpetProfiler; import net.minecraft.entity.raid.RaidManager; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.profiler.Profiler; +import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.MutableWorldProperties; import net.minecraft.world.WanderingTraderManager; import net.minecraft.world.World; @@ -28,9 +29,9 @@ public abstract class ServerWorld_tickMixin extends World //@Shadow protected abstract void sendBlockActions(); @Shadow protected abstract void method_29203(); - protected ServerWorld_tickMixin(MutableWorldProperties mutableWorldProperties, DimensionType dimensionType, Supplier supplier, boolean bl, boolean bl2, long l) + protected ServerWorld_tickMixin(MutableWorldProperties mutableWorldProperties, RegistryKey registryKey, RegistryKey registryKey2, DimensionType dimensionType, Supplier supplier, boolean bl, boolean bl2, long l) { - super(mutableWorldProperties, dimensionType, supplier, bl, bl2, l); + super(mutableWorldProperties, registryKey, registryKey2, dimensionType, supplier, bl, bl2, l); } private CarpetProfiler.ProfilerToken currentSection; diff --git a/src/main/java/carpet/mixins/SpawnHelperMixin.java b/src/main/java/carpet/mixins/SpawnHelperMixin.java index 6ee24f36..2fd3a74a 100644 --- a/src/main/java/carpet/mixins/SpawnHelperMixin.java +++ b/src/main/java/carpet/mixins/SpawnHelperMixin.java @@ -281,7 +281,7 @@ public class SpawnHelperMixin SpawnGroup entityCategory = var6[var8]; if ((spawnAnimals || !entityCategory.isPeaceful()) && (spawnMonsters || entityCategory.isPeaceful()) && (shouldSpawnAnimals || !entityCategory.isAnimal()) ) { - RegistryKey dim = world.method_27983(); // getDimensionType; + RegistryKey dim = world.method_27983(); // getDimensionType; 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 diff --git a/src/main/java/carpet/mixins/StructureBlockBlockEntity_fillUpdatesMixin.java b/src/main/java/carpet/mixins/StructureBlockBlockEntity_fillUpdatesMixin.java index 50e9fcd8..1bc38c81 100644 --- a/src/main/java/carpet/mixins/StructureBlockBlockEntity_fillUpdatesMixin.java +++ b/src/main/java/carpet/mixins/StructureBlockBlockEntity_fillUpdatesMixin.java @@ -10,20 +10,22 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; +import java.util.Random; + @Mixin(StructureBlockBlockEntity.class) public abstract class StructureBlockBlockEntity_fillUpdatesMixin { @Redirect(method = "place", at = @At( value = "INVOKE", - target = "Lnet/minecraft/structure/Structure;place(Lnet/minecraft/world/WorldAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/structure/StructurePlacementData;)V" + target = "Lnet/minecraft/structure/Structure;place(Lnet/minecraft/world/WorldAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/structure/StructurePlacementData;Ljava/util/Random;)V" )) - private void onStructurePlacen(Structure structure, WorldAccess WorldAccess_1, BlockPos blockPos_1, StructurePlacementData structurePlacementData_1) + private void onStructurePlacen(Structure structure, WorldAccess world, BlockPos pos, StructurePlacementData placementData, Random random) { if(!CarpetSettings.fillUpdates) CarpetSettings.impendingFillSkipUpdates = true; try { - structure.place(WorldAccess_1, blockPos_1, structurePlacementData_1); + structure.place(world, pos, placementData, random); } finally { diff --git a/src/main/java/carpet/mixins/StructureFeatureMixin.java b/src/main/java/carpet/mixins/StructureFeatureMixin.java index fcfedbd7..39512007 100644 --- a/src/main/java/carpet/mixins/StructureFeatureMixin.java +++ b/src/main/java/carpet/mixins/StructureFeatureMixin.java @@ -66,7 +66,7 @@ public abstract class StructureFeatureMixin implements } //generator.ge getStructurePositionToReferenceMap(this).computeIfAbsent(chId, // (x) -> new LongOpenHashSet()).add(chId); - world.getChunk(j, k).addStructureReference(this.getName(), chId); //, ChunkStatus.STRUCTURE_STARTS + world.getChunk(j, k).addStructureReference((StructureFeature) (Object)this, chId); //, ChunkStatus.STRUCTURE_STARTS BlockBox box = structurestart.getBoundingBox(); if (!wireOnly) @@ -93,7 +93,7 @@ public abstract class StructureFeatureMixin implements if (box.intersectsXZ(k1<<4, l1<<4, (k1<<4) + 15, (l1<<4) + 15)) { //generator.getStructurePositionToReferenceMap(this).computeIfAbsent(nbchkid, (__) -> new LongOpenHashSet()).add(chId); - world.getChunk(k1, l1).addStructureReference(this.getName(), chId); //, ChunkStatus.STRUCTURE_STARTS + world.getChunk(k1, l1).addStructureReference((StructureFeature) (Object)this, chId); //, ChunkStatus.STRUCTURE_STARTS //structurestart. notifyPostProcessAt(new ChunkPos(k1, l1)); } } @@ -121,7 +121,7 @@ public abstract class StructureFeatureMixin implements if (ichunk != null) { - structurestart = ichunk.getStructureStart(this.getName()); + structurestart = ichunk.getStructureStart((StructureFeature)(Object)this); if (structurestart != null && structurestart != StructureStart.DEFAULT) { @@ -140,7 +140,7 @@ public abstract class StructureFeatureMixin implements if (structurestart.hasChildren()) { - worldIn.getChunk(chunkpos.x, chunkpos.z).setStructureStart(this.getName(), structurestart); + worldIn.getChunk(chunkpos.x, chunkpos.z).setStructureStart((StructureFeature)(Object)this, structurestart); } //long2objectmap.put(packedChunkPos, structurestart); diff --git a/src/main/java/carpet/mixins/Structure_fillUpdatesMixin.java b/src/main/java/carpet/mixins/Structure_fillUpdatesMixin.java index 0d282dbc..880b53df 100644 --- a/src/main/java/carpet/mixins/Structure_fillUpdatesMixin.java +++ b/src/main/java/carpet/mixins/Structure_fillUpdatesMixin.java @@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(Structure.class) public class Structure_fillUpdatesMixin { - @Redirect( method = "place(Lnet/minecraft/world/WorldAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/structure/StructurePlacementData;I)Z", at = @At( + @Redirect( method = "place(Lnet/minecraft/world/WorldAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/structure/StructurePlacementData;Ljava/util/Random;I)Z", at = @At( value = "INVOKE", target = "Lnet/minecraft/world/WorldAccess;updateNeighbors(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/Block;)V" )) @@ -23,7 +23,7 @@ public class Structure_fillUpdatesMixin WorldAccess.updateNeighbors(var1, var2); } - @Redirect(method = "place(Lnet/minecraft/world/WorldAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/structure/StructurePlacementData;I)Z", at = @At( + @Redirect(method = "place(Lnet/minecraft/world/WorldAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/structure/StructurePlacementData;Ljava/util/Random;I)Z", at = @At( value = "INVOKE", target = "Lnet/minecraft/structure/StructurePlacementData;shouldUpdateNeighbors()Z" )) diff --git a/src/main/java/carpet/patches/EntityPlayerMPFake.java b/src/main/java/carpet/patches/EntityPlayerMPFake.java index 6bb12788..0e16498e 100644 --- a/src/main/java/carpet/patches/EntityPlayerMPFake.java +++ b/src/main/java/carpet/patches/EntityPlayerMPFake.java @@ -16,6 +16,7 @@ import net.minecraft.server.network.ServerPlayerInteractionManager; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.GameMode; +import net.minecraft.world.World; import net.minecraft.world.dimension.DimensionType; import carpet.fakes.ServerPlayerEntityInterface; import carpet.utils.Messenger; @@ -26,7 +27,7 @@ public class EntityPlayerMPFake extends ServerPlayerEntity public Runnable fixStartingPosition = () -> {}; public boolean isAShadow; - public static EntityPlayerMPFake createFake(String username, MinecraftServer server, double d0, double d1, double d2, double yaw, double pitch, RegistryKey dimensionId, GameMode gamemode) + public static EntityPlayerMPFake createFake(String username, MinecraftServer server, double d0, double d1, double d2, double yaw, double pitch, RegistryKey dimensionId, GameMode gamemode) { //prolly half of that crap is not necessary, but it works ServerWorld worldIn = server.getWorld(dimensionId); diff --git a/src/main/java/carpet/script/CarpetEventServer.java b/src/main/java/carpet/script/CarpetEventServer.java index f5d52b89..200a02f5 100644 --- a/src/main/java/carpet/script/CarpetEventServer.java +++ b/src/main/java/carpet/script/CarpetEventServer.java @@ -29,6 +29,7 @@ import net.minecraft.util.math.Direction; import net.minecraft.util.math.Vec3d; import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.RegistryKey; +import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.dimension.DimensionType; import org.apache.commons.lang3.tuple.Pair; @@ -191,7 +192,7 @@ public class CarpetEventServer { handler.call(Collections::emptyList, () -> CarpetServer.minecraft_server.getCommandSource(). - withWorld(CarpetServer.minecraft_server.getWorld(DimensionType.OVERWORLD_REGISTRY_KEY)) + withWorld(CarpetServer.minecraft_server.getWorld(World.field_25179)) ); } }, @@ -202,7 +203,7 @@ public class CarpetEventServer { handler.call(Collections::emptyList, () -> CarpetServer.minecraft_server.getCommandSource(). - withWorld(CarpetServer.minecraft_server.getWorld(DimensionType.THE_NETHER_REGISTRY_KEY)) + withWorld(CarpetServer.minecraft_server.getWorld(World.field_25180)) ); } }, @@ -213,7 +214,7 @@ public class CarpetEventServer { handler.call(Collections::emptyList, () -> CarpetServer.minecraft_server.getCommandSource(). - withWorld(CarpetServer.minecraft_server.getWorld(DimensionType.THE_END_REGISTRY_KEY)) + withWorld(CarpetServer.minecraft_server.getWorld(World.field_25181)) ); } }, @@ -531,7 +532,7 @@ public class CarpetEventServer PLAYER_CHANGES_DIMENSION("player_changes_dimension", 5, false) { @Override - public void onDimensionChange(ServerPlayerEntity player, Vec3d from, Vec3d to, RegistryKey fromDim, RegistryKey dimTo) + public void onDimensionChange(ServerPlayerEntity player, Vec3d from, Vec3d to, RegistryKey fromDim, RegistryKey dimTo) { // eligibility already checked in mixin Value fromValue = ListValue.fromTriple(from.x, from.y, from.z); @@ -620,7 +621,7 @@ public class CarpetEventServer public void onBlockBroken(ServerPlayerEntity player, BlockPos pos, BlockState previousBS) { } public void onBlockPlaced(ServerPlayerEntity player, BlockPos pos, Hand enumhand, ItemStack itemstack) { } public void onEntityAction(ServerPlayerEntity player, Entity entity, Hand enumhand) { } - public void onDimensionChange(ServerPlayerEntity player, Vec3d from, Vec3d to, RegistryKey fromDim, RegistryKey dimTo) {} + public void onDimensionChange(ServerPlayerEntity player, Vec3d from, Vec3d to, RegistryKey fromDim, RegistryKey dimTo) {} public void onDamage(Entity target, float amount, DamageSource source) { } diff --git a/src/main/java/carpet/script/CarpetExpression.java b/src/main/java/carpet/script/CarpetExpression.java index fcbe417c..e150f576 100644 --- a/src/main/java/carpet/script/CarpetExpression.java +++ b/src/main/java/carpet/script/CarpetExpression.java @@ -945,7 +945,7 @@ public class CarpetExpression boolean dropLoot = true; if (playerBreak) { - boolean isUsingEffectiveTool = state.getMaterial().canBreakByHand() || tool.isEffectiveOn(state); + boolean isUsingEffectiveTool = !state.method_29291() || tool.isEffectiveOn(state); //!can break by hand //postMine() durability from item classes float hardness = state.getHardness(world, where); int damageAmount = 0; @@ -1155,19 +1155,19 @@ public class CarpetExpression BlockArgument locator = BlockArgument.findIn(cc, lv, 0); ServerWorld world = cc.s.getWorld(); BlockPos pos = locator.block.getPos(); - Map references = world.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.STRUCTURE_REFERENCES).getStructureReferences(); + Map, LongSet> references = world.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.STRUCTURE_REFERENCES).getStructureReferences(); if (lv.size() == locator.offset) { //CarpetSettings.LOG.error(references.keySet().stream().collect(Collectors.joining(","))); List referenceList = references.entrySet().stream(). filter(e -> e.getValue()!= null && !e.getValue().isEmpty()). - map(e -> new StringValue(FeatureGenerator.structureToFeature.get(FeatureGenerator.fix(e.getKey())).get(0))).collect(Collectors.toList()); + map(e -> new StringValue(FeatureGenerator.structureToFeature.get(e.getKey()).get(0))).collect(Collectors.toList()); return (_c, _t ) -> ListValue.wrap(referenceList); } String simpleStructureName = lv.get(locator.offset).evalValue(c).getString().toLowerCase(Locale.ROOT); //CarpetSettings.LOG.error(FeatureGenerator.featureToStructure.keySet().stream().collect(Collectors.joining(","))); //CarpetSettings.LOG.error(FeatureGenerator.featureToStructure.values().stream().collect(Collectors.joining(","))); - String structureName = FeatureGenerator.featureToStructure.get(simpleStructureName); + StructureFeature structureName = FeatureGenerator.featureToStructure.get(simpleStructureName); if (structureName == null) return LazyValue.NULL; LongSet structureReferences = references.get(structureName); if (structureReferences == null || structureReferences.isEmpty()) return ListValue.lazyEmpty(); @@ -1179,7 +1179,7 @@ public class CarpetExpression }); this.expr.addLazyFunction("structure_eligibility", -1, (c, t, lv) -> - { + {// TODO rename structureName to class CarpetContext cc = (CarpetContext)c; BlockArgument locator = BlockArgument.findIn(cc, lv, 0); @@ -1193,10 +1193,8 @@ public class CarpetExpression if (!(requested instanceof NullValue)) { String reqString = requested.getString(); - String structureName = FeatureGenerator.featureToStructure.get(reqString); - if (structureName == null) throw new InternalExpressionException("Unknown structure: " + reqString); - structure = StructureFeature.STRUCTURES.get(structureName.toLowerCase(Locale.ROOT)); - if (structure == null) throw new InternalExpressionException("Unsupported structure: " + structureName); + structure = FeatureGenerator.featureToStructure.get(reqString); + if (structure == null) throw new InternalExpressionException("Unknown structure: " + reqString); } if (lv.size() > locator.offset+1) { @@ -1217,7 +1215,7 @@ public class CarpetExpression StructureStart start = FeatureGenerator.shouldStructureStartAt(world, pos, str, needSize); if (start == null) continue; - Value key = new StringValue(FeatureGenerator.structureToFeature.get(FeatureGenerator.fix(str.getName())).get(0)); + Value key = new StringValue(FeatureGenerator.structureToFeature.get(str).get(0)); ret.put(key, (!needSize)?Value.NULL:structureToValue(start)); } Value retMap = MapValue.wrap(ret); @@ -1230,18 +1228,18 @@ public class CarpetExpression ServerWorld world = cc.s.getWorld(); BlockPos pos = locator.block.getPos(); - Map> structures = world.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.STRUCTURE_STARTS).getStructureStarts(); + Map, StructureStart> structures = world.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.STRUCTURE_STARTS).getStructureStarts(); if (lv.size() == locator.offset) { Map structureList = new HashMap<>(); - for (Map.Entry> entry : structures.entrySet()) + for (Map.Entry, StructureStart> entry : structures.entrySet()) { StructureStart start = entry.getValue(); if (start == StructureStart.DEFAULT) continue; BlockBox box = start.getBoundingBox(); structureList.put( - new StringValue(FeatureGenerator.structureToFeature.get(FeatureGenerator.fix(entry.getKey())).get(0)), + new StringValue(FeatureGenerator.structureToFeature.get(entry.getKey()).get(0)), ListValue.of(ListValue.fromTriple(box.minX, box.minY, box.minZ), ListValue.fromTriple(box.maxX, box.maxY, box.maxZ)) ); } @@ -1265,14 +1263,14 @@ public class CarpetExpression if (lv.size() == locator.offset) throw new InternalExpressionException("'set_structure requires at least position and a structure name"); String structureName = lv.get(locator.offset).evalValue(c).getString().toLowerCase(Locale.ROOT); - String structureId = FeatureGenerator.featureToStructure.get(structureName); + StructureFeature structureId = FeatureGenerator.featureToStructure.get(structureName); if (structureId == null) throw new InternalExpressionException("Unknown structure: "+structureName); // good 'ol pointer Value[] result = new Value[]{Value.NULL}; // technically a world modification. Even if we could let it slide, we will still park it ((CarpetContext) c).s.getMinecraftServer().submitAndJoin(() -> { - Map> structures = world.getChunk(pos).getStructureStarts(); + Map, StructureStart> structures = world.getChunk(pos).getStructureStarts(); if (lv.size() == locator.offset + 1) { Boolean res = FeatureGenerator.gridStructure(structureName, ((CarpetContext) c).s.getWorld(), locator.block.getPos()); @@ -1296,7 +1294,7 @@ public class CarpetExpression { ChunkPos chpos = new ChunkPos(chx, chz); // getting a chunk will convert it to full, allowing to modify references - Map references = world.getChunk(chpos.getCenterBlockPos()).getStructureReferences(); + Map, LongSet> references = world.getChunk(chpos.getCenterBlockPos()).getStructureReferences(); if (references.containsKey(structureId) && references.get(structureId) != null) references.get(structureId).remove(structureChunkPos.toLong()); } @@ -3029,15 +3027,15 @@ public class CarpetExpression { case "nether": case "the_nether": - innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(DimensionType.THE_NETHER_REGISTRY_KEY)); + innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(World.field_25180)); //nether break; case "end": case "the_end": - innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(DimensionType.THE_END_REGISTRY_KEY)); + innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(World.field_25181)); //end break; case "overworld": case "over_world": - innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(DimensionType.OVERWORLD_REGISTRY_KEY)); + innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(World.field_25179)); //ow break; default: throw new InternalExpressionException("Incorrect dimension string: "+dimString); diff --git a/src/main/java/carpet/utils/HUDController.java b/src/main/java/carpet/utils/HUDController.java index 484e5794..f5be2006 100644 --- a/src/main/java/carpet/utils/HUDController.java +++ b/src/main/java/carpet/utils/HUDController.java @@ -13,6 +13,7 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.text.BaseText; import net.minecraft.text.LiteralText; import net.minecraft.util.registry.RegistryKey; +import net.minecraft.world.World; import net.minecraft.world.dimension.DimensionType; import java.util.ArrayList; @@ -59,17 +60,17 @@ public class HUDController if (LoggerRegistry.__mobcaps) LoggerRegistry.getLogger("mobcaps").log((option, player) -> { - RegistryKey dim = player.world.method_27983(); //getDimType + RegistryKey dim = player.world.method_27983(); //getDimType switch (option) { case "overworld": - dim = DimensionType.OVERWORLD_REGISTRY_KEY; + dim = World.field_25179; // OW break; case "nether": - dim = DimensionType.THE_NETHER_REGISTRY_KEY; + dim = World.field_25180; // nether break; case "end": - dim = DimensionType.THE_END_REGISTRY_KEY; + dim = World.field_25181; // end break; } return new BaseText[]{SpawnReporter.printMobcapsForDimension(server.getWorld(dim), false).get(0)}; diff --git a/src/main/java/carpet/utils/Messenger.java b/src/main/java/carpet/utils/Messenger.java index 9db5cbb5..fafabae4 100644 --- a/src/main/java/carpet/utils/Messenger.java +++ b/src/main/java/carpet/utils/Messenger.java @@ -14,6 +14,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.util.Formatting; import net.minecraft.server.MinecraftServer; +import net.minecraft.world.World; import net.minecraft.world.dimension.DimensionType; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -252,7 +253,7 @@ public class Messenger //message source public static void m(ServerCommandSource source, Object ... fields) { - source.sendFeedback(Messenger.c(fields),source.getMinecraftServer() != null && source.getMinecraftServer().getWorld(DimensionType.OVERWORLD_REGISTRY_KEY) != null); //OW + source.sendFeedback(Messenger.c(fields),source.getMinecraftServer() != null && source.getMinecraftServer().getWorld(World.field_25179) != null); //OW } public static void m(PlayerEntity player, Object ... fields) { diff --git a/src/main/java/carpet/utils/SpawnReporter.java b/src/main/java/carpet/utils/SpawnReporter.java index b09d5cf0..f0dcb84b 100644 --- a/src/main/java/carpet/utils/SpawnReporter.java +++ b/src/main/java/carpet/utils/SpawnReporter.java @@ -39,19 +39,19 @@ public class SpawnReporter public static boolean mock_spawns = false; public static Long track_spawns = 0L; - public static final HashMap, Integer> chunkCounts = new HashMap<>(); + public static final HashMap, Integer> chunkCounts = new HashMap<>(); - public static final HashMap, SpawnGroup>, Object2LongMap> spawn_stats = new HashMap<>(); + public static final HashMap, SpawnGroup>, Object2LongMap> spawn_stats = new HashMap<>(); public static double mobcap_exponent = 0.0D; - public static final HashMap, SpawnGroup>, Long> spawn_attempts = new HashMap<>(); - public static final HashMap, SpawnGroup>, Long> overall_spawn_ticks = new HashMap<>(); - public static final HashMap, SpawnGroup>, Long> spawn_ticks_full = new HashMap<>(); - public static final HashMap, SpawnGroup>, Long> spawn_ticks_fail = new HashMap<>(); - public static final HashMap, SpawnGroup>, Long> spawn_ticks_succ = new HashMap<>(); - public static final HashMap, SpawnGroup>, Long> spawn_ticks_spawns = new HashMap<>(); - public static final HashMap, SpawnGroup>, Long> spawn_cap_count = new HashMap<>(); - public static final HashMap, SpawnGroup>, EvictingQueue>> spawned_mobs = new HashMap<>(); + public static final HashMap, SpawnGroup>, Long> spawn_attempts = new HashMap<>(); + public static final HashMap, SpawnGroup>, Long> overall_spawn_ticks = new HashMap<>(); + public static final HashMap, SpawnGroup>, Long> spawn_ticks_full = new HashMap<>(); + public static final HashMap, SpawnGroup>, Long> spawn_ticks_fail = new HashMap<>(); + public static final HashMap, SpawnGroup>, Long> spawn_ticks_succ = new HashMap<>(); + public static final HashMap, SpawnGroup>, Long> spawn_ticks_spawns = new HashMap<>(); + public static final HashMap, SpawnGroup>, Long> spawn_cap_count = new HashMap<>(); + public static final HashMap, SpawnGroup>, EvictingQueue>> spawned_mobs = new HashMap<>(); public static final HashMap spawn_tries = new HashMap<>(); public static BlockPos lower_spawning_limit = null; public static BlockPos upper_spawning_limit = null; @@ -75,7 +75,7 @@ public class SpawnReporter return; } } - Pair, SpawnGroup> key = Pair.of(mob.world.method_27983(), cat); + Pair, SpawnGroup> key = Pair.of(mob.world.method_27983(), cat); long count = spawn_stats.get(key).getOrDefault(mob.getType(), 0L); spawn_stats.get(key).put(mob.getType(), count + 1); spawned_mobs.get(key).put(Pair.of(mob.getType(), pos)); @@ -85,7 +85,7 @@ public class SpawnReporter public static List printMobcapsForDimension(ServerWorld world, boolean multiline) { - RegistryKey dim = world.method_27983(); + RegistryKey dim = world.method_27983(); String name = dim.toString(); List lst = new ArrayList<>(); if (multiline) @@ -305,9 +305,9 @@ public class SpawnReporter { spawn_tries.put(enumcreaturetype, 1); } - for (RegistryKey dim : Arrays.asList(DimensionType.OVERWORLD_REGISTRY_KEY, DimensionType.THE_NETHER_REGISTRY_KEY, DimensionType.THE_END_REGISTRY_KEY)) + for (RegistryKey dim : Arrays.asList(World.field_25179, World.field_25180, World.field_25181)) { - Pair, SpawnGroup> key = Pair.of(dim, enumcreaturetype); + Pair, SpawnGroup> key = Pair.of(dim, enumcreaturetype); overall_spawn_ticks.put(key, 0L); spawn_attempts.put(key, 0L); spawn_ticks_full.put(key, 0L);