mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2024-11-15 11:05:32 +01:00
commit
e0b48f5f49
@ -12,7 +12,10 @@ package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.BackwardsMappings;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.PaintingMapping;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.BlockItemPackets1_13;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.EntityPackets1_13;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.PlayerPacket1_13;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
@ -25,31 +28,30 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol {
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
new BlockItemPackets1_13().register(this);
|
||||
new EntityPackets1_13().register(this);
|
||||
new PlayerPacket1_13().register(this);
|
||||
|
||||
// Thanks to https://wiki.vg/index.php?title=Pre-release_protocol&oldid=14150
|
||||
|
||||
|
||||
out(State.PLAY, 0x00, 0x00, cancel());
|
||||
out(State.PLAY, 0x04, 0x04, cancel());// Spawn Painting TODO MODIFIED
|
||||
out(State.PLAY, 0x00, 0x00, cancel()); // Spawn Object TODO type ids
|
||||
out(State.PLAY, 0x03, 0x03, cancel()); // Spawn Mob TODO Metadata, type ids
|
||||
out(State.PLAY, 0x07, 0x07, cancel()); // Statistics TODO MODIFIED
|
||||
out(State.PLAY, 0x09, 0x09, cancel()); // Update Block Entity TODO MODIFIED
|
||||
out(State.PLAY, 0x0B, 0x0B, cancel()); // Block Change TODO MODIFIED
|
||||
out(State.PLAY, 0x0E, 0x0F); // Chat Message (clientbound)
|
||||
out(State.PLAY, 0x0F, 0x10, cancel()); // Multi Block Change TODO MODIFIED
|
||||
out(State.PLAY, 0x10, 0x0E, cancel()); // Tab-Complete (clientbound) TODO MODIFIED
|
||||
out(State.PLAY, 0x11, -1, cancel()); // Declare Commands TODO NEW
|
||||
out(State.PLAY, 0x12, 0x11, cancel()); // Confirm Transaction (clientbound)
|
||||
out(State.PLAY, 0x13, 0x12, cancel()); // Close Window (clientbound)
|
||||
out(State.PLAY, 0x14, 0x13, cancel()); // Open Window
|
||||
out(State.PLAY, 0x15, 0x14, cancel()); // Window Items
|
||||
out(State.PLAY, 0x16, 0x15, cancel()); // Window Property
|
||||
out(State.PLAY, 0x17, 0x16, cancel()); // Set Slot
|
||||
out(State.PLAY, 0x18, 0x17); // Set Cooldown
|
||||
out(State.PLAY, 0x12, 0x11); // Confirm Transaction (clientbound)
|
||||
out(State.PLAY, 0x13, 0x12); // Close Window (clientbound)
|
||||
out(State.PLAY, 0x14, 0x13); // Open Window
|
||||
out(State.PLAY, 0x16, 0x15); // Window Property
|
||||
out(State.PLAY, 0x18, 0x17); // Set Cooldown
|
||||
out(State.PLAY, 0x19, 0x18); // Plugin Message (clientbound) TODO MODIFIED
|
||||
out(State.PLAY, 0x1A, 0x19, cancel()); // Named Sound Effect TODO MODIFIED
|
||||
out(State.PLAY, 0x1B, 0x1A); // Disconnect (play)
|
||||
out(State.PLAY, 0x1C, 0x1B); // Entity Status
|
||||
out(State.PLAY, 0x1D, -1, cancel()); // NBT Query Response TODO NEW
|
||||
out(State.PLAY, 0x1D, -1, cancel()); // NBT Query Response (client won't send a request, so the server should not answer)
|
||||
out(State.PLAY, 0x1E, 0x1C); // Explosion
|
||||
out(State.PLAY, 0x1F, 0x1D); // Unload Chunk
|
||||
out(State.PLAY, 0x20, 0x1E); // Change Game State
|
||||
@ -59,7 +61,6 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol {
|
||||
|
||||
|
||||
|
||||
out(State.PLAY, 0x23, 0x21, cancel()); // Effect TODO MODIFIED
|
||||
out(State.PLAY, 0x24, 0x22, cancel()); // Spawn Particle TODO MODIFIED
|
||||
out(State.PLAY, 0x25, 0x23, new PacketRemapper() {
|
||||
@Override
|
||||
@ -78,7 +79,6 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol {
|
||||
});
|
||||
}
|
||||
}); // Join Game
|
||||
out(State.PLAY, 0x26, 0x24, cancel()); // Map TODO MODIFIED
|
||||
out(State.PLAY, 0x27, 0x25); // Entity
|
||||
out(State.PLAY, 0x28, 0x26); // Entity Relative Move
|
||||
out(State.PLAY, 0x29, 0x27); // Entity Look And Relative Move
|
||||
@ -101,17 +101,14 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol {
|
||||
out(State.PLAY, 0x3A, 0x37); // Select Advancement Tab
|
||||
out(State.PLAY, 0x3B, 0x38); // World Border
|
||||
out(State.PLAY, 0x3C, 0x39); // Camera
|
||||
out(State.PLAY, 0x3D, 0x3A, cancel()); // Held Item Change (clientbound)
|
||||
out(State.PLAY, 0x3D, 0x3A); // Held Item Change (clientbound)
|
||||
out(State.PLAY, 0x3E, 0x3B); // Display Scoreboard
|
||||
out(State.PLAY, 0x3F, 0x3C, cancel()); // Entity Metadata
|
||||
out(State.PLAY, 0x40, 0x3D); // Attach Entity
|
||||
out(State.PLAY, 0x41, 0x3E); // Entity Velocity
|
||||
out(State.PLAY, 0x42, 0x3F, cancel()); // Entity Equipment
|
||||
out(State.PLAY, 0x43, 0x40); // Set Experience
|
||||
out(State.PLAY, 0x44, 0x41); // Update Health
|
||||
out(State.PLAY, 0x45, 0x42, cancel()); // Scoreboard Objective TODO MODIFIED
|
||||
out(State.PLAY, 0x46, 0x43); // Set Passengers
|
||||
out(State.PLAY, 0x47, 0x44, cancel()); // Teams TODO MODIFIED
|
||||
out(State.PLAY, 0x48, 0x45); // Update Score
|
||||
out(State.PLAY, 0x49, 0x46); // Spawn Position
|
||||
out(State.PLAY, 0x4A, 0x47); // Time Update
|
||||
@ -119,24 +116,21 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol {
|
||||
out(State.PLAY, 0x4C, -1, cancel()); // Stop Sound TODO NEW
|
||||
out(State.PLAY, 0x4D, 0x49); // Sound Effect
|
||||
out(State.PLAY, 0x4E, 0x4A); // Player List Header And Footer
|
||||
out(State.PLAY, 0x4F, 0x4B, cancel()); // Collect Item
|
||||
out(State.PLAY, 0x4F, 0x4B); // Collect Item
|
||||
out(State.PLAY, 0x50, 0x4C); // Entity Teleport
|
||||
out(State.PLAY, 0x51, 0x4D, cancel()); // Advancements
|
||||
out(State.PLAY, 0x52, 0x4E); // Entity Properties
|
||||
out(State.PLAY, 0x53, 0x4F); // Entity Effect
|
||||
out(State.PLAY, 0x54, -1, cancel()); // Declare Recipes TODO NEW
|
||||
out(State.PLAY, 0x55, -1, cancel()); // Tags TODO NEW
|
||||
out(State.PLAY, 0x55, -1, cancel()); // Tags (the client won't need this)
|
||||
|
||||
|
||||
in(State.PLAY, 0x01, -1, cancel()); // Query Block NBT TODO NEW
|
||||
in(State.PLAY, 0x05, 0x01); // Tab-Complete (serverbound) TODO MODIFIED
|
||||
in(State.PLAY, 0x06, 0x05); //Confirm Transaction (serverbound)
|
||||
in(State.PLAY, 0x05, 0x01, cancel()); // Tab-Complete (serverbound) TODO MODIFIED
|
||||
in(State.PLAY, 0x06, 0x05); // Confirm Transaction (serverbound)
|
||||
in(State.PLAY, 0x07, 0x06); // Enchant Item
|
||||
in(State.PLAY, 0x08, 0x07); // Click Window
|
||||
in(State.PLAY, 0x09, 0x08); // Close Window (serverbound)
|
||||
in(State.PLAY, 0x0A, 0x09, cancel()); // Plugin message (serverbound) TODO MODIFIED
|
||||
in(State.PLAY, 0x0B, -1, cancel()); // Edit Book TODO NEW
|
||||
in(State.PLAY, 0x0C, -1, cancel()); // Query Entity NBT TODO NEW
|
||||
in(State.PLAY, 0x0D, 0x0A); // Use Entity
|
||||
in(State.PLAY, 0x0E, 0x0B); // Keep Alive (serverbound)
|
||||
in(State.PLAY, 0x0F, 0x0C); // Player
|
||||
@ -160,7 +154,6 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol {
|
||||
in(State.PLAY, 0x21, 0x1A); // Held Item Change (serverbound)
|
||||
in(State.PLAY, 0x22, -1, cancel()); // Update Command Block TODO NEW
|
||||
in(State.PLAY, 0x23, -1, cancel()); // Update Command Block Minecart TODO NEW
|
||||
in(State.PLAY, 0x24, 0x1B); // Creative Inventory Action
|
||||
in(State.PLAY, 0x25, -1, cancel()); // Update Structure Block TODO NEW
|
||||
in(State.PLAY, 0x26, 0x1C); // Update Sign
|
||||
in(State.PLAY, 0x27, 0x1D); // Animation (serverbound)
|
||||
@ -194,6 +187,7 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol {
|
||||
|
||||
static {
|
||||
BackwardsMappings.init();
|
||||
PaintingMapping.init();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,45 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PaintingMapping {
|
||||
private static Map<Integer, String> paintings = new HashMap<>();
|
||||
|
||||
public static void init() {
|
||||
add("kebab");
|
||||
add("aztec");
|
||||
add("alban");
|
||||
add("aztec2");
|
||||
add("bomb");
|
||||
add("plant");
|
||||
add("wasteland");
|
||||
add("pool");
|
||||
add("courbet");
|
||||
add("sea");
|
||||
add("sunset");
|
||||
add("creebet");
|
||||
add("wanderer");
|
||||
add("graham");
|
||||
add("match");
|
||||
add("bust");
|
||||
add("stage");
|
||||
add("void");
|
||||
add("skullandroses");
|
||||
add("wither");
|
||||
add("fighters");
|
||||
add("pointer");
|
||||
add("pigscene");
|
||||
add("burningskull");
|
||||
add("skeleton");
|
||||
add("donkeykong");
|
||||
}
|
||||
|
||||
private static void add(String motive) {
|
||||
paintings.put(paintings.size(), motive);
|
||||
}
|
||||
|
||||
public static String getStringId(int id) {
|
||||
return paintings.getOrDefault(id, "kebab");
|
||||
}
|
||||
}
|
@ -15,11 +15,16 @@ import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.BackwardsMappings;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.minecraft.BlockChangeRecord;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
@ -28,6 +33,74 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
||||
@Override
|
||||
protected void registerPackets(Protocol1_12_2To1_13 protocol) {
|
||||
|
||||
//Block Change
|
||||
protocol.out(State.PLAY, 0x0B, 0x0B, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int blockState = wrapper.read(Type.VAR_INT);
|
||||
wrapper.write(Type.VAR_INT, toOldId(blockState));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//Multi Block Change
|
||||
protocol.out(State.PLAY, 0x0F, 0x10, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT);
|
||||
map(Type.INT);
|
||||
map(Type.BLOCK_CHANGE_RECORD_ARRAY);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
for (BlockChangeRecord record : wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0)) {
|
||||
record.setBlockId(toOldId(record.getBlockId()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//Windows Items
|
||||
protocol.out(State.PLAY, 0x15, 0x14, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE);
|
||||
map(Type.FLAT_ITEM_ARRAY, Type.ITEM_ARRAY);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
Item[] items = wrapper.get(Type.ITEM_ARRAY, 0);
|
||||
for (Item item : items) {
|
||||
toClient(item);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//Set Slot
|
||||
protocol.out(State.PLAY, 0x17, 0x16, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.BYTE);
|
||||
map(Type.SHORT);
|
||||
map(Type.FLAT_ITEM, Type.ITEM);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
Item item = wrapper.get(Type.ITEM, 0);
|
||||
toClient(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Chunk packet
|
||||
protocol.out(State.PLAY, 0x22, 0x20, new PacketRemapper() {
|
||||
@Override
|
||||
@ -50,7 +123,7 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
||||
for (int p = 0; p < section.getPaletteSize(); p++) {
|
||||
int old = section.getPaletteEntry(p);
|
||||
if (old != 0) {
|
||||
section.setPaletteEntry(p, toNewId(old));
|
||||
section.setPaletteEntry(p, toOldId(old));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -69,9 +142,117 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
//Effect
|
||||
protocol.out(State.PLAY, 0x21, 0x23, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // Effect Id
|
||||
map(Type.POSITION); // 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 = MappingData.oldToNewItems.inverse().get(data) >> 4);
|
||||
} else if (id == 2001) { // Block break + block break sound
|
||||
data = toOldId(data);
|
||||
int blockId = data >> 4;
|
||||
int blockData = data & 0xF;
|
||||
wrapper.set(Type.INT, 1, data = (blockId & 0xFFF) | (blockData << 12));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//Map
|
||||
protocol.out(State.PLAY, 0x26, 0x24, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.BYTE);
|
||||
map(Type.BOOLEAN);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int iconCount = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < iconCount; i++) {
|
||||
int type = wrapper.read(Type.VAR_INT);
|
||||
byte x = wrapper.read(Type.BYTE);
|
||||
byte z = wrapper.read(Type.BYTE);
|
||||
byte direction = wrapper.read(Type.BYTE);
|
||||
if (wrapper.read(Type.BOOLEAN)) {
|
||||
wrapper.read(Type.STRING);
|
||||
}
|
||||
if (type > 9) continue;
|
||||
wrapper.write(Type.BYTE, (byte) ((type << 4) | (direction & 0x0F)));
|
||||
wrapper.write(Type.BYTE, x);
|
||||
wrapper.write(Type.BYTE, z);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//Entity Equipment
|
||||
protocol.out(State.PLAY, 0x42, 0x3F, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.VAR_INT);
|
||||
map(Type.FLAT_ITEM, Type.ITEM);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
Item item = wrapper.get(Type.ITEM, 0);
|
||||
toClient(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//Set Creative Slot
|
||||
protocol.in(State.PLAY, 0x24, 0x1B, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.SHORT);
|
||||
map(Type.ITEM, Type.FLAT_ITEM);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
Item item = wrapper.get(Type.FLAT_ITEM, 0);
|
||||
toServer(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//Click Window
|
||||
protocol.in(State.PLAY, 0x08, 0x07, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE);
|
||||
map(Type.SHORT);
|
||||
map(Type.BYTE);
|
||||
map(Type.SHORT);
|
||||
map(Type.VAR_INT);
|
||||
map(Type.ITEM, Type.FLAT_ITEM);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
Item item = wrapper.get(Type.FLAT_ITEM, 0);
|
||||
toServer(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static int toNewId(int oldId) {
|
||||
public static int toOldId(int oldId) {
|
||||
if (oldId < 0) {
|
||||
oldId = 0; // Some plugins use negative numbers to clear blocks, remap them to air.
|
||||
}
|
||||
@ -84,6 +265,14 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
||||
return 1 << 4;
|
||||
}
|
||||
|
||||
//Basic translation for now. TODO remap new items; should probably use BlockItemRewriter#handleItemToClient/Server, but that needs some rewriting
|
||||
public static void toClient(Item item) {
|
||||
InventoryPackets.toServer(item);
|
||||
}
|
||||
public static void toServer(Item item) {
|
||||
InventoryPackets.toClient(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
|
||||
|
@ -0,0 +1,40 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets;
|
||||
|
||||
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.PaintingMapping;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
|
||||
public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
|
||||
|
||||
@Override
|
||||
protected void registerPackets(Protocol1_12_2To1_13 protocol) {
|
||||
|
||||
//Spawn Painting
|
||||
protocol.out(State.PLAY, 0x04, 0x04, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.UUID);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int motive = wrapper.read(Type.VAR_INT);
|
||||
String title = PaintingMapping.getStringId(motive);
|
||||
wrapper.write(Type.STRING, title);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets;
|
||||
|
||||
import nl.matsv.viabackwards.api.rewriters.Rewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
|
||||
public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
@Override
|
||||
protected void registerPackets(Protocol1_12_2To1_13 protocol) {
|
||||
|
||||
//Scoreboard Objective
|
||||
protocol.out(State.PLAY, 0x45, 0x42, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING);
|
||||
map(Type.BYTE);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
byte mode = wrapper.get(Type.BYTE, 0);
|
||||
if (mode == 0 || mode == 2) {
|
||||
String value = wrapper.read(Type.STRING);
|
||||
value = ChatRewriter.jsonTextToLegacy(value);
|
||||
if (value.length() > 32) value = value.substring(0, 32);
|
||||
wrapper.write(Type.STRING, value);
|
||||
int type = wrapper.read(Type.VAR_INT);
|
||||
wrapper.write(Type.STRING, type == 1 ? "hearts" : "integer");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//Teams
|
||||
protocol.out(State.PLAY, 0x47, 0x44, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING);
|
||||
map(Type.BYTE);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
byte action = wrapper.get(Type.BYTE, 0);
|
||||
if (action == 0 || action == 2) {
|
||||
String displayName = wrapper.read(Type.STRING);
|
||||
displayName = ChatRewriter.jsonTextToLegacy(displayName);
|
||||
if (displayName.length() > 32) displayName = displayName.substring(0, 32);
|
||||
wrapper.write(Type.STRING, displayName);
|
||||
|
||||
String prefix = wrapper.read(Type.STRING);
|
||||
String suffix = wrapper.read(Type.STRING);
|
||||
|
||||
wrapper.passthrough(Type.BYTE); //Flags
|
||||
|
||||
wrapper.passthrough(Type.STRING); //Name Tag Visibility
|
||||
wrapper.passthrough(Type.STRING); //Collision Rule
|
||||
|
||||
int colour = wrapper.read(Type.VAR_INT);
|
||||
if (colour == 21) {
|
||||
colour = -1;
|
||||
}
|
||||
|
||||
wrapper.write(Type.BYTE, (byte) colour);
|
||||
|
||||
wrapper.write(Type.STRING, ChatRewriter.jsonTextToLegacy(prefix));
|
||||
wrapper.write(Type.STRING, ChatRewriter.jsonTextToLegacy(suffix));
|
||||
}
|
||||
|
||||
if (action == 0 || action == 3 || action == 4) {
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // Entities
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
|
||||
}
|
||||
}
|
@ -78,7 +78,7 @@ public class InventoryPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// // Declare Recipes
|
||||
// Declare Recipes
|
||||
protocol.registerOutgoing(State.PLAY, 0x54, 0x54, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
|
Loading…
Reference in New Issue
Block a user