Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-28 17:10:13 +01:00
Use Map in RecipeRewriter, use correct names for 1.13/1.14 rewriters
Dieser Commit ist enthalten in:
Ursprung
42167394e0
Commit
e1464044a7
@ -6,17 +6,26 @@ import us.myles.ViaVersion.api.protocol.Protocol;
|
|||||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public abstract class RecipeRewriter {
|
public abstract class RecipeRewriter {
|
||||||
|
|
||||||
protected final Protocol protocol;
|
protected final Protocol protocol;
|
||||||
protected final ItemRewriter.RewriteFunction rewriter;
|
protected final ItemRewriter.RewriteFunction rewriter;
|
||||||
|
protected final Map<String, RecipeConsumer> recipeHandlers = new HashMap<>();
|
||||||
|
|
||||||
protected RecipeRewriter(Protocol protocol, ItemRewriter.RewriteFunction rewriter) {
|
protected RecipeRewriter(Protocol protocol, ItemRewriter.RewriteFunction rewriter) {
|
||||||
this.protocol = protocol;
|
this.protocol = protocol;
|
||||||
this.rewriter = rewriter;
|
this.rewriter = rewriter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void handle(PacketWrapper wrapper, String type) throws Exception;
|
public void handle(PacketWrapper wrapper, String type) throws Exception {
|
||||||
|
RecipeConsumer handler = recipeHandlers.get(type);
|
||||||
|
if (handler != null) {
|
||||||
|
handler.accept(wrapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void registerDefaultHandler(ClientboundPacketType packetType) {
|
public void registerDefaultHandler(ClientboundPacketType packetType) {
|
||||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||||
@ -33,4 +42,10 @@ public abstract class RecipeRewriter {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface RecipeConsumer {
|
||||||
|
|
||||||
|
void accept(PacketWrapper wrapper) throws Exception;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,11 @@ import us.myles.ViaVersion.api.protocol.Protocol;
|
|||||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||||
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||||
|
import us.myles.ViaVersion.api.rewriters.RecipeRewriter;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.RecipeRewriter1_13_2;
|
||||||
|
|
||||||
public class InventoryPackets {
|
public class InventoryPackets {
|
||||||
|
|
||||||
@ -56,49 +58,17 @@ public class InventoryPackets {
|
|||||||
|
|
||||||
itemRewriter.registerEntityEquipment(ClientboundPackets1_13.ENTITY_EQUIPMENT, Type.FLAT_ITEM);
|
itemRewriter.registerEntityEquipment(ClientboundPackets1_13.ENTITY_EQUIPMENT, Type.FLAT_ITEM);
|
||||||
|
|
||||||
|
RecipeRewriter recipeRewriter = new RecipeRewriter1_13_2(protocol, InventoryPackets::toClient);
|
||||||
protocol.registerOutgoing(ClientboundPackets1_13.DECLARE_RECIPES, new PacketRemapper() {
|
protocol.registerOutgoing(ClientboundPackets1_13.DECLARE_RECIPES, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
handler(new PacketHandler() {
|
handler(wrapper -> {
|
||||||
@Override
|
int size = wrapper.passthrough(Type.VAR_INT);
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
for (int i = 0; i < size; i++) {
|
||||||
int recipesNo = wrapper.passthrough(Type.VAR_INT);
|
// First type, then id
|
||||||
for (int i = 0; i < recipesNo; i++) {
|
String type = wrapper.passthrough(Type.STRING).replace("minecraft:", "");
|
||||||
wrapper.passthrough(Type.STRING); // Id
|
String id = wrapper.passthrough(Type.STRING); // Recipe Identifier
|
||||||
String type = wrapper.passthrough(Type.STRING);
|
recipeRewriter.handle(wrapper, type);
|
||||||
if (type.equals("crafting_shapeless")) {
|
|
||||||
wrapper.passthrough(Type.STRING); // Group
|
|
||||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT);
|
|
||||||
for (int i1 = 0; i1 < ingredientsNo; i1++) {
|
|
||||||
Item[] items = wrapper.passthrough(Type.FLAT_ITEM_ARRAY_VAR_INT);
|
|
||||||
for (Item item : items) {
|
|
||||||
InventoryPackets.toClient(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_ITEM)); // Result
|
|
||||||
} else if (type.equals("crafting_shaped")) {
|
|
||||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT);
|
|
||||||
wrapper.passthrough(Type.STRING); // Group
|
|
||||||
for (int i1 = 0; i1 < ingredientsNo; i1++) {
|
|
||||||
Item[] items = wrapper.passthrough(Type.FLAT_ITEM_ARRAY_VAR_INT);
|
|
||||||
for (Item item : items) {
|
|
||||||
InventoryPackets.toClient(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_ITEM)); // Result
|
|
||||||
} else if (type.equals("smelting")) {
|
|
||||||
wrapper.passthrough(Type.STRING); // Group
|
|
||||||
// Ingredient start
|
|
||||||
Item[] items = wrapper.passthrough(Type.FLAT_ITEM_ARRAY_VAR_INT);
|
|
||||||
for (Item item : items) {
|
|
||||||
InventoryPackets.toClient(item);
|
|
||||||
}
|
|
||||||
// Ingredient end
|
|
||||||
InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_ITEM));
|
|
||||||
wrapper.passthrough(Type.FLOAT); // EXP
|
|
||||||
wrapper.passthrough(Type.VAR_INT); // Cooking time
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,58 @@
|
|||||||
|
package us.myles.ViaVersion.protocols.protocol1_13to1_12_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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For 1.13.2, not 1.13 (1.13 reads recipe type and id in swapped order)!
|
||||||
|
*/
|
||||||
|
public class RecipeRewriter1_13_2 extends RecipeRewriter {
|
||||||
|
|
||||||
|
public RecipeRewriter1_13_2(Protocol protocol, ItemRewriter.RewriteFunction rewriter) {
|
||||||
|
super(protocol, rewriter);
|
||||||
|
recipeHandlers.put("crafting_shapeless", this::handleCraftingShapeless);
|
||||||
|
recipeHandlers.put("crafting_shaped", this::handleCraftingShaped);
|
||||||
|
recipeHandlers.put("smelting", this::handleSmelting);
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
@ -4,63 +4,27 @@ import us.myles.ViaVersion.api.PacketWrapper;
|
|||||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||||
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||||
import us.myles.ViaVersion.api.rewriters.RecipeRewriter;
|
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.RecipeRewriter1_13_2;
|
||||||
|
|
||||||
public class RecipeRewriter1_14 extends RecipeRewriter {
|
public class RecipeRewriter1_14 extends RecipeRewriter1_13_2 {
|
||||||
|
|
||||||
public RecipeRewriter1_14(Protocol protocol, ItemRewriter.RewriteFunction rewriter) {
|
public RecipeRewriter1_14(Protocol protocol, ItemRewriter.RewriteFunction rewriter) {
|
||||||
super(protocol, rewriter);
|
super(protocol, rewriter);
|
||||||
|
recipeHandlers.put("stonecutting", this::handleStonecutting);
|
||||||
|
|
||||||
|
recipeHandlers.put("blasting", this::handleSmelting);
|
||||||
|
recipeHandlers.put("smoking", this::handleSmelting);
|
||||||
|
recipeHandlers.put("campfire_cooking", this::handleSmelting);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(PacketWrapper wrapper, String type) throws Exception {
|
public void handleStonecutting(PacketWrapper wrapper) throws Exception {
|
||||||
switch (type) {
|
wrapper.passthrough(Type.STRING);
|
||||||
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
|
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||||
for (Item item : items) {
|
for (Item item : items) {
|
||||||
rewriter.rewrite(item);
|
rewriter.rewrite(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
rewriter.rewrite(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,11 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
|||||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||||
import us.myles.ViaVersion.api.rewriters.ComponentRewriter;
|
import us.myles.ViaVersion.api.rewriters.ComponentRewriter;
|
||||||
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||||
|
import us.myles.ViaVersion.api.rewriters.RecipeRewriter;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.RecipeRewriter1_13_2;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
|
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData;
|
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData;
|
||||||
@ -178,12 +180,11 @@ public class InventoryPackets {
|
|||||||
|
|
||||||
itemRewriter.registerEntityEquipment(ClientboundPackets1_13.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
|
itemRewriter.registerEntityEquipment(ClientboundPackets1_13.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
|
||||||
|
|
||||||
|
RecipeRewriter recipeRewriter = new RecipeRewriter1_13_2(protocol, InventoryPackets::toClient);
|
||||||
protocol.registerOutgoing(ClientboundPackets1_13.DECLARE_RECIPES, new PacketRemapper() {
|
protocol.registerOutgoing(ClientboundPackets1_13.DECLARE_RECIPES, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
handler(new PacketHandler() {
|
handler(wrapper -> {
|
||||||
@Override
|
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
|
||||||
int size = wrapper.passthrough(Type.VAR_INT);
|
int size = wrapper.passthrough(Type.VAR_INT);
|
||||||
int deleted = 0;
|
int deleted = 0;
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
@ -196,33 +197,9 @@ public class InventoryPackets {
|
|||||||
wrapper.write(Type.STRING, type);
|
wrapper.write(Type.STRING, type);
|
||||||
wrapper.write(Type.STRING, id);
|
wrapper.write(Type.STRING, id);
|
||||||
|
|
||||||
if (type.equals("crafting_shapeless")) {
|
recipeRewriter.handle(wrapper, type);
|
||||||
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
|
|
||||||
} else if (type.equals("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
|
|
||||||
} else if (type.equals("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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
wrapper.set(Type.VAR_INT, 0, size - deleted);
|
wrapper.set(Type.VAR_INT, 0, size - deleted);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,36 +5,13 @@ import us.myles.ViaVersion.api.minecraft.item.Item;
|
|||||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||||
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data.RecipeRewriter1_15;
|
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.RecipeRewriter1_14;
|
||||||
|
|
||||||
public class RecipeRewriter1_16 extends RecipeRewriter1_15 {
|
public class RecipeRewriter1_16 extends RecipeRewriter1_14 {
|
||||||
|
|
||||||
public RecipeRewriter1_16(Protocol protocol, ItemRewriter.RewriteFunction rewriter) {
|
public RecipeRewriter1_16(Protocol protocol, ItemRewriter.RewriteFunction rewriter) {
|
||||||
super(protocol, rewriter);
|
super(protocol, rewriter);
|
||||||
}
|
recipeHandlers.put("smithing", this::handleSmithing);
|
||||||
|
|
||||||
@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 {
|
public void handleSmithing(PacketWrapper wrapper) throws Exception {
|
||||||
|
@ -14,7 +14,7 @@ import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
|||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.api.type.types.UUIDIntArrayType;
|
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.ClientboundPackets1_15;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data.RecipeRewriter1_15;
|
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.RecipeRewriter1_14;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
|
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.MappingData;
|
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.MappingData;
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ public class InventoryPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
new RecipeRewriter1_15(protocol, InventoryPackets::toClient).registerDefaultHandler(ClientboundPackets1_15.DECLARE_RECIPES);
|
new RecipeRewriter1_14(protocol, InventoryPackets::toClient).registerDefaultHandler(ClientboundPackets1_15.DECLARE_RECIPES);
|
||||||
|
|
||||||
itemRewriter.registerClickWindow(ServerboundPackets1_16.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
|
itemRewriter.registerClickWindow(ServerboundPackets1_16.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
|
||||||
itemRewriter.registerCreativeInvAction(ServerboundPackets1_16.CREATIVE_INVENTORY_ACTION, 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