Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 00:22:51 +01:00
Commit
3e3d338ed0
@ -21,6 +21,7 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.Conne
|
|||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers.BlockConnectionProvider;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers.BlockConnectionProvider;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers.PacketBlockConnectionProvider;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers.PacketBlockConnectionProvider;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.RecipeData;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.EntityPackets;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.EntityPackets;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.WorldPackets;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.WorldPackets;
|
||||||
@ -126,6 +127,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
|||||||
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.WHITE, '?');
|
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.WHITE, '?');
|
||||||
MappingData.init();
|
MappingData.init();
|
||||||
ConnectionData.init();
|
ConnectionData.init();
|
||||||
|
RecipeData.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -429,11 +431,11 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
|||||||
registerOutgoing(State.PLAY, 0x2B, 0x2D, new PacketRemapper() {
|
registerOutgoing(State.PLAY, 0x2B, 0x2D, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
|
map(Type.BYTE);
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
// TODO This packet changed
|
wrapper.write(Type.STRING, "viaversion:legacy/" + wrapper.read(Type.VAR_INT));
|
||||||
wrapper.cancel();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -460,15 +462,97 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
|||||||
// New 0x31 - Face Player
|
// New 0x31 - Face Player
|
||||||
registerOutgoing(State.PLAY, 0x2F, 0x32);
|
registerOutgoing(State.PLAY, 0x2F, 0x32);
|
||||||
registerOutgoing(State.PLAY, 0x30, 0x33);
|
registerOutgoing(State.PLAY, 0x30, 0x33);
|
||||||
// Recipe
|
// Unlock recipes
|
||||||
registerOutgoing(State.PLAY, 0x31, 0x34, new PacketRemapper() {
|
registerOutgoing(State.PLAY, 0x31, 0x34, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT); // action
|
||||||
|
map(Type.BOOLEAN); // crafting book open
|
||||||
|
map(Type.BOOLEAN); // crafting filter active
|
||||||
|
create(new ValueCreator() {
|
||||||
|
@Override
|
||||||
|
public void write(PacketWrapper wrapper) throws Exception {
|
||||||
|
wrapper.write(Type.BOOLEAN, false); // smelting book open
|
||||||
|
wrapper.write(Type.BOOLEAN, false); // smelting filter active
|
||||||
|
}
|
||||||
|
});
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
// TODO: This has changed >.>
|
int action = wrapper.get(Type.VAR_INT, 0);
|
||||||
wrapper.cancel();
|
for (int i = 0; i < (action == 0 ? 2 : 1); i++) {
|
||||||
|
Integer[] ids = wrapper.read(Type.VAR_INT_ARRAY);
|
||||||
|
String[] stringIds = new String[ids.length];
|
||||||
|
for (int j = 0; j < ids.length; j++) {
|
||||||
|
stringIds[j] = "viaversion:legacy/" + ids[j];
|
||||||
|
}
|
||||||
|
wrapper.write(Type.STRING_ARRAY, stringIds);
|
||||||
|
}
|
||||||
|
if (action == 0) {
|
||||||
|
wrapper.create(0x54, new ValueCreator() { // Declare recipes
|
||||||
|
@Override
|
||||||
|
public void write(PacketWrapper wrapper) throws Exception {
|
||||||
|
wrapper.write(Type.VAR_INT, RecipeData.recipes.size());
|
||||||
|
for (Map.Entry<String, RecipeData.Recipe> entry : RecipeData.recipes.entrySet()) {
|
||||||
|
wrapper.write(Type.STRING, entry.getKey()); // Id
|
||||||
|
wrapper.write(Type.STRING, entry.getValue().getType());
|
||||||
|
switch (entry.getValue().getType()) {
|
||||||
|
case "crafting_shapeless": {
|
||||||
|
wrapper.write(Type.STRING, entry.getValue().getGroup());
|
||||||
|
wrapper.write(Type.VAR_INT, entry.getValue().getIngredients().length);
|
||||||
|
for (Item[] ingredient : entry.getValue().getIngredients()) {
|
||||||
|
Item[] clone = ingredient.clone(); // Clone because array and item is mutable
|
||||||
|
for (int i = 0; i < clone.length; i++) {
|
||||||
|
if (clone[i] == null) continue;
|
||||||
|
clone[i] = new Item(clone[i].getId(), clone[i].getAmount(),
|
||||||
|
(short) 0, null);
|
||||||
|
}
|
||||||
|
wrapper.write(Type.FLAT_ITEM_ARRAY_VAR_INT, clone);
|
||||||
|
}
|
||||||
|
wrapper.write(Type.FLAT_ITEM, new Item(
|
||||||
|
entry.getValue().getResult().getId(),
|
||||||
|
entry.getValue().getResult().getAmount(), (short) 0, null));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "crafting_shaped": {
|
||||||
|
wrapper.write(Type.VAR_INT, entry.getValue().getWidth());
|
||||||
|
wrapper.write(Type.VAR_INT, entry.getValue().getHeight());
|
||||||
|
wrapper.write(Type.STRING, entry.getValue().getGroup());
|
||||||
|
for (Item[] ingredient : entry.getValue().getIngredients()) {
|
||||||
|
Item[] clone = ingredient.clone(); // Clone because array and item is mutable
|
||||||
|
for (int i = 0; i < clone.length; i++) {
|
||||||
|
if (clone[i] == null) continue;
|
||||||
|
clone[i] = new Item(clone[i].getId(), clone[i].getAmount(),
|
||||||
|
(short) 0, null);
|
||||||
|
}
|
||||||
|
wrapper.write(Type.FLAT_ITEM_ARRAY_VAR_INT, clone);
|
||||||
|
}
|
||||||
|
wrapper.write(Type.FLAT_ITEM, new Item(
|
||||||
|
entry.getValue().getResult().getId(),
|
||||||
|
entry.getValue().getResult().getAmount(), (short) 0, null));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "smelting": {
|
||||||
|
wrapper.write(Type.STRING, entry.getValue().getGroup());
|
||||||
|
Item[] clone = entry.getValue().getIngredient().clone(); // Clone because array and item is mutable
|
||||||
|
for (int i = 0; i < clone.length; i++) {
|
||||||
|
if (clone[i] == null) continue;
|
||||||
|
clone[i] = new Item(clone[i].getId(), clone[i].getAmount(),
|
||||||
|
(short) 0, null);
|
||||||
|
}
|
||||||
|
wrapper.write(Type.FLAT_ITEM_ARRAY_VAR_INT, clone);
|
||||||
|
wrapper.write(Type.FLAT_ITEM, new Item(
|
||||||
|
entry.getValue().getResult().getId(),
|
||||||
|
entry.getValue().getResult().getAmount(), (short) 0, null));
|
||||||
|
wrapper.write(Type.FLOAT, entry.getValue().getExperience());
|
||||||
|
wrapper.write(Type.VAR_INT, entry.getValue().getCookingTime());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).send(Protocol1_13To1_12_2.class, true, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -835,11 +919,11 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
|||||||
registerIncoming(State.PLAY, 0x12, 0x16, new PacketRemapper() {
|
registerIncoming(State.PLAY, 0x12, 0x16, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
|
map(Type.BYTE); // Window id
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
// TODO: This has changed >.>
|
wrapper.write(Type.VAR_INT, Integer.parseInt(wrapper.read(Type.STRING).substring(18)));
|
||||||
wrapper.cancel();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -860,6 +944,9 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
|||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
int type = wrapper.get(Type.VAR_INT, 0);
|
int type = wrapper.get(Type.VAR_INT, 0);
|
||||||
|
|
||||||
|
if (type == 0) {
|
||||||
|
wrapper.write(Type.INT, Integer.parseInt(wrapper.read(Type.STRING).substring(18)));
|
||||||
|
}
|
||||||
if (type == 1) {
|
if (type == 1) {
|
||||||
wrapper.passthrough(Type.BOOLEAN); // Crafting Recipe Book Open
|
wrapper.passthrough(Type.BOOLEAN); // Crafting Recipe Book Open
|
||||||
wrapper.passthrough(Type.BOOLEAN); // Crafting Recipe Filter Active
|
wrapper.passthrough(Type.BOOLEAN); // Crafting Recipe Filter Active
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data;
|
||||||
|
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NonNull;
|
||||||
|
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||||
|
import us.myles.ViaVersion.util.GsonUtil;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class RecipeData {
|
||||||
|
public static Map<String, Recipe> recipes;
|
||||||
|
|
||||||
|
public static void init() {
|
||||||
|
InputStream stream = MappingData.class.getClassLoader()
|
||||||
|
.getResourceAsStream("assets/viaversion/data/itemrecipes1_12_2to1_13.json");
|
||||||
|
InputStreamReader reader = new InputStreamReader(stream);
|
||||||
|
try {
|
||||||
|
recipes = GsonUtil.getGson().fromJson(
|
||||||
|
reader,
|
||||||
|
new TypeToken<Map<String, Recipe>>() {
|
||||||
|
}.getType()
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
reader.close();
|
||||||
|
} catch (IOException ignored) {
|
||||||
|
// Ignored
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Recipe {
|
||||||
|
@NonNull
|
||||||
|
private String type;
|
||||||
|
private String group;
|
||||||
|
private int width;
|
||||||
|
private int height;
|
||||||
|
private float experience;
|
||||||
|
private int cookingTime;
|
||||||
|
private Item[] ingredient;
|
||||||
|
private Item[][] ingredients;
|
||||||
|
private Item result;
|
||||||
|
}
|
||||||
|
}
|
22265
common/src/main/resources/assets/viaversion/data/itemrecipes1_12_2to1_13.json
Normale Datei
22265
common/src/main/resources/assets/viaversion/data/itemrecipes1_12_2to1_13.json
Normale Datei
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren