Skip to content

Commit

Permalink
Update OptimizedDriver.java
Browse files Browse the repository at this point in the history
  • Loading branch information
strubium authored Feb 1, 2024
1 parent 2449418 commit f928e64
Showing 1 changed file with 71 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit f928e64

Please sign in to comment.