mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-12-22 16:38:20 +01:00
Remove some deprecated api usage, small cleanup
This commit is contained in:
parent
1a5f83619d
commit
088f654159
@ -136,7 +136,7 @@ public interface ViaAPI<T> {
|
||||
* Returns the supported 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
|
||||
*/
|
||||
SortedSet<Integer> getSupportedVersions();
|
||||
@ -144,7 +144,7 @@ public interface ViaAPI<T> {
|
||||
/**
|
||||
* Returns the supported protocol versions, including blocked protocols.
|
||||
*
|
||||
* @return a list of protocol versions
|
||||
* @return a sorted set of protocol versions
|
||||
*/
|
||||
SortedSet<Integer> getFullSupportedVersions();
|
||||
|
||||
|
@ -89,7 +89,6 @@ public interface ViaManager {
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
@Deprecated
|
||||
default boolean isDebug() {
|
||||
return debugHandler().enabled();
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ public interface Mappings {
|
||||
int mappedSize();
|
||||
|
||||
static <T extends Mappings> Builder<T> builder(final MappingsSupplier<T> supplier) {
|
||||
return new Builder(supplier);
|
||||
return new Builder<>(supplier);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
|
@ -54,10 +54,10 @@ public interface BlockChangeRecord {
|
||||
short getY(int chunkSectionY);
|
||||
|
||||
/**
|
||||
* Returns the absolute y coordinate - only works for sub 1.16 protocols.
|
||||
*
|
||||
* @return absolute y coordinate
|
||||
* @deprecated 1.16+ stores the relative y coordinate
|
||||
*/
|
||||
@Deprecated
|
||||
default short getY() {
|
||||
return getY(-1);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.minecraft;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
public enum BlockFace {
|
||||
@ -33,9 +33,9 @@ public enum BlockFace {
|
||||
TOP((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 {
|
||||
opposites.put(BlockFace.NORTH, BlockFace.SOUTH);
|
||||
|
@ -33,7 +33,7 @@ public class Position {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval=true)*/
|
||||
// @Deprecated/*(forRemoval=true)*/ Just leave this unchecked
|
||||
public Position(int x, short y, int z) {
|
||||
this(x, (int) y, z);
|
||||
}
|
||||
|
@ -314,6 +314,7 @@ public abstract class AbstractProtocol<C1 extends ClientboundPacketType, C2 exte
|
||||
} else {
|
||||
int mappedId = direction == Direction.CLIENTBOUND ? protocolPacket.getNewId() : protocolPacket.getOldId();
|
||||
if (unmappedId != mappedId) {
|
||||
//noinspection deprecation
|
||||
packetWrapper.setId(mappedId);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ package com.viaversion.viaversion.api.type.types;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
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.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.util.CompactArrayUtil;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@ -39,8 +41,6 @@ public class ChunkSectionType1_13 extends Type<ChunkSection> {
|
||||
public ChunkSection read(ByteBuf buffer) throws Exception {
|
||||
// Reaad bits per block
|
||||
int bitsPerBlock = buffer.readUnsignedByte();
|
||||
int originalBitsPerBlock = bitsPerBlock;
|
||||
|
||||
if (bitsPerBlock > 8) {
|
||||
bitsPerBlock = GLOBAL_PALETTE;
|
||||
} else if (bitsPerBlock < 4) {
|
||||
@ -52,8 +52,9 @@ public class ChunkSectionType1_13 extends Type<ChunkSection> {
|
||||
if (bitsPerBlock != GLOBAL_PALETTE) {
|
||||
int paletteLength = Type.VAR_INT.readPrimitive(buffer);
|
||||
chunkSection = new ChunkSectionImpl(true, paletteLength);
|
||||
DataPalette blockPalette = chunkSection.palette(PaletteType.BLOCKS);
|
||||
for (int i = 0; i < paletteLength; i++) {
|
||||
chunkSection.addPaletteEntry(Type.VAR_INT.readPrimitive(buffer));
|
||||
blockPalette.addId(Type.VAR_INT.readPrimitive(buffer));
|
||||
}
|
||||
} else {
|
||||
chunkSection = new ChunkSectionImpl(true);
|
||||
@ -64,8 +65,9 @@ public class ChunkSectionType1_13 extends Type<ChunkSection> {
|
||||
if (blockData.length > 0) {
|
||||
int expectedLength = (int) Math.ceil(ChunkSection.SIZE * bitsPerBlock / 64.0);
|
||||
if (blockData.length == expectedLength) {
|
||||
DataPalette blockPalette = chunkSection.palette(PaletteType.BLOCKS);
|
||||
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
|
||||
public void write(ByteBuf buffer, ChunkSection chunkSection) throws Exception {
|
||||
int bitsPerBlock = 4;
|
||||
while (chunkSection.getPaletteSize() > 1 << bitsPerBlock) {
|
||||
DataPalette blockPalette = chunkSection.palette(PaletteType.BLOCKS);
|
||||
while (blockPalette.size() > 1 << bitsPerBlock) {
|
||||
bitsPerBlock += 1;
|
||||
}
|
||||
|
||||
@ -87,14 +90,14 @@ public class ChunkSectionType1_13 extends Type<ChunkSection> {
|
||||
|
||||
// Write palette
|
||||
if (bitsPerBlock != GLOBAL_PALETTE) {
|
||||
Type.VAR_INT.writePrimitive(buffer, chunkSection.getPaletteSize());
|
||||
for (int i = 0; i < chunkSection.getPaletteSize(); i++) {
|
||||
Type.VAR_INT.writePrimitive(buffer, chunkSection.getPaletteEntry(i));
|
||||
Type.VAR_INT.writePrimitive(buffer, blockPalette.size());
|
||||
for (int i = 0; i < blockPalette.size(); i++) {
|
||||
Type.VAR_INT.writePrimitive(buffer, blockPalette.idByIndex(i));
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -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.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.util.CompactArrayUtil;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@ -39,8 +41,6 @@ public class ChunkSectionType1_16 extends Type<ChunkSection> {
|
||||
public ChunkSection read(ByteBuf buffer) throws Exception {
|
||||
// Reaad bits per block
|
||||
int bitsPerBlock = buffer.readUnsignedByte();
|
||||
int originalBitsPerBlock = bitsPerBlock;
|
||||
|
||||
if (bitsPerBlock > 8) {
|
||||
bitsPerBlock = GLOBAL_PALETTE;
|
||||
} else if (bitsPerBlock < 4) {
|
||||
@ -52,8 +52,9 @@ public class ChunkSectionType1_16 extends Type<ChunkSection> {
|
||||
if (bitsPerBlock != GLOBAL_PALETTE) {
|
||||
int paletteLength = Type.VAR_INT.readPrimitive(buffer);
|
||||
chunkSection = new ChunkSectionImpl(false, paletteLength);
|
||||
DataPalette blockPalette = chunkSection.palette(PaletteType.BLOCKS);
|
||||
for (int i = 0; i < paletteLength; i++) {
|
||||
chunkSection.addPaletteEntry(Type.VAR_INT.readPrimitive(buffer));
|
||||
blockPalette.addId(Type.VAR_INT.readPrimitive(buffer));
|
||||
}
|
||||
} else {
|
||||
chunkSection = new ChunkSectionImpl(false);
|
||||
@ -65,8 +66,9 @@ public class ChunkSectionType1_16 extends Type<ChunkSection> {
|
||||
char valuesPerLong = (char) (64 / bitsPerBlock);
|
||||
int expectedLength = (ChunkSection.SIZE + valuesPerLong - 1) / valuesPerLong;
|
||||
if (blockData.length == expectedLength) {
|
||||
DataPalette blockPalette = chunkSection.palette(PaletteType.BLOCKS);
|
||||
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
|
||||
public void write(ByteBuf buffer, ChunkSection chunkSection) throws Exception {
|
||||
int bitsPerBlock = 4;
|
||||
while (chunkSection.getPaletteSize() > 1 << bitsPerBlock) {
|
||||
DataPalette blockPalette = chunkSection.palette(PaletteType.BLOCKS);
|
||||
while (blockPalette.size() > 1 << bitsPerBlock) {
|
||||
bitsPerBlock += 1;
|
||||
}
|
||||
|
||||
@ -88,14 +91,14 @@ public class ChunkSectionType1_16 extends Type<ChunkSection> {
|
||||
|
||||
// Write palette
|
||||
if (bitsPerBlock != GLOBAL_PALETTE) {
|
||||
Type.VAR_INT.writePrimitive(buffer, chunkSection.getPaletteSize());
|
||||
for (int i = 0; i < chunkSection.getPaletteSize(); i++) {
|
||||
Type.VAR_INT.writePrimitive(buffer, chunkSection.getPaletteEntry(i));
|
||||
Type.VAR_INT.writePrimitive(buffer, blockPalette.size());
|
||||
for (int i = 0; i < blockPalette.size(); i++) {
|
||||
Type.VAR_INT.writePrimitive(buffer, blockPalette.idByIndex(i));
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -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.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.util.CompactArrayUtil;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@ -39,7 +41,6 @@ public class ChunkSectionType1_9 extends Type<ChunkSection> {
|
||||
public ChunkSection read(ByteBuf buffer) throws Exception {
|
||||
// Reaad bits per block
|
||||
int bitsPerBlock = buffer.readUnsignedByte();
|
||||
int originalBitsPerBlock = bitsPerBlock;
|
||||
if (bitsPerBlock < 4) {
|
||||
bitsPerBlock = 4;
|
||||
}
|
||||
@ -50,9 +51,10 @@ public class ChunkSectionType1_9 extends Type<ChunkSection> {
|
||||
// Read palette
|
||||
int paletteLength = Type.VAR_INT.readPrimitive(buffer);
|
||||
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++) {
|
||||
if (bitsPerBlock != GLOBAL_PALETTE) {
|
||||
chunkSection.addPaletteEntry(Type.VAR_INT.readPrimitive(buffer));
|
||||
blockPalette.addId(Type.VAR_INT.readPrimitive(buffer));
|
||||
} else {
|
||||
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);
|
||||
if (blockData.length == expectedLength) {
|
||||
CompactArrayUtil.iterateCompactArray(bitsPerBlock, ChunkSection.SIZE, blockData,
|
||||
bitsPerBlock == GLOBAL_PALETTE ? chunkSection::setFlatBlock
|
||||
: chunkSection::setPaletteIndex);
|
||||
bitsPerBlock == GLOBAL_PALETTE ? blockPalette::setIdAt : blockPalette::setPaletteIndexAt);
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,7 +76,8 @@ public class ChunkSectionType1_9 extends Type<ChunkSection> {
|
||||
@Override
|
||||
public void write(ByteBuf buffer, ChunkSection chunkSection) throws Exception {
|
||||
int bitsPerBlock = 4;
|
||||
while (chunkSection.getPaletteSize() > 1 << bitsPerBlock) {
|
||||
DataPalette blockPalette = chunkSection.palette(PaletteType.BLOCKS);
|
||||
while (blockPalette.size() > 1 << bitsPerBlock) {
|
||||
bitsPerBlock += 1;
|
||||
}
|
||||
|
||||
@ -87,16 +89,16 @@ public class ChunkSectionType1_9 extends Type<ChunkSection> {
|
||||
|
||||
// Write palette
|
||||
if (bitsPerBlock != GLOBAL_PALETTE) {
|
||||
Type.VAR_INT.writePrimitive(buffer, chunkSection.getPaletteSize());
|
||||
for (int i = 0; i < chunkSection.getPaletteSize(); i++) {
|
||||
Type.VAR_INT.writePrimitive(buffer, chunkSection.getPaletteEntry(i));
|
||||
Type.VAR_INT.writePrimitive(buffer, blockPalette.size());
|
||||
for (int i = 0; i < blockPalette.size(); i++) {
|
||||
Type.VAR_INT.writePrimitive(buffer, blockPalette.idByIndex(i));
|
||||
}
|
||||
} else {
|
||||
Type.VAR_INT.writePrimitive(buffer, 0);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class BlockListener extends ViaBukkitListener {
|
||||
if (isOnPipe(e.getPlayer())) {
|
||||
Block b = e.getBlockPlaced();
|
||||
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) {
|
||||
this.provider = provider;
|
||||
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) {
|
||||
|
@ -80,9 +80,7 @@ public class BungeeVersionProvider extends BaseVersionProvider {
|
||||
try {
|
||||
list = ReflectionUtil.getStatic(ref, "SUPPORTED_VERSION_IDS", List.class);
|
||||
return list.get(0);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Fallback
|
||||
|
@ -18,9 +18,6 @@
|
||||
package com.viaversion.viaversion.dump;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
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.minecraft.chunks.Chunk;
|
||||
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.protocol.AbstractProtocol;
|
||||
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();
|
||||
for (ChunkSection section : chunk.getSections()) {
|
||||
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.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.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
@ -44,9 +46,14 @@ public class WorldPackets {
|
||||
Chunk chunk = wrapper.passthrough(new Chunk1_13Type(clientWorld));
|
||||
|
||||
for (ChunkSection section : chunk.getSections()) {
|
||||
if (section == null) continue;
|
||||
for (int i = 0; i < section.getPaletteSize(); i++) {
|
||||
section.setPaletteEntry(i, protocol.getMappingData().getNewBlockStateId(section.getPaletteEntry(i)));
|
||||
if (section == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
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.ServerboundPackets1_13;
|
||||
|
||||
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() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
|
@ -17,16 +17,16 @@
|
||||
*/
|
||||
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.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
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;
|
||||
|
||||
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() {
|
||||
@Override
|
||||
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.Position;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
@ -33,7 +34,7 @@ public abstract class AbstractStempConnectionHandler extends ConnectionHandler {
|
||||
private final int baseStateId;
|
||||
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) {
|
||||
this.baseStateId = ConnectionData.getId(baseStateId);
|
||||
|
@ -218,7 +218,7 @@ public class ConnectionData {
|
||||
blockConnectionData = new Int2ObjectOpenHashMap<>(1146, .99F);
|
||||
JsonObject mappingBlockConnections = MappingDataLoader.loadData("blockConnections.json");
|
||||
for (Entry<String, JsonElement> entry : mappingBlockConnections.entrySet()) {
|
||||
int id = keyToId.get(entry.getKey());
|
||||
int id = keyToId.getInt(entry.getKey());
|
||||
BlockData blockData = new BlockData();
|
||||
for (Entry<String, JsonElement> type : entry.getValue().getAsJsonObject().entrySet()) {
|
||||
String name = type.getKey();
|
||||
@ -242,7 +242,7 @@ public class ConnectionData {
|
||||
JsonObject blockData = MappingDataLoader.loadData("blockData.json");
|
||||
JsonArray occluding = blockData.getAsJsonArray("occluding");
|
||||
for (JsonElement jsonElement : occluding) {
|
||||
occludingStates.add(keyToId.get(jsonElement.getAsString()).intValue());
|
||||
occludingStates.add(keyToId.getInt(jsonElement.getAsString()));
|
||||
}
|
||||
|
||||
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.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.ClientboundPackets1_13;
|
||||
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.data.BlockIdData;
|
||||
@ -113,7 +114,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
|
||||
|
||||
// Reset the packet
|
||||
wrapper.clearPacket();
|
||||
wrapper.setId(0x4C);
|
||||
wrapper.setPacketType(ClientboundPackets1_13.SOUND);
|
||||
|
||||
byte flags = 0;
|
||||
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
|
||||
protocol.registerClientbound(ClientboundPackets1_12_1.SPAWN_PAINTING, new PacketRemapper() {
|
||||
@Override
|
||||
@ -433,7 +433,7 @@ public class WorldPackets {
|
||||
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");
|
||||
|
@ -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.connection.StorableObject;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
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.packets.WorldPackets;
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class BlockConnectionStorage implements StorableObject {
|
||||
private static final short[] REVERSE_BLOCK_MAPPINGS = new short[8582];
|
||||
private static Constructor<?> fastUtilLongObjectHashMap;
|
||||
|
||||
private final Map<Long, Pair<byte[], NibbleArray>> blockStorage = createLongObjectMap();
|
||||
private final Map<Long, SectionData> blockStorage = createLongObjectMap();
|
||||
|
||||
static {
|
||||
try {
|
||||
@ -61,10 +59,10 @@ public class BlockConnectionStorage implements StorableObject {
|
||||
|
||||
blockState = mapping;
|
||||
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);
|
||||
map.key()[blockIndex] = (byte) (blockState >> 4);
|
||||
NibbleArray nibbleArray = map.value();
|
||||
map.blockIds()[blockIndex] = (byte) (blockState >> 4);
|
||||
NibbleArray nibbleArray = map.nibbleArray();
|
||||
if (nibbleArray != null) {
|
||||
nibbleArray.set(blockIndex, blockState);
|
||||
}
|
||||
@ -72,22 +70,22 @@ public class BlockConnectionStorage implements StorableObject {
|
||||
|
||||
public int get(int x, int y, int z) {
|
||||
long pair = getChunkSectionIndex(x, y, z);
|
||||
Pair<byte[], NibbleArray> map = blockStorage.get(pair);
|
||||
SectionData map = blockStorage.get(pair);
|
||||
if (map == null) return 0;
|
||||
short blockPosition = encodeBlockPos(x, y, z);
|
||||
NibbleArray nibbleArray = map.value();
|
||||
NibbleArray nibbleArray = map.nibbleArray();
|
||||
return WorldPackets.toNewId(
|
||||
((map.key()[blockPosition] & 0xFF) << 4)
|
||||
((map.blockIds()[blockPosition] & 0xFF) << 4)
|
||||
| (nibbleArray == null ? 0 : nibbleArray.get(blockPosition))
|
||||
);
|
||||
}
|
||||
|
||||
public void remove(int x, int y, int z) {
|
||||
long pair = getChunkSectionIndex(x, y, z);
|
||||
Pair<byte[], NibbleArray> map = blockStorage.get(pair);
|
||||
SectionData map = blockStorage.get(pair);
|
||||
if (map == null) return;
|
||||
int blockIndex = encodeBlockPos(x, y, z);
|
||||
NibbleArray nibbleArray = map.value();
|
||||
NibbleArray nibbleArray = map.nibbleArray();
|
||||
if (nibbleArray != null) {
|
||||
nibbleArray.set(blockIndex, 0);
|
||||
boolean allZero = true;
|
||||
@ -97,10 +95,10 @@ public class BlockConnectionStorage implements StorableObject {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (allZero) map.setValue(null);
|
||||
if (allZero) map.setNibbleArray(null);
|
||||
}
|
||||
map.key()[blockIndex] = 0;
|
||||
for (short entry : map.key()) {
|
||||
map.blockIds()[blockIndex] = 0;
|
||||
for (short entry : map.blockIds()) {
|
||||
if (entry != 0) return;
|
||||
}
|
||||
blockStorage.remove(pair);
|
||||
@ -111,7 +109,7 @@ public class BlockConnectionStorage implements StorableObject {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -120,14 +118,14 @@ public class BlockConnectionStorage implements StorableObject {
|
||||
blockStorage.remove(getChunkSectionIndex(x << 4, y << 4, z << 4));
|
||||
}
|
||||
|
||||
private Pair<byte[], NibbleArray> getChunkSection(long index, boolean requireNibbleArray) {
|
||||
Pair<byte[], NibbleArray> map = blockStorage.get(index);
|
||||
private SectionData getChunkSection(long index, boolean requireNibbleArray) {
|
||||
SectionData map = blockStorage.get(index);
|
||||
if (map == null) {
|
||||
map = new Pair<>(new byte[4096], null);
|
||||
map = new SectionData(new byte[4096]);
|
||||
blockStorage.put(index, map);
|
||||
}
|
||||
if (map.value() == null && requireNibbleArray) {
|
||||
map.setValue(new NibbleArray(4096));
|
||||
if (map.nibbleArray() == null && requireNibbleArray) {
|
||||
map.setNibbleArray(new NibbleArray(4096));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
@ -136,18 +134,10 @@ public class BlockConnectionStorage implements StorableObject {
|
||||
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) {
|
||||
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() {
|
||||
if (fastUtilLongObjectHashMap != null) {
|
||||
try {
|
||||
@ -158,4 +148,25 @@ public class BlockConnectionStorage implements StorableObject {
|
||||
}
|
||||
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 java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
// TODO Fix memory leak lolz (only a smol one tho)
|
||||
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.ClientboundPackets1_13;
|
||||
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.ServerboundPackets1_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);
|
||||
|
||||
if (type.equals("EntityHorse")) {
|
||||
wrapper.setId(0x1F);
|
||||
wrapper.setPacketType(ClientboundPackets1_14.OPEN_HORSE_WINDOW);
|
||||
int entityId = wrapper.read(Type.INT);
|
||||
wrapper.write(Type.UNSIGNED_BYTE, windowId);
|
||||
wrapper.write(Type.VAR_INT, slots.intValue());
|
||||
wrapper.write(Type.INT, entityId);
|
||||
} else {
|
||||
wrapper.setId(0x2E);
|
||||
wrapper.setPacketType(ClientboundPackets1_14.OPEN_WINDOW);
|
||||
wrapper.write(Type.VAR_INT, windowId.intValue());
|
||||
|
||||
int typeId = -1;
|
||||
@ -156,7 +157,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_13, Serve
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
String channel = wrapper.get(Type.STRING, 0);
|
||||
if (channel.equals("minecraft:trader_list") || channel.equals("trader_list")) {
|
||||
wrapper.setId(0x27);
|
||||
wrapper.setPacketType(ClientboundPackets1_14.TRADE_LIST);
|
||||
wrapper.resetReader();
|
||||
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")) {
|
||||
int hand = wrapper.read(Type.VAR_INT);
|
||||
wrapper.clearPacket();
|
||||
wrapper.setId(0x2D);
|
||||
wrapper.setPacketType(ClientboundPackets1_14.OPEN_BOOK);
|
||||
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.minecraft.Position;
|
||||
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.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
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 java.util.Collections;
|
||||
|
||||
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() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
|
@ -110,7 +110,7 @@ public class EntityPackets {
|
||||
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
|
||||
List<Metadata> metadata = wrapper.read(Types1_14.METADATA_LIST);
|
||||
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.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.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
@ -72,11 +74,14 @@ public class WorldPackets {
|
||||
|
||||
for (int s = 0; s < chunk.getSections().length; s++) {
|
||||
ChunkSection section = chunk.getSections()[s];
|
||||
if (section == null) continue;
|
||||
for (int i = 0; i < section.getPaletteSize(); i++) {
|
||||
int old = section.getPaletteEntry(i);
|
||||
int newId = protocol.getMappingData().getNewBlockStateId(old);
|
||||
section.setPaletteEntry(i, newId);
|
||||
if (section == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
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.chunks.Chunk;
|
||||
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.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
@ -53,10 +55,14 @@ public class WorldPackets {
|
||||
|
||||
for (int s = 0; s < chunk.getSections().length; s++) {
|
||||
ChunkSection section = chunk.getSections()[s];
|
||||
if (section == null) continue;
|
||||
for (int i = 0; i < section.getPaletteSize(); i++) {
|
||||
int old = section.getPaletteEntry(i);
|
||||
section.setPaletteEntry(i, protocol.getMappingData().getNewBlockStateId(old));
|
||||
if (section == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
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.chunks.Chunk;
|
||||
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.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.UUIDIntArrayType;
|
||||
@ -69,10 +71,14 @@ public class WorldPackets {
|
||||
|
||||
for (int s = 0; s < chunk.getSections().length; s++) {
|
||||
ChunkSection section = chunk.getSections()[s];
|
||||
if (section == null) continue;
|
||||
for (int i = 0; i < section.getPaletteSize(); i++) {
|
||||
int old = section.getPaletteEntry(i);
|
||||
section.setPaletteEntry(i, protocol.getMappingData().getNewBlockStateId(old));
|
||||
if (section == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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.chunks.Chunk;
|
||||
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.PacketWrapper;
|
||||
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);
|
||||
}
|
||||
|
||||
wrapper.setId(packetType.getId());
|
||||
wrapper.setPacketType(packetType);
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -148,10 +150,14 @@ public final class WorldPackets {
|
||||
|
||||
for (int s = 0; s < chunk.getSections().length; s++) {
|
||||
ChunkSection section = chunk.getSections()[s];
|
||||
if (section == null) continue;
|
||||
for (int i = 0; i < section.getPaletteSize(); i++) {
|
||||
int old = section.getPaletteEntry(i);
|
||||
section.setPaletteEntry(i, protocol.getMappingData().getNewBlockStateId(old));
|
||||
if (section == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
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
|
||||
BlockChangeRecord[] blockChangeRecords = new BlockChangeRecord[4096];
|
||||
DataPalette palette = section.palette(PaletteType.BLOCKS);
|
||||
int j = 0;
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int y = 0; y < 16; y++) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ package com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
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.chunks.Chunk;
|
||||
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.nbt.BinaryTagIO;
|
||||
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.remapper.PacketRemapper;
|
||||
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.setId(ClientboundPackets1_9.UPDATE_SIGN.ordinal()); //Update sign packet
|
||||
wrapper.setPacketType(ClientboundPackets1_9.UPDATE_SIGN);
|
||||
wrapper.write(Type.POSITION, position); // Position
|
||||
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
|
||||
|
@ -74,7 +74,7 @@ public class Protocol1_9_3To1_9_1_2 extends AbstractProtocol<ClientboundPackets1
|
||||
wrapper.clearInputBuffer();
|
||||
|
||||
//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.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
|
||||
|
@ -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.remapper.PacketRemapper;
|
||||
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.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_9to1_8.metadata.MetadataRewriter1_9To1_8;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.packets.*;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.*;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.*;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.packets.EntityPackets;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.packets.InventoryPackets;
|
||||
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;
|
||||
|
||||
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);
|
||||
}
|
||||
};
|
||||
private final EntityRewriter metadataRewriter = new MetadataRewriter1_9To1_8(this);
|
||||
private final MetadataRewriter1_9To1_8 metadataRewriter = new MetadataRewriter1_9To1_8(this);
|
||||
|
||||
public Protocol1_9To1_8() {
|
||||
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
|
||||
public EntityRewriter getEntityRewriter() {
|
||||
public MetadataRewriter1_9To1_8 getEntityRewriter() {
|
||||
return metadataRewriter;
|
||||
}
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ public class EntityPackets {
|
||||
// == Why 15.9? ==
|
||||
// Higher values hides the cooldown but it bugs visual animation on hand
|
||||
// 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("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
|
||||
|
@ -34,7 +34,7 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.InventoryTra
|
||||
|
||||
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() {
|
||||
|
||||
@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.item.DataItem;
|
||||
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.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
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.types.Chunk1_9_1_2Type;
|
||||
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.types.Chunk1_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.Optional;
|
||||
|
||||
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() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -320,8 +318,7 @@ public class WorldPackets {
|
||||
int hand = wrapper.read(Type.VAR_INT);
|
||||
// Wipe the input buffer
|
||||
wrapper.clearInputBuffer();
|
||||
// First set this packet ID to Block placement
|
||||
wrapper.setId(0x08);
|
||||
wrapper.setPacketType(ServerboundPackets1_8.PLAYER_BLOCK_PLACEMENT);
|
||||
wrapper.write(Type.POSITION, new Position(-1, (short) -1, -1));
|
||||
wrapper.write(Type.UNSIGNED_BYTE, (short) 255);
|
||||
// Write item in hand
|
||||
|
@ -152,7 +152,7 @@ public class EntityTracker1_9 extends EntityTrackerBase {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -111,8 +111,6 @@ public class UpdateUtil {
|
||||
return null;
|
||||
}
|
||||
return statistics.get("name").getAsString();
|
||||
} catch (MalformedURLException e) {
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
|
@ -83,8 +83,6 @@ public abstract class Config implements ConfigurationProvider {
|
||||
if (location.exists()) {
|
||||
try (FileInputStream input = new FileInputStream(location)) {
|
||||
config = (Map<String, Object>) YAML.get().load(input);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user