3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-03 14:50:30 +01:00

Merge pull request #858 from creeper123123321/dev

Update to 1.13 (not for production)
Dieser Commit ist enthalten in:
Myles 2018-07-18 18:16:53 +01:00 committet von GitHub
Commit d39c59663a
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
38 geänderte Dateien mit 1354 neuen und 849 gelöschten Zeilen

Datei anzeigen

@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>1.4.0-1.13-pre10</version>
<version>1.4.0-DEV</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>1.4.0-1.13-pre10</version>
<version>1.4.0-DEV</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>1.4.0-1.13-pre10</version>
<version>1.4.0-DEV</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -5,16 +5,62 @@ import io.netty.buffer.ByteBuf;
import java.util.List;
public interface ChunkSection {
/**
* Gets a block state id (< 1.13: block_id << 4 | data & 0xF)
* @param x Block X
* @param y Block Y
* @param z Block Z
* @return Block raw id
*/
int getBlock(int x, int y, int z);
/**
* Set a block in the chunks
*
* @param x Block X
* @param y Block Y
* @param z Block Z
* @param type The block id
* @param data The data value of the block
*/
void setBlock(int x, int y, int z, int type, int data);
void setFlatBlock(int x, int y, int z, int type);
/**
* Set a block state in the chunk
*
* @param x Block X
* @param y Block Y
* @param z Block Z
* @param blockState The block state id
*/
void setFlatBlock(int x, int y, int z, int blockState);
/**
* Gets a block id (without data)
* /!\ YOU SHOULD NOT USE THIS ON 1.13
* @param x Block X
* @param y Block Y
* @param z Block Z
* @return Block id (without data)
*/
int getBlockId(int x, int y, int z);
/**
* Write the blocks in < 1.13 format to a buffer.
*
* @param output The buffer to write to.
* @throws Exception Throws if it failed to write.
*/
void writeBlocks(ByteBuf output) throws Exception;
/**
* Write the blocks in 1.13 format to a buffer.
*
* @param output The buffer to write to.
* @throws Exception Throws if it failed to write.
*/
void writeBlocks1_13(ByteBuf output) throws Exception;
void writeBlockLight(ByteBuf output) throws Exception;
boolean hasSkyLight();

Datei anzeigen

@ -4,7 +4,7 @@ import lombok.Getter;
import lombok.RequiredArgsConstructor;
import us.myles.ViaVersion.api.minecraft.metadata.MetaType;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.ProtocolSnapshotTo1_12_2;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
@RequiredArgsConstructor
@Getter
@ -24,7 +24,7 @@ public enum MetaType1_13 implements MetaType {
OptUUID(12, Type.OPTIONAL_UUID),
BlockID(13, Type.VAR_INT),
NBTTag(14, Type.NBT),
PARTICLE(15, ProtocolSnapshotTo1_12_2.PARTICLE_TYPE),
PARTICLE(15, Protocol1_13To1_12_2.PARTICLE_TYPE),
Discontinued(99, null);
private final int typeID;

Datei anzeigen

@ -18,7 +18,7 @@ import us.myles.ViaVersion.protocols.protocol1_9_1to1_9.Protocol1_9_1TO1_9;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.Protocol1_9_3TO1_9_1_2;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion.protocols.protocol1_9to1_9_1.Protocol1_9TO1_9_1;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.ProtocolSnapshotTo1_12_2;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
@ -55,7 +55,7 @@ public class ProtocolRegistry {
registerProtocol(new Protocol1_12_2TO1_12_1(), Collections.singletonList(ProtocolVersion.v1_12_2.getId()), ProtocolVersion.v1_12_1.getId());
// 1.13 support in development! (:
registerProtocol(new ProtocolSnapshotTo1_12_2(), Collections.singletonList(ProtocolVersion.v1_13.getId()), ProtocolVersion.v1_12_2.getId());
registerProtocol(new Protocol1_13To1_12_2(), Collections.singletonList(ProtocolVersion.v1_13.getId()), ProtocolVersion.v1_12_2.getId());
}
/**

Datei anzeigen

@ -62,7 +62,7 @@ public class ProtocolVersion {
register(v1_12 = new ProtocolVersion(335, "1.12"));
register(v1_12_1 = new ProtocolVersion(338, "1.12.1"));
register(v1_12_2 = new ProtocolVersion(340, "1.12.2"));
register(v1_13 = new ProtocolVersion(392, "1.13-pre10"));
register(v1_13 = new ProtocolVersion(393, "1.13"));
register(unknown = new ProtocolVersion(-1, "UNKNOWN"));
}

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2;
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection;
@ -7,10 +7,10 @@ import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_13;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data.Particle;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data.ParticleRewriter;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets.InventoryPackets;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets.WorldPackets;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.Particle;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.ParticleRewriter;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.WorldPackets;
import java.util.ArrayList;
import java.util.List;

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2;
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.chat.ComponentSerializer;
@ -16,21 +16,21 @@ import us.myles.ViaVersion.api.remapper.ValueTransformer;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data.MappingData;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets.EntityPackets;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets.InventoryPackets;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets.WorldPackets;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.BlockEntityProvider;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.PaintingProvider;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.BlockStorage;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.EntityTracker;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.TabCompleteTracker;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.types.Particle1_13Type;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.EntityPackets;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.WorldPackets;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.BlockEntityProvider;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.PaintingProvider;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.BlockStorage;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.TabCompleteTracker;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Particle1_13Type;
import java.util.Map;
// Development of 1.13 support!
public class ProtocolSnapshotTo1_12_2 extends Protocol {
public class Protocol1_13To1_12_2 extends Protocol {
public static final Particle1_13Type PARTICLE_TYPE = new Particle1_13Type();
public static String legacyTextToJson(String legacyText) {
@ -73,7 +73,7 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol {
wrapper.write(Type.VAR_INT, 0); // Root node index
}
}).send(ProtocolSnapshotTo1_12_2.class);
}).send(Protocol1_13To1_12_2.class);
// Send tags packet
w.create(0x55, new ValueCreator() {
@ -95,7 +95,7 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol {
wrapper.write(Type.VAR_INT_ARRAY, tag.getValue().clone());
}
}
}).send(ProtocolSnapshotTo1_12_2.class);
}).send(Protocol1_13To1_12_2.class);
}
};

Datei anzeigen

@ -0,0 +1,25 @@
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.chunks;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import lombok.AllArgsConstructor;
import lombok.Data;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
import java.util.List;
@Data
@AllArgsConstructor
public class Chunk1_13 implements Chunk {
private int x;
private int z;
private boolean groundUp;
private int bitmask;
private ChunkSection1_13[] sections;
private byte[] biomeData;
private List<CompoundTag> blockEntities;
@Override
public boolean isBiomeData() {
return biomeData != null;
}
}

Datei anzeigen

@ -0,0 +1,306 @@
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.chunks;
import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
import us.myles.ViaVersion.api.minecraft.chunks.NibbleArray;
import us.myles.ViaVersion.api.type.Type;
import java.util.List;
public class ChunkSection1_13 implements ChunkSection {
/**
* Size (dimensions) of blocks in a chunks section.
*/
public static final int SIZE = 16 * 16 * 16; // width * depth * height
/**
* 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 final NibbleArray blockLight;
private NibbleArray skyLight;
public ChunkSection1_13() {
this.blocks = new int[SIZE];
this.blockLight = new NibbleArray(SIZE);
palette.add(0); // AIR
}
public void setBlock(int x, int y, int z, int type, int data) {
setBlock(index(x, y, z), type, data);
}
@Override
public void setFlatBlock(int x, int y, int z, int type) {
int index = palette.indexOf(type);
if (index == -1) {
index = palette.size();
palette.add(type);
}
blocks[index(x, y, z)] = index;
}
public int getBlockId(int x, int y, int z) {
return getBlock(x, y, z) >> 4;
}
public int getBlock(int x, int y, int z) {
int index = blocks[index(x, y, z)];
return palette.get(index);
}
/**
* Set a block in the chunks based on the index
*
* @param idx Index
* @param type The type of the block
* @param data The data value of the block
*/
public void setBlock(int idx, int type, int data) {
int hash = type << 4 | (data & 0xF);
int index = palette.indexOf(hash);
if (index == -1) {
index = palette.size();
palette.add(hash);
}
blocks[idx] = index;
}
/**
* Set the block light array
*
* @param data The value to set the block light to
*/
public void setBlockLight(byte[] data) {
blockLight.setHandle(data);
}
/**
* Set the sky light array
*
* @param data The value to set the sky light to
*/
public void setSkyLight(byte[] data) {
if (data.length != LIGHT_LENGTH) throw new IllegalArgumentException("Data length != " + LIGHT_LENGTH);
this.skyLight = new NibbleArray(data);
}
private int index(int x, int y, int z) {
return y << 8 | z << 4 | x;
}
/**
* Read blocks from input stream.
* This reads all the block related data:
* <ul>
* <li>Block length/palette type</li>
* <li>Palette</li>
* <li>Block hashes/palette reference</li>
* </ul>
*
* @param input The buffer to read from.
* @throws Exception If it fails to read
*/
public void readBlocks(ByteBuf input) throws Exception {
palette.clear();
// Read bits per block
int bitsPerBlock = input.readUnsignedByte();
long maxEntryValue = (1L << bitsPerBlock) - 1;
boolean directPalette = false;
if (bitsPerBlock == 0) {
bitsPerBlock = 14;
}
if (bitsPerBlock < 4) {
bitsPerBlock = 4;
}
if (bitsPerBlock > 9) {
directPalette = true;
bitsPerBlock = 14;
}
int paletteLength = directPalette ? 0 : Type.VAR_INT.read(input);
// Read palette
for (int i = 0; i < paletteLength; i++) {
palette.add(Type.VAR_INT.read(input));
}
// Read blocks
Long[] blockData = Type.LONG_ARRAY.read(input);
if (blockData.length > 0) {
for (int i = 0; i < blocks.length; i++) {
int bitIndex = i * bitsPerBlock;
int startIndex = bitIndex >> 6; // /64
int endIndex = ((i + 1) * bitsPerBlock - 1) >> 6; // /64
int startBitSubIndex = bitIndex & 0x3F; // % 64
int val;
if (startIndex == endIndex) {
val = (int) (blockData[startIndex] >>> startBitSubIndex & maxEntryValue);
} else {
int endBitSubIndex = 64 - startBitSubIndex;
val = (int) ((blockData[startIndex] >>> startBitSubIndex | blockData[endIndex] << endBitSubIndex) & maxEntryValue);
}
if (directPalette) {
int type = val >> 4;
int data = val & 0xF;
setBlock(i, type, data);
} else {
blocks[i] = val;
}
}
}
}
/**
* Read block light from buffer.
*
* @param input The buffer to read from
*/
public void readBlockLight(ByteBuf input) {
byte[] handle = new byte[LIGHT_LENGTH];
input.readBytes(handle);
blockLight.setHandle(handle);
}
/**
* Read sky light from buffer.
* Note: Only sent in overworld!
*
* @param input The buffer to read from
*/
public void readSkyLight(ByteBuf input) {
byte[] handle = new byte[LIGHT_LENGTH];
input.readBytes(handle);
if (skyLight != null) {
skyLight.setHandle(handle);
return;
}
this.skyLight = new NibbleArray(handle);
}
public void writeBlocks(ByteBuf output) throws Exception {
// Write bits per block
int bitsPerBlock = 4;
while (palette.size() > 1 << bitsPerBlock) {
bitsPerBlock += 1;
}
long maxEntryValue = (1L << bitsPerBlock) - 1;
output.writeByte(bitsPerBlock);
// Write pallet (or not)
Type.VAR_INT.write(output, palette.size());
for (int mappedId : palette) {
Type.VAR_INT.write(output, mappedId);
}
int length = (int) Math.ceil(SIZE * bitsPerBlock / 64.0);
Type.VAR_INT.write(output, length);
long[] data = new long[length];
for (int index = 0; index < blocks.length; index++) {
int value = blocks[index];
int bitIndex = index * bitsPerBlock;
int startIndex = bitIndex / 64;
int endIndex = ((index + 1) * bitsPerBlock - 1) / 64;
int startBitSubIndex = bitIndex % 64;
data[startIndex] = data[startIndex] & ~(maxEntryValue << startBitSubIndex) | ((long) value & maxEntryValue) << startBitSubIndex;
if (startIndex != endIndex) {
int endBitSubIndex = 64 - startBitSubIndex;
data[endIndex] = data[endIndex] >>> endBitSubIndex << endBitSubIndex | ((long) value & maxEntryValue) >> endBitSubIndex;
}
}
for (long l : data) {
Type.LONG.write(output, l);
}
}
@Override
public void writeBlocks1_13(ByteBuf output) throws Exception {
// Write bits per block
int bitsPerBlock = 4;
while (palette.size() > 1 << bitsPerBlock) {
bitsPerBlock++;
}
boolean directPalette = false;
if (bitsPerBlock > 9) {
bitsPerBlock = 14;
directPalette = true;
}
long maxEntryValue = (1L << bitsPerBlock) - 1;
output.writeByte(bitsPerBlock);
// Write pallet (or not)
if (!directPalette) {
Type.VAR_INT.write(output, palette.size());
for (int mappedId : palette) {
Type.VAR_INT.write(output, mappedId);
}
}
int length = (int) Math.ceil(SIZE * bitsPerBlock / 64.0);
Type.VAR_INT.write(output, length);
long[] data = new long[length];
for (int index = 0; index < blocks.length; index++) {
int value = directPalette ? palette.get(blocks[index]) : blocks[index];
int bitIndex = index * bitsPerBlock;
int startIndex = bitIndex / 64;
int endIndex = ((index + 1) * bitsPerBlock - 1) / 64;
int startBitSubIndex = bitIndex % 64;
data[startIndex] = data[startIndex] & ~(maxEntryValue << startBitSubIndex) | ((long) value & maxEntryValue) << startBitSubIndex;
if (startIndex != endIndex) {
int endBitSubIndex = 64 - startBitSubIndex;
data[endIndex] = data[endIndex] >>> endBitSubIndex << endBitSubIndex | ((long) value & maxEntryValue) >> endBitSubIndex;
}
}
for (long l : data) {
Type.LONG.write(output, l);
}
}
/**
* Write the block light to a buffer
*
* @param output The buffer to write to
*/
@Override
public void writeBlockLight(ByteBuf output) {
output.writeBytes(blockLight.getHandle());
}
/**
* Write the sky light to a buffer
*
* @param output The buffer to write to
*/
@Override
public void writeSkyLight(ByteBuf output) {
output.writeBytes(skyLight.getHandle());
}
/**
* Check if sky light is present
*
* @return True if skylight is present
*/
@Override
public boolean hasSkyLight() {
return skyLight != null;
}
@Override
public List<Integer> getPalette() {
return palette;
}
}

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data;
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data;
import com.google.common.base.Optional;

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data;
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data;
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data;
import lombok.AllArgsConstructor;
import lombok.Data;

Datei anzeigen

@ -1,12 +1,12 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data;
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets.InventoryPackets;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets.WorldPackets;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.WorldPackets;
import java.util.Arrays;
import java.util.LinkedList;

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data;
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data;
import com.google.common.base.Optional;
import lombok.AllArgsConstructor;

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data;
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data;
import com.google.common.base.Optional;
import com.google.common.collect.BiMap;

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets;
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets;
import com.google.common.base.Optional;
import us.myles.ViaVersion.api.PacketWrapper;
@ -10,9 +10,9 @@ import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.version.Types1_12;
import us.myles.ViaVersion.api.type.types.version.Types1_13;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.MetadataRewriter;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data.EntityTypeRewriter;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.EntityTracker;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.MetadataRewriter;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.EntityTypeRewriter;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker;
public class EntityPackets {
public static void register(Protocol protocol) {

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets;
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets;
import com.github.steveice10.opennbt.tag.builtin.*;
import com.google.common.base.Joiner;
@ -11,10 +11,10 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.ProtocolSnapshotTo1_12_2;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data.MappingData;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data.SoundSource;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data.SpawnEggRewriter;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.SoundSource;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.SpawnEggRewriter;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
@ -295,7 +295,7 @@ public class InventoryPackets {
if (((CompoundTag) tag.get("display")).get("Name") instanceof StringTag) {
StringTag name = ((CompoundTag) tag.get("display")).get("Name");
name.setValue(
ProtocolSnapshotTo1_12_2.legacyTextToJson(
Protocol1_13To1_12_2.legacyTextToJson(
name.getValue()
)
);
@ -441,7 +441,7 @@ public class InventoryPackets {
if (((CompoundTag) tag.get("display")).get("Name") instanceof StringTag) {
StringTag name = ((CompoundTag) tag.get("display")).get("Name");
name.setValue(
ProtocolSnapshotTo1_12_2.jsonTextToLegacy(
Protocol1_13To1_12_2.jsonTextToLegacy(
name.getValue()
)
);

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets;
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.google.common.base.Optional;
@ -16,13 +16,13 @@ import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data.MappingData;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data.Particle;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data.ParticleRewriter;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.BlockEntityProvider;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.PaintingProvider;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.BlockStorage;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.types.Chunk1_13Type;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.Particle;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.ParticleRewriter;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.BlockEntityProvider;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.PaintingProvider;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.BlockStorage;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
public class WorldPackets {
public static void register(Protocol protocol) {

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers;
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import us.myles.ViaVersion.api.PacketWrapper;
@ -6,11 +6,11 @@ import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.Position;
import us.myles.ViaVersion.api.platform.providers.Provider;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.ProtocolSnapshotTo1_12_2;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.blockentities.BannerHandler;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.blockentities.BedHandler;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.blockentities.FlowerPotHandler;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.blockentities.SkullHandler;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.blockentities.BannerHandler;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.blockentities.BedHandler;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.blockentities.FlowerPotHandler;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.blockentities.SkullHandler;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ -63,7 +63,7 @@ public class BlockEntityProvider implements Provider {
wrapper.write(Type.POSITION, position);
wrapper.write(Type.VAR_INT, blockId);
wrapper.send(ProtocolSnapshotTo1_12_2.class, true, true);
wrapper.send(Protocol1_13To1_12_2.class, true, true);
}

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers;
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers;
import com.google.common.base.Optional;
import us.myles.ViaVersion.api.platform.providers.Provider;

Datei anzeigen

@ -1,11 +1,11 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.blockentities;
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.blockentities;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.Position;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.BlockEntityProvider;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.BlockStorage;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.BlockEntityProvider;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.BlockStorage;
public class BannerHandler implements BlockEntityProvider.BlockEntityHandler {
private final int WALL_BANNER_START = 7110; // 4 each

Datei anzeigen

@ -1,11 +1,11 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.blockentities;
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.blockentities;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.Position;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.BlockEntityProvider;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.BlockStorage;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.BlockEntityProvider;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.BlockStorage;
public class BedHandler implements BlockEntityProvider.BlockEntityHandler {

Datei anzeigen

@ -1,9 +1,9 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.blockentities;
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.blockentities;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import us.myles.ViaVersion.api.Pair;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.BlockEntityProvider;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.BlockEntityProvider;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

Datei anzeigen

@ -1,11 +1,11 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.blockentities;
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.blockentities;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.Position;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.BlockEntityProvider;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.BlockStorage;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.BlockEntityProvider;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.BlockStorage;
public class SkullHandler implements BlockEntityProvider.BlockEntityHandler {
private final int SKULL_WALL_START = 5447;

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage;
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage;
import com.google.common.collect.Sets;
import lombok.AllArgsConstructor;

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage;
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage;
import com.google.common.base.Optional;
import us.myles.ViaVersion.api.data.StoredObject;

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage;
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage;
import us.myles.ViaVersion.api.data.StoredObject;
import us.myles.ViaVersion.api.data.UserConnection;

Datei anzeigen

@ -1,4 +1,4 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.types;
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import io.netty.buffer.ByteBuf;
@ -10,16 +10,15 @@ import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
import us.myles.ViaVersion.api.type.PartialType;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.minecraft.BaseChunkType;
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.chunks.Chunk1_9_3_4;
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.chunks.ChunkSection1_9_3_4;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.chunks.Chunk1_13;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.chunks.ChunkSection1_13;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.List;
// todo 1.13-pre2 direct pallete changes
public class Chunk1_13Type extends PartialType<Chunk, ClientWorld> {
public Chunk1_13Type(ClientWorld param) {
super(param, Chunk.class);
@ -35,7 +34,7 @@ public class Chunk1_13Type extends PartialType<Chunk, ClientWorld> {
Type.VAR_INT.read(input);
BitSet usedSections = new BitSet(16);
ChunkSection1_9_3_4[] sections = new ChunkSection1_9_3_4[16];
ChunkSection1_13[] sections = new ChunkSection1_13[16];
// Calculate section count from bitmask
for (int i = 0; i < 16; i++) {
if ((primaryBitmask & (1 << i)) != 0) {
@ -46,7 +45,7 @@ public class Chunk1_13Type extends PartialType<Chunk, ClientWorld> {
// Read sections
for (int i = 0; i < 16; i++) {
if (!usedSections.get(i)) continue; // Section not set
ChunkSection1_9_3_4 section = new ChunkSection1_9_3_4();
ChunkSection1_13 section = new ChunkSection1_13();
sections[i] = section;
section.readBlocks(input);
section.readBlockLight(input);
@ -72,7 +71,7 @@ public class Chunk1_13Type extends PartialType<Chunk, ClientWorld> {
System.out.println("Found " + array.length + " more bytes than expected while reading the chunk: " + chunkX + "/" + chunkZ);
}
return new Chunk1_9_3_4(chunkX, chunkZ, groundUp, primaryBitmask, sections, biomeData, nbtData);
return new Chunk1_13(chunkX, chunkZ, groundUp, primaryBitmask, sections, biomeData, nbtData);
}
@Override
@ -87,7 +86,7 @@ public class Chunk1_13Type extends PartialType<Chunk, ClientWorld> {
for (int i = 0; i < 16; i++) {
ChunkSection section = chunk.getSections()[i];
if (section == null) continue; // Section not set
section.writeBlocks(buf);
section.writeBlocks1_13(buf);
section.writeBlockLight(buf);
if (!section.hasSkyLight()) continue; // No sky light, we're done here.

Datei anzeigen

@ -1,8 +1,8 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.types;
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types;
import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data.Particle;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.Particle;
// TODO make future proof
public class Particle1_13Type extends Type<Particle> {

Datei anzeigen

@ -249,6 +249,49 @@ public class ChunkSection1_9_3_4 implements ChunkSection {
}
}
@Override
public void writeBlocks1_13(ByteBuf output) throws Exception {
// Write bits per block
int bitsPerBlock = 4;
while (palette.size() > 1 << bitsPerBlock) {
bitsPerBlock++;
}
boolean directPalette = false;
if (bitsPerBlock > 9) {
bitsPerBlock = 14;
directPalette = true;
}
long maxEntryValue = (1L << bitsPerBlock) - 1;
output.writeByte(bitsPerBlock);
// Write pallet (or not)
if (!directPalette) {
Type.VAR_INT.write(output, palette.size());
for (int mappedId : palette) {
Type.VAR_INT.write(output, mappedId);
}
}
int length = (int) Math.ceil(SIZE * bitsPerBlock / 64.0);
Type.VAR_INT.write(output, length);
long[] data = new long[length];
for (int index = 0; index < blocks.length; index++) {
int value = directPalette ? palette.get(blocks[index]) : blocks[index];
int bitIndex = index * bitsPerBlock;
int startIndex = bitIndex / 64;
int endIndex = ((index + 1) * bitsPerBlock - 1) / 64;
int startBitSubIndex = bitIndex % 64;
data[startIndex] = data[startIndex] & ~(maxEntryValue << startBitSubIndex) | ((long) value & maxEntryValue) << startBitSubIndex;
if (startIndex != endIndex) {
int endBitSubIndex = 64 - startBitSubIndex;
data[endIndex] = data[endIndex] >>> endBitSubIndex << endBitSubIndex | ((long) value & maxEntryValue) >> endBitSubIndex;
}
}
for (long l : data) {
Type.LONG.write(output, l);
}
}
/**
* Write the block light to a buffer
*

Datei anzeigen

@ -241,6 +241,49 @@ public class ChunkSection1_9_1_2 implements ChunkSection {
}
}
@Override
public void writeBlocks1_13(ByteBuf output) throws Exception {
// Write bits per block
int bitsPerBlock = 4;
while (palette.size() > 1 << bitsPerBlock) {
bitsPerBlock++;
}
boolean directPalette = false;
if (bitsPerBlock > 9) {
bitsPerBlock = 14;
directPalette = true;
}
long maxEntryValue = (1L << bitsPerBlock) - 1;
output.writeByte(bitsPerBlock);
// Write pallet (or not)
if (!directPalette) {
Type.VAR_INT.write(output, palette.size());
for (int mappedId : palette) {
Type.VAR_INT.write(output, mappedId);
}
}
int length = (int) Math.ceil(SIZE * bitsPerBlock / 64.0);
Type.VAR_INT.write(output, length);
long[] data = new long[length];
for (int index = 0; index < blocks.length; index++) {
int value = directPalette ? palette.get(blocks[index]) : blocks[index];
int bitIndex = index * bitsPerBlock;
int startIndex = bitIndex / 64;
int endIndex = ((index + 1) * bitsPerBlock - 1) / 64;
int startBitSubIndex = bitIndex % 64;
data[startIndex] = data[startIndex] & ~(maxEntryValue << startBitSubIndex) | ((long) value & maxEntryValue) << startBitSubIndex;
if (startIndex != endIndex) {
int endBitSubIndex = 64 - startBitSubIndex;
data[endIndex] = data[endIndex] >>> endBitSubIndex << endBitSubIndex | ((long) value & maxEntryValue) >> endBitSubIndex;
}
}
for (long l : data) {
Type.LONG.write(output, l);
}
}
/**
* Write the block light to a buffer
*

Datei anzeigen

@ -148,6 +148,49 @@ public class ChunkSection1_9to1_8 implements ChunkSection {
}
}
@Override
public void writeBlocks1_13(ByteBuf output) throws Exception {
// Write bits per block
int bitsPerBlock = 4;
while (palette.size() > 1 << bitsPerBlock) {
bitsPerBlock++;
}
boolean directPalette = false;
if (bitsPerBlock > 9) {
bitsPerBlock = 14;
directPalette = true;
}
long maxEntryValue = (1L << bitsPerBlock) - 1;
output.writeByte(bitsPerBlock);
// Write pallet (or not)
if (!directPalette) {
Type.VAR_INT.write(output, palette.size());
for (int mappedId : palette) {
Type.VAR_INT.write(output, mappedId);
}
}
int length = (int) Math.ceil(SIZE * bitsPerBlock / 64.0);
Type.VAR_INT.write(output, length);
long[] data = new long[length];
for (int index = 0; index < blocks.length; index++) {
int value = directPalette ? palette.get(blocks[index]) : blocks[index];
int bitIndex = index * bitsPerBlock;
int startIndex = bitIndex / 64;
int endIndex = ((index + 1) * bitsPerBlock - 1) / 64;
int startBitSubIndex = bitIndex % 64;
data[startIndex] = data[startIndex] & ~(maxEntryValue << startBitSubIndex) | ((long) value & maxEntryValue) << startBitSubIndex;
if (startIndex != endIndex) {
int endBitSubIndex = 64 - startBitSubIndex;
data[endIndex] = data[endIndex] >>> endBitSubIndex << endBitSubIndex | ((long) value & maxEntryValue) >> endBitSubIndex;
}
}
for (long l : data) {
Type.LONG.write(output, l);
}
}
/**
* Write the block light to a buffer
*

Datei anzeigen

@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>1.4.0-1.13-pre10</version>
<version>1.4.0-DEV</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<name>viaversion-jar</name>

Datei anzeigen

@ -6,7 +6,7 @@
<groupId>us.myles</groupId>
<artifactId>viaversion-parent</artifactId>
<version>1.4.0-1.13-pre10</version>
<version>1.4.0-DEV</version>
<packaging>pom</packaging>
<name>viaversion-parent</name>

Datei anzeigen

@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>1.4.0-1.13-pre10</version>
<version>1.4.0-DEV</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>1.4.0-1.13-pre10</version>
<version>1.4.0-DEV</version>
</parent>
<modelVersion>4.0.0</modelVersion>