Merge pull request #89 from Gerrygames/dev

remap trading gui 1.13.1 to 1.13
This commit is contained in:
Mats 2019-01-27 12:58:08 +01:00 committed by GitHub
commit bf7ea31d35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,30 +16,12 @@ public class InventoryPackets {
Outgoing packets 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 // Window items packet
protocol.registerOutgoing(State.PLAY, 0x15, 0x15, new PacketRemapper() { protocol.registerOutgoing(State.PLAY, 0x15, 0x15, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID 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() { handler(new PacketHandler() {
@Override @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 // Entity Equipment Packet
protocol.registerOutgoing(State.PLAY, 0x42, 0x42, new PacketRemapper() { protocol.registerOutgoing(State.PLAY, 0x42, 0x42, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 0 - Entity ID
map(Type.VAR_INT); // 1 - Slot 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() { handler(new PacketHandler() {
@Override @Override
@ -84,7 +121,7 @@ public class InventoryPackets {
map(Type.BYTE); // 2 - Button map(Type.BYTE); // 2 - Button
map(Type.SHORT); // 3 - Action number map(Type.SHORT); // 3 - Action number
map(Type.VAR_INT); // 4 - Mode 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() { handler(new PacketHandler() {
@Override @Override
@ -102,7 +139,7 @@ public class InventoryPackets {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.SHORT); // 0 - Slot 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() { handler(new PacketHandler() {
@Override @Override