Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 08:30:09 +01:00
Remove some deprecated api usage, small cleanup
Dieser Commit ist enthalten in:
Ursprung
1a5f83619d
Commit
088f654159
@ -136,7 +136,7 @@ public interface ViaAPI<T> {
|
|||||||
* Returns the supported protocol versions.
|
* Returns the supported protocol versions.
|
||||||
* This method removes any blocked protocol versions.
|
* This method removes any blocked protocol versions.
|
||||||
*
|
*
|
||||||
* @return a list of protocol versions
|
* @return a sorted set of protocol versions
|
||||||
* @see #getFullSupportedVersions() for a full list
|
* @see #getFullSupportedVersions() for a full list
|
||||||
*/
|
*/
|
||||||
SortedSet<Integer> getSupportedVersions();
|
SortedSet<Integer> getSupportedVersions();
|
||||||
@ -144,7 +144,7 @@ public interface ViaAPI<T> {
|
|||||||
/**
|
/**
|
||||||
* Returns the supported protocol versions, including blocked protocols.
|
* Returns the supported protocol versions, including blocked protocols.
|
||||||
*
|
*
|
||||||
* @return a list of protocol versions
|
* @return a sorted set of protocol versions
|
||||||
*/
|
*/
|
||||||
SortedSet<Integer> getFullSupportedVersions();
|
SortedSet<Integer> getFullSupportedVersions();
|
||||||
|
|
||||||
|
@ -89,7 +89,6 @@ public interface ViaManager {
|
|||||||
*
|
*
|
||||||
* @return true if enabled
|
* @return true if enabled
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
default boolean isDebug() {
|
default boolean isDebug() {
|
||||||
return debugHandler().enabled();
|
return debugHandler().enabled();
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ public interface Mappings {
|
|||||||
int mappedSize();
|
int mappedSize();
|
||||||
|
|
||||||
static <T extends Mappings> Builder<T> builder(final MappingsSupplier<T> supplier) {
|
static <T extends Mappings> Builder<T> builder(final MappingsSupplier<T> supplier) {
|
||||||
return new Builder(supplier);
|
return new Builder<>(supplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
|
@ -54,10 +54,10 @@ public interface BlockChangeRecord {
|
|||||||
short getY(int chunkSectionY);
|
short getY(int chunkSectionY);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns the absolute y coordinate - only works for sub 1.16 protocols.
|
||||||
|
*
|
||||||
* @return absolute y coordinate
|
* @return absolute y coordinate
|
||||||
* @deprecated 1.16+ stores the relative y coordinate
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
default short getY() {
|
default short getY() {
|
||||||
return getY(-1);
|
return getY(-1);
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.api.minecraft;
|
package com.viaversion.viaversion.api.minecraft;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.EnumMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public enum BlockFace {
|
public enum BlockFace {
|
||||||
@ -33,9 +33,9 @@ public enum BlockFace {
|
|||||||
TOP((byte) 0, (byte) 1, (byte) 0, EnumAxis.Y),
|
TOP((byte) 0, (byte) 1, (byte) 0, EnumAxis.Y),
|
||||||
BOTTOM((byte) 0, (byte) -1, (byte) 0, EnumAxis.Y);
|
BOTTOM((byte) 0, (byte) -1, (byte) 0, EnumAxis.Y);
|
||||||
|
|
||||||
public static final BlockFace[] HORIZONTAL = new BlockFace[]{NORTH, SOUTH, EAST, WEST};
|
public static final BlockFace[] HORIZONTAL = {NORTH, SOUTH, EAST, WEST};
|
||||||
|
|
||||||
private static final Map<BlockFace, BlockFace> opposites = new HashMap<>();
|
private static final Map<BlockFace, BlockFace> opposites = new EnumMap<>(BlockFace.class);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
opposites.put(BlockFace.NORTH, BlockFace.SOUTH);
|
opposites.put(BlockFace.NORTH, BlockFace.SOUTH);
|
||||||
|
@ -33,7 +33,7 @@ public class Position {
|
|||||||
this.z = z;
|
this.z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated/*(forRemoval=true)*/
|
// @Deprecated/*(forRemoval=true)*/ Just leave this unchecked
|
||||||
public Position(int x, short y, int z) {
|
public Position(int x, short y, int z) {
|
||||||
this(x, (int) y, z);
|
this(x, (int) y, z);
|
||||||
}
|
}
|
||||||
|
@ -314,6 +314,7 @@ public abstract class AbstractProtocol<C1 extends ClientboundPacketType, C2 exte
|
|||||||
} else {
|
} else {
|
||||||
int mappedId = direction == Direction.CLIENTBOUND ? protocolPacket.getNewId() : protocolPacket.getOldId();
|
int mappedId = direction == Direction.CLIENTBOUND ? protocolPacket.getNewId() : protocolPacket.getOldId();
|
||||||
if (unmappedId != mappedId) {
|
if (unmappedId != mappedId) {
|
||||||
|
//noinspection deprecation
|
||||||
packetWrapper.setId(mappedId);
|
packetWrapper.setId(mappedId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ package com.viaversion.viaversion.api.type.types;
|
|||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Particle {
|
public class Particle {
|
||||||
|
@ -24,6 +24,8 @@ package com.viaversion.viaversion.api.type.types.version;
|
|||||||
|
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSectionImpl;
|
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSectionImpl;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.util.CompactArrayUtil;
|
import com.viaversion.viaversion.util.CompactArrayUtil;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
@ -39,8 +41,6 @@ public class ChunkSectionType1_13 extends Type<ChunkSection> {
|
|||||||
public ChunkSection read(ByteBuf buffer) throws Exception {
|
public ChunkSection read(ByteBuf buffer) throws Exception {
|
||||||
// Reaad bits per block
|
// Reaad bits per block
|
||||||
int bitsPerBlock = buffer.readUnsignedByte();
|
int bitsPerBlock = buffer.readUnsignedByte();
|
||||||
int originalBitsPerBlock = bitsPerBlock;
|
|
||||||
|
|
||||||
if (bitsPerBlock > 8) {
|
if (bitsPerBlock > 8) {
|
||||||
bitsPerBlock = GLOBAL_PALETTE;
|
bitsPerBlock = GLOBAL_PALETTE;
|
||||||
} else if (bitsPerBlock < 4) {
|
} else if (bitsPerBlock < 4) {
|
||||||
@ -52,8 +52,9 @@ public class ChunkSectionType1_13 extends Type<ChunkSection> {
|
|||||||
if (bitsPerBlock != GLOBAL_PALETTE) {
|
if (bitsPerBlock != GLOBAL_PALETTE) {
|
||||||
int paletteLength = Type.VAR_INT.readPrimitive(buffer);
|
int paletteLength = Type.VAR_INT.readPrimitive(buffer);
|
||||||
chunkSection = new ChunkSectionImpl(true, paletteLength);
|
chunkSection = new ChunkSectionImpl(true, paletteLength);
|
||||||
|
DataPalette blockPalette = chunkSection.palette(PaletteType.BLOCKS);
|
||||||
for (int i = 0; i < paletteLength; i++) {
|
for (int i = 0; i < paletteLength; i++) {
|
||||||
chunkSection.addPaletteEntry(Type.VAR_INT.readPrimitive(buffer));
|
blockPalette.addId(Type.VAR_INT.readPrimitive(buffer));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
chunkSection = new ChunkSectionImpl(true);
|
chunkSection = new ChunkSectionImpl(true);
|
||||||
@ -64,8 +65,9 @@ public class ChunkSectionType1_13 extends Type<ChunkSection> {
|
|||||||
if (blockData.length > 0) {
|
if (blockData.length > 0) {
|
||||||
int expectedLength = (int) Math.ceil(ChunkSection.SIZE * bitsPerBlock / 64.0);
|
int expectedLength = (int) Math.ceil(ChunkSection.SIZE * bitsPerBlock / 64.0);
|
||||||
if (blockData.length == expectedLength) {
|
if (blockData.length == expectedLength) {
|
||||||
|
DataPalette blockPalette = chunkSection.palette(PaletteType.BLOCKS);
|
||||||
CompactArrayUtil.iterateCompactArray(bitsPerBlock, ChunkSection.SIZE, blockData,
|
CompactArrayUtil.iterateCompactArray(bitsPerBlock, ChunkSection.SIZE, blockData,
|
||||||
bitsPerBlock == GLOBAL_PALETTE ? chunkSection::setFlatBlock : chunkSection::setPaletteIndex);
|
bitsPerBlock == GLOBAL_PALETTE ? blockPalette::setIdAt : blockPalette::setPaletteIndexAt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +77,8 @@ public class ChunkSectionType1_13 extends Type<ChunkSection> {
|
|||||||
@Override
|
@Override
|
||||||
public void write(ByteBuf buffer, ChunkSection chunkSection) throws Exception {
|
public void write(ByteBuf buffer, ChunkSection chunkSection) throws Exception {
|
||||||
int bitsPerBlock = 4;
|
int bitsPerBlock = 4;
|
||||||
while (chunkSection.getPaletteSize() > 1 << bitsPerBlock) {
|
DataPalette blockPalette = chunkSection.palette(PaletteType.BLOCKS);
|
||||||
|
while (blockPalette.size() > 1 << bitsPerBlock) {
|
||||||
bitsPerBlock += 1;
|
bitsPerBlock += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,14 +90,14 @@ public class ChunkSectionType1_13 extends Type<ChunkSection> {
|
|||||||
|
|
||||||
// Write palette
|
// Write palette
|
||||||
if (bitsPerBlock != GLOBAL_PALETTE) {
|
if (bitsPerBlock != GLOBAL_PALETTE) {
|
||||||
Type.VAR_INT.writePrimitive(buffer, chunkSection.getPaletteSize());
|
Type.VAR_INT.writePrimitive(buffer, blockPalette.size());
|
||||||
for (int i = 0; i < chunkSection.getPaletteSize(); i++) {
|
for (int i = 0; i < blockPalette.size(); i++) {
|
||||||
Type.VAR_INT.writePrimitive(buffer, chunkSection.getPaletteEntry(i));
|
Type.VAR_INT.writePrimitive(buffer, blockPalette.idByIndex(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
long[] data = CompactArrayUtil.createCompactArray(bitsPerBlock, ChunkSection.SIZE,
|
long[] data = CompactArrayUtil.createCompactArray(bitsPerBlock, ChunkSection.SIZE,
|
||||||
bitsPerBlock == GLOBAL_PALETTE ? chunkSection::getFlatBlock : chunkSection::getPaletteIndex);
|
bitsPerBlock == GLOBAL_PALETTE ? blockPalette::idAt : blockPalette::paletteIndexAt);
|
||||||
Type.LONG_ARRAY_PRIMITIVE.write(buffer, data);
|
Type.LONG_ARRAY_PRIMITIVE.write(buffer, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,8 @@ package com.viaversion.viaversion.api.type.types.version;
|
|||||||
|
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSectionImpl;
|
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSectionImpl;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.util.CompactArrayUtil;
|
import com.viaversion.viaversion.util.CompactArrayUtil;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
@ -39,8 +41,6 @@ public class ChunkSectionType1_16 extends Type<ChunkSection> {
|
|||||||
public ChunkSection read(ByteBuf buffer) throws Exception {
|
public ChunkSection read(ByteBuf buffer) throws Exception {
|
||||||
// Reaad bits per block
|
// Reaad bits per block
|
||||||
int bitsPerBlock = buffer.readUnsignedByte();
|
int bitsPerBlock = buffer.readUnsignedByte();
|
||||||
int originalBitsPerBlock = bitsPerBlock;
|
|
||||||
|
|
||||||
if (bitsPerBlock > 8) {
|
if (bitsPerBlock > 8) {
|
||||||
bitsPerBlock = GLOBAL_PALETTE;
|
bitsPerBlock = GLOBAL_PALETTE;
|
||||||
} else if (bitsPerBlock < 4) {
|
} else if (bitsPerBlock < 4) {
|
||||||
@ -52,8 +52,9 @@ public class ChunkSectionType1_16 extends Type<ChunkSection> {
|
|||||||
if (bitsPerBlock != GLOBAL_PALETTE) {
|
if (bitsPerBlock != GLOBAL_PALETTE) {
|
||||||
int paletteLength = Type.VAR_INT.readPrimitive(buffer);
|
int paletteLength = Type.VAR_INT.readPrimitive(buffer);
|
||||||
chunkSection = new ChunkSectionImpl(false, paletteLength);
|
chunkSection = new ChunkSectionImpl(false, paletteLength);
|
||||||
|
DataPalette blockPalette = chunkSection.palette(PaletteType.BLOCKS);
|
||||||
for (int i = 0; i < paletteLength; i++) {
|
for (int i = 0; i < paletteLength; i++) {
|
||||||
chunkSection.addPaletteEntry(Type.VAR_INT.readPrimitive(buffer));
|
blockPalette.addId(Type.VAR_INT.readPrimitive(buffer));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
chunkSection = new ChunkSectionImpl(false);
|
chunkSection = new ChunkSectionImpl(false);
|
||||||
@ -65,8 +66,9 @@ public class ChunkSectionType1_16 extends Type<ChunkSection> {
|
|||||||
char valuesPerLong = (char) (64 / bitsPerBlock);
|
char valuesPerLong = (char) (64 / bitsPerBlock);
|
||||||
int expectedLength = (ChunkSection.SIZE + valuesPerLong - 1) / valuesPerLong;
|
int expectedLength = (ChunkSection.SIZE + valuesPerLong - 1) / valuesPerLong;
|
||||||
if (blockData.length == expectedLength) {
|
if (blockData.length == expectedLength) {
|
||||||
|
DataPalette blockPalette = chunkSection.palette(PaletteType.BLOCKS);
|
||||||
CompactArrayUtil.iterateCompactArrayWithPadding(bitsPerBlock, ChunkSection.SIZE, blockData,
|
CompactArrayUtil.iterateCompactArrayWithPadding(bitsPerBlock, ChunkSection.SIZE, blockData,
|
||||||
bitsPerBlock == GLOBAL_PALETTE ? chunkSection::setFlatBlock : chunkSection::setPaletteIndex);
|
bitsPerBlock == GLOBAL_PALETTE ? blockPalette::setIdAt : blockPalette::setPaletteIndexAt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +78,8 @@ public class ChunkSectionType1_16 extends Type<ChunkSection> {
|
|||||||
@Override
|
@Override
|
||||||
public void write(ByteBuf buffer, ChunkSection chunkSection) throws Exception {
|
public void write(ByteBuf buffer, ChunkSection chunkSection) throws Exception {
|
||||||
int bitsPerBlock = 4;
|
int bitsPerBlock = 4;
|
||||||
while (chunkSection.getPaletteSize() > 1 << bitsPerBlock) {
|
DataPalette blockPalette = chunkSection.palette(PaletteType.BLOCKS);
|
||||||
|
while (blockPalette.size() > 1 << bitsPerBlock) {
|
||||||
bitsPerBlock += 1;
|
bitsPerBlock += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,14 +91,14 @@ public class ChunkSectionType1_16 extends Type<ChunkSection> {
|
|||||||
|
|
||||||
// Write palette
|
// Write palette
|
||||||
if (bitsPerBlock != GLOBAL_PALETTE) {
|
if (bitsPerBlock != GLOBAL_PALETTE) {
|
||||||
Type.VAR_INT.writePrimitive(buffer, chunkSection.getPaletteSize());
|
Type.VAR_INT.writePrimitive(buffer, blockPalette.size());
|
||||||
for (int i = 0; i < chunkSection.getPaletteSize(); i++) {
|
for (int i = 0; i < blockPalette.size(); i++) {
|
||||||
Type.VAR_INT.writePrimitive(buffer, chunkSection.getPaletteEntry(i));
|
Type.VAR_INT.writePrimitive(buffer, blockPalette.idByIndex(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
long[] data = CompactArrayUtil.createCompactArrayWithPadding(bitsPerBlock, ChunkSection.SIZE,
|
long[] data = CompactArrayUtil.createCompactArrayWithPadding(bitsPerBlock, ChunkSection.SIZE,
|
||||||
bitsPerBlock == GLOBAL_PALETTE ? chunkSection::getFlatBlock : chunkSection::getPaletteIndex);
|
bitsPerBlock == GLOBAL_PALETTE ? blockPalette::idAt : blockPalette::paletteIndexAt);
|
||||||
Type.LONG_ARRAY_PRIMITIVE.write(buffer, data);
|
Type.LONG_ARRAY_PRIMITIVE.write(buffer, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,8 @@ package com.viaversion.viaversion.api.type.types.version;
|
|||||||
|
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSectionImpl;
|
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSectionImpl;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.util.CompactArrayUtil;
|
import com.viaversion.viaversion.util.CompactArrayUtil;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
@ -39,7 +41,6 @@ public class ChunkSectionType1_9 extends Type<ChunkSection> {
|
|||||||
public ChunkSection read(ByteBuf buffer) throws Exception {
|
public ChunkSection read(ByteBuf buffer) throws Exception {
|
||||||
// Reaad bits per block
|
// Reaad bits per block
|
||||||
int bitsPerBlock = buffer.readUnsignedByte();
|
int bitsPerBlock = buffer.readUnsignedByte();
|
||||||
int originalBitsPerBlock = bitsPerBlock;
|
|
||||||
if (bitsPerBlock < 4) {
|
if (bitsPerBlock < 4) {
|
||||||
bitsPerBlock = 4;
|
bitsPerBlock = 4;
|
||||||
}
|
}
|
||||||
@ -50,9 +51,10 @@ public class ChunkSectionType1_9 extends Type<ChunkSection> {
|
|||||||
// Read palette
|
// Read palette
|
||||||
int paletteLength = Type.VAR_INT.readPrimitive(buffer);
|
int paletteLength = Type.VAR_INT.readPrimitive(buffer);
|
||||||
ChunkSection chunkSection = bitsPerBlock != GLOBAL_PALETTE ? new ChunkSectionImpl(true, paletteLength) : new ChunkSectionImpl(true);
|
ChunkSection chunkSection = bitsPerBlock != GLOBAL_PALETTE ? new ChunkSectionImpl(true, paletteLength) : new ChunkSectionImpl(true);
|
||||||
|
DataPalette blockPalette = chunkSection.palette(PaletteType.BLOCKS);
|
||||||
for (int i = 0; i < paletteLength; i++) {
|
for (int i = 0; i < paletteLength; i++) {
|
||||||
if (bitsPerBlock != GLOBAL_PALETTE) {
|
if (bitsPerBlock != GLOBAL_PALETTE) {
|
||||||
chunkSection.addPaletteEntry(Type.VAR_INT.readPrimitive(buffer));
|
blockPalette.addId(Type.VAR_INT.readPrimitive(buffer));
|
||||||
} else {
|
} else {
|
||||||
Type.VAR_INT.readPrimitive(buffer);
|
Type.VAR_INT.readPrimitive(buffer);
|
||||||
}
|
}
|
||||||
@ -64,8 +66,7 @@ public class ChunkSectionType1_9 extends Type<ChunkSection> {
|
|||||||
int expectedLength = (int) Math.ceil(ChunkSection.SIZE * bitsPerBlock / 64.0);
|
int expectedLength = (int) Math.ceil(ChunkSection.SIZE * bitsPerBlock / 64.0);
|
||||||
if (blockData.length == expectedLength) {
|
if (blockData.length == expectedLength) {
|
||||||
CompactArrayUtil.iterateCompactArray(bitsPerBlock, ChunkSection.SIZE, blockData,
|
CompactArrayUtil.iterateCompactArray(bitsPerBlock, ChunkSection.SIZE, blockData,
|
||||||
bitsPerBlock == GLOBAL_PALETTE ? chunkSection::setFlatBlock
|
bitsPerBlock == GLOBAL_PALETTE ? blockPalette::setIdAt : blockPalette::setPaletteIndexAt);
|
||||||
: chunkSection::setPaletteIndex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +76,8 @@ public class ChunkSectionType1_9 extends Type<ChunkSection> {
|
|||||||
@Override
|
@Override
|
||||||
public void write(ByteBuf buffer, ChunkSection chunkSection) throws Exception {
|
public void write(ByteBuf buffer, ChunkSection chunkSection) throws Exception {
|
||||||
int bitsPerBlock = 4;
|
int bitsPerBlock = 4;
|
||||||
while (chunkSection.getPaletteSize() > 1 << bitsPerBlock) {
|
DataPalette blockPalette = chunkSection.palette(PaletteType.BLOCKS);
|
||||||
|
while (blockPalette.size() > 1 << bitsPerBlock) {
|
||||||
bitsPerBlock += 1;
|
bitsPerBlock += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,16 +89,16 @@ public class ChunkSectionType1_9 extends Type<ChunkSection> {
|
|||||||
|
|
||||||
// Write palette
|
// Write palette
|
||||||
if (bitsPerBlock != GLOBAL_PALETTE) {
|
if (bitsPerBlock != GLOBAL_PALETTE) {
|
||||||
Type.VAR_INT.writePrimitive(buffer, chunkSection.getPaletteSize());
|
Type.VAR_INT.writePrimitive(buffer, blockPalette.size());
|
||||||
for (int i = 0; i < chunkSection.getPaletteSize(); i++) {
|
for (int i = 0; i < blockPalette.size(); i++) {
|
||||||
Type.VAR_INT.writePrimitive(buffer, chunkSection.getPaletteEntry(i));
|
Type.VAR_INT.writePrimitive(buffer, blockPalette.idByIndex(i));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Type.VAR_INT.writePrimitive(buffer, 0);
|
Type.VAR_INT.writePrimitive(buffer, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
long[] data = CompactArrayUtil.createCompactArray(bitsPerBlock, ChunkSection.SIZE,
|
long[] data = CompactArrayUtil.createCompactArray(bitsPerBlock, ChunkSection.SIZE,
|
||||||
bitsPerBlock == GLOBAL_PALETTE ? chunkSection::getFlatBlock : chunkSection::getPaletteIndex);
|
bitsPerBlock == GLOBAL_PALETTE ? blockPalette::idAt : blockPalette::paletteIndexAt);
|
||||||
Type.LONG_ARRAY_PRIMITIVE.write(buffer, data);
|
Type.LONG_ARRAY_PRIMITIVE.write(buffer, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public class BlockListener extends ViaBukkitListener {
|
|||||||
if (isOnPipe(e.getPlayer())) {
|
if (isOnPipe(e.getPlayer())) {
|
||||||
Block b = e.getBlockPlaced();
|
Block b = e.getBlockPlaced();
|
||||||
EntityTracker1_9 tracker = getUserConnection(e.getPlayer()).getEntityTracker(Protocol1_9To1_8.class);
|
EntityTracker1_9 tracker = getUserConnection(e.getPlayer()).getEntityTracker(Protocol1_9To1_8.class);
|
||||||
tracker.addBlockInteraction(new Position(b.getX(), (short) b.getY(), b.getZ()));
|
tracker.addBlockInteraction(new Position(b.getX(), b.getY(), b.getZ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ public class BukkitInventoryUpdateTask implements Runnable {
|
|||||||
public BukkitInventoryUpdateTask(BukkitInventoryQuickMoveProvider provider, UUID uuid) {
|
public BukkitInventoryUpdateTask(BukkitInventoryQuickMoveProvider provider, UUID uuid) {
|
||||||
this.provider = provider;
|
this.provider = provider;
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
this.items = Collections.synchronizedList(new ArrayList<ItemTransaction>());
|
this.items = Collections.synchronizedList(new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addItem(short windowId, short slotId, short actionId) {
|
public void addItem(short windowId, short slotId, short actionId) {
|
||||||
|
@ -80,9 +80,7 @@ public class BungeeVersionProvider extends BaseVersionProvider {
|
|||||||
try {
|
try {
|
||||||
list = ReflectionUtil.getStatic(ref, "SUPPORTED_VERSION_IDS", List.class);
|
list = ReflectionUtil.getStatic(ref, "SUPPORTED_VERSION_IDS", List.class);
|
||||||
return list.get(0);
|
return list.get(0);
|
||||||
} catch (NoSuchFieldException e) {
|
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
// Fallback
|
// Fallback
|
||||||
|
@ -18,9 +18,6 @@
|
|||||||
package com.viaversion.viaversion.dump;
|
package com.viaversion.viaversion.dump;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class DumpTemplate {
|
public class DumpTemplate {
|
||||||
|
@ -21,6 +21,7 @@ import com.viaversion.viaversion.api.Via;
|
|||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
@ -201,7 +202,7 @@ public class Protocol1_10To1_9_3_4 extends AbstractProtocol<ClientboundPackets1_
|
|||||||
int replacementId = Via.getConfig().getPistonReplacementId();
|
int replacementId = Via.getConfig().getPistonReplacementId();
|
||||||
for (ChunkSection section : chunk.getSections()) {
|
for (ChunkSection section : chunk.getSections()) {
|
||||||
if (section == null) continue;
|
if (section == null) continue;
|
||||||
section.replacePaletteEntry(36, replacementId);
|
section.palette(PaletteType.BLOCKS).replaceId(36, replacementId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ package com.viaversion.viaversion.protocols.protocol1_13_1to1_13.packets;
|
|||||||
|
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
@ -44,9 +46,14 @@ public class WorldPackets {
|
|||||||
Chunk chunk = wrapper.passthrough(new Chunk1_13Type(clientWorld));
|
Chunk chunk = wrapper.passthrough(new Chunk1_13Type(clientWorld));
|
||||||
|
|
||||||
for (ChunkSection section : chunk.getSections()) {
|
for (ChunkSection section : chunk.getSections()) {
|
||||||
if (section == null) continue;
|
if (section == null) {
|
||||||
for (int i = 0; i < section.getPaletteSize(); i++) {
|
continue;
|
||||||
section.setPaletteEntry(i, protocol.getMappingData().getNewBlockStateId(section.getPaletteEntry(i)));
|
}
|
||||||
|
|
||||||
|
DataPalette palette = section.palette(PaletteType.BLOCKS);
|
||||||
|
for (int i = 0; i < palette.size(); i++) {
|
||||||
|
int mappedBlockStateId = protocol.getMappingData().getNewBlockStateId(palette.idByIndex(i));
|
||||||
|
palette.setIdByIndex(i, mappedBlockStateId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,17 +17,17 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.protocols.protocol1_13_2to1_13_1.packets;
|
package com.viaversion.viaversion.protocols.protocol1_13_2to1_13_1.packets;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_13_2to1_13_1.Protocol1_13_2To1_13_1;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||||
|
|
||||||
public class InventoryPackets {
|
public class InventoryPackets {
|
||||||
|
|
||||||
public static void register(Protocol protocol) {
|
public static void register(Protocol1_13_2To1_13_1 protocol) {
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.SET_SLOT, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.SET_SLOT, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
|
@ -17,16 +17,16 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.protocols.protocol1_13_2to1_13_1.packets;
|
package com.viaversion.viaversion.protocols.protocol1_13_2to1_13_1.packets;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_13_2to1_13_1.Protocol1_13_2To1_13_1;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||||
|
|
||||||
public class WorldPackets {
|
public class WorldPackets {
|
||||||
|
|
||||||
public static void register(Protocol protocol) {
|
public static void register(Protocol1_13_2To1_13_1 protocol) {
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_PARTICLE, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_PARTICLE, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
|
@ -21,6 +21,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
|||||||
import com.viaversion.viaversion.api.minecraft.BlockFace;
|
import com.viaversion.viaversion.api.minecraft.BlockFace;
|
||||||
import com.viaversion.viaversion.api.minecraft.Position;
|
import com.viaversion.viaversion.api.minecraft.Position;
|
||||||
|
|
||||||
|
import java.util.EnumMap;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@ -33,7 +34,7 @@ public abstract class AbstractStempConnectionHandler extends ConnectionHandler {
|
|||||||
private final int baseStateId;
|
private final int baseStateId;
|
||||||
private final Set<Integer> blockId = new HashSet<>();
|
private final Set<Integer> blockId = new HashSet<>();
|
||||||
|
|
||||||
private final Map<BlockFace, Integer> stemps = new HashMap<>();
|
private final Map<BlockFace, Integer> stemps = new EnumMap<>(BlockFace.class);
|
||||||
|
|
||||||
protected AbstractStempConnectionHandler(String baseStateId) {
|
protected AbstractStempConnectionHandler(String baseStateId) {
|
||||||
this.baseStateId = ConnectionData.getId(baseStateId);
|
this.baseStateId = ConnectionData.getId(baseStateId);
|
||||||
|
@ -218,7 +218,7 @@ public class ConnectionData {
|
|||||||
blockConnectionData = new Int2ObjectOpenHashMap<>(1146, .99F);
|
blockConnectionData = new Int2ObjectOpenHashMap<>(1146, .99F);
|
||||||
JsonObject mappingBlockConnections = MappingDataLoader.loadData("blockConnections.json");
|
JsonObject mappingBlockConnections = MappingDataLoader.loadData("blockConnections.json");
|
||||||
for (Entry<String, JsonElement> entry : mappingBlockConnections.entrySet()) {
|
for (Entry<String, JsonElement> entry : mappingBlockConnections.entrySet()) {
|
||||||
int id = keyToId.get(entry.getKey());
|
int id = keyToId.getInt(entry.getKey());
|
||||||
BlockData blockData = new BlockData();
|
BlockData blockData = new BlockData();
|
||||||
for (Entry<String, JsonElement> type : entry.getValue().getAsJsonObject().entrySet()) {
|
for (Entry<String, JsonElement> type : entry.getValue().getAsJsonObject().entrySet()) {
|
||||||
String name = type.getKey();
|
String name = type.getKey();
|
||||||
@ -242,7 +242,7 @@ public class ConnectionData {
|
|||||||
JsonObject blockData = MappingDataLoader.loadData("blockData.json");
|
JsonObject blockData = MappingDataLoader.loadData("blockData.json");
|
||||||
JsonArray occluding = blockData.getAsJsonArray("occluding");
|
JsonArray occluding = blockData.getAsJsonArray("occluding");
|
||||||
for (JsonElement jsonElement : occluding) {
|
for (JsonElement jsonElement : occluding) {
|
||||||
occludingStates.add(keyToId.get(jsonElement.getAsString()).intValue());
|
occludingStates.add(keyToId.getInt(jsonElement.getAsString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ConnectorInitAction> initActions = new ArrayList<>();
|
List<ConnectorInitAction> initActions = new ArrayList<>();
|
||||||
|
@ -35,6 +35,7 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
|||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.BlockIdData;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.BlockIdData;
|
||||||
@ -113,7 +114,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
|
|||||||
|
|
||||||
// Reset the packet
|
// Reset the packet
|
||||||
wrapper.clearPacket();
|
wrapper.clearPacket();
|
||||||
wrapper.setId(0x4C);
|
wrapper.setPacketType(ClientboundPackets1_13.SOUND);
|
||||||
|
|
||||||
byte flags = 0;
|
byte flags = 0;
|
||||||
wrapper.write(Type.BYTE, flags); // Placeholder
|
wrapper.write(Type.BYTE, flags); // Placeholder
|
||||||
|
@ -76,7 +76,7 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void register(Protocol protocol) {
|
public static void register(Protocol1_13To1_12_2 protocol) {
|
||||||
// Outgoing packets
|
// Outgoing packets
|
||||||
protocol.registerClientbound(ClientboundPackets1_12_1.SPAWN_PAINTING, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_12_1.SPAWN_PAINTING, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
@ -433,7 +433,7 @@ public class WorldPackets {
|
|||||||
replacementData.setReplacement(newId);
|
replacementData.setReplacement(newId);
|
||||||
}
|
}
|
||||||
|
|
||||||
chunk.getSections()[y >> 4].setFlatBlock(x & 0xF, y & 0xF, z & 0xF, newId);
|
chunk.getSections()[y >> 4].palette(PaletteType.BLOCKS).setIdAt(x & 0xF, y & 0xF, z & 0xF, newId);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Tag idTag = tag.get("id");
|
final Tag idTag = tag.get("id");
|
||||||
|
@ -19,23 +19,21 @@ package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.storage;
|
|||||||
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||||
import com.viaversion.viaversion.api.minecraft.Position;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.NibbleArray;
|
import com.viaversion.viaversion.api.minecraft.chunks.NibbleArray;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.packets.WorldPackets;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.packets.WorldPackets;
|
||||||
import com.viaversion.viaversion.util.Pair;
|
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class BlockConnectionStorage implements StorableObject {
|
public class BlockConnectionStorage implements StorableObject {
|
||||||
private static final short[] REVERSE_BLOCK_MAPPINGS = new short[8582];
|
private static final short[] REVERSE_BLOCK_MAPPINGS = new short[8582];
|
||||||
private static Constructor<?> fastUtilLongObjectHashMap;
|
private static Constructor<?> fastUtilLongObjectHashMap;
|
||||||
|
|
||||||
private final Map<Long, Pair<byte[], NibbleArray>> blockStorage = createLongObjectMap();
|
private final Map<Long, SectionData> blockStorage = createLongObjectMap();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
@ -61,10 +59,10 @@ public class BlockConnectionStorage implements StorableObject {
|
|||||||
|
|
||||||
blockState = mapping;
|
blockState = mapping;
|
||||||
long pair = getChunkSectionIndex(x, y, z);
|
long pair = getChunkSectionIndex(x, y, z);
|
||||||
Pair<byte[], NibbleArray> map = getChunkSection(pair, (blockState & 0xF) != 0);
|
SectionData map = getChunkSection(pair, (blockState & 0xF) != 0);
|
||||||
int blockIndex = encodeBlockPos(x, y, z);
|
int blockIndex = encodeBlockPos(x, y, z);
|
||||||
map.key()[blockIndex] = (byte) (blockState >> 4);
|
map.blockIds()[blockIndex] = (byte) (blockState >> 4);
|
||||||
NibbleArray nibbleArray = map.value();
|
NibbleArray nibbleArray = map.nibbleArray();
|
||||||
if (nibbleArray != null) {
|
if (nibbleArray != null) {
|
||||||
nibbleArray.set(blockIndex, blockState);
|
nibbleArray.set(blockIndex, blockState);
|
||||||
}
|
}
|
||||||
@ -72,22 +70,22 @@ public class BlockConnectionStorage implements StorableObject {
|
|||||||
|
|
||||||
public int get(int x, int y, int z) {
|
public int get(int x, int y, int z) {
|
||||||
long pair = getChunkSectionIndex(x, y, z);
|
long pair = getChunkSectionIndex(x, y, z);
|
||||||
Pair<byte[], NibbleArray> map = blockStorage.get(pair);
|
SectionData map = blockStorage.get(pair);
|
||||||
if (map == null) return 0;
|
if (map == null) return 0;
|
||||||
short blockPosition = encodeBlockPos(x, y, z);
|
short blockPosition = encodeBlockPos(x, y, z);
|
||||||
NibbleArray nibbleArray = map.value();
|
NibbleArray nibbleArray = map.nibbleArray();
|
||||||
return WorldPackets.toNewId(
|
return WorldPackets.toNewId(
|
||||||
((map.key()[blockPosition] & 0xFF) << 4)
|
((map.blockIds()[blockPosition] & 0xFF) << 4)
|
||||||
| (nibbleArray == null ? 0 : nibbleArray.get(blockPosition))
|
| (nibbleArray == null ? 0 : nibbleArray.get(blockPosition))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(int x, int y, int z) {
|
public void remove(int x, int y, int z) {
|
||||||
long pair = getChunkSectionIndex(x, y, z);
|
long pair = getChunkSectionIndex(x, y, z);
|
||||||
Pair<byte[], NibbleArray> map = blockStorage.get(pair);
|
SectionData map = blockStorage.get(pair);
|
||||||
if (map == null) return;
|
if (map == null) return;
|
||||||
int blockIndex = encodeBlockPos(x, y, z);
|
int blockIndex = encodeBlockPos(x, y, z);
|
||||||
NibbleArray nibbleArray = map.value();
|
NibbleArray nibbleArray = map.nibbleArray();
|
||||||
if (nibbleArray != null) {
|
if (nibbleArray != null) {
|
||||||
nibbleArray.set(blockIndex, 0);
|
nibbleArray.set(blockIndex, 0);
|
||||||
boolean allZero = true;
|
boolean allZero = true;
|
||||||
@ -97,10 +95,10 @@ public class BlockConnectionStorage implements StorableObject {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (allZero) map.setValue(null);
|
if (allZero) map.setNibbleArray(null);
|
||||||
}
|
}
|
||||||
map.key()[blockIndex] = 0;
|
map.blockIds()[blockIndex] = 0;
|
||||||
for (short entry : map.key()) {
|
for (short entry : map.blockIds()) {
|
||||||
if (entry != 0) return;
|
if (entry != 0) return;
|
||||||
}
|
}
|
||||||
blockStorage.remove(pair);
|
blockStorage.remove(pair);
|
||||||
@ -111,7 +109,7 @@ public class BlockConnectionStorage implements StorableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void unloadChunk(int x, int z) {
|
public void unloadChunk(int x, int z) {
|
||||||
for (int y = 0; y < 16; y ++) {
|
for (int y = 0; y < 16; y++) {
|
||||||
unloadSection(x, y, z);
|
unloadSection(x, y, z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,14 +118,14 @@ public class BlockConnectionStorage implements StorableObject {
|
|||||||
blockStorage.remove(getChunkSectionIndex(x << 4, y << 4, z << 4));
|
blockStorage.remove(getChunkSectionIndex(x << 4, y << 4, z << 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Pair<byte[], NibbleArray> getChunkSection(long index, boolean requireNibbleArray) {
|
private SectionData getChunkSection(long index, boolean requireNibbleArray) {
|
||||||
Pair<byte[], NibbleArray> map = blockStorage.get(index);
|
SectionData map = blockStorage.get(index);
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
map = new Pair<>(new byte[4096], null);
|
map = new SectionData(new byte[4096]);
|
||||||
blockStorage.put(index, map);
|
blockStorage.put(index, map);
|
||||||
}
|
}
|
||||||
if (map.value() == null && requireNibbleArray) {
|
if (map.nibbleArray() == null && requireNibbleArray) {
|
||||||
map.setValue(new NibbleArray(4096));
|
map.setNibbleArray(new NibbleArray(4096));
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
@ -136,18 +134,10 @@ public class BlockConnectionStorage implements StorableObject {
|
|||||||
return (((x >> 4) & 0x3FFFFFFL) << 38) | (((y >> 4) & 0xFFFL) << 26) | ((z >> 4) & 0x3FFFFFFL);
|
return (((x >> 4) & 0x3FFFFFFL) << 38) | (((y >> 4) & 0xFFFL) << 26) | ((z >> 4) & 0x3FFFFFFL);
|
||||||
}
|
}
|
||||||
|
|
||||||
private long getChunkSectionIndex(Position position) {
|
|
||||||
return getChunkSectionIndex(position.x(), position.y(), position.z());
|
|
||||||
}
|
|
||||||
|
|
||||||
private short encodeBlockPos(int x, int y, int z) {
|
private short encodeBlockPos(int x, int y, int z) {
|
||||||
return (short) (((y & 0xF) << 8) | ((x & 0xF) << 4) | (z & 0xF));
|
return (short) (((y & 0xF) << 8) | ((x & 0xF) << 4) | (z & 0xF));
|
||||||
}
|
}
|
||||||
|
|
||||||
private short encodeBlockPos(Position pos) {
|
|
||||||
return encodeBlockPos(pos.x(), pos.y(), pos.z());
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> Map<Long, T> createLongObjectMap() {
|
private <T> Map<Long, T> createLongObjectMap() {
|
||||||
if (fastUtilLongObjectHashMap != null) {
|
if (fastUtilLongObjectHashMap != null) {
|
||||||
try {
|
try {
|
||||||
@ -158,4 +148,25 @@ public class BlockConnectionStorage implements StorableObject {
|
|||||||
}
|
}
|
||||||
return new HashMap<>();
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private static final class SectionData {
|
||||||
|
private final byte[] blockIds;
|
||||||
|
private NibbleArray nibbleArray;
|
||||||
|
|
||||||
|
private SectionData(byte[] blockIds) {
|
||||||
|
this.blockIds = blockIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] blockIds() {
|
||||||
|
return blockIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable NibbleArray nibbleArray() {
|
||||||
|
return nibbleArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNibbleArray(@Nullable NibbleArray nibbleArray) {
|
||||||
|
this.nibbleArray = nibbleArray;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -24,7 +24,6 @@ import it.unimi.dsi.fastutil.ints.IntSet;
|
|||||||
import space.vectrix.flare.SyncMap;
|
import space.vectrix.flare.SyncMap;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
// TODO Fix memory leak lolz (only a smol one tho)
|
// TODO Fix memory leak lolz (only a smol one tho)
|
||||||
public class BlockStorage implements StorableObject {
|
public class BlockStorage implements StorableObject {
|
||||||
|
@ -35,6 +35,7 @@ import com.viaversion.viaversion.api.type.Type;
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.RecipeRewriter1_13_2;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.RecipeRewriter1_13_2;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.storage.EntityTracker1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.storage.EntityTracker1_14;
|
||||||
@ -81,13 +82,13 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_13, Serve
|
|||||||
Short slots = wrapper.read(Type.UNSIGNED_BYTE);
|
Short slots = wrapper.read(Type.UNSIGNED_BYTE);
|
||||||
|
|
||||||
if (type.equals("EntityHorse")) {
|
if (type.equals("EntityHorse")) {
|
||||||
wrapper.setId(0x1F);
|
wrapper.setPacketType(ClientboundPackets1_14.OPEN_HORSE_WINDOW);
|
||||||
int entityId = wrapper.read(Type.INT);
|
int entityId = wrapper.read(Type.INT);
|
||||||
wrapper.write(Type.UNSIGNED_BYTE, windowId);
|
wrapper.write(Type.UNSIGNED_BYTE, windowId);
|
||||||
wrapper.write(Type.VAR_INT, slots.intValue());
|
wrapper.write(Type.VAR_INT, slots.intValue());
|
||||||
wrapper.write(Type.INT, entityId);
|
wrapper.write(Type.INT, entityId);
|
||||||
} else {
|
} else {
|
||||||
wrapper.setId(0x2E);
|
wrapper.setPacketType(ClientboundPackets1_14.OPEN_WINDOW);
|
||||||
wrapper.write(Type.VAR_INT, windowId.intValue());
|
wrapper.write(Type.VAR_INT, windowId.intValue());
|
||||||
|
|
||||||
int typeId = -1;
|
int typeId = -1;
|
||||||
@ -156,7 +157,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_13, Serve
|
|||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
String channel = wrapper.get(Type.STRING, 0);
|
String channel = wrapper.get(Type.STRING, 0);
|
||||||
if (channel.equals("minecraft:trader_list") || channel.equals("trader_list")) {
|
if (channel.equals("minecraft:trader_list") || channel.equals("trader_list")) {
|
||||||
wrapper.setId(0x27);
|
wrapper.setPacketType(ClientboundPackets1_14.TRADE_LIST);
|
||||||
wrapper.resetReader();
|
wrapper.resetReader();
|
||||||
wrapper.read(Type.STRING); // Remove channel
|
wrapper.read(Type.STRING); // Remove channel
|
||||||
|
|
||||||
@ -192,7 +193,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_13, Serve
|
|||||||
} else if (channel.equals("minecraft:book_open") || channel.equals("book_open")) {
|
} else if (channel.equals("minecraft:book_open") || channel.equals("book_open")) {
|
||||||
int hand = wrapper.read(Type.VAR_INT);
|
int hand = wrapper.read(Type.VAR_INT);
|
||||||
wrapper.clearPacket();
|
wrapper.clearPacket();
|
||||||
wrapper.setId(0x2D);
|
wrapper.setPacketType(ClientboundPackets1_14.OPEN_BOOK);
|
||||||
wrapper.write(Type.VAR_INT, hand);
|
wrapper.write(Type.VAR_INT, hand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,19 +24,18 @@ import com.github.steveice10.opennbt.tag.builtin.Tag;
|
|||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.minecraft.Position;
|
import com.viaversion.viaversion.api.minecraft.Position;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
public class PlayerPackets {
|
public class PlayerPackets {
|
||||||
|
|
||||||
public static void register(Protocol protocol) {
|
public static void register(Protocol1_14To1_13_2 protocol) {
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.OPEN_SIGN_EDITOR, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.OPEN_SIGN_EDITOR, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
|
@ -110,7 +110,7 @@ public class EntityPackets {
|
|||||||
metadataRewriter.registerRemoveEntities(ClientboundPackets1_14.DESTROY_ENTITIES);
|
metadataRewriter.registerRemoveEntities(ClientboundPackets1_14.DESTROY_ENTITIES);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void sendMetadataPacket(PacketWrapper wrapper, int entityId, EntityRewriter rewriter) throws Exception {
|
private static void sendMetadataPacket(PacketWrapper wrapper, int entityId, EntityRewriter<?, ?> rewriter) throws Exception {
|
||||||
// Meta is no longer included in the spawn packets, but sent separately
|
// Meta is no longer included in the spawn packets, but sent separately
|
||||||
List<Metadata> metadata = wrapper.read(Types1_14.METADATA_LIST);
|
List<Metadata> metadata = wrapper.read(Types1_14.METADATA_LIST);
|
||||||
if (metadata.isEmpty()) {
|
if (metadata.isEmpty()) {
|
||||||
|
@ -19,6 +19,8 @@ package com.viaversion.viaversion.protocols.protocol1_15to1_14_4.packets;
|
|||||||
|
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
@ -72,11 +74,14 @@ public class WorldPackets {
|
|||||||
|
|
||||||
for (int s = 0; s < chunk.getSections().length; s++) {
|
for (int s = 0; s < chunk.getSections().length; s++) {
|
||||||
ChunkSection section = chunk.getSections()[s];
|
ChunkSection section = chunk.getSections()[s];
|
||||||
if (section == null) continue;
|
if (section == null) {
|
||||||
for (int i = 0; i < section.getPaletteSize(); i++) {
|
continue;
|
||||||
int old = section.getPaletteEntry(i);
|
}
|
||||||
int newId = protocol.getMappingData().getNewBlockStateId(old);
|
|
||||||
section.setPaletteEntry(i, newId);
|
DataPalette palette = section.palette(PaletteType.BLOCKS);
|
||||||
|
for (int i = 0; i < palette.size(); i++) {
|
||||||
|
int mappedBlockStateId = protocol.getMappingData().getNewBlockStateId(palette.idByIndex(i));
|
||||||
|
palette.setIdByIndex(i, mappedBlockStateId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,8 @@ import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
|||||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord1_16_2;
|
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord1_16_2;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
@ -53,10 +55,14 @@ public class WorldPackets {
|
|||||||
|
|
||||||
for (int s = 0; s < chunk.getSections().length; s++) {
|
for (int s = 0; s < chunk.getSections().length; s++) {
|
||||||
ChunkSection section = chunk.getSections()[s];
|
ChunkSection section = chunk.getSections()[s];
|
||||||
if (section == null) continue;
|
if (section == null) {
|
||||||
for (int i = 0; i < section.getPaletteSize(); i++) {
|
continue;
|
||||||
int old = section.getPaletteEntry(i);
|
}
|
||||||
section.setPaletteEntry(i, protocol.getMappingData().getNewBlockStateId(old));
|
|
||||||
|
DataPalette palette = section.palette(PaletteType.BLOCKS);
|
||||||
|
for (int i = 0; i < palette.size(); i++) {
|
||||||
|
int mappedBlockStateId = protocol.getMappingData().getNewBlockStateId(palette.idByIndex(i));
|
||||||
|
palette.setIdByIndex(i, mappedBlockStateId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -26,6 +26,8 @@ import com.google.gson.JsonElement;
|
|||||||
import com.viaversion.viaversion.api.minecraft.Position;
|
import com.viaversion.viaversion.api.minecraft.Position;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.UUIDIntArrayType;
|
import com.viaversion.viaversion.api.type.types.UUIDIntArrayType;
|
||||||
@ -69,10 +71,14 @@ public class WorldPackets {
|
|||||||
|
|
||||||
for (int s = 0; s < chunk.getSections().length; s++) {
|
for (int s = 0; s < chunk.getSections().length; s++) {
|
||||||
ChunkSection section = chunk.getSections()[s];
|
ChunkSection section = chunk.getSections()[s];
|
||||||
if (section == null) continue;
|
if (section == null) {
|
||||||
for (int i = 0; i < section.getPaletteSize(); i++) {
|
continue;
|
||||||
int old = section.getPaletteEntry(i);
|
}
|
||||||
section.setPaletteEntry(i, protocol.getMappingData().getNewBlockStateId(old));
|
|
||||||
|
DataPalette palette = section.palette(PaletteType.BLOCKS);
|
||||||
|
for (int i = 0; i < palette.size(); i++) {
|
||||||
|
int mappedBlockStateId = protocol.getMappingData().getNewBlockStateId(palette.idByIndex(i));
|
||||||
|
palette.setIdByIndex(i, mappedBlockStateId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol<ClientboundPack
|
|||||||
throw new IllegalArgumentException("Invalid title type received: " + type);
|
throw new IllegalArgumentException("Invalid title type received: " + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
wrapper.setId(packetType.getId());
|
wrapper.setPacketType(packetType);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -155,7 +155,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_16_2
|
|||||||
throw new IllegalArgumentException("Invalid combat type received: " + type);
|
throw new IllegalArgumentException("Invalid combat type received: " + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
wrapper.setId(packetType.getId());
|
wrapper.setPacketType(packetType);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -21,6 +21,8 @@ import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
|||||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord1_16_2;
|
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord1_16_2;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
@ -76,7 +78,7 @@ public final class WorldPackets {
|
|||||||
throw new IllegalArgumentException("Invalid world border type received: " + type);
|
throw new IllegalArgumentException("Invalid world border type received: " + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
wrapper.setId(packetType.getId());
|
wrapper.setPacketType(packetType);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -148,10 +150,14 @@ public final class WorldPackets {
|
|||||||
|
|
||||||
for (int s = 0; s < chunk.getSections().length; s++) {
|
for (int s = 0; s < chunk.getSections().length; s++) {
|
||||||
ChunkSection section = chunk.getSections()[s];
|
ChunkSection section = chunk.getSections()[s];
|
||||||
if (section == null) continue;
|
if (section == null) {
|
||||||
for (int i = 0; i < section.getPaletteSize(); i++) {
|
continue;
|
||||||
int old = section.getPaletteEntry(i);
|
}
|
||||||
section.setPaletteEntry(i, protocol.getMappingData().getNewBlockStateId(old));
|
|
||||||
|
DataPalette palette = section.palette(PaletteType.BLOCKS);
|
||||||
|
for (int i = 0; i < palette.size(); i++) {
|
||||||
|
int mappedBlockStateId = protocol.getMappingData().getNewBlockStateId(palette.idByIndex(i));
|
||||||
|
palette.setIdByIndex(i, mappedBlockStateId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -176,11 +182,12 @@ public final class WorldPackets {
|
|||||||
|
|
||||||
//TODO this can be optimized
|
//TODO this can be optimized
|
||||||
BlockChangeRecord[] blockChangeRecords = new BlockChangeRecord[4096];
|
BlockChangeRecord[] blockChangeRecords = new BlockChangeRecord[4096];
|
||||||
|
DataPalette palette = section.palette(PaletteType.BLOCKS);
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for (int x = 0; x < 16; x++) {
|
for (int x = 0; x < 16; x++) {
|
||||||
for (int y = 0; y < 16; y++) {
|
for (int y = 0; y < 16; y++) {
|
||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; z++) {
|
||||||
int blockStateId = Protocol1_17To1_16_4.MAPPINGS.getNewBlockStateId(section.getFlatBlock(x, y, z));
|
int blockStateId = Protocol1_17To1_16_4.MAPPINGS.getNewBlockStateId(palette.idAt(x, y, z));
|
||||||
blockChangeRecords[j++] = new BlockChangeRecord1_16_2(x, y, z, blockStateId);
|
blockChangeRecords[j++] = new BlockChangeRecord1_16_2(x, y, z, blockStateId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ package com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types;
|
|||||||
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.viaversion.viaversion.api.Via;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
|
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk1_18;
|
import com.viaversion.viaversion.api.minecraft.chunks.Chunk1_18;
|
||||||
|
@ -30,7 +30,6 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
|||||||
import com.viaversion.viaversion.api.minecraft.ProfileKey;
|
import com.viaversion.viaversion.api.minecraft.ProfileKey;
|
||||||
import com.viaversion.viaversion.api.minecraft.nbt.BinaryTagIO;
|
import com.viaversion.viaversion.api.minecraft.nbt.BinaryTagIO;
|
||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
|
||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
|
@ -61,7 +61,7 @@ public class Protocol1_9_1_2To1_9_3_4 extends AbstractProtocol<ClientboundPacket
|
|||||||
|
|
||||||
wrapper.clearPacket(); //Clear the packet
|
wrapper.clearPacket(); //Clear the packet
|
||||||
|
|
||||||
wrapper.setId(ClientboundPackets1_9.UPDATE_SIGN.ordinal()); //Update sign packet
|
wrapper.setPacketType(ClientboundPackets1_9.UPDATE_SIGN);
|
||||||
wrapper.write(Type.POSITION, position); // Position
|
wrapper.write(Type.POSITION, position); // Position
|
||||||
for (int i = 1; i < 5; i++) {
|
for (int i = 1; i < 5; i++) {
|
||||||
// Should technically be written as COMPONENT, but left as String for simplification/to remove redundant wrapping for VR
|
// Should technically be written as COMPONENT, but left as String for simplification/to remove redundant wrapping for VR
|
||||||
|
@ -74,7 +74,7 @@ public class Protocol1_9_3To1_9_1_2 extends AbstractProtocol<ClientboundPackets1
|
|||||||
wrapper.clearInputBuffer();
|
wrapper.clearInputBuffer();
|
||||||
|
|
||||||
//write data
|
//write data
|
||||||
wrapper.setId(0x09); //Update block entity
|
wrapper.setPacketType(ClientboundPackets1_9_3.BLOCK_ENTITY_DATA);
|
||||||
wrapper.write(Type.POSITION, position); //Block location
|
wrapper.write(Type.POSITION, position); //Block location
|
||||||
wrapper.write(Type.UNSIGNED_BYTE, (short) 9); //Action type (9 update sign)
|
wrapper.write(Type.UNSIGNED_BYTE, (short) 9); //Action type (9 update sign)
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ public class Chunk1_9_1_2Type extends PartialType<Chunk, ClientWorld> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new BaseChunk(chunkX, chunkZ, groundUp, false, primaryBitmask, sections, biomeData, new ArrayList<CompoundTag>());
|
return new BaseChunk(chunkX, chunkZ, groundUp, false, primaryBitmask, sections, biomeData, new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -28,15 +28,28 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
|||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
||||||
import com.viaversion.viaversion.api.rewriter.EntityRewriter;
|
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
|
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8;
|
import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.metadata.MetadataRewriter1_9To1_8;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.metadata.MetadataRewriter1_9To1_8;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.packets.*;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.packets.EntityPackets;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.*;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.packets.InventoryPackets;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.*;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.packets.PlayerPackets;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.packets.SpawnPackets;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.packets.WorldPackets;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.BossBarProvider;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.CommandBlockProvider;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.CompressionProvider;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.EntityIdProvider;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.HandItemProvider;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MainHandProvider;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.ClientChunks;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.CommandBlockStorage;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracker1_9;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.InventoryTracker;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.MovementTracker;
|
||||||
import com.viaversion.viaversion.util.GsonUtil;
|
import com.viaversion.viaversion.util.GsonUtil;
|
||||||
|
|
||||||
public class Protocol1_9To1_8 extends AbstractProtocol<ClientboundPackets1_8, ClientboundPackets1_9, ServerboundPackets1_8, ServerboundPackets1_9> {
|
public class Protocol1_9To1_8 extends AbstractProtocol<ClientboundPackets1_8, ClientboundPackets1_9, ServerboundPackets1_8, ServerboundPackets1_9> {
|
||||||
@ -46,7 +59,7 @@ public class Protocol1_9To1_8 extends AbstractProtocol<ClientboundPackets1_8, Cl
|
|||||||
return fixJson(line);
|
return fixJson(line);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private final EntityRewriter metadataRewriter = new MetadataRewriter1_9To1_8(this);
|
private final MetadataRewriter1_9To1_8 metadataRewriter = new MetadataRewriter1_9To1_8(this);
|
||||||
|
|
||||||
public Protocol1_9To1_8() {
|
public Protocol1_9To1_8() {
|
||||||
super(ClientboundPackets1_8.class, ClientboundPackets1_9.class, ServerboundPackets1_8.class, ServerboundPackets1_9.class);
|
super(ClientboundPackets1_8.class, ClientboundPackets1_9.class, ServerboundPackets1_8.class, ServerboundPackets1_9.class);
|
||||||
@ -152,7 +165,7 @@ public class Protocol1_9To1_8 extends AbstractProtocol<ClientboundPackets1_8, Cl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityRewriter getEntityRewriter() {
|
public MetadataRewriter1_9To1_8 getEntityRewriter() {
|
||||||
return metadataRewriter;
|
return metadataRewriter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -316,7 +316,7 @@ public class EntityPackets {
|
|||||||
// == Why 15.9? ==
|
// == Why 15.9? ==
|
||||||
// Higher values hides the cooldown but it bugs visual animation on hand
|
// Higher values hides the cooldown but it bugs visual animation on hand
|
||||||
// when removing item from hand with inventory gui
|
// when removing item from hand with inventory gui
|
||||||
properties.put("generic.attackSpeed", new Pair<Double, List<Triple<UUID, Double, Byte>>>(15.9, ImmutableList.of( // Neutralize modifiers
|
properties.put("generic.attackSpeed", new Pair<>(15.9, ImmutableList.of( // Neutralize modifiers
|
||||||
new Triple<>(UUID.fromString("FA233E1C-4180-4865-B01B-BCCE9785ACA3"), 0.0, (byte) 0), // Tool and weapon modifier
|
new Triple<>(UUID.fromString("FA233E1C-4180-4865-B01B-BCCE9785ACA3"), 0.0, (byte) 0), // Tool and weapon modifier
|
||||||
new Triple<>(UUID.fromString("AF8B6E3F-3328-4C0A-AA36-5BA2BB9DBEF3"), 0.0, (byte) 2), // Dig speed
|
new Triple<>(UUID.fromString("AF8B6E3F-3328-4C0A-AA36-5BA2BB9DBEF3"), 0.0, (byte) 2), // Dig speed
|
||||||
new Triple<>(UUID.fromString("55FCED67-E92A-486E-9800-B47F202C4386"), 0.0, (byte) 2) // Dig slow down
|
new Triple<>(UUID.fromString("55FCED67-E92A-486E-9800-B47F202C4386"), 0.0, (byte) 2) // Dig slow down
|
||||||
|
@ -34,7 +34,7 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.InventoryTra
|
|||||||
|
|
||||||
public class InventoryPackets {
|
public class InventoryPackets {
|
||||||
|
|
||||||
public static void register(Protocol protocol) {
|
public static void register(Protocol1_9To1_8 protocol) {
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.WINDOW_PROPERTY, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.WINDOW_PROPERTY, new PacketRemapper() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,12 +27,12 @@ import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
|||||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.DataItem;
|
import com.viaversion.viaversion.api.minecraft.item.DataItem;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
|
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_1_2Type;
|
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_1_2Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
|
||||||
@ -46,13 +46,11 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.ClientChunks
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracker1_9;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracker1_9;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.types.Chunk1_8Type;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.types.Chunk1_8Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.types.ChunkBulk1_8Type;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.types.ChunkBulk1_8Type;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class WorldPackets {
|
public class WorldPackets {
|
||||||
public static void register(Protocol protocol) {
|
public static void register(Protocol1_9To1_8 protocol) {
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.UPDATE_SIGN, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.UPDATE_SIGN, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
@ -320,8 +318,7 @@ public class WorldPackets {
|
|||||||
int hand = wrapper.read(Type.VAR_INT);
|
int hand = wrapper.read(Type.VAR_INT);
|
||||||
// Wipe the input buffer
|
// Wipe the input buffer
|
||||||
wrapper.clearInputBuffer();
|
wrapper.clearInputBuffer();
|
||||||
// First set this packet ID to Block placement
|
wrapper.setPacketType(ServerboundPackets1_8.PLAYER_BLOCK_PLACEMENT);
|
||||||
wrapper.setId(0x08);
|
|
||||||
wrapper.write(Type.POSITION, new Position(-1, (short) -1, -1));
|
wrapper.write(Type.POSITION, new Position(-1, (short) -1, -1));
|
||||||
wrapper.write(Type.UNSIGNED_BYTE, (short) 255);
|
wrapper.write(Type.UNSIGNED_BYTE, (short) 255);
|
||||||
// Write item in hand
|
// Write item in hand
|
||||||
|
@ -152,7 +152,7 @@ public class EntityTracker1_9 extends EntityTrackerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean interactedBlockRecently(int x, int y, int z) {
|
public boolean interactedBlockRecently(int x, int y, int z) {
|
||||||
return blockInteractions.contains(new Position(x, (short) y, z));
|
return blockInteractions.contains(new Position(x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addBlockInteraction(Position p) {
|
public void addBlockInteraction(Position p) {
|
||||||
|
@ -111,8 +111,6 @@ public class UpdateUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return statistics.get("name").getAsString();
|
return statistics.get("name").getAsString();
|
||||||
} catch (MalformedURLException e) {
|
|
||||||
return null;
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -83,8 +83,6 @@ public abstract class Config implements ConfigurationProvider {
|
|||||||
if (location.exists()) {
|
if (location.exists()) {
|
||||||
try (FileInputStream input = new FileInputStream(location)) {
|
try (FileInputStream input = new FileInputStream(location)) {
|
||||||
config = (Map<String, Object>) YAML.get().load(input);
|
config = (Map<String, Object>) YAML.get().load(input);
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren