Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-03 14:50:30 +01:00
Cleanup declare recipe, trade list, and advancement packets
Dieser Commit ist enthalten in:
Ursprung
1ec2551fcc
Commit
67c5e78e7b
@ -70,7 +70,7 @@ public class ItemRewriter {
|
||||
byte slot;
|
||||
do {
|
||||
slot = wrapper.passthrough(Type.BYTE);
|
||||
// & 0x7F into an extra variable if slot is needed
|
||||
// & 0x7F into an extra variable if slot is needed
|
||||
toClient.rewrite(wrapper.passthrough(type));
|
||||
} while ((slot & 0xFFFFFF80) != 0);
|
||||
});
|
||||
@ -118,6 +118,77 @@ public class ItemRewriter {
|
||||
});
|
||||
}
|
||||
|
||||
// 1.14.4+
|
||||
public void registerTradeList(ClientboundPacketType packetType, Type<Item> type) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
toClient.rewrite(wrapper.passthrough(type)); // Input
|
||||
toClient.rewrite(wrapper.passthrough(type)); // Output
|
||||
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) { // Has second item
|
||||
toClient.rewrite(wrapper.passthrough(type)); // Second Item
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
|
||||
wrapper.passthrough(Type.INT); // Number of tools uses
|
||||
wrapper.passthrough(Type.INT); // Maximum number of trade uses
|
||||
|
||||
wrapper.passthrough(Type.INT); // XP
|
||||
wrapper.passthrough(Type.INT); // Special price
|
||||
wrapper.passthrough(Type.FLOAT); // Price multiplier
|
||||
wrapper.passthrough(Type.INT); // Demand
|
||||
}
|
||||
//...
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerAdvancements(ClientboundPacketType packetType, Type<Item> type) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
wrapper.passthrough(Type.BOOLEAN); // Reset/clear
|
||||
int size = wrapper.passthrough(Type.VAR_INT); // Mapping size
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.passthrough(Type.STRING); // Identifier
|
||||
|
||||
// Parent
|
||||
if (wrapper.passthrough(Type.BOOLEAN))
|
||||
wrapper.passthrough(Type.STRING);
|
||||
|
||||
// Display data
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.COMPONENT); // Title
|
||||
wrapper.passthrough(Type.COMPONENT); // Description
|
||||
toClient.rewrite(wrapper.passthrough(type)); // Icon
|
||||
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||
int flags = wrapper.passthrough(Type.INT); // Flags
|
||||
if ((flags & 1) != 0) {
|
||||
wrapper.passthrough(Type.STRING); // Background texture
|
||||
}
|
||||
wrapper.passthrough(Type.FLOAT); // X
|
||||
wrapper.passthrough(Type.FLOAT); // Y
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // Criteria
|
||||
|
||||
int arrayLength = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int array = 0; array < arrayLength; array++) {
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // String array
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Only sent to the client
|
||||
public PacketHandler itemArrayHandler(Type<Item[]> type) {
|
||||
return wrapper -> {
|
||||
|
@ -0,0 +1,36 @@
|
||||
package us.myles.ViaVersion.api.rewriters;
|
||||
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
|
||||
public abstract class RecipeRewriter {
|
||||
|
||||
protected final Protocol protocol;
|
||||
protected final ItemRewriter.RewriteFunction rewriter;
|
||||
|
||||
protected RecipeRewriter(Protocol protocol, ItemRewriter.RewriteFunction rewriter) {
|
||||
this.protocol = protocol;
|
||||
this.rewriter = rewriter;
|
||||
}
|
||||
|
||||
public abstract void handle(PacketWrapper wrapper, String type) throws Exception;
|
||||
|
||||
public void registerDefaultHandler(ClientboundPacketType packetType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
int size = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < size; i++) {
|
||||
String type = wrapper.passthrough(Type.STRING).replace("minecraft:", "");
|
||||
String id = wrapper.passthrough(Type.STRING); // Recipe Identifier
|
||||
handle(wrapper, type);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -118,48 +118,6 @@ public class Protocol1_13_1To1_13 extends Protocol<ClientboundPackets1_13, Clien
|
||||
}
|
||||
});
|
||||
|
||||
registerOutgoing(ClientboundPackets1_13.ADVANCEMENTS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.BOOLEAN); // Reset/clear
|
||||
int size = wrapper.passthrough(Type.VAR_INT); // Mapping size
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.passthrough(Type.STRING); // Identifier
|
||||
|
||||
// Parent
|
||||
if (wrapper.passthrough(Type.BOOLEAN))
|
||||
wrapper.passthrough(Type.STRING);
|
||||
|
||||
// Display data
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.COMPONENT); // Title
|
||||
wrapper.passthrough(Type.COMPONENT); // Description
|
||||
Item icon = wrapper.passthrough(Type.FLAT_ITEM);
|
||||
InventoryPackets.toClient(icon);
|
||||
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||
int flags = wrapper.passthrough(Type.INT); // Flags
|
||||
if ((flags & 1) != 0)
|
||||
wrapper.passthrough(Type.STRING); // Background texture
|
||||
wrapper.passthrough(Type.FLOAT); // X
|
||||
wrapper.passthrough(Type.FLOAT); // Y
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // Criteria
|
||||
|
||||
int arrayLength = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int array = 0; array < arrayLength; array++) {
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // String array
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerOutgoing(ClientboundPackets1_13.TAGS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
|
@ -18,6 +18,7 @@ public class InventoryPackets {
|
||||
itemRewriter.registerSetCooldown(ClientboundPackets1_13.COOLDOWN, InventoryPackets::getNewItemId);
|
||||
itemRewriter.registerSetSlot(ClientboundPackets1_13.SET_SLOT, Type.FLAT_ITEM);
|
||||
itemRewriter.registerWindowItems(ClientboundPackets1_13.WINDOW_ITEMS, Type.FLAT_ITEM_ARRAY);
|
||||
itemRewriter.registerAdvancements(ClientboundPackets1_13.ADVANCEMENTS, Type.FLAT_ITEM);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
|
@ -55,8 +55,9 @@ public class Protocol1_13_2To1_13_1 extends Protocol<ClientboundPackets1_13, Cli
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM, icon);
|
||||
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||
int flags = wrapper.passthrough(Type.INT); // Flags
|
||||
if ((flags & 1) != 0)
|
||||
if ((flags & 1) != 0) {
|
||||
wrapper.passthrough(Type.STRING); // Background texture
|
||||
}
|
||||
wrapper.passthrough(Type.FLOAT); // X
|
||||
wrapper.passthrough(Type.FLOAT); // Y
|
||||
}
|
||||
|
@ -41,47 +41,6 @@ public class Protocol1_14To1_13_2 extends Protocol<ClientboundPackets1_13, Clien
|
||||
ComponentRewriter componentRewriter = new ComponentRewriter1_14(this);
|
||||
componentRewriter.registerChatMessage(ClientboundPackets1_13.CHAT_MESSAGE);
|
||||
|
||||
registerOutgoing(ClientboundPackets1_13.ADVANCEMENTS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.BOOLEAN); // Reset/clear
|
||||
int size = wrapper.passthrough(Type.VAR_INT); // Mapping size
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.passthrough(Type.STRING); // Identifier
|
||||
|
||||
// Parent
|
||||
if (wrapper.passthrough(Type.BOOLEAN))
|
||||
wrapper.passthrough(Type.STRING);
|
||||
|
||||
// Display data
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.COMPONENT); // Title
|
||||
wrapper.passthrough(Type.COMPONENT); // Description
|
||||
InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Icon
|
||||
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||
int flags = wrapper.passthrough(Type.INT); // Flags
|
||||
if ((flags & 1) != 0)
|
||||
wrapper.passthrough(Type.STRING); // Background texture
|
||||
wrapper.passthrough(Type.FLOAT); // X
|
||||
wrapper.passthrough(Type.FLOAT); // Y
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // Criteria
|
||||
|
||||
int arrayLength = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int array = 0; array < arrayLength; array++) {
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // String array
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerOutgoing(ClientboundPackets1_13.TAGS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
|
@ -0,0 +1,66 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data;
|
||||
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||
import us.myles.ViaVersion.api.rewriters.RecipeRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
|
||||
public class RecipeRewriter1_14 extends RecipeRewriter {
|
||||
|
||||
public RecipeRewriter1_14(Protocol protocol, ItemRewriter.RewriteFunction rewriter) {
|
||||
super(protocol, rewriter);
|
||||
}
|
||||
|
||||
public void handle(PacketWrapper wrapper, String type) throws Exception {
|
||||
switch (type) {
|
||||
case "crafting_shapeless":
|
||||
handleCraftingShapeless(wrapper);
|
||||
break;
|
||||
case "crafting_shaped":
|
||||
handleCraftingShaped(wrapper);
|
||||
break;
|
||||
case "smelting":
|
||||
handleSmelting(wrapper);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void handleSmelting(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (Item item : items) {
|
||||
rewriter.rewrite(item);
|
||||
}
|
||||
|
||||
rewriter.rewrite(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
|
||||
wrapper.passthrough(Type.FLOAT); // EXP
|
||||
wrapper.passthrough(Type.VAR_INT); // Cooking time
|
||||
}
|
||||
|
||||
public void handleCraftingShaped(PacketWrapper wrapper) throws Exception {
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
for (int j = 0; j < ingredientsNo; j++) {
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (Item item : items) {
|
||||
rewriter.rewrite(item);
|
||||
}
|
||||
}
|
||||
rewriter.rewrite(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
}
|
||||
|
||||
public void handleCraftingShapeless(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int j = 0; j < ingredientsNo; j++) {
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (Item item : items) {
|
||||
rewriter.rewrite(item);
|
||||
}
|
||||
}
|
||||
rewriter.rewrite(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
}
|
||||
}
|
@ -46,6 +46,7 @@ public class InventoryPackets {
|
||||
ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer);
|
||||
|
||||
itemRewriter.registerSetCooldown(ClientboundPackets1_13.COOLDOWN, InventoryPackets::getNewItemId);
|
||||
itemRewriter.registerAdvancements(ClientboundPackets1_13.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.OPEN_WINDOW, null, new PacketRemapper() {
|
||||
@Override
|
||||
|
@ -1,10 +1,8 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_15to1_14_4;
|
||||
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.SoundRewriter;
|
||||
import us.myles.ViaVersion.api.rewriters.TagRewriter;
|
||||
@ -49,47 +47,6 @@ public class Protocol1_15To1_14_4 extends Protocol<ClientboundPackets1_14, Clien
|
||||
}
|
||||
});
|
||||
|
||||
registerOutgoing(ClientboundPackets1_14.ADVANCEMENTS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.BOOLEAN); // Reset/clear
|
||||
int size = wrapper.passthrough(Type.VAR_INT); // Mapping size
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.passthrough(Type.STRING); // Identifier
|
||||
|
||||
// Parent
|
||||
if (wrapper.passthrough(Type.BOOLEAN))
|
||||
wrapper.passthrough(Type.STRING);
|
||||
|
||||
// Display data
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.COMPONENT); // Title
|
||||
wrapper.passthrough(Type.COMPONENT); // Description
|
||||
InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Icon
|
||||
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||
int flags = wrapper.passthrough(Type.INT); // Flags
|
||||
if ((flags & 1) != 0)
|
||||
wrapper.passthrough(Type.STRING); // Background texture
|
||||
wrapper.passthrough(Type.FLOAT); // X
|
||||
wrapper.passthrough(Type.FLOAT); // Y
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // Criteria
|
||||
|
||||
int arrayLength = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int array = 0; array < arrayLength; array++) {
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // String array
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
tagRewriter = new TagRewriter(this, Protocol1_15To1_14_4::getNewBlockId, InventoryPackets::getNewItemId, EntityPackets::getNewEntityId);
|
||||
tagRewriter.register(ClientboundPackets1_14.TAGS);
|
||||
}
|
||||
|
@ -0,0 +1,46 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data;
|
||||
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.RecipeRewriter1_14;
|
||||
|
||||
public class RecipeRewriter1_15 extends RecipeRewriter1_14 {
|
||||
|
||||
public RecipeRewriter1_15(Protocol protocol, ItemRewriter.RewriteFunction rewriter) {
|
||||
super(protocol, rewriter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper, String type) throws Exception {
|
||||
switch (type) {
|
||||
case "crafting_shapeless":
|
||||
handleCraftingShapeless(wrapper);
|
||||
break;
|
||||
case "crafting_shaped":
|
||||
handleCraftingShaped(wrapper);
|
||||
break;
|
||||
case "blasting": // new
|
||||
case "smoking": // new
|
||||
case "campfire_cooking": // new
|
||||
case "smelting":
|
||||
handleSmelting(wrapper);
|
||||
break;
|
||||
case "stonecutting": // new
|
||||
handleStonecutting(wrapper);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void handleStonecutting(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (Item item : items) {
|
||||
rewriter.rewrite(item);
|
||||
}
|
||||
|
||||
rewriter.rewrite(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
}
|
||||
}
|
@ -1,15 +1,13 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_15to1_14_4.packets;
|
||||
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.RecipeRewriter1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data.MappingData;
|
||||
|
||||
public class InventoryPackets {
|
||||
@ -19,114 +17,12 @@ public class InventoryPackets {
|
||||
|
||||
itemRewriter.registerSetCooldown(ClientboundPackets1_14.COOLDOWN, InventoryPackets::getNewItemId);
|
||||
itemRewriter.registerWindowItems(ClientboundPackets1_14.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.TRADE_LIST, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
Item input = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
toClient(input);
|
||||
|
||||
Item output = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
toClient(output);
|
||||
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) { // Has second item
|
||||
// Second Item
|
||||
Item second = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
toClient(second);
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
|
||||
wrapper.passthrough(Type.INT); // Number of tools uses
|
||||
wrapper.passthrough(Type.INT); // Maximum number of trade uses
|
||||
|
||||
wrapper.passthrough(Type.INT);
|
||||
wrapper.passthrough(Type.INT);
|
||||
wrapper.passthrough(Type.FLOAT);
|
||||
wrapper.passthrough(Type.INT);
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.BOOLEAN);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
itemRewriter.registerTradeList(ClientboundPackets1_14.TRADE_LIST, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerSetSlot(ClientboundPackets1_14.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerEntityEquipment(ClientboundPackets1_14.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerAdvancements(ClientboundPackets1_14.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.DECLARE_RECIPES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int size = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < size; i++) {
|
||||
String type = wrapper.passthrough(Type.STRING).replace("minecraft:", "");
|
||||
String id = wrapper.passthrough(Type.STRING);
|
||||
|
||||
switch (type) {
|
||||
case "crafting_shapeless": {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int j = 0; j < ingredientsNo; j++) {
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (Item item : items) toClient(item);
|
||||
}
|
||||
toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
|
||||
break;
|
||||
}
|
||||
case "crafting_shaped": {
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
|
||||
for (int j = 0; j < ingredientsNo; j++) {
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (Item item : items) toClient(item);
|
||||
}
|
||||
toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
|
||||
break;
|
||||
}
|
||||
case "blasting":
|
||||
case "smoking":
|
||||
case "campfire_cooking":
|
||||
case "smelting": {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
|
||||
for (Item item : items) toClient(item);
|
||||
toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
|
||||
wrapper.passthrough(Type.FLOAT); // EXP
|
||||
|
||||
wrapper.passthrough(Type.VAR_INT); // Cooking time
|
||||
|
||||
break;
|
||||
}
|
||||
case "stonecutting": {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (Item item : items) toClient(item);
|
||||
toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
new RecipeRewriter1_14(protocol, InventoryPackets::toClient).registerDefaultHandler(ClientboundPackets1_14.DECLARE_RECIPES);
|
||||
|
||||
itemRewriter.registerClickWindow(ServerboundPackets1_14.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerCreativeInvAction(ServerboundPackets1_14.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
||||
|
@ -41,44 +41,6 @@ public class Protocol1_16_2To1_16_1 extends Protocol<ClientboundPackets1_16, Cli
|
||||
soundRewriter.registerSound(ClientboundPackets1_16.SOUND);
|
||||
soundRewriter.registerSound(ClientboundPackets1_16.ENTITY_SOUND);
|
||||
|
||||
registerOutgoing(ClientboundPackets1_16.ADVANCEMENTS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
wrapper.passthrough(Type.BOOLEAN); // Reset/clear
|
||||
int size = wrapper.passthrough(Type.VAR_INT); // Mapping size
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.passthrough(Type.STRING); // Identifier
|
||||
|
||||
// Parent
|
||||
if (wrapper.passthrough(Type.BOOLEAN))
|
||||
wrapper.passthrough(Type.STRING);
|
||||
|
||||
// Display data
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.COMPONENT); // Title
|
||||
wrapper.passthrough(Type.COMPONENT); // Description
|
||||
InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Icon
|
||||
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||
int flags = wrapper.passthrough(Type.INT); // Flags
|
||||
if ((flags & 1) != 0)
|
||||
wrapper.passthrough(Type.STRING); // Background texture
|
||||
wrapper.passthrough(Type.FLOAT); // X
|
||||
wrapper.passthrough(Type.FLOAT); // Y
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // Criteria
|
||||
|
||||
int arrayLength = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int array = 0; array < arrayLength; array++) {
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // String array
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Recipe book data has been split into 2 separate packets
|
||||
registerIncoming(ServerboundPackets1_16_2.RECIPE_BOOK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
|
@ -9,6 +9,7 @@ import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16
|
||||
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16;
|
||||
|
||||
public class InventoryPackets {
|
||||
|
||||
@ -17,6 +18,10 @@ public class InventoryPackets {
|
||||
|
||||
itemRewriter.registerSetCooldown(ClientboundPackets1_16.COOLDOWN, InventoryPackets::getNewItemId);
|
||||
itemRewriter.registerWindowItems(ClientboundPackets1_16.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
|
||||
itemRewriter.registerTradeList(ClientboundPackets1_16.TRADE_LIST, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerSetSlot(ClientboundPackets1_16.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerEntityEquipmentArray(ClientboundPackets1_16.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerAdvancements(ClientboundPackets1_16.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16.UNLOCK_RECIPES, new PacketRemapper() {
|
||||
@Override
|
||||
@ -36,110 +41,7 @@ public class InventoryPackets {
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16.TRADE_LIST, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
Item input = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
toClient(input);
|
||||
|
||||
Item output = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
toClient(output);
|
||||
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) { // Has second item
|
||||
toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Second Item
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
|
||||
wrapper.passthrough(Type.INT); // Number of tools uses
|
||||
wrapper.passthrough(Type.INT); // Maximum number of trade uses
|
||||
|
||||
wrapper.passthrough(Type.INT);
|
||||
wrapper.passthrough(Type.INT);
|
||||
wrapper.passthrough(Type.FLOAT);
|
||||
wrapper.passthrough(Type.INT);
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.BOOLEAN);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
itemRewriter.registerSetSlot(ClientboundPackets1_16.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerEntityEquipmentArray(ClientboundPackets1_16.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16.DECLARE_RECIPES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
int size = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < size; i++) {
|
||||
String type = wrapper.passthrough(Type.STRING).replace("minecraft:", "");
|
||||
String id = wrapper.passthrough(Type.STRING);
|
||||
switch (type) {
|
||||
case "crafting_shapeless": {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int j = 0; j < ingredientsNo; j++) {
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (Item item : items) toClient(item);
|
||||
}
|
||||
toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
break;
|
||||
}
|
||||
case "crafting_shaped": {
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
|
||||
for (int j = 0; j < ingredientsNo; j++) {
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (Item item : items) toClient(item);
|
||||
}
|
||||
toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
break;
|
||||
}
|
||||
case "blasting":
|
||||
case "smoking":
|
||||
case "campfire_cooking":
|
||||
case "smelting": {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
|
||||
for (Item item : items) toClient(item);
|
||||
toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
|
||||
wrapper.passthrough(Type.FLOAT); // EXP
|
||||
|
||||
wrapper.passthrough(Type.VAR_INT); // Cooking time
|
||||
break;
|
||||
}
|
||||
case "stonecutting": {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (Item item : items) toClient(item);
|
||||
toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
|
||||
break;
|
||||
}
|
||||
case "smithing": {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT);
|
||||
for (Item item : items) toClient(item);
|
||||
items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT);
|
||||
for (Item item : items) toClient(item);
|
||||
toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
new RecipeRewriter1_16(protocol, InventoryPackets::toClient).registerDefaultHandler(ClientboundPackets1_16.DECLARE_RECIPES);
|
||||
|
||||
itemRewriter.registerClickWindow(ServerboundPackets1_16_2.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerCreativeInvAction(ServerboundPackets1_16_2.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
||||
|
@ -120,44 +120,6 @@ public class Protocol1_16To1_15_2 extends Protocol<ClientboundPackets1_15, Clien
|
||||
soundRewriter.registerSound(ClientboundPackets1_15.SOUND);
|
||||
soundRewriter.registerSound(ClientboundPackets1_15.ENTITY_SOUND);
|
||||
|
||||
registerOutgoing(ClientboundPackets1_15.ADVANCEMENTS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
wrapper.passthrough(Type.BOOLEAN); // Reset/clear
|
||||
int size = wrapper.passthrough(Type.VAR_INT); // Mapping size
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.passthrough(Type.STRING); // Identifier
|
||||
|
||||
// Parent
|
||||
if (wrapper.passthrough(Type.BOOLEAN))
|
||||
wrapper.passthrough(Type.STRING);
|
||||
|
||||
// Display data
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.COMPONENT); // Title
|
||||
wrapper.passthrough(Type.COMPONENT); // Description
|
||||
InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Icon
|
||||
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||
int flags = wrapper.passthrough(Type.INT); // Flags
|
||||
if ((flags & 1) != 0)
|
||||
wrapper.passthrough(Type.STRING); // Background texture
|
||||
wrapper.passthrough(Type.FLOAT); // X
|
||||
wrapper.passthrough(Type.FLOAT); // Y
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // Criteria
|
||||
|
||||
int arrayLength = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int array = 0; array < arrayLength; array++) {
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // String array
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerIncoming(ServerboundPackets1_16.INTERACT_ENTITY, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
|
@ -0,0 +1,51 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data;
|
||||
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data.RecipeRewriter1_15;
|
||||
|
||||
public class RecipeRewriter1_16 extends RecipeRewriter1_15 {
|
||||
|
||||
public RecipeRewriter1_16(Protocol protocol, ItemRewriter.RewriteFunction rewriter) {
|
||||
super(protocol, rewriter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper, String type) throws Exception {
|
||||
switch (type) {
|
||||
case "crafting_shapeless":
|
||||
handleCraftingShapeless(wrapper);
|
||||
break;
|
||||
case "crafting_shaped":
|
||||
handleCraftingShaped(wrapper);
|
||||
break;
|
||||
case "blasting":
|
||||
case "smoking":
|
||||
case "campfire_cooking":
|
||||
case "smelting":
|
||||
handleSmelting(wrapper);
|
||||
break;
|
||||
case "stonecutting":
|
||||
handleStonecutting(wrapper);
|
||||
break;
|
||||
case "smithing": // new
|
||||
handleSmithing(wrapper);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void handleSmithing(PacketWrapper wrapper) throws Exception {
|
||||
Item[] baseIngredients = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT);
|
||||
for (Item item : baseIngredients) {
|
||||
rewriter.rewrite(item);
|
||||
}
|
||||
Item[] ingredients = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT);
|
||||
for (Item item : ingredients) {
|
||||
rewriter.rewrite(item);
|
||||
}
|
||||
rewriter.rewrite(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.UUIDIntArrayType;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data.RecipeRewriter1_15;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.MappingData;
|
||||
|
||||
@ -58,43 +59,9 @@ public class InventoryPackets {
|
||||
|
||||
itemRewriter.registerSetCooldown(ClientboundPackets1_15.COOLDOWN, InventoryPackets::getNewItemId);
|
||||
itemRewriter.registerWindowItems(ClientboundPackets1_15.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_15.TRADE_LIST, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
Item input = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
toClient(input);
|
||||
|
||||
Item output = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
toClient(output);
|
||||
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) { // Has second item
|
||||
// Second Item
|
||||
toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
|
||||
wrapper.passthrough(Type.INT); // Number of tools uses
|
||||
wrapper.passthrough(Type.INT); // Maximum number of trade uses
|
||||
|
||||
wrapper.passthrough(Type.INT);
|
||||
wrapper.passthrough(Type.INT);
|
||||
wrapper.passthrough(Type.FLOAT);
|
||||
wrapper.passthrough(Type.INT);
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.BOOLEAN);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
itemRewriter.registerTradeList(ClientboundPackets1_15.TRADE_LIST, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerSetSlot(ClientboundPackets1_15.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerAdvancements(ClientboundPackets1_15.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_15.ENTITY_EQUIPMENT, new PacketRemapper() {
|
||||
@Override
|
||||
@ -109,64 +76,7 @@ public class InventoryPackets {
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_15.DECLARE_RECIPES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
int size = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < size; i++) {
|
||||
String type = wrapper.passthrough(Type.STRING).replace("minecraft:", "");
|
||||
String id = wrapper.passthrough(Type.STRING);
|
||||
switch (type) {
|
||||
case "crafting_shapeless": {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int j = 0; j < ingredientsNo; j++) {
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (Item item : items) toClient(item);
|
||||
}
|
||||
toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
break;
|
||||
}
|
||||
case "crafting_shaped": {
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
|
||||
for (int j = 0; j < ingredientsNo; j++) {
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (Item item : items) toClient(item);
|
||||
}
|
||||
toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
break;
|
||||
}
|
||||
case "blasting":
|
||||
case "smoking":
|
||||
case "campfire_cooking":
|
||||
case "smelting": {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
|
||||
for (Item item : items) toClient(item);
|
||||
toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
|
||||
wrapper.passthrough(Type.FLOAT); // EXP
|
||||
|
||||
wrapper.passthrough(Type.VAR_INT); // Cooking time
|
||||
break;
|
||||
}
|
||||
case "stonecutting": {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (Item item : items) toClient(item);
|
||||
toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
new RecipeRewriter1_15(protocol, InventoryPackets::toClient).registerDefaultHandler(ClientboundPackets1_15.DECLARE_RECIPES);
|
||||
|
||||
itemRewriter.registerClickWindow(ServerboundPackets1_16.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerCreativeInvAction(ServerboundPackets1_16.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren