Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-03 14:50:30 +01:00
Keep Chunk as an interface
Dieser Commit ist enthalten in:
Ursprung
ae73ef1a33
Commit
9cf5a66e2f
@ -0,0 +1,24 @@
|
||||
package us.myles.ViaVersion.api.minecraft.chunks;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
public class BaseChunk implements Chunk {
|
||||
protected int x;
|
||||
protected int z;
|
||||
protected boolean groundUp;
|
||||
protected int bitmask;
|
||||
protected ChunkSection[] sections;
|
||||
protected byte[] biomeData;
|
||||
protected List<CompoundTag> blockEntities;
|
||||
|
||||
@Override
|
||||
public boolean isBiomeData() {
|
||||
return biomeData != null;
|
||||
}
|
||||
}
|
@ -1,23 +1,23 @@
|
||||
package us.myles.ViaVersion.api.minecraft.chunks;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class Chunk {
|
||||
protected int x;
|
||||
protected int z;
|
||||
protected boolean groundUp;
|
||||
protected int bitmask;
|
||||
protected ChunkSection[] sections;
|
||||
protected byte[] biomeData;
|
||||
protected List<CompoundTag> blockEntities;
|
||||
public interface Chunk {
|
||||
int getX();
|
||||
|
||||
public boolean isBiomeData() {
|
||||
return biomeData != null;
|
||||
}
|
||||
int getZ();
|
||||
|
||||
boolean isBiomeData();
|
||||
|
||||
int getBitmask();
|
||||
|
||||
ChunkSection[] getSections();
|
||||
|
||||
byte[] getBiomeData();
|
||||
|
||||
List<CompoundTag> getBlockEntities();
|
||||
|
||||
boolean isGroundUp();
|
||||
}
|
||||
|
@ -1,18 +1,16 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_9to1_8.chunks;
|
||||
package us.myles.ViaVersion.api.minecraft.chunks;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import lombok.Getter;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Chunk1_9to1_8 extends Chunk {
|
||||
public class Chunk1_8 extends BaseChunk {
|
||||
@Getter
|
||||
private boolean unloadPacket = false;
|
||||
|
||||
public Chunk1_9to1_8(int x, int z, boolean groundUp, int bitmask, ChunkSection[] sections, byte[] biomeData, List<CompoundTag> blockEntities) {
|
||||
public Chunk1_8(int x, int z, boolean groundUp, int bitmask, ChunkSection[] sections, byte[] biomeData, List<CompoundTag> blockEntities) {
|
||||
super(x, z, groundUp, bitmask, sections, biomeData, blockEntities);
|
||||
}
|
||||
|
||||
@ -22,7 +20,7 @@ public class Chunk1_9to1_8 extends Chunk {
|
||||
* @param x coord
|
||||
* @param z coord
|
||||
*/
|
||||
public Chunk1_9to1_8(int x, int z) {
|
||||
public Chunk1_8(int x, int z) {
|
||||
this(x, z, true, 0, new ChunkSection[16], null, new ArrayList<CompoundTag>());
|
||||
this.unloadPacket = true;
|
||||
}
|
@ -14,9 +14,6 @@ public class ChunkSection {
|
||||
* Length of the sky and block light nibble arrays.
|
||||
*/
|
||||
public static final int LIGHT_LENGTH = 16 * 16 * 16 / 2; // size * size * size / 2 (nibble bit count)
|
||||
/**
|
||||
* Length of the block data array.
|
||||
*/
|
||||
private final List<Integer> palette = Lists.newArrayList();
|
||||
private final int[] blocks;
|
||||
private NibbleArray blockLight;
|
||||
|
@ -4,6 +4,7 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.minecraft.Environment;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.BaseChunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.type.PartialType;
|
||||
@ -69,7 +70,7 @@ public class Chunk1_13Type extends PartialType<Chunk, ClientWorld> {
|
||||
}
|
||||
}
|
||||
|
||||
return new Chunk(chunkX, chunkZ, groundUp, primaryBitmask, sections, biomeData, nbtData);
|
||||
return new BaseChunk(chunkX, chunkZ, groundUp, primaryBitmask, sections, biomeData, nbtData);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,6 +3,7 @@ package us.myles.ViaVersion.protocols.protocol1_14to1_13_2.types;
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.BaseChunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.type.PartialType;
|
||||
@ -64,7 +65,7 @@ public class Chunk1_14Type extends PartialType<Chunk, ClientWorld> {
|
||||
}
|
||||
}
|
||||
|
||||
return new Chunk(chunkX, chunkZ, groundUp, primaryBitmask, sections, biomeData, nbtData);
|
||||
return new BaseChunk(chunkX, chunkZ, groundUp, primaryBitmask, sections, biomeData, nbtData);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,6 +4,7 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.minecraft.Environment;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.BaseChunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.type.PartialType;
|
||||
@ -67,7 +68,7 @@ public class Chunk1_9_3_4Type extends PartialType<Chunk, ClientWorld> {
|
||||
}
|
||||
}
|
||||
|
||||
return new Chunk(chunkX, chunkZ, groundUp, primaryBitmask, sections, biomeData, nbtData);
|
||||
return new BaseChunk(chunkX, chunkZ, groundUp, primaryBitmask, sections, biomeData, nbtData);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,6 +4,7 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.minecraft.Environment;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.BaseChunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.type.PartialType;
|
||||
@ -65,7 +66,7 @@ public class Chunk1_9_1_2Type extends PartialType<Chunk, ClientWorld> {
|
||||
input.readBytes(biomeData);
|
||||
}
|
||||
|
||||
return new Chunk(chunkX, chunkZ, groundUp, primaryBitmask, sections, biomeData, new ArrayList<CompoundTag>());
|
||||
return new BaseChunk(chunkX, chunkZ, groundUp, primaryBitmask, sections, biomeData, new ArrayList<CompoundTag>());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -16,7 +16,7 @@ import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.ItemRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.chunks.Chunk1_9to1_8;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.BulkChunkTranslatorProvider;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.CommandBlockProvider;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.sounds.Effect;
|
||||
@ -121,7 +121,7 @@ public class WorldPackets {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ClientChunks clientChunks = wrapper.user().get(ClientChunks.class);
|
||||
Chunk1_9to1_8 chunk = (Chunk1_9to1_8) wrapper.passthrough(new Chunk1_9to1_8Type(clientChunks));
|
||||
Chunk1_8 chunk = (Chunk1_8) wrapper.passthrough(new Chunk1_9to1_8Type(clientChunks));
|
||||
if (chunk.isUnloadPacket()) {
|
||||
wrapper.setId(0x1D);
|
||||
|
||||
|
@ -12,7 +12,7 @@ import us.myles.ViaVersion.api.type.types.version.Types1_8;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_9;
|
||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.Protocol1_10To1_9_3_4;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.chunks.Chunk1_9to1_8;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.ClientChunks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -77,7 +77,7 @@ public class Chunk1_9to1_8Type extends PartialType<Chunk, ClientChunks> {
|
||||
if (sectionCount == 0 && groundUp && !isBulkPacket && param.getLoadedChunks().contains(chunkHash)) {
|
||||
// This is a chunks unload packet
|
||||
param.getLoadedChunks().remove(chunkHash);
|
||||
return new Chunk1_9to1_8(chunkX, chunkZ);
|
||||
return new Chunk1_8(chunkX, chunkZ);
|
||||
}
|
||||
|
||||
int startIndex = input.readerIndex();
|
||||
@ -123,14 +123,14 @@ public class Chunk1_9to1_8Type extends PartialType<Chunk, ClientChunks> {
|
||||
}
|
||||
|
||||
// Return chunks
|
||||
return new Chunk1_9to1_8(chunkX, chunkZ, groundUp, bitmask, sections, biomeData, new ArrayList<CompoundTag>());
|
||||
return new Chunk1_8(chunkX, chunkZ, groundUp, bitmask, sections, biomeData, new ArrayList<CompoundTag>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf output, ClientChunks param, Chunk input) throws Exception {
|
||||
if (!(input instanceof Chunk1_9to1_8)) throw new Exception("Incompatible chunk, " + input.getClass());
|
||||
if (!(input instanceof Chunk1_8)) throw new Exception("Incompatible chunk, " + input.getClass());
|
||||
|
||||
Chunk1_9to1_8 chunk = (Chunk1_9to1_8) input;
|
||||
Chunk1_8 chunk = (Chunk1_8) input;
|
||||
// Write primary info
|
||||
output.writeInt(chunk.getX());
|
||||
output.writeInt(chunk.getZ());
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren