3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-11-20 06:50:10 +01:00

Merge pull request #89 from Gerrygames/dev

remap trading gui 1.13.1 to 1.13
Dieser Commit ist enthalten in:
Mats 2019-01-27 12:58:08 +01:00 committet von GitHub
Commit bf7ea31d35
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -16,30 +16,12 @@ public class InventoryPackets {
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_ITEM); // 2 - Slot Value
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
Item stack = wrapper.get(Type.FLAT_ITEM, 0);
toClient(stack);
}
});
}
});
// 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_ITEM_ARRAY); // 1 - Window Values
map(Type.FLAT_ITEM_ARRAY); // 1 - Window Values
handler(new PacketHandler() {
@Override
@ -52,13 +34,68 @@ public class InventoryPackets {
}
});
// 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); // 2 - Slot Value
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
Item stack = wrapper.get(Type.FLAT_ITEM, 0);
toClient(stack);
}
});
}
});
//Plugin Message
protocol.registerOutgoing(State.PLAY, 0x19, 0x19, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
String channel = wrapper.passthrough(Type.STRING);
if (channel.equals("minecraft: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
Item input = wrapper.passthrough(Type.FLAT_ITEM);
toClient(input);
//Output Item
Item output = wrapper.passthrough(Type.FLAT_ITEM);
toClient(input);
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); //Has second item
if (secondItem) {
//Second Item
Item second = wrapper.passthrough(Type.FLAT_ITEM);
toClient(input);
}
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_ITEM); // 2 - Item
map(Type.FLAT_ITEM); // 2 - Item
handler(new PacketHandler() {
@Override
@ -84,7 +121,7 @@ public class InventoryPackets {
map(Type.BYTE); // 2 - Button
map(Type.SHORT); // 3 - Action number
map(Type.VAR_INT); // 4 - Mode
map(Type.FLAT_ITEM, Type.FLAT_ITEM); // 5 - Clicked Item
map(Type.FLAT_ITEM); // 5 - Clicked Item
handler(new PacketHandler() {
@Override
@ -102,7 +139,7 @@ public class InventoryPackets {
@Override
public void registerMap() {
map(Type.SHORT); // 0 - Slot
map(Type.FLAT_ITEM, Type.FLAT_ITEM); // 1 - Clicked Item
map(Type.FLAT_ITEM); // 1 - Clicked Item
handler(new PacketHandler() {
@Override