mirror of
https://github.com/barkeser2002/CatServer.git
synced 2026-09-25 02:20:01 +03:00
61 lines
2.1 KiB
Diff
61 lines
2.1 KiB
Diff
--- ../src-base/minecraft/net/minecraft/world/chunk/BlockStateContainer.java
|
|
+++ ../src-work/minecraft/net/minecraft/world/chunk/BlockStateContainer.java
|
|
@@ -30,6 +30,10 @@
|
|
|
|
private void setBits(int bitsIn)
|
|
{
|
|
+ setBits(bitsIn, false);
|
|
+ }
|
|
+ private void setBits(int bitsIn, boolean forceBits)
|
|
+ {
|
|
if (bitsIn != this.bits)
|
|
{
|
|
this.bits = bitsIn;
|
|
@@ -47,6 +51,8 @@
|
|
{
|
|
this.palette = REGISTRY_BASED_PALETTE;
|
|
this.bits = MathHelper.log2DeBruijn(Block.BLOCK_STATE_IDS.size());
|
|
+ if (forceBits)
|
|
+ this.bits = bitsIn;
|
|
}
|
|
|
|
this.palette.idFor(AIR_BLOCK_STATE);
|
|
@@ -102,11 +108,15 @@
|
|
|
|
if (this.bits != i)
|
|
{
|
|
- this.setBits(i);
|
|
+ this.setBits(i, true); //Forge, Force bit density to fix network issues, resize below if needed.
|
|
}
|
|
|
|
this.palette.read(buf);
|
|
buf.readLongArray(this.storage.getBackingLongArray());
|
|
+
|
|
+ int regSize = MathHelper.log2DeBruijn(Block.BLOCK_STATE_IDS.size());
|
|
+ if (this.palette == REGISTRY_BASED_PALETTE && this.bits != regSize) // Resize bits to fit registry.
|
|
+ this.onResize(regSize, AIR_BLOCK_STATE);
|
|
}
|
|
|
|
public void write(PacketBuffer buf)
|
|
@@ -154,7 +164,19 @@
|
|
int l = i >> 4 & 15;
|
|
int i1 = blockIdExtension == null ? 0 : blockIdExtension.get(j, k, l);
|
|
int j1 = i1 << 12 | (blockIds[i] & 255) << 4 | data.get(j, k, l);
|
|
- this.set(i, Block.BLOCK_STATE_IDS.getByValue(j1));
|
|
+ IBlockState state = Block.BLOCK_STATE_IDS.getByValue(j1);
|
|
+ if (state == null) {
|
|
+ Block block = Block.getBlockById(j1 >> 4);
|
|
+ if (block != null) {
|
|
+ try {
|
|
+ state = block.getDefaultState();
|
|
+ } catch (Exception ignored) {
|
|
+ state = block.getDefaultState();
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ this.set(i, state);
|
|
+// this.set(i, Block.BLOCK_STATE_IDS.getByValue(j1));
|
|
}
|
|
}
|
|
|