Skip to content

Commit

Permalink
Replaced deprecated API usage
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Oct 26, 2023
1 parent b0e7a20 commit c2f19c6
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static void register(Protocol1_7_6_10To1_8 protocol) {
public void register() {
map(Type.VAR_INT, Type.INT); // entity id
map(Type.SHORT); // slot
map(Type.ITEM, Types1_7_6_10.COMPRESSED_NBT_ITEM); // item
map(Type.ITEM1_8, Types1_7_6_10.COMPRESSED_NBT_ITEM); // item

// remap item
handler(wrapper -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void register() {
}
});

map(Type.ITEM, Types1_7_6_10.COMPRESSED_NBT_ITEM); // item
map(Type.ITEM1_8, Types1_7_6_10.COMPRESSED_NBT_ITEM); // item

// remap item
handler(wrapper -> {
Expand Down Expand Up @@ -123,7 +123,7 @@ public void register() {
handler(wrapper -> {
final short windowType = wrapper.user().get(InventoryTracker.class).get(wrapper.get(Type.UNSIGNED_BYTE, 0));

Item[] items = wrapper.read(Type.ITEM_ARRAY);
Item[] items = wrapper.read(Type.ITEM1_8_SHORT_ARRAY);
if (windowType == 4) { // Enchantment Table
Item[] old = items;
items = new Item[old.length - 1];
Expand Down Expand Up @@ -240,13 +240,13 @@ public void register() {
map(Type.BYTE); // button
map(Type.SHORT); // action number
map(Type.BYTE); // mode
map(Types1_7_6_10.COMPRESSED_NBT_ITEM, Type.ITEM); // clicked item
map(Types1_7_6_10.COMPRESSED_NBT_ITEM, Type.ITEM1_8); // clicked item

// remap item
handler(wrapper -> {
final Item item = wrapper.get(Type.ITEM, 0);
final Item item = wrapper.get(Type.ITEM1_8, 0);
protocol.getItemRewriter().handleItemToServer(item);
wrapper.set(Type.ITEM, 0, item);
wrapper.set(Type.ITEM1_8, 0, item);
});
}
});
Expand All @@ -255,13 +255,13 @@ public void register() {
@Override
public void register() {
map(Type.SHORT); // slot
map(Types1_7_6_10.COMPRESSED_NBT_ITEM, Type.ITEM); // item
map(Types1_7_6_10.COMPRESSED_NBT_ITEM, Type.ITEM1_8); // item

// remap item
handler(wrapper -> {
final Item item = wrapper.get(Type.ITEM, 0);
final Item item = wrapper.get(Type.ITEM1_8, 0);
protocol.getItemRewriter().handleItemToServer(item);
wrapper.set(Type.ITEM, 0, item);
wrapper.set(Type.ITEM1_8, 0, item);
});
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,15 +410,15 @@ public void register() {
}

for (int i = 0; i < size; i++) {
Item item = protocol.getItemRewriter().handleItemToClient(packetWrapper.read(Type.ITEM));
Item item = protocol.getItemRewriter().handleItemToClient(packetWrapper.read(Type.ITEM1_8));
packetWrapper.write(Types1_7_6_10.COMPRESSED_NBT_ITEM, item); //Buy Item 1

item = protocol.getItemRewriter().handleItemToClient(packetWrapper.read(Type.ITEM));
item = protocol.getItemRewriter().handleItemToClient(packetWrapper.read(Type.ITEM1_8));
packetWrapper.write(Types1_7_6_10.COMPRESSED_NBT_ITEM, item); //Buy Item 3

boolean has3Items = packetWrapper.passthrough(Type.BOOLEAN);
if (has3Items) {
item = protocol.getItemRewriter().handleItemToClient(packetWrapper.read(Type.ITEM));
item = protocol.getItemRewriter().handleItemToClient(packetWrapper.read(Type.ITEM1_8));
packetWrapper.write(Types1_7_6_10.COMPRESSED_NBT_ITEM, item); //Buy Item 2
}

Expand Down Expand Up @@ -676,7 +676,7 @@ public void register() {
packetWrapper.passthrough(Type.BYTE); //Direction
Item item = packetWrapper.read(Types1_7_6_10.COMPRESSED_NBT_ITEM);
item = protocol.getItemRewriter().handleItemToServer(item);
packetWrapper.write(Type.ITEM, item);
packetWrapper.write(Type.ITEM1_8, item);

for (int i = 0; i < 3; i++) {
packetWrapper.passthrough(Type.BYTE);
Expand Down Expand Up @@ -890,7 +890,7 @@ public void register() {
page.setValue(value);
}
}
packetWrapper.write(Type.ITEM, book);
packetWrapper.write(Type.ITEM1_8, book);
break;
}
case "MC|Brand": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ public void register() {
}
packetWrapper.write(Type.SHORT, (short) slot);
});
map(Type.ITEM);
handler(packetWrapper -> packetWrapper.set(Type.ITEM, 0, protocol.getItemRewriter().handleItemToClient(packetWrapper.get(Type.ITEM, 0))));
map(Type.ITEM1_8);
handler(packetWrapper -> packetWrapper.set(Type.ITEM1_8, 0, protocol.getItemRewriter().handleItemToClient(packetWrapper.get(Type.ITEM1_8, 0))));
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void register() {
map(Type.UNSIGNED_BYTE);
handler(packetWrapper -> {
short windowId = packetWrapper.get(Type.UNSIGNED_BYTE, 0);
Item[] items = packetWrapper.read(Type.ITEM_ARRAY);
Item[] items = packetWrapper.read(Type.ITEM1_8_SHORT_ARRAY);
for (int i = 0; i < items.length; i++) {
items[i] = protocol.getItemRewriter().handleItemToClient(items[i]);
}
Expand All @@ -97,7 +97,7 @@ public void register() {
System.arraycopy(old, 5, items, 4, old.length - 5);
}
}
packetWrapper.write(Type.ITEM_ARRAY, items);
packetWrapper.write(Type.ITEM1_8_SHORT_ARRAY, items);
});
}
});
Expand All @@ -110,9 +110,9 @@ public void register() {
public void register() {
map(Type.UNSIGNED_BYTE);
map(Type.SHORT);
map(Type.ITEM);
map(Type.ITEM1_8);
handler(packetWrapper -> {
packetWrapper.set(Type.ITEM, 0, protocol.getItemRewriter().handleItemToClient(packetWrapper.get(Type.ITEM, 0)));
packetWrapper.set(Type.ITEM1_8, 0, protocol.getItemRewriter().handleItemToClient(packetWrapper.get(Type.ITEM1_8, 0)));
byte windowId = packetWrapper.get(Type.UNSIGNED_BYTE, 0).byteValue();
short slot = packetWrapper.get(Type.SHORT, 0);
if (windowId == 0 && slot == 45) {
Expand All @@ -126,9 +126,9 @@ public void register() {
packetWrapper.set(Type.SHORT, 0, slot -= 1);
} else if (slot == 4) {
packetWrapper.cancel();
Windows.updateBrewingStand(packetWrapper.user(), packetWrapper.get(Type.ITEM, 0), windowId);
Windows.updateBrewingStand(packetWrapper.user(), packetWrapper.get(Type.ITEM1_8, 0), windowId);
} else {
packetWrapper.user().get(Windows.class).getBrewingItems(windowId)[slot] = packetWrapper.get(Type.ITEM, 0);
packetWrapper.user().get(Windows.class).getBrewingItems(windowId)[slot] = packetWrapper.get(Type.ITEM1_8, 0);
}
}
});
Expand Down Expand Up @@ -158,8 +158,8 @@ public void register() {
map(Type.BYTE);
map(Type.SHORT);
map(Type.BYTE, Type.VAR_INT);
map(Type.ITEM);
handler(packetWrapper -> packetWrapper.set(Type.ITEM, 0, protocol.getItemRewriter().handleItemToServer(packetWrapper.get(Type.ITEM, 0))));
map(Type.ITEM1_8);
handler(packetWrapper -> packetWrapper.set(Type.ITEM1_8, 0, protocol.getItemRewriter().handleItemToServer(packetWrapper.get(Type.ITEM1_8, 0))));
handler(packetWrapper -> {
short windowId = packetWrapper.get(Type.UNSIGNED_BYTE, 0);
Windows windows = packetWrapper.user().get(Windows.class);
Expand All @@ -179,8 +179,8 @@ public void register() {
@Override
public void register() {
map(Type.SHORT);
map(Type.ITEM);
handler(packetWrapper -> packetWrapper.set(Type.ITEM, 0, protocol.getItemRewriter().handleItemToServer(packetWrapper.get(Type.ITEM, 0))));
map(Type.ITEM1_8);
handler(packetWrapper -> packetWrapper.set(Type.ITEM1_8, 0, protocol.getItemRewriter().handleItemToServer(packetWrapper.get(Type.ITEM1_8, 0))));
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ public void register() {
final ItemRewriter<?> itemRewriter = protocol.getItemRewriter();

for (int i = 0; i < size; i++) {
packetWrapper.write(Type.ITEM, itemRewriter.handleItemToClient(packetWrapper.read(Type.ITEM))); //Buy Item 1
packetWrapper.write(Type.ITEM, itemRewriter.handleItemToClient(packetWrapper.read(Type.ITEM))); //Buy Item 3
packetWrapper.write(Type.ITEM1_8, itemRewriter.handleItemToClient(packetWrapper.read(Type.ITEM1_8))); //Buy Item 1
packetWrapper.write(Type.ITEM1_8, itemRewriter.handleItemToClient(packetWrapper.read(Type.ITEM1_8))); //Buy Item 3

boolean has3Items = packetWrapper.passthrough(Type.BOOLEAN);
if (has3Items) {
packetWrapper.write(Type.ITEM, itemRewriter.handleItemToClient(packetWrapper.read(Type.ITEM))); //Buy Item 2
packetWrapper.write(Type.ITEM1_8, itemRewriter.handleItemToClient(packetWrapper.read(Type.ITEM1_8))); //Buy Item 2
}

packetWrapper.passthrough(Type.BOOLEAN); //Unavailable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static void updateBrewingStand(UserConnection user, Item blazePowder, sho
PacketWrapper setSlot = PacketWrapper.create(ClientboundPackets1_8.SET_SLOT, user);
setSlot.write(Type.UNSIGNED_BYTE, windowId);
setSlot.write(Type.SHORT, (short) i);
setSlot.write(Type.ITEM, items[i]);
setSlot.write(Type.ITEM1_8, items[i]);
PacketUtil.sendPacket(setSlot, Protocol1_8To1_9.class);
}
}
Expand Down

0 comments on commit c2f19c6

Please sign in to comment.