diff --git a/gradle.properties b/gradle.properties index 46a3cbd9d..c6bff3a9c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,7 +19,7 @@ parchment_version = 2021.12.19 # dependency versions registrate_version = MC1.18-1.0.21 -flywheel_version = 1.18-0.5.1.40 +flywheel_version = 1.18-0.5.1.42 jei_minecraft_version = 1.18 jei_version = 9.0.0.40 diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionWorld.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionWorld.java index 592b0a538..0699bfc0a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionWorld.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionWorld.java @@ -5,6 +5,7 @@ import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; import net.minecraft.core.BlockPos; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundSource; +import net.minecraft.util.Mth; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; @@ -14,14 +15,24 @@ import net.minecraft.world.phys.Vec3; public class ContraptionWorld extends WrappedWorld { final Contraption contraption; + private final int minY; + private final int height; - public ContraptionWorld(Level world, Contraption contraption) { + public ContraptionWorld(Level world, Contraption contraption) { super(world); this.contraption = contraption; - } - @Override + minY = nextMultipleOf16(contraption.bounds.minY); + height = nextMultipleOf16(contraption.bounds.maxY) - minY; + } + + // https://math.stackexchange.com/questions/291468 + private static int nextMultipleOf16(double a) { + return (((Math.abs((int) a) - 1) | 15) + 1) * Mth.sign(a); + } + + @Override public BlockState getBlockState(BlockPos pos) { StructureTemplate.StructureBlockInfo blockInfo = contraption.getBlocks().get(pos); @@ -51,11 +62,11 @@ public class ContraptionWorld extends WrappedWorld { @Override public int getHeight() { - return getMinBuildHeight() * (-2); + return height; } @Override public int getMinBuildHeight() { - return - (int) contraption.bounds.getYsize(); + return minY; } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java index 1966cd557..b86d5261f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java @@ -106,7 +106,7 @@ public class ContraptionRenderDispatcher { public static VirtualRenderWorld setupRenderWorld(Level world, Contraption c) { ContraptionWorld contraptionWorld = c.getContraptionWorld(); - VirtualRenderWorld renderWorld = new VirtualRenderWorld(world, contraptionWorld.getHeight(), contraptionWorld.getMinBuildHeight()); + VirtualRenderWorld renderWorld = new VirtualRenderWorld(world, c.anchor, contraptionWorld.getHeight(), contraptionWorld.getMinBuildHeight()); renderWorld.setBlockEntities(c.presentTileEntities.values());