From f928e6430f57265483d93fd992c31b75faaad7f4 Mon Sep 17 00:00:00 2001 From: strubium <113206902+strubium@users.noreply.github.com> Date: Thu, 1 Feb 2024 11:50:10 -0600 Subject: [PATCH] Update OptimizedDriver.java --- .../world/driver/OptimizedDriver.java | 73 ++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/src/main/java/mcjty/lostcities/dimensions/world/driver/OptimizedDriver.java b/src/main/java/mcjty/lostcities/dimensions/world/driver/OptimizedDriver.java index a3eaeb72..85f5c639 100644 --- a/src/main/java/mcjty/lostcities/dimensions/world/driver/OptimizedDriver.java +++ b/src/main/java/mcjty/lostcities/dimensions/world/driver/OptimizedDriver.java @@ -2,14 +2,14 @@ import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; -import net.minecraft.world.chunk.ChunkPrimer; +import net.minecraft.world.chunk.Chunk; import java.util.Arrays; import java.util.Objects; public class OptimizedDriver implements IPrimerDriver { - public ChunkPrimer primer; + public Chunk primer; private int current; @Override @@ -78,6 +78,75 @@ public int getY() { public int getZ() { return (current >> 8) & 0xf; } + @Override + public void setBlockRange(int x, int y, int z, int y2, char c) { + int s = getBlockIndex(x, y, z); + int e = s + y2-y; + Arrays.fill(primer.data, s, e, c); + } + + @Override + public void setBlockRangeSafe(int x, int y, int z, int y2, char c) { + if (y2 <= y) { + return; + } + int s = getBlockIndex(x, y, z); + int e = s + y2-y; + Arrays.fill(primer.data, s, e, c); + } + + @Override + public IPrimerDriver block(char c) { + primer.data[current] = c; + return this; + } + + @Override + public IPrimerDriver block(IBlockState c) { + primer.data[current] = (char) Block.BLOCK_STATE_IDS.get(c); + return this; + } + + @Override + public IPrimerDriver add(char c) { + primer.data[current++] = c; + return this; + } + + @Override + public char getBlock() { + return primer.data[current]; + } + + @Override + public char getBlockDown() { + return primer.data[current-1]; + } + + @Override + public char getBlockEast() { + return primer.data[current + (1<<12)]; + } + + @Override + public char getBlockWest() { + return primer.data[current - (1<<12)]; + } + + @Override + public char getBlockSouth() { + return primer.data[current + (1<<8)]; + } + + @Override + public char getBlockNorth() { + return primer.data[current - (1<<8)]; + } + + @Override + public char getBlock(int x, int y, int z) { + return primer.data[getBlockIndex(x, y, z)]; + } @Override public IIndex getIndex(int x, int y, int z) {