Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
685e4e5c4b
Commit
21b271c01a
@ -26,12 +26,12 @@ import io.netty.buffer.UnpooledByteBufAllocator;
|
||||
import net.minecraft.core.IRegistry;
|
||||
import net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData;
|
||||
import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
|
||||
import net.minecraft.util.SimpleBitStorage;
|
||||
import net.minecraft.world.level.block.entity.TileEntityTypes;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.LongBuffer;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.IntFunction;
|
||||
@ -93,15 +93,17 @@ public class TechHider18 implements TechHider.ChunkHider {
|
||||
buffer.writeBytes(data, curI, dataArrayLength * 8);
|
||||
} else {
|
||||
ByteBuffer source = ByteBuffer.wrap(data, curI, dataArrayLength * 8);
|
||||
VariableValueArray values = new VariableValueArray(bitsPerBlock, dataArrayLength, source.asLongBuffer());
|
||||
long[] array = new long[dataArrayLength];
|
||||
source.asLongBuffer().get(array);
|
||||
SimpleBitStorage values = new SimpleBitStorage(bitsPerBlock, 4096, array);
|
||||
|
||||
for (int pos = 0; pos < 4096; pos++) {
|
||||
if (hiddenBlockIds.contains(values.get(pos))) {
|
||||
values.set(pos, obfuscateWith);
|
||||
if (hiddenBlockIds.contains(values.a(pos))) {
|
||||
values.b(pos, obfuscateWith);
|
||||
}
|
||||
}
|
||||
|
||||
for (long l : values.backing)
|
||||
for (long l : values.a())
|
||||
buffer.writeLong(l);
|
||||
}
|
||||
});
|
||||
@ -145,30 +147,4 @@ public class TechHider18 implements TechHider.ChunkHider {
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
private static final class VariableValueArray {
|
||||
private final long[] backing;
|
||||
private final int bitsPerValue;
|
||||
private final long valueMask;
|
||||
private final int valuesPerLong;
|
||||
|
||||
public VariableValueArray(int bitsPerEntry, int dataArrayLength, LongBuffer buffer) {
|
||||
this.bitsPerValue = bitsPerEntry;
|
||||
this.backing = new long[dataArrayLength];
|
||||
buffer.get(backing);
|
||||
this.valueMask = (1L << this.bitsPerValue) - 1;
|
||||
this.valuesPerLong = 64 / bitsPerEntry;
|
||||
}
|
||||
|
||||
public int get(int index) {
|
||||
return (int)((backing[index / valuesPerLong] >> ((index % valuesPerLong) * bitsPerValue)) & valueMask);
|
||||
}
|
||||
|
||||
public void set(int index, int value) {
|
||||
int i0 = index / valuesPerLong;
|
||||
int i1 = index % valuesPerLong;
|
||||
|
||||
backing[i0] = backing[i0] & ~(this.valueMask << i1) | (value & valueMask) << i1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren