diff --git a/.travis.yml b/.travis.yml index f87395083..af8e7d1c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,8 @@ jdk: oraclejdk8 cache: directories: - - '$HOME/.m2/repository' + - '$HOME/.m2/repository' script: - - mvn dependency:purge-local-repository -DactTransitively=false -DreResolve=false - - mvn clean install -B -U +- mvn dependency:purge-local-repository -DactTransitively=false -DreResolve=false +- mvn clean install -B -U diff --git a/bukkit/pom.xml b/bukkit/pom.xml index 8dda19ea8..b2d383d89 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 1.6.1-SNAPSHOT + 1.6.1-18w43c 4.0.0 diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/DeathListener.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/DeathListener.java index 164ffb394..de1f0d110 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/DeathListener.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/DeathListener.java @@ -38,7 +38,7 @@ public class DeathListener extends ViaBukkitListener { @Override public void run() { // If online - if(getUserConnection(p) != null) { + if (getUserConnection(p) != null) { PacketWrapper wrapper = new PacketWrapper(0x2C, null, getUserConnection(p)); try { wrapper.write(Type.VAR_INT, 2); // Event - Entity dead diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/HandItemCache.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/HandItemCache.java index 776003017..4cf432898 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/HandItemCache.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/HandItemCache.java @@ -6,7 +6,10 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; import us.myles.ViaVersion.api.minecraft.item.Item; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; public class HandItemCache extends BukkitRunnable { diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitConfigAPI.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitConfigAPI.java index b033cdb79..2aea4289e 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitConfigAPI.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitConfigAPI.java @@ -164,7 +164,7 @@ public class BukkitConfigAPI extends Config implements ViaVersionConfig { public boolean is1_12NBTArrayFix() { return getBoolean("chat-nbt-fix", true); } - + @Override public boolean is1_12QuickMoveActionFix() { return getBoolean("quick-move-action-fix", false); diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaLoader.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaLoader.java index 1ab52ede5..babf3e0fd 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaLoader.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaLoader.java @@ -13,12 +13,12 @@ import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.platform.ViaPlatformLoader; import us.myles.ViaVersion.api.protocol.ProtocolRegistry; import us.myles.ViaVersion.api.protocol.ProtocolVersion; +import us.myles.ViaVersion.bukkit.classgenerator.ClassGenerator; import us.myles.ViaVersion.bukkit.listeners.UpdateListener; import us.myles.ViaVersion.bukkit.listeners.protocol1_9to1_8.*; import us.myles.ViaVersion.bukkit.providers.BukkitInventoryQuickMoveProvider; import us.myles.ViaVersion.bukkit.providers.BukkitViaBulkChunkTranslator; import us.myles.ViaVersion.bukkit.providers.BukkitViaMovementTransmitter; -import us.myles.ViaVersion.bukkit.classgenerator.ClassGenerator; import us.myles.ViaVersion.protocols.base.ProtocolInfo; import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.providers.InventoryQuickMoveProvider; import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.BulkChunkTranslatorProvider; @@ -77,7 +77,7 @@ public class BukkitViaLoader implements ViaPlatformLoader { if ((Bukkit.getVersion().toLowerCase().contains("paper") || Bukkit.getVersion().toLowerCase().contains("taco") || Bukkit.getVersion().toLowerCase().contains("torch")) - && ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_12.getId()) { + && ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_12.getId()) { plugin.getLogger().info("Enabling Paper/TacoSpigot/Torch patch: Fixes block placement."); storeListener(new PaperPatch(plugin)).register(); } diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/providers/BukkitInventoryQuickMoveProvider.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/providers/BukkitInventoryQuickMoveProvider.java index a3e6eeb1f..f2586442c 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/providers/BukkitInventoryQuickMoveProvider.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/providers/BukkitInventoryQuickMoveProvider.java @@ -1,19 +1,10 @@ package us.myles.ViaVersion.bukkit.providers; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; -import java.util.logging.Level; - import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; - import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.protocol.ProtocolRegistry; @@ -25,6 +16,14 @@ import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.providers.InventoryQui import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.storage.ItemTransaction; import us.myles.ViaVersion.util.ReflectionUtil; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; +import java.util.logging.Level; + public class BukkitInventoryQuickMoveProvider extends InventoryQuickMoveProvider { private static Map updateTasks = new ConcurrentHashMap(); diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/tasks/protocol1_12to1_11_1/BukkitInventoryUpdateTask.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/tasks/protocol1_12to1_11_1/BukkitInventoryUpdateTask.java index 7f3ac0941..529363b8c 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/tasks/protocol1_12to1_11_1/BukkitInventoryUpdateTask.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/tasks/protocol1_12to1_11_1/BukkitInventoryUpdateTask.java @@ -1,16 +1,15 @@ package us.myles.ViaVersion.bukkit.tasks.protocol1_12to1_11_1; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import us.myles.ViaVersion.bukkit.providers.BukkitInventoryQuickMoveProvider; +import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.storage.ItemTransaction; + import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.UUID; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import us.myles.ViaVersion.bukkit.providers.BukkitInventoryQuickMoveProvider; -import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.storage.ItemTransaction; - public class BukkitInventoryUpdateTask implements Runnable { private BukkitInventoryQuickMoveProvider provider; diff --git a/bungee/pom.xml b/bungee/pom.xml index d09b21455..c99f4abc3 100644 --- a/bungee/pom.xml +++ b/bungee/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 1.6.1-SNAPSHOT + 1.6.1-18w43c 4.0.0 diff --git a/bungee/src/main/java/us/myles/ViaVersion/bungee/platform/BungeeConfigAPI.java b/bungee/src/main/java/us/myles/ViaVersion/bungee/platform/BungeeConfigAPI.java index 1c013f3f2..5b773185d 100644 --- a/bungee/src/main/java/us/myles/ViaVersion/bungee/platform/BungeeConfigAPI.java +++ b/bungee/src/main/java/us/myles/ViaVersion/bungee/platform/BungeeConfigAPI.java @@ -203,7 +203,7 @@ public class BungeeConfigAPI extends Config implements ViaVersionConfig { public boolean is1_12NBTArrayFix() { return getBoolean("chat-nbt-fix", true); } - + @Override public boolean is1_12QuickMoveActionFix() { return false; diff --git a/bungee/src/main/java/us/myles/ViaVersion/bungee/util/BungeePipelineUtil.java b/bungee/src/main/java/us/myles/ViaVersion/bungee/util/BungeePipelineUtil.java index d6218cc2d..9cc27c37b 100644 --- a/bungee/src/main/java/us/myles/ViaVersion/bungee/util/BungeePipelineUtil.java +++ b/bungee/src/main/java/us/myles/ViaVersion/bungee/util/BungeePipelineUtil.java @@ -4,7 +4,6 @@ import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToByteEncoder; import io.netty.handler.codec.MessageToMessageDecoder; -import us.myles.ViaVersion.api.Via; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; diff --git a/circle.yml b/circle.yml index df3c57ab6..6d6afa5b6 100644 --- a/circle.yml +++ b/circle.yml @@ -3,9 +3,9 @@ machine: version: oraclejdk8 general: artifacts: - - "target/*.jar" + - "target/*.jar" test: override: - - mvn clean install -B + - mvn clean install -B post: - - cp ./target/*.jar $CIRCLE_ARTIFACTS + - cp ./target/*.jar $CIRCLE_ARTIFACTS diff --git a/common/pom.xml b/common/pom.xml index d1cad3b92..ac602f7fb 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 1.6.1-SNAPSHOT + 1.6.1-18w43c 4.0.0 diff --git a/common/src/main/java/us/myles/ViaVersion/api/PacketWrapper.java b/common/src/main/java/us/myles/ViaVersion/api/PacketWrapper.java index f5fc26223..7dfba2c7b 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/PacketWrapper.java +++ b/common/src/main/java/us/myles/ViaVersion/api/PacketWrapper.java @@ -278,8 +278,8 @@ public class PacketWrapper { * Be careful not to send packets twice. * (Sends it after current) * - * @param packetProtocol - The protocol version of the packet. - * @param skipCurrentPipeline - Skip the current pipeline + * @param packetProtocol The protocol version of the packet. + * @param skipCurrentPipeline Skip the current pipeline * @throws Exception if it fails to write */ public void send(Class packetProtocol, boolean skipCurrentPipeline) throws Exception { @@ -291,9 +291,9 @@ public class PacketWrapper { * Be careful not to send packets twice. * (Sends it after current) * - * @param packetProtocol - The protocol version of the packet. - * @param skipCurrentPipeline - Skip the current pipeline - * @param currentThread - Run in the same thread + * @param packetProtocol The protocol version of the packet. + * @param skipCurrentPipeline Skip the current pipeline + * @param currentThread Run in the same thread * @throws Exception if it fails to write */ public void send(Class packetProtocol, boolean skipCurrentPipeline, boolean currentThread) throws Exception { @@ -306,8 +306,8 @@ public class PacketWrapper { /** * Let the packet go through the protocol pipes and write it to ByteBuf * - * @param packetProtocol - The protocol version of the packet. - * @param skipCurrentPipeline - Skip the current pipeline + * @param packetProtocol The protocol version of the packet. + * @param skipCurrentPipeline Skip the current pipeline * @return Packet buffer * @throws Exception if it fails to write */ @@ -343,7 +343,7 @@ public class PacketWrapper { * Be careful not to send packets twice. * (Sends it after current) * - * @param packetProtocol - The protocol version of the packet. + * @param packetProtocol The protocol version of the packet. * @throws Exception if it fails to write */ public void send(Class packetProtocol) throws Exception { @@ -356,7 +356,7 @@ public class PacketWrapper { * (Sends it after current) * Also returns the packets ChannelFuture * - * @param packetProtocol - The protocol version of the packet. + * @param packetProtocol The protocol version of the packet. * @return The packets ChannelFuture * @throws Exception if it fails to write */ @@ -486,9 +486,9 @@ public class PacketWrapper { /** * Send this packet to the server. * - * @param packetProtocol - The protocol version of the packet. - * @param skipCurrentPipeline - Skip the current pipeline - * @param currentThread - Run in the same thread + * @param packetProtocol The protocol version of the packet. + * @param skipCurrentPipeline Skip the current pipeline + * @param currentThread Run in the same thread * @throws Exception if it fails to write */ public void sendToServer(Class packetProtocol, boolean skipCurrentPipeline, boolean currentThread) throws Exception { diff --git a/common/src/main/java/us/myles/ViaVersion/api/data/UserConnection.java b/common/src/main/java/us/myles/ViaVersion/api/data/UserConnection.java index aa9019262..ffc4b4a58 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/data/UserConnection.java +++ b/common/src/main/java/us/myles/ViaVersion/api/data/UserConnection.java @@ -205,7 +205,7 @@ public class UserConnection { /** * Sends a raw packet to the server * - * @param packet Raw packet to be sent + * @param packet Raw packet to be sent * @param currentThread If {@code true} executes immediately, {@code false} submits a task to EventLoop */ public void sendRawPacketToServer(final ByteBuf packet, boolean currentThread) { @@ -244,5 +244,7 @@ public class UserConnection { * * @param packet Raw packet to be sent */ - public void sendRawPacketToServer(ByteBuf packet) { sendRawPacketToServer(packet, false); } + public void sendRawPacketToServer(ByteBuf packet) { + sendRawPacketToServer(packet, false); + } } diff --git a/common/src/main/java/us/myles/ViaVersion/api/entities/Entity1_14Types.java b/common/src/main/java/us/myles/ViaVersion/api/entities/Entity1_14Types.java index 46384c855..7446949b0 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/entities/Entity1_14Types.java +++ b/common/src/main/java/us/myles/ViaVersion/api/entities/Entity1_14Types.java @@ -8,12 +8,7 @@ import us.myles.ViaVersion.api.Via; public class Entity1_14Types { public static EntityType getTypeFromId(int typeID, boolean isObject) { - Optional type; - - if (isObject) - type = ObjectTypes.getPCEntity(typeID); - else - type = EntityType.findById(typeID); + Optional type = isObject ? ObjectTypes.getPCEntity(typeID) : EntityType.findById(typeID); if (!type.isPresent()) { Via.getPlatform().getLogger().severe("Could not find type id " + typeID + " isObject=" + isObject); diff --git a/common/src/main/java/us/myles/ViaVersion/api/minecraft/chunks/BaseChunk.java b/common/src/main/java/us/myles/ViaVersion/api/minecraft/chunks/BaseChunk.java index 82dd09429..931dda65e 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/minecraft/chunks/BaseChunk.java +++ b/common/src/main/java/us/myles/ViaVersion/api/minecraft/chunks/BaseChunk.java @@ -9,16 +9,16 @@ import java.util.List; @AllArgsConstructor @Data public class BaseChunk implements Chunk { - protected int x; - protected int z; - protected boolean groundUp; - protected int bitmask; - protected ChunkSection[] sections; - protected byte[] biomeData; - protected List blockEntities; + protected int x; + protected int z; + protected boolean groundUp; + protected int bitmask; + protected ChunkSection[] sections; + protected byte[] biomeData; + protected List blockEntities; - @Override - public boolean isBiomeData() { - return biomeData != null; - } + @Override + public boolean isBiomeData() { + return biomeData != null; + } } diff --git a/common/src/main/java/us/myles/ViaVersion/api/minecraft/chunks/ChunkSection.java b/common/src/main/java/us/myles/ViaVersion/api/minecraft/chunks/ChunkSection.java index 7e15d1f07..f5a15d1a6 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/minecraft/chunks/ChunkSection.java +++ b/common/src/main/java/us/myles/ViaVersion/api/minecraft/chunks/ChunkSection.java @@ -17,7 +17,7 @@ public class ChunkSection { */ public static final int LIGHT_LENGTH = 16 * 16 * 16 / 2; // size * size * size / 2 (nibble bit count) @Getter - private final List palette = Lists.newArrayList(); + private final List palette = Lists.newArrayList(); private final int[] blocks; private NibbleArray blockLight; private NibbleArray skyLight; @@ -72,19 +72,19 @@ public class ChunkSection { } public void setPaletteIndex(int idx, int index) { - blocks[idx] = index; + blocks[idx] = index; } public int getPaletteIndex(int idx) { - return blocks[idx]; + return blocks[idx]; } /** * Set a block state in the chunk * This method will not update non-air blocks count * - * @param idx Index - * @param id The raw or flat id of the block + * @param idx Index + * @param id The raw or flat id of the block */ public void setFlatBlock(int idx, int id) { int index = palette.indexOf(id); diff --git a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java index 4037abf26..0b1036c19 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java +++ b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java @@ -13,6 +13,7 @@ import us.myles.ViaVersion.protocols.protocol1_11to1_10.Protocol1_11To1_10; import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.Protocol1_12_1TO1_12; import us.myles.ViaVersion.protocols.protocol1_12_2to1_12_1.Protocol1_12_2TO1_12_1; import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1; +import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13; import us.myles.ViaVersion.protocols.protocol1_13_2to1_13_1.Protocol1_13_2To1_13_1; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2; @@ -21,7 +22,6 @@ import us.myles.ViaVersion.protocols.protocol1_9_1to1_9.Protocol1_9_1TO1_9; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.Protocol1_9_3TO1_9_1_2; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8; import us.myles.ViaVersion.protocols.protocol1_9to1_9_1.Protocol1_9TO1_9_1; -import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13; import java.util.*; import java.util.concurrent.ConcurrentHashMap; @@ -58,10 +58,10 @@ public class ProtocolRegistry { registerProtocol(new Protocol1_12_2TO1_12_1(), Collections.singletonList(ProtocolVersion.v1_12_2.getId()), ProtocolVersion.v1_12_1.getId()); registerProtocol(new Protocol1_13To1_12_2(), Collections.singletonList(ProtocolVersion.v1_13.getId()), ProtocolVersion.v1_12_2.getId()); - registerProtocol(new Protocol1_13_1To1_13(), Arrays.asList(ProtocolVersion.v1_13_1.getId()), ProtocolVersion.v1_13.getId()); - registerProtocol(new Protocol1_13_2To1_13_1(), Arrays.asList(ProtocolVersion.v1_13_2.getId()), ProtocolVersion.v1_13_1.getId()); + registerProtocol(new Protocol1_13_1To1_13(), Arrays.asList(ProtocolVersion.v1_13_1.getId()), ProtocolVersion.v1_13.getId()); + registerProtocol(new Protocol1_13_2To1_13_1(), Arrays.asList(ProtocolVersion.v1_13_2.getId()), ProtocolVersion.v1_13_1.getId()); - registerProtocol(new Protocol1_14To1_13_2(), Arrays.asList(ProtocolVersion.v1_14.getId()), ProtocolVersion.v1_13_2.getId()); + registerProtocol(new Protocol1_14To1_13_2(), Arrays.asList(ProtocolVersion.v1_14.getId()), ProtocolVersion.v1_13_2.getId()); } /** @@ -98,7 +98,7 @@ public class ProtocolRegistry { * Base Protocols registered later have higher priority * Only one base protocol will be added to pipeline * - * @param baseProtocol Base Protocol to register + * @param baseProtocol Base Protocol to register * @param supportedProtocols Versions that baseProtocol supports */ public static void registerBaseProtocol(Protocol baseProtocol, Range supportedProtocols) { diff --git a/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/BaseItemType.java b/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/BaseItemType.java index af19f82fb..f17db803c 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/BaseItemType.java +++ b/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/BaseItemType.java @@ -1,6 +1,5 @@ package us.myles.ViaVersion.api.type.types.minecraft; -import us.myles.ViaVersion.api.minecraft.chunks.Chunk; import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.type.Type; diff --git a/common/src/main/java/us/myles/ViaVersion/api/type/types/version/ChunkSectionType1_13.java b/common/src/main/java/us/myles/ViaVersion/api/type/types/version/ChunkSectionType1_13.java index ee6b89721..900773fac 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/type/types/version/ChunkSectionType1_13.java +++ b/common/src/main/java/us/myles/ViaVersion/api/type/types/version/ChunkSectionType1_13.java @@ -8,107 +8,107 @@ import java.util.List; public class ChunkSectionType1_13 extends Type { - public ChunkSectionType1_13() { - super("Chunk Section Type", ChunkSection.class); - } + public ChunkSectionType1_13() { + super("Chunk Section Type", ChunkSection.class); + } - @Override - public ChunkSection read(ByteBuf buffer) throws Exception { - ChunkSection chunkSection = new ChunkSection(); - List palette = chunkSection.getPalette(); - palette.clear(); + @Override + public ChunkSection read(ByteBuf buffer) throws Exception { + ChunkSection chunkSection = new ChunkSection(); + List palette = chunkSection.getPalette(); + palette.clear(); - // Reaad bits per block - int bitsPerBlock = buffer.readUnsignedByte(); - long maxEntryValue = (1L << bitsPerBlock) - 1; + // Reaad bits per block + int bitsPerBlock = buffer.readUnsignedByte(); + long maxEntryValue = (1L << bitsPerBlock) - 1; - if (bitsPerBlock == 0) { - bitsPerBlock = 14; - } - if (bitsPerBlock < 4) { - bitsPerBlock = 4; - } - if (bitsPerBlock > 8) { - bitsPerBlock = 14; - } - int paletteLength = bitsPerBlock == 14 ? 0 : Type.VAR_INT.read(buffer); - // Read palette - for (int i = 0; i < paletteLength; i++) { - palette.add(Type.VAR_INT.read(buffer)); - } + if (bitsPerBlock == 0) { + bitsPerBlock = 14; + } + if (bitsPerBlock < 4) { + bitsPerBlock = 4; + } + if (bitsPerBlock > 8) { + bitsPerBlock = 14; + } + int paletteLength = bitsPerBlock == 14 ? 0 : Type.VAR_INT.read(buffer); + // Read palette + for (int i = 0; i < paletteLength; i++) { + palette.add(Type.VAR_INT.read(buffer)); + } - // Read blocks - long[] blockData = new long[Type.VAR_INT.read(buffer)]; - if (blockData.length > 0) { - for (int i = 0; i < blockData.length; i++) { - blockData[i] = buffer.readLong(); - } - for (int i = 0; i < ChunkSection.SIZE; i++) { - int bitIndex = i * bitsPerBlock; - int startIndex = bitIndex / 64; - int endIndex = ((i + 1) * bitsPerBlock - 1) / 64; - int startBitSubIndex = bitIndex % 64; - int val; - if (startIndex == endIndex) { - val = (int) (blockData[startIndex] >>> startBitSubIndex & maxEntryValue); - } else { - int endBitSubIndex = 64 - startBitSubIndex; - val = (int) ((blockData[startIndex] >>> startBitSubIndex | blockData[endIndex] << endBitSubIndex) & maxEntryValue); - } + // Read blocks + long[] blockData = new long[Type.VAR_INT.read(buffer)]; + if (blockData.length > 0) { + for (int i = 0; i < blockData.length; i++) { + blockData[i] = buffer.readLong(); + } + for (int i = 0; i < ChunkSection.SIZE; i++) { + int bitIndex = i * bitsPerBlock; + int startIndex = bitIndex / 64; + int endIndex = ((i + 1) * bitsPerBlock - 1) / 64; + int startBitSubIndex = bitIndex % 64; + int val; + if (startIndex == endIndex) { + val = (int) (blockData[startIndex] >>> startBitSubIndex & maxEntryValue); + } else { + int endBitSubIndex = 64 - startBitSubIndex; + val = (int) ((blockData[startIndex] >>> startBitSubIndex | blockData[endIndex] << endBitSubIndex) & maxEntryValue); + } - if (bitsPerBlock == 14) { - chunkSection.setFlatBlock(i, val); - } else { - chunkSection.setPaletteIndex(i, val); - } - } - } + if (bitsPerBlock == 14) { + chunkSection.setFlatBlock(i, val); + } else { + chunkSection.setPaletteIndex(i, val); + } + } + } - return chunkSection; - } + return chunkSection; + } - @Override - public void write(ByteBuf buffer, ChunkSection chunkSection) throws Exception { - List palette = chunkSection.getPalette(); + @Override + public void write(ByteBuf buffer, ChunkSection chunkSection) throws Exception { + List palette = chunkSection.getPalette(); - int bitsPerBlock = 4; - while (palette.size() > 1 << bitsPerBlock) { - bitsPerBlock += 1; - } + int bitsPerBlock = 4; + while (palette.size() > 1 << bitsPerBlock) { + bitsPerBlock += 1; + } - if (bitsPerBlock > 8) { - bitsPerBlock = 14; - } + if (bitsPerBlock > 8) { + bitsPerBlock = 14; + } - long maxEntryValue = (1L << bitsPerBlock) - 1; - buffer.writeByte(bitsPerBlock); + long maxEntryValue = (1L << bitsPerBlock) - 1; + buffer.writeByte(bitsPerBlock); - // Write pallet (or not) - if (bitsPerBlock != 14) { - Type.VAR_INT.write(buffer, palette.size()); - for (int mappedId : palette) { - Type.VAR_INT.write(buffer, mappedId); - } - } + // Write pallet (or not) + if (bitsPerBlock != 14) { + Type.VAR_INT.write(buffer, palette.size()); + for (int mappedId : palette) { + Type.VAR_INT.write(buffer, mappedId); + } + } - int length = (int) Math.ceil(ChunkSection.SIZE * bitsPerBlock / 64.0); - Type.VAR_INT.write(buffer, length); - long[] data = new long[length]; - for (int index = 0; index < ChunkSection.SIZE; index++) { - int value = bitsPerBlock == 14 ? chunkSection.getFlatBlock(index) : chunkSection.getPaletteIndex(index); - int bitIndex = index * bitsPerBlock; - int startIndex = bitIndex / 64; - int endIndex = ((index + 1) * bitsPerBlock - 1) / 64; - int startBitSubIndex = bitIndex % 64; - data[startIndex] = data[startIndex] & ~(maxEntryValue << startBitSubIndex) | ((long) value & maxEntryValue) << startBitSubIndex; - if (startIndex != endIndex) { - int endBitSubIndex = 64 - startBitSubIndex; - data[endIndex] = data[endIndex] >>> endBitSubIndex << endBitSubIndex | ((long) value & maxEntryValue) >> endBitSubIndex; - } - } - for (long l : data) { - buffer.writeLong(l); - } - } + int length = (int) Math.ceil(ChunkSection.SIZE * bitsPerBlock / 64.0); + Type.VAR_INT.write(buffer, length); + long[] data = new long[length]; + for (int index = 0; index < ChunkSection.SIZE; index++) { + int value = bitsPerBlock == 14 ? chunkSection.getFlatBlock(index) : chunkSection.getPaletteIndex(index); + int bitIndex = index * bitsPerBlock; + int startIndex = bitIndex / 64; + int endIndex = ((index + 1) * bitsPerBlock - 1) / 64; + int startBitSubIndex = bitIndex % 64; + data[startIndex] = data[startIndex] & ~(maxEntryValue << startBitSubIndex) | ((long) value & maxEntryValue) << startBitSubIndex; + if (startIndex != endIndex) { + int endBitSubIndex = 64 - startBitSubIndex; + data[endIndex] = data[endIndex] >>> endBitSubIndex << endBitSubIndex | ((long) value & maxEntryValue) >> endBitSubIndex; + } + } + for (long l : data) { + buffer.writeLong(l); + } + } } diff --git a/common/src/main/java/us/myles/ViaVersion/api/type/types/version/ChunkSectionType1_8.java b/common/src/main/java/us/myles/ViaVersion/api/type/types/version/ChunkSectionType1_8.java index 66de27a4a..f930361ac 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/type/types/version/ChunkSectionType1_8.java +++ b/common/src/main/java/us/myles/ViaVersion/api/type/types/version/ChunkSectionType1_8.java @@ -12,32 +12,32 @@ import java.util.List; public class ChunkSectionType1_8 extends Type { - public ChunkSectionType1_8() { - super("Chunk Section Type", ChunkSection.class); - } + public ChunkSectionType1_8() { + super("Chunk Section Type", ChunkSection.class); + } - @Override - public ChunkSection read(ByteBuf buffer) throws Exception { - ChunkSection chunkSection = new ChunkSection(); - List palette = chunkSection.getPalette(); - palette.clear(); + @Override + public ChunkSection read(ByteBuf buffer) throws Exception { + ChunkSection chunkSection = new ChunkSection(); + List palette = chunkSection.getPalette(); + palette.clear(); - byte[] blockData = new byte[ChunkSection.SIZE * 2]; - buffer.readBytes(blockData); - ShortBuffer blockBuf = ByteBuffer.wrap(blockData).order(ByteOrder.LITTLE_ENDIAN).asShortBuffer(); + byte[] blockData = new byte[ChunkSection.SIZE * 2]; + buffer.readBytes(blockData); + ShortBuffer blockBuf = ByteBuffer.wrap(blockData).order(ByteOrder.LITTLE_ENDIAN).asShortBuffer(); - for (int i = 0; i < ChunkSection.SIZE; i++) { - int mask = blockBuf.get(); - int type = mask >> 4; - int data = mask & 0xF; - chunkSection.setBlock(i, type, data); - } + for (int i = 0; i < ChunkSection.SIZE; i++) { + int mask = blockBuf.get(); + int type = mask >> 4; + int data = mask & 0xF; + chunkSection.setBlock(i, type, data); + } - return chunkSection; - } + return chunkSection; + } - @Override - public void write(ByteBuf buffer, ChunkSection chunkSection) throws Exception { - throw new NotImplementedException(); - } + @Override + public void write(ByteBuf buffer, ChunkSection chunkSection) throws Exception { + throw new NotImplementedException(); + } } diff --git a/common/src/main/java/us/myles/ViaVersion/api/type/types/version/ChunkSectionType1_9.java b/common/src/main/java/us/myles/ViaVersion/api/type/types/version/ChunkSectionType1_9.java index 98d6b3b4d..bf9635f8c 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/type/types/version/ChunkSectionType1_9.java +++ b/common/src/main/java/us/myles/ViaVersion/api/type/types/version/ChunkSectionType1_9.java @@ -8,103 +8,103 @@ import java.util.List; public class ChunkSectionType1_9 extends Type { - public ChunkSectionType1_9() { - super("Chunk Section Type", ChunkSection.class); - } + public ChunkSectionType1_9() { + super("Chunk Section Type", ChunkSection.class); + } - @Override - public ChunkSection read(ByteBuf buffer) throws Exception { - ChunkSection chunkSection = new ChunkSection(); - List palette = chunkSection.getPalette(); - palette.clear(); + @Override + public ChunkSection read(ByteBuf buffer) throws Exception { + ChunkSection chunkSection = new ChunkSection(); + List palette = chunkSection.getPalette(); + palette.clear(); - // Reaad bits per block - int bitsPerBlock = buffer.readUnsignedByte(); - long maxEntryValue = (1L << bitsPerBlock) - 1; + // Reaad bits per block + int bitsPerBlock = buffer.readUnsignedByte(); + long maxEntryValue = (1L << bitsPerBlock) - 1; - if (bitsPerBlock == 0) { - bitsPerBlock = 13; - } - if (bitsPerBlock < 4) { - bitsPerBlock = 4; - } - if (bitsPerBlock > 8) { - bitsPerBlock = 13; - } - int paletteLength = Type.VAR_INT.read(buffer); - // Read palette - for (int i = 0; i < paletteLength; i++) { - if (bitsPerBlock != 13) { - palette.add(Type.VAR_INT.read(buffer)); - } else { - Type.VAR_INT.read(buffer); - } - } + if (bitsPerBlock == 0) { + bitsPerBlock = 13; + } + if (bitsPerBlock < 4) { + bitsPerBlock = 4; + } + if (bitsPerBlock > 8) { + bitsPerBlock = 13; + } + int paletteLength = Type.VAR_INT.read(buffer); + // Read palette + for (int i = 0; i < paletteLength; i++) { + if (bitsPerBlock != 13) { + palette.add(Type.VAR_INT.read(buffer)); + } else { + Type.VAR_INT.read(buffer); + } + } - // Read blocks - long[] blockData = new long[Type.VAR_INT.read(buffer)]; - if (blockData.length > 0) { - for (int i = 0; i < blockData.length; i++) { - blockData[i] = buffer.readLong(); - } - for (int i = 0; i < ChunkSection.SIZE; i++) { - int bitIndex = i * bitsPerBlock; - int startIndex = bitIndex / 64; - int endIndex = ((i + 1) * bitsPerBlock - 1) / 64; - int startBitSubIndex = bitIndex % 64; - int val; - if (startIndex == endIndex) { - val = (int) (blockData[startIndex] >>> startBitSubIndex & maxEntryValue); - } else { - int endBitSubIndex = 64 - startBitSubIndex; - val = (int) ((blockData[startIndex] >>> startBitSubIndex | blockData[endIndex] << endBitSubIndex) & maxEntryValue); - } + // Read blocks + long[] blockData = new long[Type.VAR_INT.read(buffer)]; + if (blockData.length > 0) { + for (int i = 0; i < blockData.length; i++) { + blockData[i] = buffer.readLong(); + } + for (int i = 0; i < ChunkSection.SIZE; i++) { + int bitIndex = i * bitsPerBlock; + int startIndex = bitIndex / 64; + int endIndex = ((i + 1) * bitsPerBlock - 1) / 64; + int startBitSubIndex = bitIndex % 64; + int val; + if (startIndex == endIndex) { + val = (int) (blockData[startIndex] >>> startBitSubIndex & maxEntryValue); + } else { + int endBitSubIndex = 64 - startBitSubIndex; + val = (int) ((blockData[startIndex] >>> startBitSubIndex | blockData[endIndex] << endBitSubIndex) & maxEntryValue); + } - if (bitsPerBlock == 13) { - chunkSection.setBlock(i, val >> 4, val & 0xF); - } else { - chunkSection.setPaletteIndex(i, val); - } - } - } + if (bitsPerBlock == 13) { + chunkSection.setBlock(i, val >> 4, val & 0xF); + } else { + chunkSection.setPaletteIndex(i, val); + } + } + } - return chunkSection; - } + return chunkSection; + } - @Override - public void write(ByteBuf buffer, ChunkSection chunkSection) throws Exception { - List palette = chunkSection.getPalette(); + @Override + public void write(ByteBuf buffer, ChunkSection chunkSection) throws Exception { + List palette = chunkSection.getPalette(); - int bitsPerBlock = 4; - while (palette.size() > 1 << bitsPerBlock) { - bitsPerBlock += 1; - } - long maxEntryValue = (1L << bitsPerBlock) - 1; - buffer.writeByte(bitsPerBlock); + int bitsPerBlock = 4; + while (palette.size() > 1 << bitsPerBlock) { + bitsPerBlock += 1; + } + long maxEntryValue = (1L << bitsPerBlock) - 1; + buffer.writeByte(bitsPerBlock); - // Write pallet - Type.VAR_INT.write(buffer, palette.size()); - for (int mappedId : palette) { - Type.VAR_INT.write(buffer, mappedId); - } + // Write pallet + Type.VAR_INT.write(buffer, palette.size()); + for (int mappedId : palette) { + Type.VAR_INT.write(buffer, mappedId); + } - int length = (int) Math.ceil(ChunkSection.SIZE * bitsPerBlock / 64.0); - Type.VAR_INT.write(buffer, length); - long[] data = new long[length]; - for (int index = 0; index < ChunkSection.SIZE; index++) { - int value = chunkSection.getPaletteIndex(index); - int bitIndex = index * bitsPerBlock; - int startIndex = bitIndex / 64; - int endIndex = ((index + 1) * bitsPerBlock - 1) / 64; - int startBitSubIndex = bitIndex % 64; - data[startIndex] = data[startIndex] & ~(maxEntryValue << startBitSubIndex) | ((long) value & maxEntryValue) << startBitSubIndex; - if (startIndex != endIndex) { - int endBitSubIndex = 64 - startBitSubIndex; - data[endIndex] = data[endIndex] >>> endBitSubIndex << endBitSubIndex | ((long) value & maxEntryValue) >> endBitSubIndex; - } - } - for (long l : data) { - buffer.writeLong(l); - } - } + int length = (int) Math.ceil(ChunkSection.SIZE * bitsPerBlock / 64.0); + Type.VAR_INT.write(buffer, length); + long[] data = new long[length]; + for (int index = 0; index < ChunkSection.SIZE; index++) { + int value = chunkSection.getPaletteIndex(index); + int bitIndex = index * bitsPerBlock; + int startIndex = bitIndex / 64; + int endIndex = ((index + 1) * bitsPerBlock - 1) / 64; + int startBitSubIndex = bitIndex % 64; + data[startIndex] = data[startIndex] & ~(maxEntryValue << startBitSubIndex) | ((long) value & maxEntryValue) << startBitSubIndex; + if (startIndex != endIndex) { + int endBitSubIndex = 64 - startBitSubIndex; + data[endIndex] = data[endIndex] >>> endBitSubIndex << endBitSubIndex | ((long) value & maxEntryValue) >> endBitSubIndex; + } + } + for (long l : data) { + buffer.writeLong(l); + } + } } diff --git a/common/src/main/java/us/myles/ViaVersion/api/type/types/version/Metadata1_13_2Type.java b/common/src/main/java/us/myles/ViaVersion/api/type/types/version/Metadata1_13_2Type.java index 608547c0f..468ec6b00 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/type/types/version/Metadata1_13_2Type.java +++ b/common/src/main/java/us/myles/ViaVersion/api/type/types/version/Metadata1_13_2Type.java @@ -6,24 +6,24 @@ import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_13_2; import us.myles.ViaVersion.api.type.types.minecraft.MetaTypeTemplate; public class Metadata1_13_2Type extends MetaTypeTemplate { - @Override - public Metadata read(ByteBuf buffer) throws Exception { - short index = buffer.readUnsignedByte(); + @Override + public Metadata read(ByteBuf buffer) throws Exception { + short index = buffer.readUnsignedByte(); - if (index == 0xff) return null; //End of metadata - MetaType1_13_2 type = MetaType1_13_2.byId(buffer.readByte()); + if (index == 0xff) return null; //End of metadata + MetaType1_13_2 type = MetaType1_13_2.byId(buffer.readByte()); - return new Metadata(index, type, type.getType().read(buffer)); - } + return new Metadata(index, type, type.getType().read(buffer)); + } - @Override - public void write(ByteBuf buffer, Metadata object) throws Exception { - if (object == null) { - buffer.writeByte(255); - } else { - buffer.writeByte(object.getId()); - buffer.writeByte(object.getMetaType().getTypeID()); - object.getMetaType().getType().write(buffer, object.getValue()); - } - } + @Override + public void write(ByteBuf buffer, Metadata object) throws Exception { + if (object == null) { + buffer.writeByte(255); + } else { + buffer.writeByte(object.getId()); + buffer.writeByte(object.getMetaType().getTypeID()); + object.getMetaType().getType().write(buffer, object.getValue()); + } + } } diff --git a/common/src/main/java/us/myles/ViaVersion/api/type/types/version/Types1_13_2.java b/common/src/main/java/us/myles/ViaVersion/api/type/types/version/Types1_13_2.java index 0f3a40173..643f2efb2 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/type/types/version/Types1_13_2.java +++ b/common/src/main/java/us/myles/ViaVersion/api/type/types/version/Types1_13_2.java @@ -6,13 +6,13 @@ import us.myles.ViaVersion.api.type.Type; import java.util.List; public class Types1_13_2 { - /** - * Metadata list type for 1.13 - */ - public static final Type> METADATA_LIST = new MetadataList1_13_2Type(); + /** + * Metadata list type for 1.13 + */ + public static final Type> METADATA_LIST = new MetadataList1_13_2Type(); - /** - * Metadata type for 1.13 - */ - public static final Type METADATA = new Metadata1_13_2Type(); + /** + * Metadata type for 1.13 + */ + public static final Type METADATA = new Metadata1_13_2Type(); } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11to1_10/MetadataRewriter.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11to1_10/MetadataRewriter.java index 4e62fd061..224f63dc7 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11to1_10/MetadataRewriter.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11to1_10/MetadataRewriter.java @@ -100,7 +100,7 @@ public class MetadataRewriter { public static void handleMetadata(int entityId, EntityType type, List metadatas, UserConnection connection) { for (Metadata metadata : new ArrayList<>(metadatas)) { try { - if(metadata.getValue() instanceof Item) { + if (metadata.getValue() instanceof Item) { // Apply rewrite EntityIdRewriter.toClientItem((Item) metadata.getValue()); } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/TranslateRewriter.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/TranslateRewriter.java index 4a09752c1..982cb39b7 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/TranslateRewriter.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/TranslateRewriter.java @@ -8,8 +8,8 @@ public class TranslateRewriter { public static boolean toClient(JsonElement element, UserConnection user) { if (element instanceof JsonObject) { JsonObject obj = (JsonObject) element; - if(obj.has("translate")) { - if(obj.get("translate").getAsString().equals("chat.type.achievement")) { + if (obj.has("translate")) { + if (obj.get("translate").getAsString().equals("chat.type.achievement")) { return false; } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/packets/EntityPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/packets/EntityPackets.java index 483d57c12..c4134183b 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/packets/EntityPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/packets/EntityPackets.java @@ -11,8 +11,8 @@ import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.types.version.Types1_13; import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.MetadataRewriter; -import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker; import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13; +import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker; public class EntityPackets { diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/Protocol1_13_2To1_13_1.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/Protocol1_13_2To1_13_1.java index 0bc2d5534..bd01d958c 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/Protocol1_13_2To1_13_1.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/Protocol1_13_2To1_13_1.java @@ -14,69 +14,69 @@ import us.myles.ViaVersion.protocols.protocol1_13_2to1_13_1.packets.WorldPackets import us.myles.ViaVersion.protocols.protocol1_13_2to1_13_1.types.Particle1_13_2Type; public class Protocol1_13_2To1_13_1 extends Protocol { - public static final Particle1_13_2Type PARTICLE_TYPE = new Particle1_13_2Type(); + public static final Particle1_13_2Type PARTICLE_TYPE = new Particle1_13_2Type(); - @Override - protected void registerPackets() { - InventoryPackets.register(this); - WorldPackets.register(this); - EntityPackets.register(this); + @Override + protected void registerPackets() { + InventoryPackets.register(this); + WorldPackets.register(this); + EntityPackets.register(this); - //Edit Book - registerIncoming(State.PLAY, 0x0B, 0x0B, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM); - map(Type.BOOLEAN); - } - }); + //Edit Book + registerIncoming(State.PLAY, 0x0B, 0x0B, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM); + map(Type.BOOLEAN); + } + }); - // Advancements - registerOutgoing(State.PLAY, 0x51, 0x51, new PacketRemapper() { - @Override - public void registerMap() { - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - wrapper.passthrough(Type.BOOLEAN); // Reset/clear - int size = wrapper.passthrough(Type.VAR_INT); // Mapping size + // Advancements + registerOutgoing(State.PLAY, 0x51, 0x51, new PacketRemapper() { + @Override + public void registerMap() { + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + wrapper.passthrough(Type.BOOLEAN); // Reset/clear + int size = wrapper.passthrough(Type.VAR_INT); // Mapping size - for (int i = 0; i < size; i++) { - wrapper.passthrough(Type.STRING); // Identifier + for (int i = 0; i < size; i++) { + wrapper.passthrough(Type.STRING); // Identifier - // Parent - if (wrapper.passthrough(Type.BOOLEAN)) - wrapper.passthrough(Type.STRING); + // Parent + if (wrapper.passthrough(Type.BOOLEAN)) + wrapper.passthrough(Type.STRING); - // Display data - if (wrapper.passthrough(Type.BOOLEAN)) { - wrapper.passthrough(Type.STRING); // Title - wrapper.passthrough(Type.STRING); // Description - Item icon = wrapper.read(Type.FLAT_ITEM); - wrapper.write(Type.FLAT_VAR_INT_ITEM, icon); - wrapper.passthrough(Type.VAR_INT); // Frame type - int flags = wrapper.passthrough(Type.INT); // Flags - if ((flags & 1) != 0) - wrapper.passthrough(Type.STRING); // Background texture - wrapper.passthrough(Type.FLOAT); // X - wrapper.passthrough(Type.FLOAT); // Y - } + // Display data + if (wrapper.passthrough(Type.BOOLEAN)) { + wrapper.passthrough(Type.STRING); // Title + wrapper.passthrough(Type.STRING); // Description + Item icon = wrapper.read(Type.FLAT_ITEM); + wrapper.write(Type.FLAT_VAR_INT_ITEM, icon); + wrapper.passthrough(Type.VAR_INT); // Frame type + int flags = wrapper.passthrough(Type.INT); // Flags + if ((flags & 1) != 0) + wrapper.passthrough(Type.STRING); // Background texture + wrapper.passthrough(Type.FLOAT); // X + wrapper.passthrough(Type.FLOAT); // Y + } - wrapper.passthrough(Type.STRING_ARRAY); // Criteria + wrapper.passthrough(Type.STRING_ARRAY); // Criteria - int arrayLength = wrapper.passthrough(Type.VAR_INT); - for (int array = 0; array < arrayLength; array++) { - wrapper.passthrough(Type.STRING_ARRAY); // String array - } - } - } - }); - } - }); - } + int arrayLength = wrapper.passthrough(Type.VAR_INT); + for (int array = 0; array < arrayLength; array++) { + wrapper.passthrough(Type.STRING_ARRAY); // String array + } + } + } + }); + } + }); + } - @Override - public void init(UserConnection userConnection) { + @Override + public void init(UserConnection userConnection) { - } + } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/packets/EntityPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/packets/EntityPackets.java index 5076c268f..b44b505c6 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/packets/EntityPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/packets/EntityPackets.java @@ -14,84 +14,84 @@ import us.myles.ViaVersion.packets.State; public class EntityPackets { - public static void register(Protocol protocol) { - // Spawn mob packet - protocol.registerOutgoing(State.PLAY, 0x3, 0x3, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.UUID); // 1 - Entity UUID - map(Type.VAR_INT); // 2 - Entity Type - map(Type.DOUBLE); // 3 - X - map(Type.DOUBLE); // 4 - Y - map(Type.DOUBLE); // 5 - Z - map(Type.BYTE); // 6 - Yaw - map(Type.BYTE); // 7 - Pitch - map(Type.BYTE); // 8 - Head Pitch - map(Type.SHORT); // 9 - Velocity X - map(Type.SHORT); // 10 - Velocity Y - map(Type.SHORT); // 11 - Velocity Z - map(Types1_13.METADATA_LIST, Types1_13_2.METADATA_LIST); // 12 - Metadata + public static void register(Protocol protocol) { + // Spawn mob packet + protocol.registerOutgoing(State.PLAY, 0x3, 0x3, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // 0 - Entity ID + map(Type.UUID); // 1 - Entity UUID + map(Type.VAR_INT); // 2 - Entity Type + map(Type.DOUBLE); // 3 - X + map(Type.DOUBLE); // 4 - Y + map(Type.DOUBLE); // 5 - Z + map(Type.BYTE); // 6 - Yaw + map(Type.BYTE); // 7 - Pitch + map(Type.BYTE); // 8 - Head Pitch + map(Type.SHORT); // 9 - Velocity X + map(Type.SHORT); // 10 - Velocity Y + map(Type.SHORT); // 11 - Velocity Z + map(Types1_13.METADATA_LIST, Types1_13_2.METADATA_LIST); // 12 - Metadata - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - for (Metadata metadata : wrapper.get(Types1_13_2.METADATA_LIST, 0)) { - if (metadata.getMetaType() == MetaType1_13.Slot) { - metadata.setMetaType(MetaType1_13_2.Slot); - } - } - } - }); - } - }); + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + for (Metadata metadata : wrapper.get(Types1_13_2.METADATA_LIST, 0)) { + if (metadata.getMetaType() == MetaType1_13.Slot) { + metadata.setMetaType(MetaType1_13_2.Slot); + } + } + } + }); + } + }); - // Spawn player packet - protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.UUID); // 1 - Player UUID - map(Type.DOUBLE); // 2 - X - map(Type.DOUBLE); // 3 - Y - map(Type.DOUBLE); // 4 - Z - map(Type.BYTE); // 5 - Yaw - map(Type.BYTE); // 6 - Pitch - map(Types1_13.METADATA_LIST, Types1_13_2.METADATA_LIST); // 7 - Metadata + // Spawn player packet + protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // 0 - Entity ID + map(Type.UUID); // 1 - Player UUID + map(Type.DOUBLE); // 2 - X + map(Type.DOUBLE); // 3 - Y + map(Type.DOUBLE); // 4 - Z + map(Type.BYTE); // 5 - Yaw + map(Type.BYTE); // 6 - Pitch + map(Types1_13.METADATA_LIST, Types1_13_2.METADATA_LIST); // 7 - Metadata - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - for (Metadata metadata : wrapper.get(Types1_13_2.METADATA_LIST, 0)) { - if (metadata.getMetaType() == MetaType1_13.Slot) { - metadata.setMetaType(MetaType1_13_2.Slot); - } - } - } - }); - } - }); + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + for (Metadata metadata : wrapper.get(Types1_13_2.METADATA_LIST, 0)) { + if (metadata.getMetaType() == MetaType1_13.Slot) { + metadata.setMetaType(MetaType1_13_2.Slot); + } + } + } + }); + } + }); - // Metadata packet - protocol.registerOutgoing(State.PLAY, 0x3F, 0x3F, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT); // 0 - Entity ID - map(Types1_13.METADATA_LIST, Types1_13_2.METADATA_LIST); // 1 - Metadata list + // Metadata packet + protocol.registerOutgoing(State.PLAY, 0x3F, 0x3F, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // 0 - Entity ID + map(Types1_13.METADATA_LIST, Types1_13_2.METADATA_LIST); // 1 - Metadata list - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - for (Metadata metadata : wrapper.get(Types1_13_2.METADATA_LIST, 0)) { - if (metadata.getMetaType() == MetaType1_13.Slot) { - metadata.setMetaType(MetaType1_13_2.Slot); - } - } - } - }); - } - }); - } + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + for (Metadata metadata : wrapper.get(Types1_13_2.METADATA_LIST, 0)) { + if (metadata.getMetaType() == MetaType1_13.Slot) { + metadata.setMetaType(MetaType1_13_2.Slot); + } + } + } + }); + } + }); + } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/packets/InventoryPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/packets/InventoryPackets.java index faa866127..6ea931ea8 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/packets/InventoryPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/packets/InventoryPackets.java @@ -9,143 +9,143 @@ import us.myles.ViaVersion.packets.State; public class InventoryPackets { - public static void register(Protocol protocol) { + public static void register(Protocol protocol) { /* Outgoing packets */ - // Set slot packet - protocol.registerOutgoing(State.PLAY, 0x17, 0x17, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.BYTE); // 0 - Window ID - map(Type.SHORT); // 1 - Slot ID - map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM); // 2 - Slot Value - } - }); + // Set slot packet + protocol.registerOutgoing(State.PLAY, 0x17, 0x17, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.BYTE); // 0 - Window ID + map(Type.SHORT); // 1 - Slot ID + map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM); // 2 - Slot Value + } + }); - // Window items packet - protocol.registerOutgoing(State.PLAY, 0x15, 0x15, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.UNSIGNED_BYTE); // 0 - Window ID - map(Type.FLAT_ITEM_ARRAY, Type.FLAT_VAR_INT_ITEM_ARRAY); // 1 - Window Values - } - }); + // Window items packet + protocol.registerOutgoing(State.PLAY, 0x15, 0x15, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.UNSIGNED_BYTE); // 0 - Window ID + map(Type.FLAT_ITEM_ARRAY, Type.FLAT_VAR_INT_ITEM_ARRAY); // 1 - Window Values + } + }); - // Plugin message - protocol.registerOutgoing(State.PLAY, 0x19, 0x19, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.STRING); // Channel - handler(new PacketHandler() { - @Override - 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.passthrough(Type.INT); // Passthrough Window ID + // Plugin message + protocol.registerOutgoing(State.PLAY, 0x19, 0x19, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.STRING); // Channel + handler(new PacketHandler() { + @Override + 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.passthrough(Type.INT); // Passthrough Window ID - int size = wrapper.passthrough(Type.UNSIGNED_BYTE); - for (int i = 0; i < size; i++) { - // Input Item - wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM)); - // Output Item - wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM)); + int size = wrapper.passthrough(Type.UNSIGNED_BYTE); + for (int i = 0; i < size; i++) { + // Input Item + wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM)); + // Output Item + wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM)); - boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item - if (secondItem) { - wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM)); - } + boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item + if (secondItem) { + wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM)); + } - wrapper.passthrough(Type.BOOLEAN); // Trade disabled - wrapper.passthrough(Type.INT); // Number of tools uses - wrapper.passthrough(Type.INT); // Maximum number of trade uses - } - } - } - }); - } - }); + wrapper.passthrough(Type.BOOLEAN); // Trade disabled + wrapper.passthrough(Type.INT); // Number of tools uses + wrapper.passthrough(Type.INT); // Maximum number of trade uses + } + } + } + }); + } + }); - // Entity Equipment Packet - protocol.registerOutgoing(State.PLAY, 0x42, 0x42, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.VAR_INT); // 1 - Slot ID - map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM); // 2 - Item - } - }); + // Entity Equipment Packet + protocol.registerOutgoing(State.PLAY, 0x42, 0x42, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // 0 - Entity ID + map(Type.VAR_INT); // 1 - Slot ID + map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM); // 2 - Item + } + }); - // Declare Recipes - protocol.registerOutgoing(State.PLAY, 0x54, 0x54, new PacketRemapper() { - @Override - public void registerMap() { - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - int recipesNo = wrapper.passthrough(Type.VAR_INT); - for (int i = 0; i < recipesNo; i++) { - wrapper.passthrough(Type.STRING); // Id - String type = wrapper.passthrough(Type.STRING); - if (type.equals("crafting_shapeless")) { - wrapper.passthrough(Type.STRING); // Group - int ingredientsNo = wrapper.passthrough(Type.VAR_INT); - for (int i1 = 0; i1 < ingredientsNo; i1++) { - wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, wrapper.read(Type.FLAT_ITEM_ARRAY_VAR_INT)); - } - wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM)); - } else if (type.equals("crafting_shaped")) { - int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT); - wrapper.passthrough(Type.STRING); // Group - for (int i1 = 0; i1 < ingredientsNo; i1++) { - wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, wrapper.read(Type.FLAT_ITEM_ARRAY_VAR_INT)); - } - wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM)); - } else if (type.equals("smelting")) { - wrapper.passthrough(Type.STRING); // Group - // Ingredient start - wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, wrapper.read(Type.FLAT_ITEM_ARRAY_VAR_INT)); - // Ingredient end - wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM)); - wrapper.passthrough(Type.FLOAT); // EXP - wrapper.passthrough(Type.VAR_INT); // Cooking time - } - } - } - }); - } - }); + // Declare Recipes + protocol.registerOutgoing(State.PLAY, 0x54, 0x54, new PacketRemapper() { + @Override + public void registerMap() { + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int recipesNo = wrapper.passthrough(Type.VAR_INT); + for (int i = 0; i < recipesNo; i++) { + wrapper.passthrough(Type.STRING); // Id + String type = wrapper.passthrough(Type.STRING); + if (type.equals("crafting_shapeless")) { + wrapper.passthrough(Type.STRING); // Group + int ingredientsNo = wrapper.passthrough(Type.VAR_INT); + for (int i1 = 0; i1 < ingredientsNo; i1++) { + wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, wrapper.read(Type.FLAT_ITEM_ARRAY_VAR_INT)); + } + wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM)); + } else if (type.equals("crafting_shaped")) { + int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT); + wrapper.passthrough(Type.STRING); // Group + for (int i1 = 0; i1 < ingredientsNo; i1++) { + wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, wrapper.read(Type.FLAT_ITEM_ARRAY_VAR_INT)); + } + wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM)); + } else if (type.equals("smelting")) { + wrapper.passthrough(Type.STRING); // Group + // Ingredient start + wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, wrapper.read(Type.FLAT_ITEM_ARRAY_VAR_INT)); + // Ingredient end + wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM)); + wrapper.passthrough(Type.FLOAT); // EXP + wrapper.passthrough(Type.VAR_INT); // Cooking time + } + } + } + }); + } + }); /* Incoming packets */ - // Click window packet - protocol.registerIncoming(State.PLAY, 0x08, 0x08, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.UNSIGNED_BYTE); // 0 - Window ID - map(Type.SHORT); // 1 - Slot - map(Type.BYTE); // 2 - Button - map(Type.SHORT); // 3 - Action number - map(Type.VAR_INT); // 4 - Mode - map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM); // 5 - Clicked Item - } - } - ); + // Click window packet + protocol.registerIncoming(State.PLAY, 0x08, 0x08, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.UNSIGNED_BYTE); // 0 - Window ID + map(Type.SHORT); // 1 - Slot + map(Type.BYTE); // 2 - Button + map(Type.SHORT); // 3 - Action number + map(Type.VAR_INT); // 4 - Mode + map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM); // 5 - Clicked Item + } + } + ); - // Creative Inventory Action - protocol.registerIncoming(State.PLAY, 0x24, 0x24, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.SHORT); // 0 - Slot - map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM); // 1 - Clicked Item - } - } - ); - } + // Creative Inventory Action + protocol.registerIncoming(State.PLAY, 0x24, 0x24, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.SHORT); // 0 - Slot + map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM); // 1 - Clicked Item + } + } + ); + } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/packets/WorldPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/packets/WorldPackets.java index b62319af7..cdbe42151 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/packets/WorldPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/packets/WorldPackets.java @@ -9,32 +9,32 @@ import us.myles.ViaVersion.packets.State; public class WorldPackets { - public static void register(Protocol protocol) { - //spawn particle - protocol.registerOutgoing(State.PLAY, 0x24, 0x24, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.INT); // 0 - Particle ID - map(Type.BOOLEAN); // 1 - Long Distance - map(Type.FLOAT); // 2 - X - map(Type.FLOAT); // 3 - Y - map(Type.FLOAT); // 4 - Z - map(Type.FLOAT); // 5 - Offset X - map(Type.FLOAT); // 6 - Offset Y - map(Type.FLOAT); // 7 - Offset Z - map(Type.FLOAT); // 8 - Particle Data - map(Type.INT); // 9 - Particle Count - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - int id = wrapper.get(Type.INT, 0); - if (id == 27) { - wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM)); - } - } - }); - } - }); - } + public static void register(Protocol protocol) { + //spawn particle + protocol.registerOutgoing(State.PLAY, 0x24, 0x24, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.INT); // 0 - Particle ID + map(Type.BOOLEAN); // 1 - Long Distance + map(Type.FLOAT); // 2 - X + map(Type.FLOAT); // 3 - Y + map(Type.FLOAT); // 4 - Z + map(Type.FLOAT); // 5 - Offset X + map(Type.FLOAT); // 6 - Offset Y + map(Type.FLOAT); // 7 - Offset Z + map(Type.FLOAT); // 8 - Particle Data + map(Type.INT); // 9 - Particle Count + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int id = wrapper.get(Type.INT, 0); + if (id == 27) { + wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM)); + } + } + }); + } + }); + } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java index f775508d5..ca501ec8f 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java @@ -97,27 +97,25 @@ public class Protocol1_13To1_12_2 extends Protocol { } }; - // @formatter:off // These are arbitrary rewrite values, it just needs an invalid color code character. protected static EnumMap SCOREBOARD_TEAM_NAME_REWRITE = new EnumMap(ChatColor.class) {{ - put(ChatColor.BLACK, ChatColor.COLOR_CHAR + "g"); - put(ChatColor.DARK_BLUE, ChatColor.COLOR_CHAR + "h"); - put(ChatColor.DARK_GREEN, ChatColor.COLOR_CHAR + "i"); - put(ChatColor.DARK_AQUA, ChatColor.COLOR_CHAR + "j"); - put(ChatColor.DARK_RED, ChatColor.COLOR_CHAR + "p"); - put(ChatColor.DARK_PURPLE, ChatColor.COLOR_CHAR + "q"); - put(ChatColor.GOLD, ChatColor.COLOR_CHAR + "s"); - put(ChatColor.GRAY, ChatColor.COLOR_CHAR + "t"); - put(ChatColor.DARK_GRAY, ChatColor.COLOR_CHAR + "u"); - put(ChatColor.BLUE, ChatColor.COLOR_CHAR + "v"); - put(ChatColor.GREEN, ChatColor.COLOR_CHAR + "w"); - put(ChatColor.AQUA, ChatColor.COLOR_CHAR + "x"); - put(ChatColor.RED, ChatColor.COLOR_CHAR + "y"); + put(ChatColor.BLACK, ChatColor.COLOR_CHAR + "g"); + put(ChatColor.DARK_BLUE, ChatColor.COLOR_CHAR + "h"); + put(ChatColor.DARK_GREEN, ChatColor.COLOR_CHAR + "i"); + put(ChatColor.DARK_AQUA, ChatColor.COLOR_CHAR + "j"); + put(ChatColor.DARK_RED, ChatColor.COLOR_CHAR + "p"); + put(ChatColor.DARK_PURPLE, ChatColor.COLOR_CHAR + "q"); + put(ChatColor.GOLD, ChatColor.COLOR_CHAR + "s"); + put(ChatColor.GRAY, ChatColor.COLOR_CHAR + "t"); + put(ChatColor.DARK_GRAY, ChatColor.COLOR_CHAR + "u"); + put(ChatColor.BLUE, ChatColor.COLOR_CHAR + "v"); + put(ChatColor.GREEN, ChatColor.COLOR_CHAR + "w"); + put(ChatColor.AQUA, ChatColor.COLOR_CHAR + "x"); + put(ChatColor.RED, ChatColor.COLOR_CHAR + "y"); put(ChatColor.LIGHT_PURPLE, ChatColor.COLOR_CHAR + "z"); - put(ChatColor.YELLOW, ChatColor.COLOR_CHAR + "!"); - put(ChatColor.WHITE, ChatColor.COLOR_CHAR + "?"); + put(ChatColor.YELLOW, ChatColor.COLOR_CHAR + "!"); + put(ChatColor.WHITE, ChatColor.COLOR_CHAR + "?"); }}; - // @formatter:on static { MappingData.init(); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/EntityTypeRewriter.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/EntityTypeRewriter.java index 8fe62e6db..0a2c17518 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/EntityTypeRewriter.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/EntityTypeRewriter.java @@ -6,97 +6,93 @@ import com.google.common.base.Optional; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -// Constant type changes to stop depending on names (the EntityTypes1_13 will be auto-generated so some fields can be obfuscated) public class EntityTypeRewriter { private static Map entityTypes = new ConcurrentHashMap<>(); static { - // Generated by codename Bevet - - // Entities 1.12 -> 18w15a - regEnt(1, 32); // item - ajl - regEnt(2, 22); // xp_orb - abx - regEnt(3, 0); // area_effect_cloud - abp - regEnt(4, 15); // elder_guardian - aju - regEnt(5, 84); // wither_skeleton - aku - regEnt(6, 71); // stray - akq - regEnt(7, 74); // egg - alz - regEnt(8, 35); // leash_knot - ajb - regEnt(9, 49); // painting - ajd - regEnt(10, 2); // arrow - all - regEnt(11, 67); // snowball - alw - regEnt(12, 34); // fireball - alq - regEnt(13, 65); // small_fireball - alv - regEnt(14, 75); // ender_pearl - ama - regEnt(15, 23); // eye_of_ender_signal - alo - regEnt(16, 77); // potion - amc - regEnt(17, 76); // xp_bottle - amb - regEnt(18, 33); // item_frame - aja - regEnt(19, 85); // wither_skull - ame - regEnt(20, 55); // tnt - ajm - regEnt(21, 24); // falling_block - ajk - regEnt(22, 25); // fireworks_rocket - alp - regEnt(23, 30); // husk - akc - regEnt(24, 68); // spectral_arrow - alx - regEnt(25, 60); // shulker_bullet - alu - regEnt(26, 13); // dragon_fireball - alm - regEnt(27, 89); // zombie_villager - akw - regEnt(28, 63); // skeleton_horse - aht - regEnt(29, 88); // zombie_horse - ahv - regEnt(30, 1); // armor_stand - aiy - regEnt(31, 11); // donkey - aho - regEnt(32, 46); // mule - ahs - regEnt(33, 20); // evocation_fangs - aln - regEnt(34, 21); // evocation_illager - ajy - regEnt(35, 78); // vex - akr - regEnt(36, 81); // vindication_illager - aks - regEnt(37, 31); // illusion_illager - akd - regEnt(40, 41); // commandblock_minecart - aml - regEnt(41, 5); // boat - ami - regEnt(42, 39); // minecart - amj - regEnt(43, 40); // chest_minecart - amk - regEnt(44, 42); // furnace_minecart - amm - regEnt(45, 45); // tnt_minecart - amp - regEnt(46, 43); // hopper_minecart - amn - regEnt(47, 44); // spawner_minecart - amo - regEnt(50, 10); // creeper - ajs - regEnt(51, 62); // skeleton - akm - regEnt(52, 69); // spider - akp - regEnt(53, 27); // giant - aka - regEnt(54, 87); // zombie - akv - regEnt(55, 64); // slime - akn - regEnt(56, 26); // ghast - ajz - regEnt(57, 53); // zombie_pigman - akh - regEnt(58, 18); // enderman - ajv - regEnt(59, 6); // cave_spider - ajr - regEnt(60, 61); // silverfish - akl - regEnt(61, 4); // blaze - ajq - regEnt(62, 38); // magma_cube - ake - regEnt(63, 17); // ender_dragon - aic - regEnt(64, 83); // wither - aiw - regEnt(65, 3); // bat - agl - regEnt(66, 82); // witch - akt - regEnt(67, 19); // endermite - ajw - regEnt(68, 28); // guardian - akb - regEnt(69, 59); // shulker - akk - regEnt(200, 16); // ender_crystal - aib - regEnt(90, 51); // pig - agy - regEnt(91, 58); // sheep - ahd - regEnt(92, 9); // cow - ags - regEnt(93, 7); // chicken - agq - regEnt(94, 70); // squid - ahg - regEnt(95, 86); // wolf - ahl - regEnt(96, 47); // mooshroom - agv - regEnt(97, 66); // snowman - ahf - regEnt(98, 48); // ocelot - agw - regEnt(99, 80); // villager_golem - ahj - regEnt(100, 29); // horse - ahp - regEnt(101, 56); // rabbit - ahb - regEnt(102, 54); // polar_bear - agz - regEnt(103, 36); // llama - ahr - regEnt(104, 37); // llama_spit - alr - regEnt(105, 50); // parrot - agx - regEnt(120, 79); // villager - ala + registerEntity(1, 32); // item - ajl + registerEntity(2, 22); // xp_orb - abx + registerEntity(3, 0); // area_effect_cloud - abp + registerEntity(4, 15); // elder_guardian - aju + registerEntity(5, 84); // wither_skeleton - aku + registerEntity(6, 71); // stray - akq + registerEntity(7, 74); // egg - alz + registerEntity(8, 35); // leash_knot - ajb + registerEntity(9, 49); // painting - ajd + registerEntity(10, 2); // arrow - all + registerEntity(11, 67); // snowball - alw + registerEntity(12, 34); // fireball - alq + registerEntity(13, 65); // small_fireball - alv + registerEntity(14, 75); // ender_pearl - ama + registerEntity(15, 23); // eye_of_ender_signal - alo + registerEntity(16, 77); // potion - amc + registerEntity(17, 76); // xp_bottle - amb + registerEntity(18, 33); // item_frame - aja + registerEntity(19, 85); // wither_skull - ame + registerEntity(20, 55); // tnt - ajm + registerEntity(21, 24); // falling_block - ajk + registerEntity(22, 25); // fireworks_rocket - alp + registerEntity(23, 30); // husk - akc + registerEntity(24, 68); // spectral_arrow - alx + registerEntity(25, 60); // shulker_bullet - alu + registerEntity(26, 13); // dragon_fireball - alm + registerEntity(27, 89); // zombie_villager - akw + registerEntity(28, 63); // skeleton_horse - aht + registerEntity(29, 88); // zombie_horse - ahv + registerEntity(30, 1); // armor_stand - aiy + registerEntity(31, 11); // donkey - aho + registerEntity(32, 46); // mule - ahs + registerEntity(33, 20); // evocation_fangs - aln + registerEntity(34, 21); // evocation_illager - ajy + registerEntity(35, 78); // vex - akr + registerEntity(36, 81); // vindication_illager - aks + registerEntity(37, 31); // illusion_illager - akd + registerEntity(40, 41); // commandblock_minecart - aml + registerEntity(41, 5); // boat - ami + registerEntity(42, 39); // minecart - amj + registerEntity(43, 40); // chest_minecart - amk + registerEntity(44, 42); // furnace_minecart - amm + registerEntity(45, 45); // tnt_minecart - amp + registerEntity(46, 43); // hopper_minecart - amn + registerEntity(47, 44); // spawner_minecart - amo + registerEntity(50, 10); // creeper - ajs + registerEntity(51, 62); // skeleton - akm + registerEntity(52, 69); // spider - akp + registerEntity(53, 27); // giant - aka + registerEntity(54, 87); // zombie - akv + registerEntity(55, 64); // slime - akn + registerEntity(56, 26); // ghast - ajz + registerEntity(57, 53); // zombie_pigman - akh + registerEntity(58, 18); // enderman - ajv + registerEntity(59, 6); // cave_spider - ajr + registerEntity(60, 61); // silverfish - akl + registerEntity(61, 4); // blaze - ajq + registerEntity(62, 38); // magma_cube - ake + registerEntity(63, 17); // ender_dragon - aic + registerEntity(64, 83); // wither - aiw + registerEntity(65, 3); // bat - agl + registerEntity(66, 82); // witch - akt + registerEntity(67, 19); // endermite - ajw + registerEntity(68, 28); // guardian - akb + registerEntity(69, 59); // shulker - akk + registerEntity(200, 16); // ender_crystal - aib + registerEntity(90, 51); // pig - agy + registerEntity(91, 58); // sheep - ahd + registerEntity(92, 9); // cow - ags + registerEntity(93, 7); // chicken - agq + registerEntity(94, 70); // squid - ahg + registerEntity(95, 86); // wolf - ahl + registerEntity(96, 47); // mooshroom - agv + registerEntity(97, 66); // snowman - ahf + registerEntity(98, 48); // ocelot - agw + registerEntity(99, 80); // villager_golem - ahj + registerEntity(100, 29); // horse - ahp + registerEntity(101, 56); // rabbit - ahb + registerEntity(102, 54); // polar_bear - agz + registerEntity(103, 36); // llama - ahr + registerEntity(104, 37); // llama_spit - alr + registerEntity(105, 50); // parrot - agx + registerEntity(120, 79); // villager - ala // OBJECTS @@ -104,7 +100,7 @@ public class EntityTypeRewriter { } - private static void regEnt(int type1_12, int type1_13) { + private static void registerEntity(int type1_12, int type1_13) { entityTypes.put(type1_12, type1_13); } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/types/Chunk1_13Type.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/types/Chunk1_13Type.java index 3d4e40154..7b5d72100 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/types/Chunk1_13Type.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/types/Chunk1_13Type.java @@ -56,7 +56,7 @@ public class Chunk1_13Type extends PartialType { if (groundUp) { for (int i = 0; i < 256; i++) { // todo use int in Chunk? - biomeData[i] = (byte) input.readInt();; + biomeData[i] = (byte) input.readInt(); } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/MetadataRewriter.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/MetadataRewriter.java index 18a865c35..3c99f5e16 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/MetadataRewriter.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/MetadataRewriter.java @@ -13,32 +13,32 @@ import java.util.List; public class MetadataRewriter { - public static void handleMetadata(int entityId, Entity1_14Types.EntityType type, List metadatas, UserConnection connection) { - for (Metadata metadata : new ArrayList<>(metadatas)) { - try { - // 1.13 changed item to flat item (no data) - if (metadata.getMetaType() == MetaType1_13_2.Slot) { - InventoryPackets.toClient((Item) metadata.getValue()); - } else if (metadata.getMetaType() == MetaType1_13_2.BlockID) { - // Convert to new block id - int data = (int) metadata.getValue(); - metadata.setValue(Protocol1_14To1_13_2.getNewBlockStateId(data)); - } - if (type == null) continue; - if (type.isOrHasParent(Entity1_14Types.EntityType.MINECART_ABSTRACT) && metadata.getId() == 9) { - // New block format - int data = (int) metadata.getValue(); - metadata.setValue(Protocol1_14To1_13_2.getNewBlockStateId(data)); - } - } catch (Exception e) { - metadatas.remove(metadata); - if (!Via.getConfig().isSuppressMetadataErrors() || Via.getManager().isDebug()) { - Via.getPlatform().getLogger().warning("An error occurred with entity metadata handler"); - Via.getPlatform().getLogger().warning("Metadata: " + metadata); - e.printStackTrace(); - } - } - } - } + public static void handleMetadata(int entityId, Entity1_14Types.EntityType type, List metadatas, UserConnection connection) { + for (Metadata metadata : new ArrayList<>(metadatas)) { + try { + // 1.13 changed item to flat item (no data) + if (metadata.getMetaType() == MetaType1_13_2.Slot) { + InventoryPackets.toClient((Item) metadata.getValue()); + } else if (metadata.getMetaType() == MetaType1_13_2.BlockID) { + // Convert to new block id + int data = (int) metadata.getValue(); + metadata.setValue(Protocol1_14To1_13_2.getNewBlockStateId(data)); + } + if (type == null) continue; + if (type.isOrHasParent(Entity1_14Types.EntityType.MINECART_ABSTRACT) && metadata.getId() == 9) { + // New block format + int data = (int) metadata.getValue(); + metadata.setValue(Protocol1_14To1_13_2.getNewBlockStateId(data)); + } + } catch (Exception e) { + metadatas.remove(metadata); + if (!Via.getConfig().isSuppressMetadataErrors() || Via.getManager().isDebug()) { + Via.getPlatform().getLogger().warning("An error occurred with entity metadata handler"); + Via.getPlatform().getLogger().warning("Metadata: " + metadata); + e.printStackTrace(); + } + } + } + } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/Protocol1_14To1_13_2.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/Protocol1_14To1_13_2.java index 0ec12cbd5..1806592ae 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/Protocol1_14To1_13_2.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/Protocol1_14To1_13_2.java @@ -15,271 +15,271 @@ import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.storage.EntityTracker; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; public class Protocol1_14To1_13_2 extends Protocol { - @Override - protected void registerPackets() { - InventoryPackets.register(this); - EntityPackets.register(this); - WorldPackets.register(this); - PlayerPackets.register(this); + @Override + protected void registerPackets() { + InventoryPackets.register(this); + EntityPackets.register(this); + WorldPackets.register(this); + PlayerPackets.register(this); - // Sound Effect - registerOutgoing(State.PLAY, 0x4D, 0x4D, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT); // Sound Id - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - wrapper.set(Type.VAR_INT, 0, getNewSoundId(wrapper.get(Type.VAR_INT, 0))); - } - }); - } - }); - registerOutgoing(State.PLAY, 0x4E, 0x4F); - registerOutgoing(State.PLAY, 0x4F, 0x50); - registerOutgoing(State.PLAY, 0x50, 0x51); + // Sound Effect + registerOutgoing(State.PLAY, 0x4D, 0x4D, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // Sound Id + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + wrapper.set(Type.VAR_INT, 0, getNewSoundId(wrapper.get(Type.VAR_INT, 0))); + } + }); + } + }); + registerOutgoing(State.PLAY, 0x4E, 0x4F); + registerOutgoing(State.PLAY, 0x4F, 0x50); + registerOutgoing(State.PLAY, 0x50, 0x51); - registerOutgoing(State.PLAY, 0x51, 0x52, new PacketRemapper() { - @Override - public void registerMap() { - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - wrapper.passthrough(Type.BOOLEAN); // Reset/clear - int size = wrapper.passthrough(Type.VAR_INT); // Mapping size + registerOutgoing(State.PLAY, 0x51, 0x52, new PacketRemapper() { + @Override + public void registerMap() { + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + wrapper.passthrough(Type.BOOLEAN); // Reset/clear + int size = wrapper.passthrough(Type.VAR_INT); // Mapping size - for (int i = 0; i < size; i++) { - wrapper.passthrough(Type.STRING); // Identifier + for (int i = 0; i < size; i++) { + wrapper.passthrough(Type.STRING); // Identifier - // Parent - if (wrapper.passthrough(Type.BOOLEAN)) - wrapper.passthrough(Type.STRING); + // Parent + if (wrapper.passthrough(Type.BOOLEAN)) + wrapper.passthrough(Type.STRING); - // Display data - if (wrapper.passthrough(Type.BOOLEAN)) { - wrapper.passthrough(Type.STRING); // Title - wrapper.passthrough(Type.STRING); // Description - InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Icon - wrapper.passthrough(Type.VAR_INT); // Frame type - int flags = wrapper.passthrough(Type.INT); // Flags - if ((flags & 1) != 0) - wrapper.passthrough(Type.STRING); // Background texture - wrapper.passthrough(Type.FLOAT); // X - wrapper.passthrough(Type.FLOAT); // Y - } + // Display data + if (wrapper.passthrough(Type.BOOLEAN)) { + wrapper.passthrough(Type.STRING); // Title + wrapper.passthrough(Type.STRING); // Description + InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Icon + wrapper.passthrough(Type.VAR_INT); // Frame type + int flags = wrapper.passthrough(Type.INT); // Flags + if ((flags & 1) != 0) + wrapper.passthrough(Type.STRING); // Background texture + wrapper.passthrough(Type.FLOAT); // X + wrapper.passthrough(Type.FLOAT); // Y + } - wrapper.passthrough(Type.STRING_ARRAY); // Criteria + wrapper.passthrough(Type.STRING_ARRAY); // Criteria - int arrayLength = wrapper.passthrough(Type.VAR_INT); - for (int array = 0; array < arrayLength; array++) { - wrapper.passthrough(Type.STRING_ARRAY); // String array - } - } - } - }); - } - }); + int arrayLength = wrapper.passthrough(Type.VAR_INT); + for (int array = 0; array < arrayLength; array++) { + wrapper.passthrough(Type.STRING_ARRAY); // String array + } + } + } + }); + } + }); + + registerOutgoing(State.PLAY, 0x52, 0x53); + registerOutgoing(State.PLAY, 0x53, 0x54); - registerOutgoing(State.PLAY, 0x52, 0x53); - registerOutgoing(State.PLAY, 0x53, 0x54); + registerOutgoing(State.PLAY, 0x55, 0x56, new PacketRemapper() { + @Override + public void registerMap() { + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int blockTagsSize = wrapper.passthrough(Type.VAR_INT); // block tags + for (int i = 0; i < blockTagsSize; i++) { + wrapper.passthrough(Type.STRING); + Integer[] blockIds = wrapper.passthrough(Type.VAR_INT_ARRAY); + for (int j = 0; j < blockIds.length; j++) { + blockIds[j] = getNewBlockId(blockIds[j]); + } + } + int itemTagsSize = wrapper.passthrough(Type.VAR_INT); // item tags + for (int i = 0; i < itemTagsSize; i++) { + wrapper.passthrough(Type.STRING); + Integer[] itemIds = wrapper.passthrough(Type.VAR_INT_ARRAY); + for (int j = 0; j < itemIds.length; j++) { + itemIds[j] = InventoryPackets.getNewItemId(itemIds[j]); + } + } + int fluidTagsSize = wrapper.passthrough(Type.VAR_INT); // fluid tags + for (int i = 0; i < fluidTagsSize; i++) { + wrapper.passthrough(Type.STRING); + wrapper.passthrough(Type.VAR_INT_ARRAY); + } + wrapper.write(Type.VAR_INT, 0); // new unknown tags + } + }); + } + }); + } - registerOutgoing(State.PLAY, 0x55, 0x56, new PacketRemapper() { - @Override - public void registerMap() { - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - int blockTagsSize = wrapper.passthrough(Type.VAR_INT); // block tags - for (int i = 0; i < blockTagsSize; i++) { - wrapper.passthrough(Type.STRING); - Integer[] blockIds = wrapper.passthrough(Type.VAR_INT_ARRAY); - for (int j = 0; j < blockIds.length; j++) { - blockIds[j] = getNewBlockId(blockIds[j]); - } - } - int itemTagsSize = wrapper.passthrough(Type.VAR_INT); // item tags - for (int i = 0; i < itemTagsSize; i++) { - wrapper.passthrough(Type.STRING); - Integer[] itemIds = wrapper.passthrough(Type.VAR_INT_ARRAY); - for (int j = 0; j < itemIds.length; j++) { - itemIds[j] = InventoryPackets.getNewItemId(itemIds[j]); - } - } - int fluidTagsSize = wrapper.passthrough(Type.VAR_INT); // fluid tags - for (int i = 0; i < fluidTagsSize; i++) { - wrapper.passthrough(Type.STRING); - wrapper.passthrough(Type.VAR_INT_ARRAY); - } - wrapper.write(Type.VAR_INT, 0); // new unknown tags - } - }); - } - }); - } + public static int getNewSoundId(int id) { + // AUTO GENERATED - todo compact this? + if (id < 15) return id + 0; // 15 = block.beacon.activate + if (id < 19) return id + 29; // 19 = block.brewing_stand.brew + if (id < 25) return id + 42; // 25 = block.chest.close + if (id < 28) return id + 54; // 28 = block.chorus_flower.death + if (id < 30) return id + 59; // 30 = block.wool.break + if (id < 35) return id + 60; // 35 = block.comparator.click + if (id < 41) return id + 64; // 41 = block.dispenser.dispense + if (id < 44) return id + 80; // 44 = block.enchantment_table.use + if (id < 45) return id + 114; // 45 = block.end_gateway.spawn + if (id < 46) return id + 136; // 46 = block.end_portal.spawn + if (id < 47) return id + 137; // 47 = block.end_portal_frame.fill + if (id < 48) return id + 135; // 48 = block.ender_chest.close + if (id < 50) return id + 111; // 50 = block.fence_gate.close + if (id < 52) return id + 144; // 52 = block.fire.ambient + if (id < 54) return id + 153; // 54 = block.furnace.fire_crackle + if (id < 55) return id + 155; // 55 = block.glass.break + if (id < 80) return id + 172; // 80 = block.iron_door.close + if (id < 82) return id + 219; // 82 = block.iron_trapdoor.close + if (id < 84) return id + 223; // 84 = block.ladder.break + if (id < 92) return id + 230; // 92 = block.lever.click + if (id < 93) return id + 232; // 93 = block.metal.break + if (id < 97) return id + 248; // 97 = block.metal.step + if (id < 98) return id + 250; // 98 = block.metal_pressure_plate.click_off + if (id < 100) return id + 247; // 100 = block.note_block.basedrum + if (id < 111) return id + 263; // 111 = block.piston.contract + if (id < 113) return id + 325; // 113 = block.portal.ambient + if (id < 116) return id + 349; // 116 = block.pumpkin.carve + if (id < 117) return id + 356; // 117 = block.redstone_torch.burnout + if (id < 118) return id + 373; // 118 = block.sand.break + if (id < 123) return id + 377; // 123 = block.shulker_box.close + if (id < 125) return id + 386; // 125 = block.slime_block.break + if (id < 130) return id + 417; // 130 = block.snow.break + if (id < 132) return id + 425; // 132 = block.snow.hit + if (id < 135) return id + 429; // 135 = block.stone.break + if (id < 136) return id + 439; // 136 = block.stone.fall + if (id < 139) return id + 441; // 139 = block.stone.step + if (id < 140) return id + 443; // 140 = block.stone_button.click_off + if (id < 142) return id + 435; // 142 = block.stone_pressure_plate.click_off + if (id < 144) return id + 438; // 144 = block.tripwire.attach + if (id < 148) return id + 454; // 148 = block.water.ambient + if (id < 149) return id + 490; // 149 = block.lily_pad.place + if (id < 150) return id + 488; // 150 = block.wood.break + if (id < 151) return id + 519; // 151 = block.wood.fall + if (id < 154) return id + 521; // 154 = block.wood.step + if (id < 155) return id + 523; // 155 = block.wooden_button.click_off + if (id < 157) return id + 515; // 157 = block.wooden_pressure_plate.click_off + if (id < 159) return id + 518; // 159 = block.wooden_door.close + if (id < 163) return id + 506; // 163 = enchant.thorns.hit + if (id < 164) return id + 424; // 164 = entity.armor_stand.break + if (id < 171) return id + -141; // 171 = entity.bat.ambient + if (id < 176) return id + -132; // 176 = entity.blaze.ambient + if (id < 186) return id + -128; // 186 = entity.cat.ambient + if (id < 192) return id + -113; // 192 = entity.chicken.ambient + if (id < 197) return id + -110; // 197 = entity.cod.ambient + if (id < 201) return id + -102; // 201 = entity.cow.ambient + if (id < 209) return id + -96; // 209 = entity.dolphin.ambient + if (id < 242) return id + -85; // 242 = entity.ender_dragon.ambient + if (id < 244) return id + -81; // 244 = entity.ender_dragon.flap + if (id < 248) return id + -80; // 248 = entity.dragon_fireball.explode + if (id < 249) return id + -85; // 249 = entity.ender_eye.death + if (id < 262) return id + -81; // 262 = entity.evoker.ambient + if (id < 265) return id + -78; // 265 = entity.evoker.hurt + if (id < 269) return id + -77; // 269 = entity.evoker_fangs.attack + if (id < 270) return id + -82; // 270 = entity.experience_bottle.throw + if (id < 272) return id + -78; // 272 = entity.firework_rocket.blast + if (id < 280) return id + -75; // 280 = entity.fish.swim + if (id < 281) return id + -73; // 281 = entity.generic.big_fall + if (id < 298) return id + -71; // 298 = entity.guardian.ambient + if (id < 306) return id + -46; // 306 = entity.horse.ambient + if (id < 330) return id + -45; // 330 = entity.illusioner.ambient + if (id < 337) return id + -38; // 337 = entity.iron_golem.attack + if (id < 341) return id + -36; // 341 = entity.item.break + if (id < 343) return id + -29; // 343 = entity.item_frame.add_item + if (id < 348) return id + -36; // 348 = entity.leash_knot.break + if (id < 350) return id + -26; // 350 = entity.lightning_bolt.impact + if (id < 366) return id + -25; // 366 = entity.minecart.inside + if (id < 373) return id + -18; // 373 = entity.painting.break + if (id < 375) return id + 1; // 375 = entity.parrot.ambient + if (id < 421) return id + 12; // 421 = entity.player.attack.crit + if (id < 445) return id + 17; // 445 = entity.puffer_fish.ambient + if (id < 452) return id + 20; // 452 = entity.rabbit.ambient + if (id < 457) return id + 21; // 457 = entity.salmon.ambient + if (id < 461) return id + 34; // 461 = entity.sheep.ambient + if (id < 466) return id + 39; // 466 = entity.shulker.ambient + if (id < 467) return id + 42; // 467 = entity.shulker.close + if (id < 474) return id + 46; // 474 = entity.shulker_bullet.hit + if (id < 476) return id + 37; // 476 = entity.silverfish.ambient + if (id < 482) return id + 44; // 482 = entity.skeleton.hurt + if (id < 485) return id + 52; // 485 = entity.skeleton_horse.ambient + if (id < 493) return id + 41; // 493 = entity.slime.attack + if (id < 498) return id + 44; // 498 = entity.magma_cube.death_small + if (id < 505) return id + 49; // 505 = entity.snow_golem.ambient + if (id < 509) return id + 52; // 509 = entity.snowball.throw + if (id < 510) return id + 45; // 510 = entity.spider.ambient + if (id < 520) return id + 54; // 520 = entity.stray.ambient + if (id < 524) return id + 63; // 524 = entity.tnt.primed + if (id < 525) return id + 64; // 525 = entity.tropical_fish.ambient + if (id < 541) return id + 77; // 541 = entity.vex.ambient + if (id < 554) return id + 83; // 554 = entity.witch.ambient + if (id < 564) return id + 87; // 564 = entity.wither.spawn + if (id < 565) return id + 91; // 565 = entity.wither_skeleton.ambient + if (id < 569) return id + 86; // 569 = entity.wolf.ambient + if (id < 578) return id + 87; // 578 = entity.zombie.ambient + if (id < 585) return id + 100; // 585 = entity.zombie.hurt + if (id < 587) return id + 103; // 587 = entity.zombie.step + if (id < 588) return id + 107; // 588 = entity.zombie_horse.ambient + if (id < 591) return id + 97; // 591 = entity.zombie_pigman.ambient + if (id < 595) return id + 99; // 595 = entity.zombie_villager.ambient + if (id < 601) return id + 100; // 601 = item.armor.equip_chain + if (id < 609) return id + -586; // 609 = item.axe.strip + if (id < 610) return id + -579; // 610 = item.bottle.empty + if (id < 613) return id + -552; // 613 = item.bucket.empty + if (id < 619) return id + -546; // 619 = item.chorus_fruit.teleport + if (id < 620) return id + -530; // 620 = item.elytra.flying + if (id < 621) return id + -463; // 621 = item.firecharge.use + if (id < 622) return id + -425; // 622 = item.flintandsteel.use + if (id < 623) return id + -414; // 623 = item.hoe.till + if (id < 624) return id + -363; // 624 = item.shield.block + if (id < 627) return id + -119; // 627 = item.totem.use + if (id < 636) return id + -38; // 636 = music.creative + if (id < 644) return id + -281; // 644 = music_disc.11 + if (id < 656) return id + -166; // 656 = ui.button.click + if (id < 657) return id + -38; // 657 = ui.toast.challenge_complete + if (id < 660) return id + -36; // 660 = weather.rain + return id + -21; + } - public static int getNewSoundId(int id) { - // AUTO GENERATED - todo compact this? - if (id < 15) return id + 0; // 15 = block.beacon.activate - if (id < 19) return id + 29; // 19 = block.brewing_stand.brew - if (id < 25) return id + 42; // 25 = block.chest.close - if (id < 28) return id + 54; // 28 = block.chorus_flower.death - if (id < 30) return id + 59; // 30 = block.wool.break - if (id < 35) return id + 60; // 35 = block.comparator.click - if (id < 41) return id + 64; // 41 = block.dispenser.dispense - if (id < 44) return id + 80; // 44 = block.enchantment_table.use - if (id < 45) return id + 114; // 45 = block.end_gateway.spawn - if (id < 46) return id + 136; // 46 = block.end_portal.spawn - if (id < 47) return id + 137; // 47 = block.end_portal_frame.fill - if (id < 48) return id + 135; // 48 = block.ender_chest.close - if (id < 50) return id + 111; // 50 = block.fence_gate.close - if (id < 52) return id + 144; // 52 = block.fire.ambient - if (id < 54) return id + 153; // 54 = block.furnace.fire_crackle - if (id < 55) return id + 155; // 55 = block.glass.break - if (id < 80) return id + 172; // 80 = block.iron_door.close - if (id < 82) return id + 219; // 82 = block.iron_trapdoor.close - if (id < 84) return id + 223; // 84 = block.ladder.break - if (id < 92) return id + 230; // 92 = block.lever.click - if (id < 93) return id + 232; // 93 = block.metal.break - if (id < 97) return id + 248; // 97 = block.metal.step - if (id < 98) return id + 250; // 98 = block.metal_pressure_plate.click_off - if (id < 100) return id + 247; // 100 = block.note_block.basedrum - if (id < 111) return id + 263; // 111 = block.piston.contract - if (id < 113) return id + 325; // 113 = block.portal.ambient - if (id < 116) return id + 349; // 116 = block.pumpkin.carve - if (id < 117) return id + 356; // 117 = block.redstone_torch.burnout - if (id < 118) return id + 373; // 118 = block.sand.break - if (id < 123) return id + 377; // 123 = block.shulker_box.close - if (id < 125) return id + 386; // 125 = block.slime_block.break - if (id < 130) return id + 417; // 130 = block.snow.break - if (id < 132) return id + 425; // 132 = block.snow.hit - if (id < 135) return id + 429; // 135 = block.stone.break - if (id < 136) return id + 439; // 136 = block.stone.fall - if (id < 139) return id + 441; // 139 = block.stone.step - if (id < 140) return id + 443; // 140 = block.stone_button.click_off - if (id < 142) return id + 435; // 142 = block.stone_pressure_plate.click_off - if (id < 144) return id + 438; // 144 = block.tripwire.attach - if (id < 148) return id + 454; // 148 = block.water.ambient - if (id < 149) return id + 490; // 149 = block.lily_pad.place - if (id < 150) return id + 488; // 150 = block.wood.break - if (id < 151) return id + 519; // 151 = block.wood.fall - if (id < 154) return id + 521; // 154 = block.wood.step - if (id < 155) return id + 523; // 155 = block.wooden_button.click_off - if (id < 157) return id + 515; // 157 = block.wooden_pressure_plate.click_off - if (id < 159) return id + 518; // 159 = block.wooden_door.close - if (id < 163) return id + 506; // 163 = enchant.thorns.hit - if (id < 164) return id + 424; // 164 = entity.armor_stand.break - if (id < 171) return id + -141; // 171 = entity.bat.ambient - if (id < 176) return id + -132; // 176 = entity.blaze.ambient - if (id < 186) return id + -128; // 186 = entity.cat.ambient - if (id < 192) return id + -113; // 192 = entity.chicken.ambient - if (id < 197) return id + -110; // 197 = entity.cod.ambient - if (id < 201) return id + -102; // 201 = entity.cow.ambient - if (id < 209) return id + -96; // 209 = entity.dolphin.ambient - if (id < 242) return id + -85; // 242 = entity.ender_dragon.ambient - if (id < 244) return id + -81; // 244 = entity.ender_dragon.flap - if (id < 248) return id + -80; // 248 = entity.dragon_fireball.explode - if (id < 249) return id + -85; // 249 = entity.ender_eye.death - if (id < 262) return id + -81; // 262 = entity.evoker.ambient - if (id < 265) return id + -78; // 265 = entity.evoker.hurt - if (id < 269) return id + -77; // 269 = entity.evoker_fangs.attack - if (id < 270) return id + -82; // 270 = entity.experience_bottle.throw - if (id < 272) return id + -78; // 272 = entity.firework_rocket.blast - if (id < 280) return id + -75; // 280 = entity.fish.swim - if (id < 281) return id + -73; // 281 = entity.generic.big_fall - if (id < 298) return id + -71; // 298 = entity.guardian.ambient - if (id < 306) return id + -46; // 306 = entity.horse.ambient - if (id < 330) return id + -45; // 330 = entity.illusioner.ambient - if (id < 337) return id + -38; // 337 = entity.iron_golem.attack - if (id < 341) return id + -36; // 341 = entity.item.break - if (id < 343) return id + -29; // 343 = entity.item_frame.add_item - if (id < 348) return id + -36; // 348 = entity.leash_knot.break - if (id < 350) return id + -26; // 350 = entity.lightning_bolt.impact - if (id < 366) return id + -25; // 366 = entity.minecart.inside - if (id < 373) return id + -18; // 373 = entity.painting.break - if (id < 375) return id + 1; // 375 = entity.parrot.ambient - if (id < 421) return id + 12; // 421 = entity.player.attack.crit - if (id < 445) return id + 17; // 445 = entity.puffer_fish.ambient - if (id < 452) return id + 20; // 452 = entity.rabbit.ambient - if (id < 457) return id + 21; // 457 = entity.salmon.ambient - if (id < 461) return id + 34; // 461 = entity.sheep.ambient - if (id < 466) return id + 39; // 466 = entity.shulker.ambient - if (id < 467) return id + 42; // 467 = entity.shulker.close - if (id < 474) return id + 46; // 474 = entity.shulker_bullet.hit - if (id < 476) return id + 37; // 476 = entity.silverfish.ambient - if (id < 482) return id + 44; // 482 = entity.skeleton.hurt - if (id < 485) return id + 52; // 485 = entity.skeleton_horse.ambient - if (id < 493) return id + 41; // 493 = entity.slime.attack - if (id < 498) return id + 44; // 498 = entity.magma_cube.death_small - if (id < 505) return id + 49; // 505 = entity.snow_golem.ambient - if (id < 509) return id + 52; // 509 = entity.snowball.throw - if (id < 510) return id + 45; // 510 = entity.spider.ambient - if (id < 520) return id + 54; // 520 = entity.stray.ambient - if (id < 524) return id + 63; // 524 = entity.tnt.primed - if (id < 525) return id + 64; // 525 = entity.tropical_fish.ambient - if (id < 541) return id + 77; // 541 = entity.vex.ambient - if (id < 554) return id + 83; // 554 = entity.witch.ambient - if (id < 564) return id + 87; // 564 = entity.wither.spawn - if (id < 565) return id + 91; // 565 = entity.wither_skeleton.ambient - if (id < 569) return id + 86; // 569 = entity.wolf.ambient - if (id < 578) return id + 87; // 578 = entity.zombie.ambient - if (id < 585) return id + 100; // 585 = entity.zombie.hurt - if (id < 587) return id + 103; // 587 = entity.zombie.step - if (id < 588) return id + 107; // 588 = entity.zombie_horse.ambient - if (id < 591) return id + 97; // 591 = entity.zombie_pigman.ambient - if (id < 595) return id + 99; // 595 = entity.zombie_villager.ambient - if (id < 601) return id + 100; // 601 = item.armor.equip_chain - if (id < 609) return id + -586; // 609 = item.axe.strip - if (id < 610) return id + -579; // 610 = item.bottle.empty - if (id < 613) return id + -552; // 613 = item.bucket.empty - if (id < 619) return id + -546; // 619 = item.chorus_fruit.teleport - if (id < 620) return id + -530; // 620 = item.elytra.flying - if (id < 621) return id + -463; // 621 = item.firecharge.use - if (id < 622) return id + -425; // 622 = item.flintandsteel.use - if (id < 623) return id + -414; // 623 = item.hoe.till - if (id < 624) return id + -363; // 624 = item.shield.block - if (id < 627) return id + -119; // 627 = item.totem.use - if (id < 636) return id + -38; // 636 = music.creative - if (id < 644) return id + -281; // 644 = music_disc.11 - if (id < 656) return id + -166; // 656 = ui.button.click - if (id < 657) return id + -38; // 657 = ui.toast.challenge_complete - if (id < 660) return id + -36; // 660 = weather.rain - return id + -21; - } + public static int getNewBlockStateId(int id) { + if (id < 1121) return id; + else if (id < 3108) return id + 3; + else if (id < 3278) return id + 163; + else if (id < 3978) return id + 203; + else if (id < 3984) return id + 207; + else if (id < 3988) return id + 197; + else if (id < 5284) return id + 203; + else if (id < 7300) return id + 206; + else if (id < 8591) return id + 212; + else if (id < 8595) return id + 226; + else return id + 2192; + } - public static int getNewBlockStateId(int id) { - if (id < 1121) return id; - else if (id < 3108) return id + 3; - else if (id < 3278) return id + 163; - else if (id < 3978) return id + 203; - else if (id < 3984) return id + 207; - else if (id < 3988) return id + 197; - else if (id < 5284) return id + 203; - else if (id < 7300) return id + 206; - else if (id < 8591) return id + 212; - else if (id < 8595) return id + 226; - else return id + 2192; - } + public static int getNewBlockId(int id) { + // AUTO GENERATED + if (id < 128) return id + 0; // 128 = minecraft:brown_mushroom + if (id < 151) return id + 3; // 151 = minecraft:oak_door + if (id < 156) return id + 8; // 156 = minecraft:lever + if (id < 208) return id + 13; // 208 = minecraft:infested_stone + if (id < 214) return id + 17; // 214 = minecraft:stone_bricks + if (id < 218) return id + 7; // 218 = minecraft:brown_mushroom_block + if (id < 278) return id + 13; // 278 = minecraft:potted_red_mushroom + if (id < 435) return id + 16; // 435 = minecraft:sandstone_slab + if (id < 594) return id + 17; // 594 = minecraft:void_air + if (id < 597) return id + 20; // 597 = minecraft:structure_block + return id + 59; + } - public static int getNewBlockId(int id) { - // AUTO GENERATED - if (id < 128) return id + 0; // 128 = minecraft:brown_mushroom - if (id < 151) return id + 3; // 151 = minecraft:oak_door - if (id < 156) return id + 8; // 156 = minecraft:lever - if (id < 208) return id + 13; // 208 = minecraft:infested_stone - if (id < 214) return id + 17; // 214 = minecraft:stone_bricks - if (id < 218) return id + 7; // 218 = minecraft:brown_mushroom_block - if (id < 278) return id + 13; // 278 = minecraft:potted_red_mushroom - if (id < 435) return id + 16; // 435 = minecraft:sandstone_slab - if (id < 594) return id + 17; // 594 = minecraft:void_air - if (id < 597) return id + 20; // 597 = minecraft:structure_block - return id + 59; - } + @Override + public void init(UserConnection userConnection) { + userConnection.put(new EntityTracker(userConnection)); + if (!userConnection.has(ClientWorld.class)) + userConnection.put(new ClientWorld(userConnection)); - @Override - public void init(UserConnection userConnection) { - userConnection.put(new EntityTracker(userConnection)); - if (!userConnection.has(ClientWorld.class)) - userConnection.put(new ClientWorld(userConnection)); - - } + } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/data/EntityTypeRewriter.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/data/EntityTypeRewriter.java index 3c33a2372..e1fa300d1 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/data/EntityTypeRewriter.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/data/EntityTypeRewriter.java @@ -6,62 +6,62 @@ import java.util.HashMap; import java.util.Map; public class EntityTypeRewriter { - private static Map entityTypes = new HashMap<>(); - private static Map objectTypes = new HashMap<>(); + private static Map entityTypes = new HashMap<>(); + private static Map objectTypes = new HashMap<>(); - static { - regEnt(74, 75); // egg - regEnt(75, 76); // ender_pearl - regEnt(76, 77); // experience_bottle - regEnt(93, 96); // fishing_bobber - regEnt(80, 81); // iron_golem - regEnt(91, 94); // lightning_bolt - regEnt(50, 51); // parrot - regEnt(90, 92); // phantom - regEnt(51, 52); // pig - regEnt(92, 95); // player - regEnt(54, 55); // polar_bear - regEnt(77, 78); // potion - regEnt(52, 53); // pufferfish - regEnt(56, 57); // rabbit - regEnt(57, 58); // salmon - regEnt(58, 59); // sheep - regEnt(59, 60); // shulker - regEnt(60, 61); // shulker_bullet - regEnt(61, 62); // silverfish - regEnt(62, 63); // skeleton - regEnt(63, 64); // skeleton_horse - regEnt(64, 65); // slime - regEnt(65, 66); // small_fireball - regEnt(66, 67); // snowgolem - regEnt(67, 68); // snowball - regEnt(68, 69); // spectral_arrow - regEnt(69, 70); // spider - regEnt(70, 71); // squid - regEnt(71, 72); // stray - regEnt(55, 56); // tnt - regEnt(94, 97); // trident - regEnt(72, 73); // tropical_fish - regEnt(73, 74); // turtle - regEnt(78, 79); // vex - regEnt(79, 80); // villager - regEnt(81, 82); // vindicator - regEnt(82, 84); // witch - regEnt(83, 85); // wither - regEnt(84, 86); // wither_skeleton - regEnt(85, 87); // wither_skull - regEnt(86, 88); // wolf - regEnt(87, 89); // zombie - regEnt(88, 90); // zombie_horse - regEnt(53, 54); // zombie_pigman - regEnt(89, 91); // zombie_villager - } + static { + regEnt(74, 75); // egg + regEnt(75, 76); // ender_pearl + regEnt(76, 77); // experience_bottle + regEnt(93, 96); // fishing_bobber + regEnt(80, 81); // iron_golem + regEnt(91, 94); // lightning_bolt + regEnt(50, 51); // parrot + regEnt(90, 92); // phantom + regEnt(51, 52); // pig + regEnt(92, 95); // player + regEnt(54, 55); // polar_bear + regEnt(77, 78); // potion + regEnt(52, 53); // pufferfish + regEnt(56, 57); // rabbit + regEnt(57, 58); // salmon + regEnt(58, 59); // sheep + regEnt(59, 60); // shulker + regEnt(60, 61); // shulker_bullet + regEnt(61, 62); // silverfish + regEnt(62, 63); // skeleton + regEnt(63, 64); // skeleton_horse + regEnt(64, 65); // slime + regEnt(65, 66); // small_fireball + regEnt(66, 67); // snowgolem + regEnt(67, 68); // snowball + regEnt(68, 69); // spectral_arrow + regEnt(69, 70); // spider + regEnt(70, 71); // squid + regEnt(71, 72); // stray + regEnt(55, 56); // tnt + regEnt(94, 97); // trident + regEnt(72, 73); // tropical_fish + regEnt(73, 74); // turtle + regEnt(78, 79); // vex + regEnt(79, 80); // villager + regEnt(81, 82); // vindicator + regEnt(82, 84); // witch + regEnt(83, 85); // wither + regEnt(84, 86); // wither_skeleton + regEnt(85, 87); // wither_skull + regEnt(86, 88); // wolf + regEnt(87, 89); // zombie + regEnt(88, 90); // zombie_horse + regEnt(53, 54); // zombie_pigman + regEnt(89, 91); // zombie_villager + } - private static void regEnt(int type1_13, int type1_14) { - entityTypes.put(type1_13, type1_14); - } + private static void regEnt(int type1_13, int type1_14) { + entityTypes.put(type1_13, type1_14); + } - public static Optional getNewId(int type1_13) { - return Optional.fromNullable(entityTypes.get(type1_13)); - } + public static Optional getNewId(int type1_13) { + return Optional.fromNullable(entityTypes.get(type1_13)); + } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/EntityPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/EntityPackets.java index cd1738597..b460c0c6e 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/EntityPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/EntityPackets.java @@ -16,163 +16,163 @@ import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.storage.EntityTracker; public class EntityPackets { - public static void register(Protocol protocol) { + public static void register(Protocol protocol) { - // Spawn entity - protocol.registerOutgoing(State.PLAY, 0x0, 0x0, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT); // 0 - Entity id - map(Type.UUID); // 1 - UUID - map(Type.BYTE); // 2 - Type - map(Type.DOUBLE); // 3 - X - map(Type.DOUBLE); // 4 - Y - map(Type.DOUBLE); // 5 - Z - map(Type.BYTE); // 6 - Pitch - map(Type.BYTE); // 7 - Yaw - map(Type.INT); // 8 - Data + // Spawn entity + protocol.registerOutgoing(State.PLAY, 0x0, 0x0, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // 0 - Entity id + map(Type.UUID); // 1 - UUID + map(Type.BYTE); // 2 - Type + map(Type.DOUBLE); // 3 - X + map(Type.DOUBLE); // 4 - Y + map(Type.DOUBLE); // 5 - Z + map(Type.BYTE); // 6 - Pitch + map(Type.BYTE); // 7 - Yaw + map(Type.INT); // 8 - Data - // Track Entity - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - int entityId = wrapper.get(Type.VAR_INT, 0); - byte type = wrapper.get(Type.BYTE, 0); - Entity1_14Types.EntityType entType = Entity1_14Types.getTypeFromId(type, true); + // Track Entity + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int entityId = wrapper.get(Type.VAR_INT, 0); + byte type = wrapper.get(Type.BYTE, 0); + Entity1_14Types.EntityType entType = Entity1_14Types.getTypeFromId(type, true); - if (entType != null) { - if (entType.is(Entity1_14Types.EntityType.FALLING_BLOCK)) { - int data = wrapper.get(Type.INT, 0); - wrapper.set(Type.INT, 0, Protocol1_14To1_13_2.getNewBlockStateId(data)); - } - } - // Register Type ID - wrapper.user().get(EntityTracker.class).addEntity(entityId, entType); - } - }); - } - }); + if (entType != null) { + if (entType.is(Entity1_14Types.EntityType.FALLING_BLOCK)) { + int data = wrapper.get(Type.INT, 0); + wrapper.set(Type.INT, 0, Protocol1_14To1_13_2.getNewBlockStateId(data)); + } + } + // Register Type ID + wrapper.user().get(EntityTracker.class).addEntity(entityId, entType); + } + }); + } + }); - // Spawn mob packet - protocol.registerOutgoing(State.PLAY, 0x3, 0x3, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.UUID); // 1 - Entity UUID - map(Type.VAR_INT); // 2 - Entity Type - map(Type.DOUBLE); // 3 - X - map(Type.DOUBLE); // 4 - Y - map(Type.DOUBLE); // 5 - Z - map(Type.BYTE); // 6 - Yaw - map(Type.BYTE); // 7 - Pitch - map(Type.BYTE); // 8 - Head Pitch - map(Type.SHORT); // 9 - Velocity X - map(Type.SHORT); // 10 - Velocity Y - map(Type.SHORT); // 11 - Velocity Z - map(Types1_13_2.METADATA_LIST); // 12 - Metadata + // Spawn mob packet + protocol.registerOutgoing(State.PLAY, 0x3, 0x3, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // 0 - Entity ID + map(Type.UUID); // 1 - Entity UUID + map(Type.VAR_INT); // 2 - Entity Type + map(Type.DOUBLE); // 3 - X + map(Type.DOUBLE); // 4 - Y + map(Type.DOUBLE); // 5 - Z + map(Type.BYTE); // 6 - Yaw + map(Type.BYTE); // 7 - Pitch + map(Type.BYTE); // 8 - Head Pitch + map(Type.SHORT); // 9 - Velocity X + map(Type.SHORT); // 10 - Velocity Y + map(Type.SHORT); // 11 - Velocity Z + map(Types1_13_2.METADATA_LIST); // 12 - Metadata - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - int entityId = wrapper.get(Type.VAR_INT, 0); - int type = wrapper.get(Type.VAR_INT, 1); + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int entityId = wrapper.get(Type.VAR_INT, 0); + int type = wrapper.get(Type.VAR_INT, 1); - type = EntityTypeRewriter.getNewId(type).or(type); + type = EntityTypeRewriter.getNewId(type).or(type); - Entity1_14Types.EntityType entType = Entity1_14Types.getTypeFromId(type, false); + Entity1_14Types.EntityType entType = Entity1_14Types.getTypeFromId(type, false); - wrapper.set(Type.VAR_INT, 1, type); + wrapper.set(Type.VAR_INT, 1, type); - // Register Type ID - wrapper.user().get(EntityTracker.class).addEntity(entityId, entType); + // Register Type ID + wrapper.user().get(EntityTracker.class).addEntity(entityId, entType); - MetadataRewriter.handleMetadata(entityId, entType, wrapper.get(Types1_13_2.METADATA_LIST, 0), wrapper.user()); - } - }); - } - }); + MetadataRewriter.handleMetadata(entityId, entType, wrapper.get(Types1_13_2.METADATA_LIST, 0), wrapper.user()); + } + }); + } + }); - // Spawn painting - protocol.registerOutgoing(State.PLAY, 0x04, 0x04, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT); - map(Type.UUID); - map(Type.VAR_INT); - map(Type.POSITION, Type.POSITION1_14); - map(Type.BYTE); - } - }); + // Spawn painting + protocol.registerOutgoing(State.PLAY, 0x04, 0x04, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); + map(Type.UUID); + map(Type.VAR_INT); + map(Type.POSITION, Type.POSITION1_14); + map(Type.BYTE); + } + }); - // Spawn player packet - protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.UUID); // 1 - Player UUID - map(Type.DOUBLE); // 2 - X - map(Type.DOUBLE); // 3 - Y - map(Type.DOUBLE); // 4 - Z - map(Type.BYTE); // 5 - Yaw - map(Type.BYTE); // 6 - Pitch - map(Types1_13_2.METADATA_LIST); // 7 - Metadata + // Spawn player packet + protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // 0 - Entity ID + map(Type.UUID); // 1 - Player UUID + map(Type.DOUBLE); // 2 - X + map(Type.DOUBLE); // 3 - Y + map(Type.DOUBLE); // 4 - Z + map(Type.BYTE); // 5 - Yaw + map(Type.BYTE); // 6 - Pitch + map(Types1_13_2.METADATA_LIST); // 7 - Metadata - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - int entityId = wrapper.get(Type.VAR_INT, 0); + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int entityId = wrapper.get(Type.VAR_INT, 0); - Entity1_14Types.EntityType entType = Entity1_14Types.EntityType.PLAYER; - // Register Type ID - wrapper.user().get(EntityTracker.class).addEntity(entityId, entType); - MetadataRewriter.handleMetadata(entityId, entType, wrapper.get(Types1_13_2.METADATA_LIST, 0), wrapper.user()); - } - }); - } - }); + Entity1_14Types.EntityType entType = Entity1_14Types.EntityType.PLAYER; + // Register Type ID + wrapper.user().get(EntityTracker.class).addEntity(entityId, entType); + MetadataRewriter.handleMetadata(entityId, entType, wrapper.get(Types1_13_2.METADATA_LIST, 0), wrapper.user()); + } + }); + } + }); - // Use bed - protocol.registerOutgoing(State.PLAY, 0x33, 0x33, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT); - map(Type.POSITION, Type.POSITION1_14); - } - }); + // Use bed + protocol.registerOutgoing(State.PLAY, 0x33, 0x33, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); + map(Type.POSITION, Type.POSITION1_14); + } + }); - // Destroy entities - protocol.registerOutgoing(State.PLAY, 0x35, 0x35, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT_ARRAY); // 0 - Entity IDS + // Destroy entities + protocol.registerOutgoing(State.PLAY, 0x35, 0x35, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT_ARRAY); // 0 - Entity IDS - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - for (int entity : wrapper.get(Type.VAR_INT_ARRAY, 0)) - wrapper.user().get(EntityTracker.class).removeEntity(entity); - } - }); - } - }); + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + for (int entity : wrapper.get(Type.VAR_INT_ARRAY, 0)) + wrapper.user().get(EntityTracker.class).removeEntity(entity); + } + }); + } + }); - // Metadata packet - protocol.registerOutgoing(State.PLAY, 0x3F, 0x3F, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT); // 0 - Entity ID - map(Types1_13_2.METADATA_LIST); // 1 - Metadata list - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - int entityId = wrapper.get(Type.VAR_INT, 0); + // Metadata packet + protocol.registerOutgoing(State.PLAY, 0x3F, 0x3F, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // 0 - Entity ID + map(Types1_13_2.METADATA_LIST); // 1 - Metadata list + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int entityId = wrapper.get(Type.VAR_INT, 0); - Optional type = wrapper.user().get(EntityTracker.class).get(entityId); - MetadataRewriter.handleMetadata(entityId, type.orNull(), wrapper.get(Types1_13_2.METADATA_LIST, 0), wrapper.user()); - } - }); - } - }); + Optional type = wrapper.user().get(EntityTracker.class).get(entityId); + MetadataRewriter.handleMetadata(entityId, type.orNull(), wrapper.get(Types1_13_2.METADATA_LIST, 0), wrapper.user()); + } + }); + } + }); - } + } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/InventoryPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/InventoryPackets.java index b4e62f4ce..fff6245e3 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/InventoryPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/InventoryPackets.java @@ -10,234 +10,234 @@ import us.myles.ViaVersion.packets.State; public class InventoryPackets { - public static void register(Protocol protocol) { + public static void register(Protocol protocol) { /* Outgoing packets */ - // Set slot packet - protocol.registerOutgoing(State.PLAY, 0x17, 0x17, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.BYTE); // 0 - Window ID - map(Type.SHORT); // 1 - Slot ID - map(Type.FLAT_VAR_INT_ITEM); // 2 - Slot Value + // Set slot packet + protocol.registerOutgoing(State.PLAY, 0x17, 0x17, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.BYTE); // 0 - Window ID + map(Type.SHORT); // 1 - Slot ID + map(Type.FLAT_VAR_INT_ITEM); // 2 - Slot Value - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - toClient(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0)); - } - }); - } - }); + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + toClient(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0)); + } + }); + } + }); - // Window items packet - protocol.registerOutgoing(State.PLAY, 0x15, 0x15, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.UNSIGNED_BYTE); // 0 - Window ID - map(Type.FLAT_VAR_INT_ITEM_ARRAY); // 1 - Window Values + // Window items packet + protocol.registerOutgoing(State.PLAY, 0x15, 0x15, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.UNSIGNED_BYTE); // 0 - Window ID + map(Type.FLAT_VAR_INT_ITEM_ARRAY); // 1 - Window Values - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - Item[] stacks = wrapper.get(Type.FLAT_VAR_INT_ITEM_ARRAY, 0); - for (Item stack : stacks) toClient(stack); - } - }); - } - }); + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + Item[] stacks = wrapper.get(Type.FLAT_VAR_INT_ITEM_ARRAY, 0); + for (Item stack : stacks) toClient(stack); + } + }); + } + }); - // Plugin message - protocol.registerOutgoing(State.PLAY, 0x19, 0x19, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.STRING); // Channel - handler(new PacketHandler() { - @Override - 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.passthrough(Type.INT); // Passthrough Window ID + // Plugin message + protocol.registerOutgoing(State.PLAY, 0x19, 0x19, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.STRING); // Channel + handler(new PacketHandler() { + @Override + 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.passthrough(Type.INT); // Passthrough Window ID - int size = wrapper.passthrough(Type.UNSIGNED_BYTE); - for (int i = 0; i < size; i++) { - // Input Item - toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); - // Output Item - toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); + int size = wrapper.passthrough(Type.UNSIGNED_BYTE); + for (int i = 0; i < size; i++) { + // Input Item + toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); + // Output Item + toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); - boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item - if (secondItem) { - // Second Item - toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); - } + boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item + if (secondItem) { + // Second Item + toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); + } - wrapper.passthrough(Type.BOOLEAN); // Trade disabled - wrapper.passthrough(Type.INT); // Number of tools uses - wrapper.passthrough(Type.INT); // Maximum number of trade uses - } - } - } - }); - } - }); + wrapper.passthrough(Type.BOOLEAN); // Trade disabled + wrapper.passthrough(Type.INT); // Number of tools uses + wrapper.passthrough(Type.INT); // Maximum number of trade uses + } + } + } + }); + } + }); - // Entity Equipment Packet - protocol.registerOutgoing(State.PLAY, 0x42, 0x42, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.VAR_INT); // 1 - Slot ID - map(Type.FLAT_VAR_INT_ITEM); // 2 - Item + // Entity Equipment Packet + protocol.registerOutgoing(State.PLAY, 0x42, 0x42, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // 0 - Entity ID + map(Type.VAR_INT); // 1 - Slot ID + map(Type.FLAT_VAR_INT_ITEM); // 2 - Item - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - toClient(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0)); - } - }); - } - }); + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + toClient(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0)); + } + }); + } + }); - // Declare Recipes - protocol.registerOutgoing(State.PLAY, 0x54, 0x55, new PacketRemapper() { - @Override - public void registerMap() { - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - int size = wrapper.passthrough(Type.VAR_INT); - int deleted = 0; - for (int i = 0; i < size; i++) { - String id = wrapper.read(Type.STRING); // Recipe Identifier - String type = wrapper.read(Type.STRING); - if (type.equals("crafting_special_banneraddpattern")) { - deleted++; - continue; - } - wrapper.write(Type.STRING, id); - wrapper.write(Type.STRING, type); + // Declare Recipes + protocol.registerOutgoing(State.PLAY, 0x54, 0x55, new PacketRemapper() { + @Override + public void registerMap() { + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int size = wrapper.passthrough(Type.VAR_INT); + int deleted = 0; + for (int i = 0; i < size; i++) { + String id = wrapper.read(Type.STRING); // Recipe Identifier + String type = wrapper.read(Type.STRING); + if (type.equals("crafting_special_banneraddpattern")) { + deleted++; + continue; + } + wrapper.write(Type.STRING, id); + wrapper.write(Type.STRING, type); - if (type.equals("crafting_shapeless")) { - wrapper.passthrough(Type.STRING); // Group - int ingredientsNo = wrapper.passthrough(Type.VAR_INT); - for (int j = 0; j < ingredientsNo; j++) { - Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients - for (Item item : items) toClient(item); - } - toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result - } else if (type.equals("crafting_shaped")) { - int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT); - wrapper.passthrough(Type.STRING); // Group - for (int j = 0; j < ingredientsNo; j++) { - Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients - for (Item item : items) toClient(item); - } - toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result - } else if (type.equals("smelting")) { - wrapper.passthrough(Type.STRING); // Group - Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients - for (Item item : items) toClient(item); - toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); - wrapper.passthrough(Type.FLOAT); // EXP - wrapper.passthrough(Type.VAR_INT); // Cooking time - } - } - wrapper.set(Type.VAR_INT, 0, size - deleted); - } - }); - } - }); + if (type.equals("crafting_shapeless")) { + wrapper.passthrough(Type.STRING); // Group + int ingredientsNo = wrapper.passthrough(Type.VAR_INT); + for (int j = 0; j < ingredientsNo; j++) { + Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients + for (Item item : items) toClient(item); + } + toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result + } else if (type.equals("crafting_shaped")) { + int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT); + wrapper.passthrough(Type.STRING); // Group + for (int j = 0; j < ingredientsNo; j++) { + Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients + for (Item item : items) toClient(item); + } + toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result + } else if (type.equals("smelting")) { + wrapper.passthrough(Type.STRING); // Group + Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients + for (Item item : items) toClient(item); + toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); + wrapper.passthrough(Type.FLOAT); // EXP + wrapper.passthrough(Type.VAR_INT); // Cooking time + } + } + wrapper.set(Type.VAR_INT, 0, size - deleted); + } + }); + } + }); /* Incoming packets */ - // Click window packet - protocol.registerIncoming(State.PLAY, 0x08, 0x08, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.UNSIGNED_BYTE); // 0 - Window ID - map(Type.SHORT); // 1 - Slot - map(Type.BYTE); // 2 - Button - map(Type.SHORT); // 3 - Action number - map(Type.VAR_INT); // 4 - Mode - map(Type.FLAT_VAR_INT_ITEM); // 5 - Clicked Item + // Click window packet + protocol.registerIncoming(State.PLAY, 0x08, 0x08, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.UNSIGNED_BYTE); // 0 - Window ID + map(Type.SHORT); // 1 - Slot + map(Type.BYTE); // 2 - Button + map(Type.SHORT); // 3 - Action number + map(Type.VAR_INT); // 4 - Mode + map(Type.FLAT_VAR_INT_ITEM); // 5 - Clicked Item - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - toServer(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0)); - } - }); - } - }); + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + toServer(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0)); + } + }); + } + }); - // Creative Inventory Action - protocol.registerIncoming(State.PLAY, 0x24, 0x24, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.SHORT); // 0 - Slot - map(Type.FLAT_VAR_INT_ITEM); // 1 - Clicked Item + // Creative Inventory Action + protocol.registerIncoming(State.PLAY, 0x24, 0x24, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.SHORT); // 0 - Slot + map(Type.FLAT_VAR_INT_ITEM); // 1 - Clicked Item - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - toServer(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0)); - } - }); - } - }); - } + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + toServer(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0)); + } + }); + } + }); + } - public static void toClient(Item item) { - if (item == null) return; - item.setId((short) getNewItemId(item.getId())); - } + public static void toClient(Item item) { + if (item == null) return; + item.setId((short) getNewItemId(item.getId())); + } - public static int getNewItemId(int id) { - if (id < 108) return id; - else if (id < 119) return id + 3; - else if (id < 460) return id + 4; - else if (id < 542) return id + 43; - else if (id < 561) return id + 48; - else if (id < 593) return id + 49; - else if (id < 657) return id + 53; - else if (id < 662) return id + 54; - else if (id < 665) return id + 55; - else return id + 56; - } + public static int getNewItemId(int id) { + if (id < 108) return id; + else if (id < 119) return id + 3; + else if (id < 460) return id + 4; + else if (id < 542) return id + 43; + else if (id < 561) return id + 48; + else if (id < 593) return id + 49; + else if (id < 657) return id + 53; + else if (id < 662) return id + 54; + else if (id < 665) return id + 55; + else return id + 56; + } - public static void toServer(Item item) { - if (item == null) return; - item.setId((short) getOldItemId(item.getId())); - } + public static void toServer(Item item) { + if (item == null) return; + item.setId((short) getOldItemId(item.getId())); + } - public static int getOldItemId(int id) { - if (id < 108) return id; - else if (id < 111) return 1; - else if (id < 122) return id - 3; - else if (id < 123) return 1; - else if (id < 464) return id - 4; - else if (id < 503) return 1; - else if (id < 585) return id - 43; - else if (id < 590) return 1; - else if (id < 609) return id - 48; - else if (id < 610) return 1; - else if (id < 642) return id - 49; - else if (id < 646) return 1; - else if (id < 710) return id - 53; - else if (id < 711) return 1; - else if (id < 716) return id - 54; - else if (id < 717) return 1; - else if (id < 720) return id - 55; - else if (id < 721) return 1; - else if (id < 846) return id - 56; - else return 1; - } + public static int getOldItemId(int id) { + if (id < 108) return id; + else if (id < 111) return 1; + else if (id < 122) return id - 3; + else if (id < 123) return 1; + else if (id < 464) return id - 4; + else if (id < 503) return 1; + else if (id < 585) return id - 43; + else if (id < 590) return 1; + else if (id < 609) return id - 48; + else if (id < 610) return 1; + else if (id < 642) return id - 49; + else if (id < 646) return 1; + else if (id < 710) return id - 53; + else if (id < 711) return 1; + else if (id < 716) return id - 54; + else if (id < 717) return 1; + else if (id < 720) return id - 55; + else if (id < 721) return 1; + else if (id < 846) return id - 56; + else return 1; + } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/PlayerPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/PlayerPackets.java index 91f4b9b13..9801bbdca 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/PlayerPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/PlayerPackets.java @@ -7,65 +7,65 @@ import us.myles.ViaVersion.packets.State; public class PlayerPackets { - public static void register(Protocol protocol) { + public static void register(Protocol protocol) { - // Open Sign Editor - protocol.registerOutgoing(State.PLAY, 0x2C, 0x2C, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.POSITION, Type.POSITION1_14); - } - }); + // Open Sign Editor + protocol.registerOutgoing(State.PLAY, 0x2C, 0x2C, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.POSITION, Type.POSITION1_14); + } + }); - // Query Block NBT - protocol.registerIncoming(State.PLAY, 0x01, 0x01, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT); - map(Type.POSITION1_14, Type.POSITION); - } - }); + // Query Block NBT + protocol.registerIncoming(State.PLAY, 0x01, 0x01, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); + map(Type.POSITION1_14, Type.POSITION); + } + }); - // Player Digging - protocol.registerIncoming(State.PLAY, 0x18, 0x18, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT); - map(Type.POSITION1_14, Type.POSITION); - map(Type.BYTE); - } - }); + // Player Digging + protocol.registerIncoming(State.PLAY, 0x18, 0x18, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); + map(Type.POSITION1_14, Type.POSITION); + map(Type.BYTE); + } + }); - // Update Command Block - protocol.registerIncoming(State.PLAY, 0x22, 0x22, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.POSITION1_14, Type.POSITION); - } - }); + // Update Command Block + protocol.registerIncoming(State.PLAY, 0x22, 0x22, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.POSITION1_14, Type.POSITION); + } + }); - // Update Structure Block - protocol.registerIncoming(State.PLAY, 0x25, 0x25, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.POSITION1_14, Type.POSITION); - } - }); + // Update Structure Block + protocol.registerIncoming(State.PLAY, 0x25, 0x25, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.POSITION1_14, Type.POSITION); + } + }); - // Update Sign - protocol.registerIncoming(State.PLAY, 0x26, 0x26, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.POSITION1_14, Type.POSITION); - } - }); + // Update Sign + protocol.registerIncoming(State.PLAY, 0x26, 0x26, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.POSITION1_14, Type.POSITION); + } + }); - // Player Block Placement - protocol.registerIncoming(State.PLAY, 0x29, 0x29, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.POSITION1_14, Type.POSITION); - } - }); - } + // Player Block Placement + protocol.registerIncoming(State.PLAY, 0x29, 0x29, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.POSITION1_14, Type.POSITION); + } + }); + } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/WorldPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/WorldPackets.java index b55c1d769..8392455b1 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/WorldPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/WorldPackets.java @@ -18,252 +18,252 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; public class WorldPackets { - public static void register(Protocol protocol) { + public static void register(Protocol protocol) { - // Block break animation - protocol.registerOutgoing(State.PLAY, 0x08, 0x08, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT); - map(Type.POSITION, Type.POSITION1_14); - map(Type.BYTE); - } - }); + // Block break animation + protocol.registerOutgoing(State.PLAY, 0x08, 0x08, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); + map(Type.POSITION, Type.POSITION1_14); + map(Type.BYTE); + } + }); - // Update block entity - protocol.registerOutgoing(State.PLAY, 0x09, 0x09, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.POSITION, Type.POSITION1_14); - } - }); + // Update block entity + protocol.registerOutgoing(State.PLAY, 0x09, 0x09, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.POSITION, Type.POSITION1_14); + } + }); - // Block Action - protocol.registerOutgoing(State.PLAY, 0x0A, 0x0A, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.POSITION, Type.POSITION1_14); // Location - map(Type.UNSIGNED_BYTE); // Action id - map(Type.UNSIGNED_BYTE); // Action param - map(Type.VAR_INT); // Block id - /!\ NOT BLOCK STATE - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - wrapper.set(Type.VAR_INT, 0, Protocol1_14To1_13_2.getNewBlockId(wrapper.get(Type.VAR_INT, 0))); - } - }); - } - }); + // Block Action + protocol.registerOutgoing(State.PLAY, 0x0A, 0x0A, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.POSITION, Type.POSITION1_14); // Location + map(Type.UNSIGNED_BYTE); // Action id + map(Type.UNSIGNED_BYTE); // Action param + map(Type.VAR_INT); // Block id - /!\ NOT BLOCK STATE + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + wrapper.set(Type.VAR_INT, 0, Protocol1_14To1_13_2.getNewBlockId(wrapper.get(Type.VAR_INT, 0))); + } + }); + } + }); - // Block Change - protocol.registerOutgoing(State.PLAY, 0xB, 0xB, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.POSITION, Type.POSITION1_14); - map(Type.VAR_INT); - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - int id = wrapper.get(Type.VAR_INT, 0); + // Block Change + protocol.registerOutgoing(State.PLAY, 0xB, 0xB, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.POSITION, Type.POSITION1_14); + map(Type.VAR_INT); + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int id = wrapper.get(Type.VAR_INT, 0); - wrapper.set(Type.VAR_INT, 0, Protocol1_14To1_13_2.getNewBlockStateId(id)); - } - }); - } - }); + wrapper.set(Type.VAR_INT, 0, Protocol1_14To1_13_2.getNewBlockStateId(id)); + } + }); + } + }); - // Multi Block Change - protocol.registerOutgoing(State.PLAY, 0xF, 0xF, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.INT); // 0 - Chunk X - map(Type.INT); // 1 - Chunk Z - map(Type.BLOCK_CHANGE_RECORD_ARRAY); // 2 - Records - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - // Convert ids - for (BlockChangeRecord record : wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0)) { - int id = record.getBlockId(); - record.setBlockId(Protocol1_14To1_13_2.getNewBlockStateId(id)); - } - } - }); - } - }); - //Chunk - protocol.registerOutgoing(State.PLAY, 0x22, 0x22, new PacketRemapper() { - @Override - public void registerMap() { - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); - Chunk chunk = wrapper.read(new Chunk1_13Type(clientWorld)); - wrapper.write(new Chunk1_14Type(clientWorld), chunk); + // Multi Block Change + protocol.registerOutgoing(State.PLAY, 0xF, 0xF, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.INT); // 0 - Chunk X + map(Type.INT); // 1 - Chunk Z + map(Type.BLOCK_CHANGE_RECORD_ARRAY); // 2 - Records + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + // Convert ids + for (BlockChangeRecord record : wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0)) { + int id = record.getBlockId(); + record.setBlockId(Protocol1_14To1_13_2.getNewBlockStateId(id)); + } + } + }); + } + }); + //Chunk + protocol.registerOutgoing(State.PLAY, 0x22, 0x22, new PacketRemapper() { + @Override + public void registerMap() { + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); + Chunk chunk = wrapper.read(new Chunk1_13Type(clientWorld)); + wrapper.write(new Chunk1_14Type(clientWorld), chunk); - for (ChunkSection section : chunk.getSections()) { - if (section == null) continue; - boolean hasBlock = false; - for (int i = 0; i < section.getPalette().size(); i++) { - int old = section.getPalette().get(i); - if (!hasBlock && !(old == 0 || old == 8591 || old == 8592)) { // air, void_air, cave_air - hasBlock = true; - } - int newId = Protocol1_14To1_13_2.getNewBlockStateId(old); - section.getPalette().set(i, newId); - } - if (!hasBlock) { - section.setNonAirBlocksCount(0); - continue; - } - int nonAirBlockCount = 0; - for (int x = 0; x < 16; x++) { - for (int y = 0; y < 16; y++) { - for (int z = 0; z < 16; z++) { - int id = section.getFlatBlock(x, y, z); - if (id == 0 || id == 8591 || id == 8592) { - nonAirBlockCount++; - } - } - } - } - section.setNonAirBlocksCount(nonAirBlockCount); - } + for (ChunkSection section : chunk.getSections()) { + if (section == null) continue; + boolean hasBlock = false; + for (int i = 0; i < section.getPalette().size(); i++) { + int old = section.getPalette().get(i); + if (!hasBlock && !(old == 0 || old == 8591 || old == 8592)) { // air, void_air, cave_air + hasBlock = true; + } + int newId = Protocol1_14To1_13_2.getNewBlockStateId(old); + section.getPalette().set(i, newId); + } + if (!hasBlock) { + section.setNonAirBlocksCount(0); + continue; + } + int nonAirBlockCount = 0; + for (int x = 0; x < 16; x++) { + for (int y = 0; y < 16; y++) { + for (int z = 0; z < 16; z++) { + int id = section.getFlatBlock(x, y, z); + if (id == 0 || id == 8591 || id == 8592) { + nonAirBlockCount++; + } + } + } + } + section.setNonAirBlocksCount(nonAirBlockCount); + } - PacketWrapper lightPacket = wrapper.create(0x57); - lightPacket.write(Type.VAR_INT, chunk.getX()); - lightPacket.write(Type.VAR_INT, chunk.getZ()); - int skyLightMask = 0; - int blockLightMask = 0; - for (int i = 0; i < chunk.getSections().length; i++) { - ChunkSection sec = chunk.getSections()[i]; - if (sec == null) continue; - if (sec.hasSkyLight()) { - skyLightMask |= (1 << (i + 1)); - } - blockLightMask |= (1 << (i + 1)); - } - lightPacket.write(Type.VAR_INT, skyLightMask); - lightPacket.write(Type.VAR_INT, blockLightMask); - for (ChunkSection section : chunk.getSections()) { - if (section == null || !section.hasSkyLight()) continue; - ByteBuf buf = wrapper.user().getChannel().alloc().buffer(); - section.writeSkyLight(buf); - byte[] data = new byte[buf.readableBytes()]; - buf.readBytes(data); - buf.release(); - lightPacket.write(Type.BYTE_ARRAY, Bytes.asList(data).toArray(new Byte[0])); - } - for (ChunkSection section : chunk.getSections()) { - if (section == null) continue; - ByteBuf buf = wrapper.user().getChannel().alloc().buffer(); - section.writeBlockLight(buf); - byte[] data = new byte[buf.readableBytes()]; - buf.readBytes(data); - buf.release(); - lightPacket.write(Type.BYTE_ARRAY, Bytes.asList(data).toArray(new Byte[0])); - } - lightPacket.send(Protocol1_14To1_13_2.class); - } - }); - } - }); + PacketWrapper lightPacket = wrapper.create(0x57); + lightPacket.write(Type.VAR_INT, chunk.getX()); + lightPacket.write(Type.VAR_INT, chunk.getZ()); + int skyLightMask = 0; + int blockLightMask = 0; + for (int i = 0; i < chunk.getSections().length; i++) { + ChunkSection sec = chunk.getSections()[i]; + if (sec == null) continue; + if (sec.hasSkyLight()) { + skyLightMask |= (1 << (i + 1)); + } + blockLightMask |= (1 << (i + 1)); + } + lightPacket.write(Type.VAR_INT, skyLightMask); + lightPacket.write(Type.VAR_INT, blockLightMask); + for (ChunkSection section : chunk.getSections()) { + if (section == null || !section.hasSkyLight()) continue; + ByteBuf buf = wrapper.user().getChannel().alloc().buffer(); + section.writeSkyLight(buf); + byte[] data = new byte[buf.readableBytes()]; + buf.readBytes(data); + buf.release(); + lightPacket.write(Type.BYTE_ARRAY, Bytes.asList(data).toArray(new Byte[0])); + } + for (ChunkSection section : chunk.getSections()) { + if (section == null) continue; + ByteBuf buf = wrapper.user().getChannel().alloc().buffer(); + section.writeBlockLight(buf); + byte[] data = new byte[buf.readableBytes()]; + buf.readBytes(data); + buf.release(); + lightPacket.write(Type.BYTE_ARRAY, Bytes.asList(data).toArray(new Byte[0])); + } + lightPacket.send(Protocol1_14To1_13_2.class); + } + }); + } + }); - // Effect packet - protocol.registerOutgoing(State.PLAY, 0x23, 0x23, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.INT); // Effect Id - map(Type.POSITION, Type.POSITION1_14); // Location - map(Type.INT); // Data - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - int id = wrapper.get(Type.INT, 0); - int data = wrapper.get(Type.INT, 1); - if (id == 1010) { // Play record - wrapper.set(Type.INT, 1, data = InventoryPackets.getNewItemId(data)); - } else if (id == 2001) { // Block break + block break sound - wrapper.set(Type.INT, 1, data = Protocol1_14To1_13_2.getNewBlockStateId(data)); - } - } - }); - } - }); + // Effect packet + protocol.registerOutgoing(State.PLAY, 0x23, 0x23, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.INT); // Effect Id + map(Type.POSITION, Type.POSITION1_14); // Location + map(Type.INT); // Data + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int id = wrapper.get(Type.INT, 0); + int data = wrapper.get(Type.INT, 1); + if (id == 1010) { // Play record + wrapper.set(Type.INT, 1, data = InventoryPackets.getNewItemId(data)); + } else if (id == 2001) { // Block break + block break sound + wrapper.set(Type.INT, 1, data = Protocol1_14To1_13_2.getNewBlockStateId(data)); + } + } + }); + } + }); - //spawn particle - protocol.registerOutgoing(State.PLAY, 0x24, 0x24, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.INT); // 0 - Particle ID - map(Type.BOOLEAN); // 1 - Long Distance - map(Type.FLOAT); // 2 - X - map(Type.FLOAT); // 3 - Y - map(Type.FLOAT); // 4 - Z - map(Type.FLOAT); // 5 - Offset X - map(Type.FLOAT); // 6 - Offset Y - map(Type.FLOAT); // 7 - Offset Z - map(Type.FLOAT); // 8 - Particle Data - map(Type.INT); // 9 - Particle Count - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - int id = wrapper.get(Type.INT, 0); - if (id == 3 || id == 20) { - int data = wrapper.passthrough(Type.VAR_INT); - wrapper.set(Type.VAR_INT, 0, Protocol1_14To1_13_2.getNewBlockStateId(data)); - } else if (id == 27) { - InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); - } - } - }); - } - }); + //spawn particle + protocol.registerOutgoing(State.PLAY, 0x24, 0x24, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.INT); // 0 - Particle ID + map(Type.BOOLEAN); // 1 - Long Distance + map(Type.FLOAT); // 2 - X + map(Type.FLOAT); // 3 - Y + map(Type.FLOAT); // 4 - Z + map(Type.FLOAT); // 5 - Offset X + map(Type.FLOAT); // 6 - Offset Y + map(Type.FLOAT); // 7 - Offset Z + map(Type.FLOAT); // 8 - Particle Data + map(Type.INT); // 9 - Particle Count + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int id = wrapper.get(Type.INT, 0); + if (id == 3 || id == 20) { + int data = wrapper.passthrough(Type.VAR_INT); + wrapper.set(Type.VAR_INT, 0, Protocol1_14To1_13_2.getNewBlockStateId(data)); + } else if (id == 27) { + InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); + } + } + }); + } + }); - //join game - protocol.registerOutgoing(State.PLAY, 0x25, 0x25, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.INT); // 0 - Entity ID - map(Type.UNSIGNED_BYTE); // 1 - Gamemode - map(Type.INT); // 2 - Dimension + //join game + protocol.registerOutgoing(State.PLAY, 0x25, 0x25, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.INT); // 0 - Entity ID + map(Type.UNSIGNED_BYTE); // 1 - Gamemode + map(Type.INT); // 2 - Dimension - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - // Store the player - ClientWorld clientChunks = wrapper.user().get(ClientWorld.class); - int dimensionId = wrapper.get(Type.INT, 1); - clientChunks.setEnvironment(dimensionId); - } - }); - } - }); + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + // Store the player + ClientWorld clientChunks = wrapper.user().get(ClientWorld.class); + int dimensionId = wrapper.get(Type.INT, 1); + clientChunks.setEnvironment(dimensionId); + } + }); + } + }); - //respawn - protocol.registerOutgoing(State.PLAY, 0x38, 0x38, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.INT); // 0 - Dimension ID - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); - int dimensionId = wrapper.get(Type.INT, 0); - clientWorld.setEnvironment(dimensionId); - } - }); - } - }); + //respawn + protocol.registerOutgoing(State.PLAY, 0x38, 0x38, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.INT); // 0 - Dimension ID + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); + int dimensionId = wrapper.get(Type.INT, 0); + clientWorld.setEnvironment(dimensionId); + } + }); + } + }); - // Spawn position - protocol.registerOutgoing(State.PLAY, 0x49, 0x49, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.POSITION, Type.POSITION1_14); - } - }); - } + // Spawn position + protocol.registerOutgoing(State.PLAY, 0x49, 0x49, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.POSITION, Type.POSITION1_14); + } + }); + } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/storage/EntityTracker.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/storage/EntityTracker.java index 9d7f7fb88..5f4cc24e2 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/storage/EntityTracker.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/storage/EntityTracker.java @@ -9,25 +9,25 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class EntityTracker extends StoredObject { - private final Map clientEntityTypes = new ConcurrentHashMap<>(); + private final Map clientEntityTypes = new ConcurrentHashMap<>(); - public EntityTracker(UserConnection user) { - super(user); - } + public EntityTracker(UserConnection user) { + super(user); + } - public void removeEntity(int entityId) { - clientEntityTypes.remove(entityId); - } + public void removeEntity(int entityId) { + clientEntityTypes.remove(entityId); + } - public void addEntity(int entityId, Entity1_14Types.EntityType type) { - clientEntityTypes.put(entityId, type); - } + public void addEntity(int entityId, Entity1_14Types.EntityType type) { + clientEntityTypes.put(entityId, type); + } - public boolean has(int entityId) { - return clientEntityTypes.containsKey(entityId); - } + public boolean has(int entityId) { + return clientEntityTypes.containsKey(entityId); + } - public Optional get(int id) { - return Optional.fromNullable(clientEntityTypes.get(id)); - } + public Optional get(int id) { + return Optional.fromNullable(clientEntityTypes.get(id)); + } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/types/Chunk1_14Type.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/types/Chunk1_14Type.java index e49e2ce79..29751f944 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/types/Chunk1_14Type.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/types/Chunk1_14Type.java @@ -19,90 +19,90 @@ import java.util.List; public class Chunk1_14Type extends PartialType { - public Chunk1_14Type(ClientWorld param) { - super(param, Chunk.class); - } + public Chunk1_14Type(ClientWorld param) { + super(param, Chunk.class); + } - @Override - public Chunk read(ByteBuf input, ClientWorld world) throws Exception { - int chunkX = input.readInt(); - int chunkZ = input.readInt(); + @Override + public Chunk read(ByteBuf input, ClientWorld world) throws Exception { + int chunkX = input.readInt(); + int chunkZ = input.readInt(); - boolean groundUp = input.readBoolean(); - int primaryBitmask = Type.VAR_INT.read(input); - Type.VAR_INT.read(input); + boolean groundUp = input.readBoolean(); + int primaryBitmask = Type.VAR_INT.read(input); + Type.VAR_INT.read(input); - BitSet usedSections = new BitSet(16); - ChunkSection[] sections = new ChunkSection[16]; - // Calculate section count from bitmask - for (int i = 0; i < 16; i++) { - if ((primaryBitmask & (1 << i)) != 0) { - usedSections.set(i); - } - } + BitSet usedSections = new BitSet(16); + ChunkSection[] sections = new ChunkSection[16]; + // Calculate section count from bitmask + for (int i = 0; i < 16; i++) { + if ((primaryBitmask & (1 << i)) != 0) { + usedSections.set(i); + } + } - // Read sections - for (int i = 0; i < 16; i++) { - if (!usedSections.get(i)) continue; // Section not set - short nonAirBlocksCount = input.readShort(); - ChunkSection section = Types1_13.CHUNK_SECTION.read(input); - section.setNonAirBlocksCount(nonAirBlocksCount); - sections[i] = section; - } + // Read sections + for (int i = 0; i < 16; i++) { + if (!usedSections.get(i)) continue; // Section not set + short nonAirBlocksCount = input.readShort(); + ChunkSection section = Types1_13.CHUNK_SECTION.read(input); + section.setNonAirBlocksCount(nonAirBlocksCount); + sections[i] = section; + } - byte[] biomeData = groundUp ? new byte[256] : null; - if (groundUp) { - for (int i = 0; i < 256; i++) { - biomeData[i] = (byte) input.readInt(); - } - } + byte[] biomeData = groundUp ? new byte[256] : null; + if (groundUp) { + for (int i = 0; i < 256; i++) { + biomeData[i] = (byte) input.readInt(); + } + } - List nbtData = new ArrayList<>(Arrays.asList(Type.NBT_ARRAY.read(input))); + List nbtData = new ArrayList<>(Arrays.asList(Type.NBT_ARRAY.read(input))); - // Read all the remaining bytes (workaround for #681) - if (input.readableBytes() > 0) { - byte[] array = Type.REMAINING_BYTES.read(input); - if (Via.getManager().isDebug()) { - Via.getPlatform().getLogger().warning("Found " + array.length + " more bytes than expected while reading the chunk: " + chunkX + "/" + chunkZ); - } - } + // Read all the remaining bytes (workaround for #681) + if (input.readableBytes() > 0) { + byte[] array = Type.REMAINING_BYTES.read(input); + if (Via.getManager().isDebug()) { + Via.getPlatform().getLogger().warning("Found " + array.length + " more bytes than expected while reading the chunk: " + chunkX + "/" + chunkZ); + } + } - return new BaseChunk(chunkX, chunkZ, groundUp, primaryBitmask, sections, biomeData, nbtData); - } + return new BaseChunk(chunkX, chunkZ, groundUp, primaryBitmask, sections, biomeData, nbtData); + } - @Override - public void write(ByteBuf output, ClientWorld world, Chunk chunk) throws Exception { - output.writeInt(chunk.getX()); - output.writeInt(chunk.getZ()); + @Override + public void write(ByteBuf output, ClientWorld world, Chunk chunk) throws Exception { + output.writeInt(chunk.getX()); + output.writeInt(chunk.getZ()); - output.writeBoolean(chunk.isGroundUp()); - Type.VAR_INT.write(output, chunk.getBitmask()); + output.writeBoolean(chunk.isGroundUp()); + Type.VAR_INT.write(output, chunk.getBitmask()); - ByteBuf buf = output.alloc().buffer(); - for (int i = 0; i < 16; i++) { - ChunkSection section = chunk.getSections()[i]; - if (section == null) continue; // Section not set - buf.writeShort(section.getNonAirBlocksCount()); - Types1_13.CHUNK_SECTION.write(buf, section); - } - buf.readerIndex(0); - Type.VAR_INT.write(output, buf.readableBytes() + (chunk.isBiomeData() ? 256 * 4 : 0)); - output.writeBytes(buf); - buf.release(); // release buffer + ByteBuf buf = output.alloc().buffer(); + for (int i = 0; i < 16; i++) { + ChunkSection section = chunk.getSections()[i]; + if (section == null) continue; // Section not set + buf.writeShort(section.getNonAirBlocksCount()); + Types1_13.CHUNK_SECTION.write(buf, section); + } + buf.readerIndex(0); + Type.VAR_INT.write(output, buf.readableBytes() + (chunk.isBiomeData() ? 256 * 4 : 0)); + output.writeBytes(buf); + buf.release(); // release buffer - // Write biome data - if (chunk.isBiomeData()) { - for (byte value : chunk.getBiomeData()) { - output.writeInt(value & 0xFF); // This is a temporary workaround, we'll look into fixing this soon :) - } - } + // Write biome data + if (chunk.isBiomeData()) { + for (byte value : chunk.getBiomeData()) { + output.writeInt(value & 0xFF); // This is a temporary workaround, we'll look into fixing this soon :) + } + } - // Write Block Entities - Type.NBT_ARRAY.write(output, chunk.getBlockEntities().toArray(new CompoundTag[0])); - } + // Write Block Entities + Type.NBT_ARRAY.write(output, chunk.getBlockEntities().toArray(new CompoundTag[0])); + } - @Override - public Class getBaseClass() { - return BaseChunkType.class; - } + @Override + public Class getBaseClass() { + return BaseChunkType.class; + } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/ItemRewriter.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/ItemRewriter.java index da848d8f0..c73af9382 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/ItemRewriter.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/ItemRewriter.java @@ -186,7 +186,7 @@ public class ItemRewriter { } } } - + public static void rewriteBookToServer(Item item) { short id = item.getId(); if (id != 387) { @@ -212,7 +212,7 @@ public class ItemRewriter { stag.setValue(value); } } - + private static String fixBookSpaceChars(String str) { if (!str.startsWith(" ")) { return str; diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java index f6fb17809..79c14418b 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java @@ -7,6 +7,7 @@ import io.netty.buffer.ByteBuf; import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.minecraft.Position; +import us.myles.ViaVersion.api.minecraft.chunks.Chunk1_8; import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.remapper.PacketHandler; @@ -16,7 +17,6 @@ import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_9to1_8.ItemRewriter; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8; -import us.myles.ViaVersion.api.minecraft.chunks.Chunk1_8; import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.BulkChunkTranslatorProvider; import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.CommandBlockProvider; import us.myles.ViaVersion.protocols.protocol1_9to1_8.sounds.Effect; @@ -307,7 +307,7 @@ public class WorldPackets { // Blocking patch if (Via.getConfig().isShieldBlocking()) { EntityTracker tracker = wrapper.user().get(EntityTracker.class); - + if (item != null && Protocol1_9TO1_8.isSword(item.getId())) { if (hand == 0) { if (!tracker.isBlocking()) { diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/storage/EntityTracker.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/storage/EntityTracker.java index 64906f7b7..9a9dce713 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/storage/EntityTracker.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/storage/EntityTracker.java @@ -258,7 +258,7 @@ public class EntityTracker extends StoredObject { } else { wrapper.write(Type.BYTE, (byte) 3); } - wrapper.write(Type.STRING_ARRAY, new String[] {getUser().get(ProtocolInfo.class).getUsername()}); + wrapper.write(Type.STRING_ARRAY, new String[]{getUser().get(ProtocolInfo.class).getUsername()}); } else { wrapper.write(Type.BYTE, (byte) 1); // remove team } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/types/Chunk1_9to1_8Type.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/types/Chunk1_9to1_8Type.java index 877a5aa5c..a0a997ae6 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/types/Chunk1_9to1_8Type.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/types/Chunk1_9to1_8Type.java @@ -4,6 +4,7 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import io.netty.buffer.ByteBuf; import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.minecraft.chunks.Chunk; +import us.myles.ViaVersion.api.minecraft.chunks.Chunk1_8; import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection; import us.myles.ViaVersion.api.type.PartialType; import us.myles.ViaVersion.api.type.Type; @@ -12,7 +13,6 @@ import us.myles.ViaVersion.api.type.types.version.Types1_8; import us.myles.ViaVersion.api.type.types.version.Types1_9; import us.myles.ViaVersion.protocols.base.ProtocolInfo; import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.Protocol1_10To1_9_3_4; -import us.myles.ViaVersion.api.minecraft.chunks.Chunk1_8; import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.ClientChunks; import java.util.ArrayList; diff --git a/jar/pom.xml b/jar/pom.xml index a9399516f..e99da1236 100644 --- a/jar/pom.xml +++ b/jar/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 1.6.1-SNAPSHOT + 1.6.1-18w43c 4.0.0 viaversion-jar diff --git a/pom.xml b/pom.xml index 00c615f8a..9241a13ab 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ us.myles viaversion-parent - 1.6.1-SNAPSHOT + 1.6.1-18w43c pom viaversion-parent diff --git a/sponge-legacy/pom.xml b/sponge-legacy/pom.xml index ac481ad6b..e8e3e7e06 100644 --- a/sponge-legacy/pom.xml +++ b/sponge-legacy/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 1.6.1-SNAPSHOT + 1.6.1-18w43c 4.0.0 diff --git a/sponge/pom.xml b/sponge/pom.xml index d9367e0e1..13d6e1fa9 100644 --- a/sponge/pom.xml +++ b/sponge/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 1.6.1-SNAPSHOT + 1.6.1-18w43c 4.0.0 @@ -42,7 +42,8 @@ - lombok.launch.AnnotationProcessorHider$AnnotationProcessor + lombok.launch.AnnotationProcessorHider$AnnotationProcessor + diff --git a/sponge/src/main/java/us/myles/ViaVersion/SpongePlugin.java b/sponge/src/main/java/us/myles/ViaVersion/SpongePlugin.java index 7ca0ac3f6..a5d1f76ce 100644 --- a/sponge/src/main/java/us/myles/ViaVersion/SpongePlugin.java +++ b/sponge/src/main/java/us/myles/ViaVersion/SpongePlugin.java @@ -17,7 +17,6 @@ import org.spongepowered.api.plugin.PluginContainer; import org.spongepowered.api.scheduler.Task; import org.spongepowered.api.text.serializer.TextSerializers; import us.myles.ViaVersion.api.Via; -import us.myles.ViaVersion.api.ViaAPI; import us.myles.ViaVersion.api.command.ViaCommandSender; import us.myles.ViaVersion.api.configuration.ConfigurationProvider; import us.myles.ViaVersion.api.platform.TaskId; @@ -32,10 +31,8 @@ import us.myles.ViaVersion.util.GsonUtil; import java.io.File; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.UUID; -import java.util.concurrent.TimeUnit; import java.util.logging.Logger; @Plugin(id = "viaversion", diff --git a/sponge/src/main/java/us/myles/ViaVersion/sponge/platform/SpongeConfigAPI.java b/sponge/src/main/java/us/myles/ViaVersion/sponge/platform/SpongeConfigAPI.java index 86a98cef7..d5ec668db 100644 --- a/sponge/src/main/java/us/myles/ViaVersion/sponge/platform/SpongeConfigAPI.java +++ b/sponge/src/main/java/us/myles/ViaVersion/sponge/platform/SpongeConfigAPI.java @@ -185,7 +185,7 @@ public class SpongeConfigAPI extends Config implements ViaVersionConfig { public boolean is1_12NBTArrayFix() { return getBoolean("chat-nbt-fix", true); } - + @Override public boolean is1_12QuickMoveActionFix() { return false;