mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2024-12-23 17:08:00 +01:00
fix item remaps
This commit is contained in:
parent
41d286feb5
commit
89099a6f0d
@ -139,7 +139,10 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
Item[] stacks = wrapper.get(Type.FLAT_VAR_INT_ITEM_ARRAY, 0);
|
Item[] stacks = wrapper.get(Type.FLAT_VAR_INT_ITEM_ARRAY, 0);
|
||||||
for (Item stack : stacks) handleItemToClient(stack);
|
for (int i = 0; i < stacks.length; i++) {
|
||||||
|
stacks[i] = handleItemToClient(stacks[i]);
|
||||||
|
}
|
||||||
|
wrapper.set(Type.FLAT_VAR_INT_ITEM_ARRAY, 0, stacks);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -156,7 +159,9 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
|
|||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
handleItemToClient(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0));
|
Item item = wrapper.get(Type.FLAT_VAR_INT_ITEM, 0);
|
||||||
|
item = handleItemToClient(item);
|
||||||
|
wrapper.set(Type.FLAT_VAR_INT_ITEM, 0, item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -178,14 +183,22 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
|
|||||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
// Input Item
|
// Input Item
|
||||||
handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
|
Item input = wrapper.read(Type.FLAT_VAR_INT_ITEM);
|
||||||
|
input = handleItemToClient(input);
|
||||||
|
wrapper.write(Type.FLAT_VAR_INT_ITEM, input);
|
||||||
|
|
||||||
|
|
||||||
// Output Item
|
// Output Item
|
||||||
handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
|
Item output = wrapper.read(Type.FLAT_VAR_INT_ITEM);
|
||||||
|
output = handleItemToClient(output);
|
||||||
|
wrapper.write(Type.FLAT_VAR_INT_ITEM, output);
|
||||||
|
|
||||||
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
|
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
|
||||||
if (secondItem) {
|
if (secondItem) {
|
||||||
// Second Item
|
// Second Item
|
||||||
handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
|
Item second = wrapper.read(Type.FLAT_VAR_INT_ITEM);
|
||||||
|
second = handleItemToClient(second);
|
||||||
|
wrapper.write(Type.FLAT_VAR_INT_ITEM, second);
|
||||||
}
|
}
|
||||||
|
|
||||||
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
|
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
|
||||||
@ -229,7 +242,8 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
|
|||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
handleItemToClient(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0));
|
Item item = handleItemToClient(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0));
|
||||||
|
wrapper.set(Type.FLAT_VAR_INT_ITEM, 0, item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -302,23 +316,37 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
|
|||||||
wrapper.passthrough(Type.STRING); // Group
|
wrapper.passthrough(Type.STRING); // Group
|
||||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT);
|
int ingredientsNo = wrapper.passthrough(Type.VAR_INT);
|
||||||
for (int j = 0; j < ingredientsNo; j++) {
|
for (int j = 0; j < ingredientsNo; j++) {
|
||||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
Item[] items = wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||||
for (Item item : items) handleItemToClient(item);
|
for (int k = 0; k < items.length; k++) {
|
||||||
|
items[k] = handleItemToClient(items[k]);
|
||||||
|
}
|
||||||
|
wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, items);
|
||||||
}
|
}
|
||||||
handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
Item result = handleItemToClient(wrapper.read(Type.FLAT_VAR_INT_ITEM));// Result
|
||||||
|
wrapper.write(Type.FLAT_VAR_INT_ITEM, result);
|
||||||
} else if (type.equals("crafting_shaped")) {
|
} else if (type.equals("crafting_shaped")) {
|
||||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT);
|
int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT);
|
||||||
wrapper.passthrough(Type.STRING); // Group
|
wrapper.passthrough(Type.STRING); // Group
|
||||||
for (int j = 0; j < ingredientsNo; j++) {
|
for (int j = 0; j < ingredientsNo; j++) {
|
||||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
Item[] items = wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||||
for (Item item : items) handleItemToClient(item);
|
for (int k = 0; k < items.length; k++) {
|
||||||
|
items[k] = handleItemToClient(items[k]);
|
||||||
|
}
|
||||||
|
wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, items);
|
||||||
}
|
}
|
||||||
handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
Item result = handleItemToClient(wrapper.read(Type.FLAT_VAR_INT_ITEM));// Result
|
||||||
|
wrapper.write(Type.FLAT_VAR_INT_ITEM, result);
|
||||||
} else if (type.equals("smelting")) {
|
} else if (type.equals("smelting")) {
|
||||||
wrapper.passthrough(Type.STRING); // Group
|
wrapper.passthrough(Type.STRING); // Group
|
||||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
Item[] items = wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||||
for (Item item : items) handleItemToClient(item);
|
for (int k = 0; k < items.length; k++) {
|
||||||
handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
|
items[k] = handleItemToClient(items[k]);
|
||||||
|
}
|
||||||
|
wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, items);
|
||||||
|
|
||||||
|
Item result = handleItemToClient(wrapper.read(Type.FLAT_VAR_INT_ITEM));// Result
|
||||||
|
wrapper.write(Type.FLAT_VAR_INT_ITEM, result);
|
||||||
|
|
||||||
wrapper.passthrough(Type.FLOAT); // EXP
|
wrapper.passthrough(Type.FLOAT); // EXP
|
||||||
wrapper.passthrough(Type.VAR_INT); // Cooking time
|
wrapper.passthrough(Type.VAR_INT); // Cooking time
|
||||||
}
|
}
|
||||||
@ -348,7 +376,8 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
|
|||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
handleItemToServer(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0));
|
Item item = handleItemToServer(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0));
|
||||||
|
wrapper.set(Type.FLAT_VAR_INT_ITEM, 0, item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -364,7 +393,8 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
|
|||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
handleItemToServer(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0));
|
Item item = handleItemToServer(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0));
|
||||||
|
wrapper.set(Type.FLAT_VAR_INT_ITEM, 0, item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -516,7 +546,8 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
|
|||||||
int data = wrapper.passthrough(Type.VAR_INT);
|
int data = wrapper.passthrough(Type.VAR_INT);
|
||||||
wrapper.set(Type.VAR_INT, 0, Protocol1_13_2To1_14.getNewBlockStateId(data));
|
wrapper.set(Type.VAR_INT, 0, Protocol1_13_2To1_14.getNewBlockStateId(data));
|
||||||
} else if (id == 27) {
|
} else if (id == 27) {
|
||||||
handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
|
Item item = handleItemToClient(wrapper.read(Type.FLAT_VAR_INT_ITEM));
|
||||||
|
wrapper.write(Type.FLAT_VAR_INT_ITEM, item);
|
||||||
}
|
}
|
||||||
wrapper.set(Type.INT, 0, id);
|
wrapper.set(Type.INT, 0, id);
|
||||||
}
|
}
|
||||||
@ -670,6 +701,15 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CompoundTag getNamedTag(String text) {
|
||||||
|
CompoundTag tag = new CompoundTag("");
|
||||||
|
tag.put(new CompoundTag("display"));
|
||||||
|
((CompoundTag) tag.get("display")).put(new StringTag("Name", ChatRewriter.legacyTextToJson(text)));
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static int getNewItemId(int id) {
|
public static int getNewItemId(int id) {
|
||||||
Integer newId = MappingData.oldToNewItems.get(id);
|
Integer newId = MappingData.oldToNewItems.get(id);
|
||||||
if (newId == null) {
|
if (newId == null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user