From 628a350ea13855244b81935754f8cbda287406fb Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 28 Aug 2019 20:23:32 -0300 Subject: [PATCH] 19w35a --- gradle.properties | 6 +++--- .../fakes/StructureFeatureInterface.java | 6 +++--- .../helpers/EntityPlayerActionPack.java | 9 ++------ .../java/carpet/helpers/FeatureGenerator.java | 11 +++++----- ...EntityRenderDispatcher_movableTEMixin.java | 2 +- .../BuriedTreasureGeneratorPieceMixin.java | 4 ++-- .../java/carpet/mixins/CarpetBlockMixin.java | 3 ++- .../carpet/mixins/FossilFeatureMixin.java | 4 ++-- .../GravityStructureProcessorMixin.java | 7 ++++--- .../mixins/IglooGeneratorPieceMixin.java | 4 ++-- .../mixins/OceanRuinGeneratorPieceMixin.java | 4 ++-- .../PistonBlockEntity_movableTEMixin.java | 2 +- .../java/carpet/mixins/SaplingBlockMixin.java | 12 +++++------ .../mixins/ServerChunkManagerMixin.java | 5 ++--- .../mixins/ShipwreckGeneratorPieceMixin.java | 6 +++--- .../java/carpet/mixins/SpawnHelperMixin.java | 15 +++++++------ .../carpet/mixins/StructureFeatureMixin.java | 10 +++++---- .../carpet/mixins/StructurePieceMixin.java | 7 ++++--- .../java/carpet/script/CarpetExpression.java | 12 +++++------ src/main/java/carpet/utils/BlockInfo.java | 21 +++++++++---------- .../carpet/utils/PerimeterDiagnostics.java | 6 +++--- src/main/java/carpet/utils/SpawnReporter.java | 6 +++--- src/main/java/carpet/utils/WoolTool.java | 3 ++- 23 files changed, 82 insertions(+), 83 deletions(-) diff --git a/gradle.properties b/gradle.properties index 97f0a326..fd0348bc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,9 +4,9 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html - minecraft_version=19w34a - yarn_mappings=19w34a+build.6 - loader_version=0.4.8+build.159 + minecraft_version=19w35a + yarn_mappings=19w35a+build.1 + loader_version=0.6.1+build.164 # Mod Properties mod_version = 1.0.4+v190823_115 diff --git a/src/main/java/carpet/fakes/StructureFeatureInterface.java b/src/main/java/carpet/fakes/StructureFeatureInterface.java index f1180709..bbf42d56 100644 --- a/src/main/java/carpet/fakes/StructureFeatureInterface.java +++ b/src/main/java/carpet/fakes/StructureFeatureInterface.java @@ -1,12 +1,12 @@ package carpet.fakes; +import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorld; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.chunk.ChunkGeneratorConfig; public interface StructureFeatureInterface { - public boolean plopAnywhere(IWorld world, BlockPos pos); - public boolean plopAnywhere(IWorld world, BlockPos pos, ChunkGenerator generator); + public boolean plopAnywhere(ServerWorld world, BlockPos pos); + public boolean plopAnywhere(ServerWorld world, BlockPos pos, ChunkGenerator generator); } diff --git a/src/main/java/carpet/helpers/EntityPlayerActionPack.java b/src/main/java/carpet/helpers/EntityPlayerActionPack.java index 114bb3e7..c3ba4f53 100644 --- a/src/main/java/carpet/helpers/EntityPlayerActionPack.java +++ b/src/main/java/carpet/helpers/EntityPlayerActionPack.java @@ -1,7 +1,6 @@ package carpet.helpers; import carpet.fakes.ServerPlayerEntityInterface; -import carpet.mixins.PlayerActionC2SPacketMixin; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; @@ -13,11 +12,7 @@ import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.EntityHitResult; import net.minecraft.util.hit.HitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec2f; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.*; import java.util.List; import java.util.Map; @@ -281,7 +276,7 @@ public class EntityPlayerActionPack BlockPos pos = blockHit.getBlockPos(); Direction side = blockHit.getSide(); if (player.method_21701(player.world, pos, player.interactionManager.getGameMode())) return false; - if (ap.currentBlock != null && player.world.isAir(ap.currentBlock)) + if (ap.currentBlock != null && player.world.getBlockState(ap.currentBlock).isAir()) { ap.currentBlock = null; return false; diff --git a/src/main/java/carpet/helpers/FeatureGenerator.java b/src/main/java/carpet/helpers/FeatureGenerator.java index 2764ee3c..ffe49e83 100644 --- a/src/main/java/carpet/helpers/FeatureGenerator.java +++ b/src/main/java/carpet/helpers/FeatureGenerator.java @@ -3,6 +3,7 @@ package carpet.helpers; import carpet.settings.CarpetSettings; import carpet.fakes.StructureFeatureInterface; import net.minecraft.block.Blocks; +import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; @@ -41,7 +42,7 @@ public class FeatureGenerator @FunctionalInterface private interface Thing { - Boolean plop(World world, BlockPos pos); + Boolean plop(ServerWorld world, BlockPos pos); } private static Thing simplePlop(Feature feature) { @@ -51,7 +52,7 @@ public class FeatureGenerator { return (w, p) -> { CarpetSettings.skipGenerationChecks=true; - boolean res = feature.generate(w, w.getChunkManager().getChunkGenerator(), w.random, p, config); + boolean res = feature.generate(w, w.method_14178().getChunkGenerator(), w.random, p, config); CarpetSettings.skipGenerationChecks=false; return res; }; @@ -61,7 +62,7 @@ public class FeatureGenerator private static Thing spawnCustomStructure(StructureFeature structure, FeatureConfig conf, Biome biome) { return (w, p) -> { - ChunkGenerator chunkgen = new OverworldChunkGenerator(w, w.getChunkManager().getChunkGenerator().getBiomeSource(), new OverworldChunkGeneratorConfig()) // BiomeSourceType.VANILLA_LAYERED.applyConfig((BiomeSourceType.VANILLA_LAYERED.getConfig())), ChunkGeneratorType.SURFACE.createSettings()) + ChunkGenerator chunkgen = new OverworldChunkGenerator(w, w.method_14178().getChunkGenerator().getBiomeSource(), new OverworldChunkGeneratorConfig()) // BiomeSourceType.VANILLA_LAYERED.applyConfig((BiomeSourceType.VANILLA_LAYERED.getConfig())), ChunkGeneratorType.SURFACE.createSettings()) { @Override public C getStructureConfig(Biome biome_1, StructureFeature structureFeature_1) @@ -72,7 +73,7 @@ public class FeatureGenerator @Override public BiomeSource getBiomeSource() { - return new VanillaLayeredBiomeSource(new VanillaLayeredBiomeSourceConfig().setLevelProperties(w.getLevelProperties())) + return new VanillaLayeredBiomeSource(new VanillaLayeredBiomeSourceConfig(w.getLevelProperties())) { @Override public Biome getBiome(int i, int j) @@ -88,7 +89,7 @@ public class FeatureGenerator }; } - public static Boolean spawn(String name, World world, BlockPos pos) + public static Boolean spawn(String name, ServerWorld world, BlockPos pos) { if (featureMap.containsKey(name)) return featureMap.get(name).plop(world, pos); diff --git a/src/main/java/carpet/mixins/BlockEntityRenderDispatcher_movableTEMixin.java b/src/main/java/carpet/mixins/BlockEntityRenderDispatcher_movableTEMixin.java index 06f43b24..faefaa00 100644 --- a/src/main/java/carpet/mixins/BlockEntityRenderDispatcher_movableTEMixin.java +++ b/src/main/java/carpet/mixins/BlockEntityRenderDispatcher_movableTEMixin.java @@ -41,7 +41,7 @@ public abstract class BlockEntityRenderDispatcher_movableTEMixin implements Bloc this.cameraEntity.getPos().z - zOffset) < blockEntity_1.getSquaredRenderDistance()) { GuiLighting.enable(); - int i = this.world.getLightmapIndex(blockEntity_1.getPos(), 0); + int i = this.world.method_22337(blockEntity_1.getPos()); int j = i % 65536; int k = i / 65536; RenderSystem.glMultiTexCoord2f(GL20.GL_TEXTURE1, (float) j, (float) k); diff --git a/src/main/java/carpet/mixins/BuriedTreasureGeneratorPieceMixin.java b/src/main/java/carpet/mixins/BuriedTreasureGeneratorPieceMixin.java index 560ebb6f..0fe17949 100644 --- a/src/main/java/carpet/mixins/BuriedTreasureGeneratorPieceMixin.java +++ b/src/main/java/carpet/mixins/BuriedTreasureGeneratorPieceMixin.java @@ -13,10 +13,10 @@ public class BuriedTreasureGeneratorPieceMixin { @Redirect(method = "generate", at = @At( value = "INVOKE", - target = "Lnet/minecraft/world/IWorld;getTop(Lnet/minecraft/world/Heightmap$Type;II)I" + target = "Lnet/minecraft/world/IWorld;getLightLevel(Lnet/minecraft/world/Heightmap$Type;II)I" )) private int getTop(IWorld iWorld, Heightmap.Type var1, int var2, int var3) { - return iWorld.getTop(CarpetSettings.skipGenerationChecks?Heightmap.Type.OCEAN_FLOOR:Heightmap.Type.OCEAN_FLOOR_WG, var2, var3); + return iWorld.getLightLevel(CarpetSettings.skipGenerationChecks?Heightmap.Type.OCEAN_FLOOR:Heightmap.Type.OCEAN_FLOOR_WG, var2, var3); } } diff --git a/src/main/java/carpet/mixins/CarpetBlockMixin.java b/src/main/java/carpet/mixins/CarpetBlockMixin.java index f1d9f1f8..922538dd 100644 --- a/src/main/java/carpet/mixins/CarpetBlockMixin.java +++ b/src/main/java/carpet/mixins/CarpetBlockMixin.java @@ -5,6 +5,7 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.CarpetBlock; import net.minecraft.item.ItemPlacementContext; +import net.minecraft.server.world.ServerWorld; import org.spongepowered.asm.mixin.Mixin; @Mixin(CarpetBlock.class) @@ -21,7 +22,7 @@ public abstract class CarpetBlockMixin extends Block BlockState state = super.getPlacementState(context); if (context.getPlayer() != null && !context.getWorld().isClient) { - WoolTool.carpetPlacedAction(((CarpetBlock)(Object)this).getColor(), context.getPlayer(), context.getBlockPos(), context.getWorld()); + WoolTool.carpetPlacedAction(((CarpetBlock)(Object)this).getColor(), context.getPlayer(), context.getBlockPos(), (ServerWorld) context.getWorld()); } return state; } diff --git a/src/main/java/carpet/mixins/FossilFeatureMixin.java b/src/main/java/carpet/mixins/FossilFeatureMixin.java index 92e7b5d9..d3f17a92 100644 --- a/src/main/java/carpet/mixins/FossilFeatureMixin.java +++ b/src/main/java/carpet/mixins/FossilFeatureMixin.java @@ -13,10 +13,10 @@ public class FossilFeatureMixin { @Redirect(method = "method_13236", at = @At( value = "INVOKE", - target = "Lnet/minecraft/world/IWorld;getTop(Lnet/minecraft/world/Heightmap$Type;II)I" + target = "Lnet/minecraft/world/IWorld;getLightLevel(Lnet/minecraft/world/Heightmap$Type;II)I" )) private int getTop(IWorld iWorld, Heightmap.Type var1, int var2, int var3) { - return iWorld.getTop(CarpetSettings.skipGenerationChecks?Heightmap.Type.OCEAN_FLOOR:Heightmap.Type.OCEAN_FLOOR_WG, var2, var3); + return iWorld.getLightLevel(CarpetSettings.skipGenerationChecks?Heightmap.Type.OCEAN_FLOOR:Heightmap.Type.OCEAN_FLOOR_WG, var2, var3); } } diff --git a/src/main/java/carpet/mixins/GravityStructureProcessorMixin.java b/src/main/java/carpet/mixins/GravityStructureProcessorMixin.java index 137557f2..aef98136 100644 --- a/src/main/java/carpet/mixins/GravityStructureProcessorMixin.java +++ b/src/main/java/carpet/mixins/GravityStructureProcessorMixin.java @@ -1,6 +1,7 @@ package carpet.mixins; import carpet.settings.CarpetSettings; +import net.minecraft.class_4538; import net.minecraft.structure.processor.GravityStructureProcessor; import net.minecraft.world.Heightmap; import net.minecraft.world.ViewableWorld; @@ -13,10 +14,10 @@ public class GravityStructureProcessorMixin { @Redirect(method = "process", at = @At( value = "INVOKE", - target = "Lnet/minecraft/world/ViewableWorld;getTop(Lnet/minecraft/world/Heightmap$Type;II)I" + target = "Lnet/minecraft/class_4538;getLightLevel(Lnet/minecraft/world/Heightmap$Type;II)I" )) - private int getTop(ViewableWorld viewableWorld, Heightmap.Type var1, int var2, int var3) + private int getTop(class_4538 class_4538, Heightmap.Type var1, int var2, int var3) { - return viewableWorld.getTop(CarpetSettings.skipGenerationChecks?Heightmap.Type.WORLD_SURFACE:var1, var2, var3); + return class_4538.getLightLevel(CarpetSettings.skipGenerationChecks?Heightmap.Type.WORLD_SURFACE:var1, var2, var3); } } diff --git a/src/main/java/carpet/mixins/IglooGeneratorPieceMixin.java b/src/main/java/carpet/mixins/IglooGeneratorPieceMixin.java index 988f460b..d7cf285f 100644 --- a/src/main/java/carpet/mixins/IglooGeneratorPieceMixin.java +++ b/src/main/java/carpet/mixins/IglooGeneratorPieceMixin.java @@ -13,10 +13,10 @@ public class IglooGeneratorPieceMixin { @Redirect(method = "generate", at = @At( value = "INVOKE", - target = "Lnet/minecraft/world/IWorld;getTop(Lnet/minecraft/world/Heightmap$Type;II)I" + target = "Lnet/minecraft/world/IWorld;getLightLevel(Lnet/minecraft/world/Heightmap$Type;II)I" )) private int getTop(IWorld iWorld, Heightmap.Type var1, int var2, int var3) { - return iWorld.getTop(CarpetSettings.skipGenerationChecks?Heightmap.Type.WORLD_SURFACE:Heightmap.Type.WORLD_SURFACE_WG, var2, var3); + return iWorld.getLightLevel(CarpetSettings.skipGenerationChecks?Heightmap.Type.WORLD_SURFACE:Heightmap.Type.WORLD_SURFACE_WG, var2, var3); } } diff --git a/src/main/java/carpet/mixins/OceanRuinGeneratorPieceMixin.java b/src/main/java/carpet/mixins/OceanRuinGeneratorPieceMixin.java index 4cf03752..2bb99167 100644 --- a/src/main/java/carpet/mixins/OceanRuinGeneratorPieceMixin.java +++ b/src/main/java/carpet/mixins/OceanRuinGeneratorPieceMixin.java @@ -13,10 +13,10 @@ public class OceanRuinGeneratorPieceMixin { @Redirect(method = "generate", at = @At( value = "INVOKE", - target = "Lnet/minecraft/world/IWorld;getTop(Lnet/minecraft/world/Heightmap$Type;II)I" + target = "Lnet/minecraft/world/IWorld;getLightLevel(Lnet/minecraft/world/Heightmap$Type;II)I" )) private int getTop(IWorld iWorld, Heightmap.Type var1, int var2, int var3) { - return iWorld.getTop(CarpetSettings.skipGenerationChecks?Heightmap.Type.OCEAN_FLOOR:Heightmap.Type.OCEAN_FLOOR_WG, var2, var3); + return iWorld.getLightLevel(CarpetSettings.skipGenerationChecks?Heightmap.Type.OCEAN_FLOOR:Heightmap.Type.OCEAN_FLOOR_WG, var2, var3); } } diff --git a/src/main/java/carpet/mixins/PistonBlockEntity_movableTEMixin.java b/src/main/java/carpet/mixins/PistonBlockEntity_movableTEMixin.java index 0de7a544..8b7f632f 100644 --- a/src/main/java/carpet/mixins/PistonBlockEntity_movableTEMixin.java +++ b/src/main/java/carpet/mixins/PistonBlockEntity_movableTEMixin.java @@ -111,7 +111,7 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple else blockState_2 = Block.getRenderingState(this.pushedBlock, this.world, this.pos); ((WorldInterface) (this.world)).setBlockStateWithBlockEntity(this.pos, blockState_2, this.carriedBlockEntity, 3); - this.world.breakBlock(this.pos, true); + this.world.breakBlock(this.pos, true, null); } } diff --git a/src/main/java/carpet/mixins/SaplingBlockMixin.java b/src/main/java/carpet/mixins/SaplingBlockMixin.java index fb5dc59d..245eb263 100644 --- a/src/main/java/carpet/mixins/SaplingBlockMixin.java +++ b/src/main/java/carpet/mixins/SaplingBlockMixin.java @@ -1,12 +1,12 @@ package carpet.mixins; -import carpet.settings.CarpetSettings; import carpet.helpers.BlockSaplingHelper; +import carpet.settings.CarpetSettings; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.SaplingBlock; +import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorld; import net.minecraft.world.biome.Biomes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -19,13 +19,13 @@ import java.util.Random; public abstract class SaplingBlockMixin { @Inject(method = "generate", at = @At(value = "INVOKE", shift = At.Shift.BEFORE, - target = "Lnet/minecraft/block/sapling/SaplingGenerator;generate(Lnet/minecraft/world/IWorld;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Ljava/util/Random;)Z"), + target = "Lnet/minecraft/block/sapling/SaplingGenerator;generate(Lnet/minecraft/world/IWorld;Lnet/minecraft/world/gen/chunk/ChunkGenerator;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Ljava/util/Random;)Z"), cancellable = true) - private void onGenerate(IWorld iWorld_1, BlockPos blockPos_1, BlockState blockState_1, Random random_1, CallbackInfo ci) + private void onGenerate(ServerWorld serverWorld_1, BlockPos blockPos_1, BlockState blockState_1, Random random_1, CallbackInfo ci) { - if(CarpetSettings.desertShrubs && iWorld_1.getBiome(blockPos_1) == Biomes.DESERT && !BlockSaplingHelper.hasWater(iWorld_1, blockPos_1)) + if(CarpetSettings.desertShrubs && serverWorld_1.getBiome(blockPos_1) == Biomes.DESERT && !BlockSaplingHelper.hasWater(serverWorld_1, blockPos_1)) { - iWorld_1.setBlockState(blockPos_1, Blocks.DEAD_BUSH.getDefaultState(), 3); + serverWorld_1.setBlockState(blockPos_1, Blocks.DEAD_BUSH.getDefaultState(), 3); ci.cancel(); } } diff --git a/src/main/java/carpet/mixins/ServerChunkManagerMixin.java b/src/main/java/carpet/mixins/ServerChunkManagerMixin.java index ab20320f..7aaef59f 100644 --- a/src/main/java/carpet/mixins/ServerChunkManagerMixin.java +++ b/src/main/java/carpet/mixins/ServerChunkManagerMixin.java @@ -7,7 +7,6 @@ import net.minecraft.server.world.ServerChunkManager; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; import net.minecraft.world.SpawnHelper; -import net.minecraft.world.World; import net.minecraft.world.chunk.WorldChunk; import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.level.LevelProperties; @@ -77,10 +76,10 @@ public abstract class ServerChunkManagerMixin @Redirect(method = "method_20801", at = @At( value = "INVOKE", - target = "Lnet/minecraft/world/SpawnHelper;spawnEntitiesInChunk(Lnet/minecraft/entity/EntityCategory;Lnet/minecraft/world/World;Lnet/minecraft/world/chunk/WorldChunk;Lnet/minecraft/util/math/BlockPos;)V" + target = "Lnet/minecraft/world/SpawnHelper;spawnEntitiesInChunk(Lnet/minecraft/entity/EntityCategory;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/chunk/WorldChunk;Lnet/minecraft/util/math/BlockPos;)V" )) // inject our repeat of spawns if more spawn ticks per tick are chosen. - private void spawnMultipleTimes(EntityCategory entityCategory_1, World world_1, WorldChunk worldChunk_1, BlockPos blockPos_1) + private void spawnMultipleTimes(EntityCategory entityCategory_1, ServerWorld world_1, WorldChunk worldChunk_1, BlockPos blockPos_1) { for (int i = 0; i < SpawnReporter.spawn_tries.get(entityCategory_1); i++) { diff --git a/src/main/java/carpet/mixins/ShipwreckGeneratorPieceMixin.java b/src/main/java/carpet/mixins/ShipwreckGeneratorPieceMixin.java index 8ed3032e..6684d1e8 100644 --- a/src/main/java/carpet/mixins/ShipwreckGeneratorPieceMixin.java +++ b/src/main/java/carpet/mixins/ShipwreckGeneratorPieceMixin.java @@ -17,13 +17,13 @@ public class ShipwreckGeneratorPieceMixin @Redirect(method = "generate", at = @At( value = "INVOKE", - target = "Lnet/minecraft/world/IWorld;getTop(Lnet/minecraft/world/Heightmap$Type;II)I" + target = "Lnet/minecraft/world/IWorld;getLightLevel(Lnet/minecraft/world/Heightmap$Type;II)I" )) private int getTop(IWorld iWorld, Heightmap.Type var1, int var2, int var3) { if (grounded) - return iWorld.getTop(CarpetSettings.skipGenerationChecks?Heightmap.Type.WORLD_SURFACE:Heightmap.Type.WORLD_SURFACE_WG, var2, var3); + return iWorld.getLightLevel(CarpetSettings.skipGenerationChecks?Heightmap.Type.WORLD_SURFACE:Heightmap.Type.WORLD_SURFACE_WG, var2, var3); else - return iWorld.getTop(CarpetSettings.skipGenerationChecks?Heightmap.Type.OCEAN_FLOOR:Heightmap.Type.OCEAN_FLOOR_WG, var2, var3); + return iWorld.getLightLevel(CarpetSettings.skipGenerationChecks?Heightmap.Type.OCEAN_FLOOR:Heightmap.Type.OCEAN_FLOOR_WG, var2, var3); } } diff --git a/src/main/java/carpet/mixins/SpawnHelperMixin.java b/src/main/java/carpet/mixins/SpawnHelperMixin.java index af352d57..be6143c7 100644 --- a/src/main/java/carpet/mixins/SpawnHelperMixin.java +++ b/src/main/java/carpet/mixins/SpawnHelperMixin.java @@ -1,7 +1,7 @@ package carpet.mixins; -import carpet.settings.CarpetSettings; import carpet.fakes.WorldInterface; +import carpet.settings.CarpetSettings; import carpet.utils.SpawnReporter; import net.minecraft.block.Block; import net.minecraft.entity.Entity; @@ -9,6 +9,7 @@ import net.minecraft.entity.EntityCategory; import net.minecraft.entity.EntityType; import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Box; import net.minecraft.util.math.MathHelper; @@ -19,9 +20,7 @@ import net.minecraft.world.World; import net.minecraft.world.chunk.WorldChunk; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.Map; @@ -33,9 +32,9 @@ public class SpawnHelperMixin @Redirect(method = "spawnEntitiesInChunk", at = @At( value = "INVOKE", - target = "Lnet/minecraft/world/World;doesNotCollide(Lnet/minecraft/util/math/Box;)Z" + target = "Lnet/minecraft/server/world/ServerWorld;doesNotCollide(Lnet/minecraft/util/math/Box;)Z" )) - private static boolean doesNotCollide(World world, Box bb) + private static boolean doesNotCollide(ServerWorld world, Box bb) { //.doesNotCollide is VERY expensive. On the other side - most worlds are not made of trapdoors in // various configurations, but solid and 'passable' blocks, like air, water grass, etc. @@ -88,9 +87,9 @@ public class SpawnHelperMixin @Redirect(method = "spawnEntitiesInChunk", at = @At( value = "INVOKE", - target = "Lnet/minecraft/world/World;spawnEntity(Lnet/minecraft/entity/Entity;)Z" + target = "Lnet/minecraft/server/world/ServerWorld;spawnEntity(Lnet/minecraft/entity/Entity;)Z" )) - private static boolean spawnEntity(World world, Entity entity_1) + private static boolean spawnEntity(ServerWorld world, Entity entity_1) { if (CarpetSettings.lagFreeSpawning) // we used the mob - next time we will create a new one when needed @@ -114,7 +113,7 @@ public class SpawnHelperMixin 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_1, World world_1, WorldChunk worldChunk_1, BlockPos blockPos_1) + EntityCategory entityCategory_1, ServerWorld world_1, WorldChunk worldChunk_1, BlockPos blockPos_1) { double distanceTo = playerEntity.squaredDistanceTo(double_1, double_2, double_3); if (CarpetSettings.lagFreeSpawning && distanceTo > 16384.0D && entityCategory_1 != EntityCategory.CREATURE) diff --git a/src/main/java/carpet/mixins/StructureFeatureMixin.java b/src/main/java/carpet/mixins/StructureFeatureMixin.java index baf2b738..bf4862c2 100644 --- a/src/main/java/carpet/mixins/StructureFeatureMixin.java +++ b/src/main/java/carpet/mixins/StructureFeatureMixin.java @@ -32,11 +32,12 @@ public abstract class StructureFeatureMixin implements StructureFeatureInterface @Shadow public abstract StructureFeature.StructureStartFactory getStructureStartFactory(); @Override - public boolean plopAnywhere(IWorld world, BlockPos pos) + public boolean plopAnywhere(ServerWorld world, BlockPos pos) { - return plopAnywhere(world, pos, world.getChunkManager().getChunkGenerator()); + return plopAnywhere(world, pos, world.method_14178().getChunkGenerator()); } - public boolean plopAnywhere(IWorld world, BlockPos pos, ChunkGenerator generator) + @Override + public boolean plopAnywhere(ServerWorld world, BlockPos pos, ChunkGenerator generator) { if (world.isClient()) return false; @@ -60,6 +61,7 @@ public abstract class StructureFeatureMixin implements StructureFeatureInterface MutableIntBoundingBox box = structurestart.getBoundingBox(); structurestart.generateStructure( world, + generator, rand, new MutableIntBoundingBox( pos.getX() - this.getRadius()*16, @@ -102,7 +104,7 @@ public abstract class StructureFeatureMixin implements StructureFeatureInterface ChunkPos chunkpos = new ChunkPos(packedChunkPos); StructureStart structurestart; - Chunk ichunk = worldIn.getChunk(chunkpos.x, chunkpos.z, ChunkStatus.STRUCTURE_STARTS); + Chunk ichunk = worldIn.getChunk(chunkpos.x, chunkpos.z, ChunkStatus.STRUCTURE_STARTS, false); if (ichunk != null) { diff --git a/src/main/java/carpet/mixins/StructurePieceMixin.java b/src/main/java/carpet/mixins/StructurePieceMixin.java index abecaed9..e0063aa4 100644 --- a/src/main/java/carpet/mixins/StructurePieceMixin.java +++ b/src/main/java/carpet/mixins/StructurePieceMixin.java @@ -1,6 +1,7 @@ package carpet.mixins; import carpet.settings.CarpetSettings; +import net.minecraft.class_4538; import net.minecraft.structure.StructurePiece; import net.minecraft.world.Heightmap; import net.minecraft.world.ViewableWorld; @@ -13,10 +14,10 @@ public class StructurePieceMixin { @Redirect(method = "isUnderSeaLevel", at = @At( value = "INVOKE", - target = "Lnet/minecraft/world/ViewableWorld;getTop(Lnet/minecraft/world/Heightmap$Type;II)I" + target = "Lnet/minecraft/class_4538;getLightLevel(Lnet/minecraft/world/Heightmap$Type;II)I" )) - private int getTop(ViewableWorld viewableWorld, Heightmap.Type var1, int var2, int var3) + private int getTop(class_4538 class_4538, Heightmap.Type var1, int var2, int var3) { - return viewableWorld.getTop(CarpetSettings.skipGenerationChecks?Heightmap.Type.OCEAN_FLOOR:Heightmap.Type.OCEAN_FLOOR_WG, var2, var3); + return class_4538.getLightLevel(CarpetSettings.skipGenerationChecks?Heightmap.Type.OCEAN_FLOOR:Heightmap.Type.OCEAN_FLOOR_WG, var2, var3); } } diff --git a/src/main/java/carpet/script/CarpetExpression.java b/src/main/java/carpet/script/CarpetExpression.java index fcbf681a..2629543a 100644 --- a/src/main/java/carpet/script/CarpetExpression.java +++ b/src/main/java/carpet/script/CarpetExpression.java @@ -291,7 +291,7 @@ public class CarpetExpression private void forceChunkUpdate(BlockPos pos, ServerWorld world) { - Chunk chunk = world.getChunk(pos); + Chunk chunk = world.method_22350(pos); chunk.setShouldSave(true); for (int i = 0; i<16; i++) { @@ -706,7 +706,7 @@ public class CarpetExpression genericStateTest(c, "emitted_light", lv, (s, p, w) -> new NumericValue(s.getLuminance()))); this.expr.addLazyFunction("light", -1, (c, t, lv) -> - genericStateTest(c, "light", lv, (s, p, w) -> new NumericValue(w.getLightLevel(p)))); + genericStateTest(c, "light", lv, (s, p, w) -> new NumericValue(Math.max(w.getLightLevel(LightType.BLOCK, p), w.getLightLevel(LightType.SKY, p))))); this.expr.addLazyFunction("block_light", -1, (c, t, lv) -> genericStateTest(c, "block_light", lv, (s, p, w) -> new NumericValue(w.getLightLevel(LightType.BLOCK, p)))); @@ -748,7 +748,7 @@ public class CarpetExpression this.expr.addLazyFunction("loaded", -1, (c, t, lv) -> { - Value retval = ((CarpetContext) c).s.getWorld().isBlockLoaded(BlockValue.fromParams((CarpetContext) c, lv, 0).block.getPos()) ? Value.TRUE : Value.FALSE; + Value retval = ((CarpetContext) c).s.getWorld().isHeightValidAndBlockLoaded(BlockValue.fromParams((CarpetContext) c, lv, 0).block.getPos()) ? Value.TRUE : Value.FALSE; return (c_, t_) -> retval; }); @@ -780,7 +780,7 @@ public class CarpetExpression this.expr.addLazyFunction("block_tick", -1, (c, t, lv) -> booleanStateTest(c, "block_tick", lv, (s, p) -> { - World w = ((CarpetContext)c).s.getWorld(); + ServerWorld w = ((CarpetContext)c).s.getWorld(); s.onRandomTick(w, p, w.random); return true; })); @@ -788,7 +788,7 @@ public class CarpetExpression this.expr.addLazyFunction("random_tick", -1, (c, t, lv) -> booleanStateTest(c, "random_tick", lv, (s, p) -> { - World w = ((CarpetContext)c).s.getWorld(); + ServerWorld w = ((CarpetContext)c).s.getWorld(); if (s.hasRandomTicks() || s.getFluidState().hasRandomTicks()) s.onRandomTick(w, p, w.random); return true; @@ -1008,7 +1008,7 @@ public class CarpetExpression throw new InternalExpressionException("Unknown biome: "+biomeName); ServerWorld world = cc.s.getWorld(); BlockPos pos = locator.block.getPos(); - Chunk chunk = world.getChunk(pos); + Chunk chunk = world.method_22350(pos); chunk.getBiomeArray()[(pos.getX() & 15) | (pos.getZ() & 15) << 4] = biome; this.forceChunkUpdate(pos, world); return LazyValue.NULL; diff --git a/src/main/java/carpet/utils/BlockInfo.java b/src/main/java/carpet/utils/BlockInfo.java index 6632ee43..6187e8ee 100644 --- a/src/main/java/carpet/utils/BlockInfo.java +++ b/src/main/java/carpet/utils/BlockInfo.java @@ -1,21 +1,18 @@ package carpet.utils; -import net.minecraft.block.Block; +import net.minecraft.block.*; import net.minecraft.entity.EntityType; import net.minecraft.entity.SpawnType; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.block.Material; -import net.minecraft.block.MaterialColor; -import net.minecraft.block.BlockState; -import net.minecraft.entity.mob.MobEntityWithAi; -import net.minecraft.entity.ai.goal.WanderAroundGoal; import net.minecraft.entity.ai.PathfindingUtil; +import net.minecraft.entity.ai.goal.WanderAroundGoal; +import net.minecraft.entity.mob.MobEntityWithAi; import net.minecraft.entity.mob.ZombiePigmanEntity; -import net.minecraft.block.BlockPlacementEnvironment; +import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.text.BaseText; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.util.registry.Registry; -import net.minecraft.text.BaseText; +import net.minecraft.world.LightType; import net.minecraft.world.World; import java.util.ArrayList; @@ -171,8 +168,10 @@ public class BlockInfo lst.add(Messenger.s(String.format(" - Normal cube: %s", state.isSimpleFullBlock(world, pos)))); //isNormalCube()))); lst.add(Messenger.s(String.format(" - Is liquid: %s", material.isLiquid()))); lst.add(Messenger.s("")); - lst.add(Messenger.s(String.format(" - Light in: %d, above: %d", world.getLightLevel(pos), world.getLightLevel(pos.up())))); - lst.add(Messenger.s(String.format(" - Brightness in: %.2f, above: %.2f", world.getBrightness(pos), world.getBrightness(pos.up())))); + lst.add(Messenger.s(String.format(" - Light in: %d, above: %d", + Math.max(world.getLightLevel(LightType.BLOCK, pos),world.getLightLevel(LightType.SKY, pos)) , + Math.max(world.getLightLevel(LightType.BLOCK, pos.up()),world.getLightLevel(LightType.SKY, pos.up()))))); + lst.add(Messenger.s(String.format(" - Brightness in: %.2f, above: %.2f", world.method_22349(pos), world.method_22349(pos.up())))); lst.add(Messenger.s(String.format(" - Is opaque: %s", material.isSolid() ))); //lst.add(Messenger.s(String.format(" - Light opacity: %d", state.getOpacity(world,pos)))); lst.add(Messenger.s(String.format(" - Blocks light: %s", state.getMaterial().blocksLight()))); diff --git a/src/main/java/carpet/utils/PerimeterDiagnostics.java b/src/main/java/carpet/utils/PerimeterDiagnostics.java index b93c9099..7b5b4267 100644 --- a/src/main/java/carpet/utils/PerimeterDiagnostics.java +++ b/src/main/java/carpet/utils/PerimeterDiagnostics.java @@ -155,10 +155,10 @@ public class PerimeterDiagnostics private boolean check_entity_spawn(BlockPos pos) { - if (sle == null || !worldServer.getChunkManager().getChunkGenerator().getEntitySpawnList(ctype, pos).contains(sle)) + if (sle == null || !worldServer.method_14178().getChunkGenerator().getEntitySpawnList(ctype, pos).contains(sle)) { sle = null; - for (Biome.SpawnEntry sle: worldServer.getChunkManager().getChunkGenerator().getEntitySpawnList(ctype, pos)) + for (Biome.SpawnEntry sle: worldServer.method_14178().getChunkGenerator().getEntitySpawnList(ctype, pos)) { if (el.getType() == sle.type) { @@ -166,7 +166,7 @@ public class PerimeterDiagnostics break; } } - if (sle == null || !worldServer.getChunkManager().getChunkGenerator().getEntitySpawnList(ctype, pos).contains(sle)) + if (sle == null || !worldServer.method_14178().getChunkGenerator().getEntitySpawnList(ctype, pos).contains(sle)) { return false; } diff --git a/src/main/java/carpet/utils/SpawnReporter.java b/src/main/java/carpet/utils/SpawnReporter.java index 97b8419e..7e6ee079 100644 --- a/src/main/java/carpet/utils/SpawnReporter.java +++ b/src/main/java/carpet/utils/SpawnReporter.java @@ -394,11 +394,11 @@ public class SpawnReporter entity.remove(); } - public static List report(BlockPos pos, World worldIn) + public static List report(BlockPos pos, ServerWorld worldIn) { List rep = new ArrayList<>(); int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); - Chunk chunk = worldIn.getChunk(pos); + Chunk chunk = worldIn.method_22350(pos); int lc = chunk.sampleHeightmap(Heightmap.Type.WORLD_SURFACE, x, z) + 1; String where = String.format((y >= lc) ? "%d blocks above it." : "%d blocks below it.", MathHelper.abs(y-lc)); if (y == lc) where = "right at it."; @@ -407,7 +407,7 @@ public class SpawnReporter for (EntityCategory enumcreaturetype : EntityCategory.values()) { String type_code = String.format("%s", enumcreaturetype).substring(0, 3); - List lst = ((ChunkGenerator)worldIn.getChunkManager().getChunkGenerator()).getEntitySpawnList(enumcreaturetype, pos); + List lst = ((ChunkGenerator)worldIn.method_14178().getChunkGenerator()).getEntitySpawnList(enumcreaturetype, pos); if (lst != null && !lst.isEmpty()) { for (Biome.SpawnEntry spawnEntry : lst) diff --git a/src/main/java/carpet/utils/WoolTool.java b/src/main/java/carpet/utils/WoolTool.java index 9634ae6c..5614b3a0 100644 --- a/src/main/java/carpet/utils/WoolTool.java +++ b/src/main/java/carpet/utils/WoolTool.java @@ -7,6 +7,7 @@ import net.minecraft.block.MaterialColor; import net.minecraft.block.BlockState; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.server.world.ServerWorld; import net.minecraft.util.DyeColor; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; @@ -28,7 +29,7 @@ public class WoolTool } } - public static void carpetPlacedAction(DyeColor color, PlayerEntity placer, BlockPos pos, World worldIn) + public static void carpetPlacedAction(DyeColor color, PlayerEntity placer, BlockPos pos, ServerWorld worldIn) { if (!CarpetSettings.carpets) {