diff --git a/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java b/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java index a0e3049e6..92a1c50fb 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java @@ -11,6 +11,7 @@ import com.simibubi.create.content.contraptions.components.actors.SeatBlock; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Registry; +import net.minecraft.core.SectionPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerLevel; @@ -194,17 +195,19 @@ public class BlockHelper { } private static void placeRailWithoutUpdate(Level world, BlockState state, BlockPos target) { - int i = target.getX() & 15; - int j = target.getY(); - int k = target.getZ() & 15; LevelChunk chunk = world.getChunkAt(target); - LevelChunkSection chunksection = chunk.getSections()[j >> 4]; + int idx = chunk.getSectionIndex(target.getY()); + LevelChunkSection chunksection = chunk.getSection(idx); if (chunksection == null) { - chunksection = new LevelChunkSection(j >> 4 << 4, world.registryAccess() - .registryOrThrow(Registry.BIOME_REGISTRY)); - chunk.getSections()[j >> 4] = chunksection; + chunksection = new LevelChunkSection(chunk.getSectionYFromSectionIndex(idx), + world.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY)); + chunk.getSections()[idx] = chunksection; } - BlockState old = chunksection.setBlockState(i, j & 15, k, state); + BlockState old = chunksection.setBlockState( + SectionPos.sectionRelative(target.getX()), + SectionPos.sectionRelative(target.getY()), + SectionPos.sectionRelative(target.getZ()), + state); chunk.setUnsaved(true); world.markAndNotifyBlock(target, chunk, old, state, 82, 512);