3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 16:12:42 +01:00

Better support for nbt arrays rereading in chunks

Dieser Commit ist enthalten in:
Myles 2017-05-17 19:43:48 +01:00
Ursprung 2bd03ad92c
Commit 21eb824395
4 geänderte Dateien mit 11 neuen und 16 gelöschten Zeilen

Datei anzeigen

@ -17,7 +17,6 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.chunks.FakeTileEntit
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_1_2Type; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_1_2Type;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class Protocol1_9_3TO1_9_1_2 extends Protocol { public class Protocol1_9_3TO1_9_1_2 extends Protocol {
@ -80,7 +79,7 @@ public class Protocol1_9_3TO1_9_1_2 extends Protocol {
Chunk1_9_1_2Type type = new Chunk1_9_1_2Type(clientWorld); Chunk1_9_1_2Type type = new Chunk1_9_1_2Type(clientWorld);
Chunk chunk = wrapper.passthrough(type); Chunk chunk = wrapper.passthrough(type);
List<CompoundTag> tags = new ArrayList<>(); List<CompoundTag> tags = chunk.getBlockEntities();
for (int i = 0; i < chunk.getSections().length; i++) { for (int i = 0; i < chunk.getSections().length; i++) {
ChunkSection section = chunk.getSections()[i]; ChunkSection section = chunk.getSections()[i];
if (section == null) if (section == null)
@ -98,7 +97,8 @@ public class Protocol1_9_3TO1_9_1_2 extends Protocol {
} }
} }
wrapper.write(Type.NBT_ARRAY, tags.toArray(new CompoundTag[0])); // Send (for clients on this version)
wrapper.write(Type.NBT_ARRAY, chunk.getBlockEntities().toArray(new CompoundTag[0]));
} }
}); });
} }

Datei anzeigen

@ -16,7 +16,7 @@ public class Chunk1_9_1_2 implements Chunk {
private int bitmask; private int bitmask;
private final ChunkSection1_9_1_2[] sections; private final ChunkSection1_9_1_2[] sections;
private byte[] biomeData; private byte[] biomeData;
List<CompoundTag> blockEntities; private List<CompoundTag> blockEntities;
public boolean isBiomeData() { public boolean isBiomeData() {
return biomeData != null; return biomeData != null;

Datei anzeigen

@ -6,7 +6,7 @@ import lombok.RequiredArgsConstructor;
import lombok.ToString; import lombok.ToString;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk; import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
import java.util.Collections; import java.util.ArrayList;
import java.util.List; import java.util.List;
@RequiredArgsConstructor @RequiredArgsConstructor
@ -19,6 +19,7 @@ public class Chunk1_9to1_8 implements Chunk {
private final int primaryBitmask; private final int primaryBitmask;
private final ChunkSection1_9to1_8[] sections; private final ChunkSection1_9to1_8[] sections;
private final byte[] biomeData; private final byte[] biomeData;
private final List<CompoundTag> blockEntities;
private boolean unloadPacket = false; private boolean unloadPacket = false;
/** /**
@ -28,7 +29,8 @@ public class Chunk1_9to1_8 implements Chunk {
* @param z coord * @param z coord
*/ */
public Chunk1_9to1_8(int x, int z) { public Chunk1_9to1_8(int x, int z) {
this(x, z, true, 0, new ChunkSection1_9to1_8[16], null); this(x, z, true, 0, new ChunkSection1_9to1_8[16], null,
new ArrayList<CompoundTag>());
this.unloadPacket = true; this.unloadPacket = true;
} }
@ -50,9 +52,4 @@ public class Chunk1_9to1_8 implements Chunk {
public int getBitmask() { public int getBitmask() {
return primaryBitmask; return primaryBitmask;
} }
@Override
public List<CompoundTag> getBlockEntities() {
return Collections.emptyList();
}
} }

Datei anzeigen

@ -1,5 +1,6 @@
package us.myles.ViaVersion.protocols.protocol1_9to1_8.types; package us.myles.ViaVersion.protocols.protocol1_9to1_8.types;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
@ -16,6 +17,7 @@ import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.ClientChunks;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import java.nio.ShortBuffer; import java.nio.ShortBuffer;
import java.util.ArrayList;
import java.util.BitSet; import java.util.BitSet;
import java.util.logging.Level; import java.util.logging.Level;
@ -137,7 +139,7 @@ public class ChunkType extends PartialType<Chunk, ClientChunks> {
} }
// Return chunks // Return chunks
return new Chunk1_9to1_8(chunkX, chunkZ, groundUp, bitmask, sections, biomeData); return new Chunk1_9to1_8(chunkX, chunkZ, groundUp, bitmask, sections, biomeData, new ArrayList<CompoundTag>());
} }
@Override @Override
@ -172,9 +174,5 @@ public class ChunkType extends PartialType<Chunk, ClientChunks> {
if (chunk.hasBiomeData()) { if (chunk.hasBiomeData()) {
output.writeBytes(chunk.getBiomeData()); output.writeBytes(chunk.getBiomeData());
} }
} }
} }