optimize
This commit is contained in:
@@ -6,5 +6,4 @@ dependencies {
|
||||
|
||||
/* Components */
|
||||
compile (group: 'com.google.code.gson', name: 'gson', version: '2.8.5')
|
||||
compile (group: 'net.sf.trove4j', name: 'trove4j', version: '3.0.3')
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package mc.core.network.proto_1_12_2.packets;
|
||||
|
||||
import com.flowpowered.nbt.CompoundTag;
|
||||
import gnu.trove.list.TIntList;
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -11,7 +9,6 @@ import mc.core.network.SCPacket;
|
||||
import mc.core.network.proto_1_12_2.ByteArrayOutputNetStream;
|
||||
import mc.core.utils.NibbleArray;
|
||||
import mc.core.world.block.Block;
|
||||
import mc.core.world.block.BlockLocation;
|
||||
import mc.core.world.block.BlockType;
|
||||
import mc.core.world.chunk.Chunk;
|
||||
import mc.core.world.chunk.ChunkSection;
|
||||
@@ -208,15 +205,11 @@ public class ChunkDataPacket implements SCPacket {
|
||||
}
|
||||
|
||||
private class PalettedChunkSection {
|
||||
private TIntList palette = new TIntArrayList();
|
||||
private List<Integer> palette = new ArrayList<>();
|
||||
private byte[] blocks = new byte[4096];
|
||||
private NibbleArray blockLight = new NibbleArray();
|
||||
private NibbleArray skyLight = new NibbleArray();
|
||||
|
||||
private int coordsToIndex(BlockLocation location) {
|
||||
return coordsToIndex(location.getX(), location.getY(), location.getZ());
|
||||
}
|
||||
|
||||
private int coordsToIndex(int x, int y, int z) {
|
||||
return y << 8 | z << 4 | x;
|
||||
}
|
||||
@@ -238,14 +231,13 @@ public class ChunkDataPacket implements SCPacket {
|
||||
}
|
||||
|
||||
void addBlock(Block block, int skyLight) {
|
||||
BlockLocation location = new BlockLocation(
|
||||
block.getLocation().getX() - ((block.getLocation().getX() >> 4) << 4),
|
||||
block.getLocation().getY() - ((block.getLocation().getY() >> 4) << 4),
|
||||
block.getLocation().getZ() - ((block.getLocation().getZ() >> 4) << 4)
|
||||
);
|
||||
blocks[coordsToIndex(location)] = addBlockType(block.getType());
|
||||
blockLight.set(location, block.getLight());
|
||||
this.skyLight.set(location, skyLight);
|
||||
final int bx = block.getLocation().getX() - ((block.getLocation().getX() >> 4) << 4);
|
||||
final int by = block.getLocation().getY() - ((block.getLocation().getY() >> 4) << 4);
|
||||
final int bz = block.getLocation().getZ() - ((block.getLocation().getZ() >> 4) << 4);
|
||||
|
||||
blocks[coordsToIndex(bx, by, bz)] = addBlockType(block.getType());
|
||||
blockLight.set(bx, by, bz, block.getLight());
|
||||
this.skyLight.set(bx, by, bz, skyLight);
|
||||
}
|
||||
|
||||
void writeToNetStream(final NetOutputStream netOutputStream) {
|
||||
@@ -264,7 +256,7 @@ public class ChunkDataPacket implements SCPacket {
|
||||
// <Palette>
|
||||
netOutputStream.writeUnsignedByte(bitsPerBlock); // Bits Per Block
|
||||
netOutputStream.writeVarInt(palette.size()); // Size of palette
|
||||
palette.forEach(value -> { netOutputStream.writeVarInt(value); return true; }); // Palette
|
||||
palette.forEach(netOutputStream::writeVarInt); // Palette
|
||||
// </Palette>
|
||||
// <Data Array>
|
||||
final int dataLength = (4096/*16*16*16*/ * bitsPerBlock) / 64/*size of long in bits*/;
|
||||
|
||||
Reference in New Issue
Block a user