3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-26 00:00:33 +01:00

Fix 1.13->1.12.2 enchantment table preview

Fixes #192
Dieser Commit ist enthalten in:
KennyTV 2020-03-31 19:13:41 +02:00
Ursprung 1d48bf5086
Commit 910f5d98dc
4 geänderte Dateien mit 24 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -8,6 +8,10 @@ import java.util.Arrays;
public class VBMappings extends Mappings { public class VBMappings extends Mappings {
public VBMappings(JsonObject oldMapping, JsonObject newMapping, boolean warnOnMissing) {
this(oldMapping, newMapping, null, warnOnMissing);
}
public VBMappings(int size, JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping) { public VBMappings(int size, JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping) {
this(size, oldMapping, newMapping, diffMapping, true); this(size, oldMapping, newMapping, diffMapping, true);
} }

Datei anzeigen

@ -92,7 +92,6 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol {
out(State.PLAY, 0x11, -1, cancel()); // Declare Commands TODO NEW out(State.PLAY, 0x11, -1, cancel()); // Declare Commands TODO NEW
out(State.PLAY, 0x12, 0x11); // Confirm Transaction (clientbound) out(State.PLAY, 0x12, 0x11); // Confirm Transaction (clientbound)
out(State.PLAY, 0x13, 0x12); // Close Window (clientbound) out(State.PLAY, 0x13, 0x12); // Close Window (clientbound)
out(State.PLAY, 0x16, 0x15); // Window Property
out(State.PLAY, 0x1C, 0x1B); // Entity Status out(State.PLAY, 0x1C, 0x1B); // Entity Status
out(State.PLAY, 0x1D, -1, cancel()); // NBT Query Response (client won't send a request, so the server should not answer) out(State.PLAY, 0x1D, -1, cancel()); // NBT Query Response (client won't send a request, so the server should not answer)
out(State.PLAY, 0x1E, 0x1C); // Explosion out(State.PLAY, 0x1E, 0x1C); // Explosion

Datei anzeigen

@ -34,6 +34,7 @@ public class BackwardsMappings {
public static BlockMappingsShortArray blockMappings; public static BlockMappingsShortArray blockMappings;
public static VBSoundMappings soundMappings; public static VBSoundMappings soundMappings;
public static VBItemMappings itemMappings; public static VBItemMappings itemMappings;
public static Mappings enchantmentMappings;
public static void init() { public static void init() {
JsonObject mapping1_12 = MappingDataLoader.loadData("mapping-1.12.json"); JsonObject mapping1_12 = MappingDataLoader.loadData("mapping-1.12.json");
@ -44,6 +45,7 @@ public class BackwardsMappings {
blockMappings = new BlockMappingsShortArray(mapping1_13.getAsJsonObject("blocks"), mapping1_12.getAsJsonObject("blocks"), mapping1_12_2to1_13.getAsJsonObject("blockstates")); blockMappings = new BlockMappingsShortArray(mapping1_13.getAsJsonObject("blocks"), mapping1_12.getAsJsonObject("blocks"), mapping1_12_2to1_13.getAsJsonObject("blockstates"));
itemMappings = new VBItemMappings(mapping1_13.getAsJsonObject("items"), mapping1_12.getAsJsonObject("items"), mapping1_12_2to1_13.getAsJsonObject("items")); itemMappings = new VBItemMappings(mapping1_13.getAsJsonObject("items"), mapping1_12.getAsJsonObject("items"), mapping1_12_2to1_13.getAsJsonObject("items"));
soundMappings = new VBSoundMappings(mapping1_13.getAsJsonArray("sounds"), mapping1_12.getAsJsonArray("sounds"), mapping1_12_2to1_13.getAsJsonObject("sounds")); soundMappings = new VBSoundMappings(mapping1_13.getAsJsonArray("sounds"), mapping1_12.getAsJsonArray("sounds"), mapping1_12_2to1_13.getAsJsonObject("sounds"));
enchantmentMappings = new VBMappings(mapping1_13.getAsJsonObject("enchantments"), mapping1_12.getAsJsonObject("enchantments"), false);
for (Map.Entry<String, Integer> entry : StatisticMappings.statistics.entrySet()) { for (Map.Entry<String, Integer> entry : StatisticMappings.statistics.entrySet()) {
statisticMappings.put(entry.getValue(), entry.getKey()); statisticMappings.put(entry.getValue(), entry.getKey());

Datei anzeigen

@ -470,6 +470,24 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
} }
}); });
// Window Property
protocol.out(State.PLAY, 0x16, 0x15, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.UNSIGNED_BYTE); // Window Id
map(Type.SHORT); // Property
map(Type.SHORT); // Value
handler(wrapper -> {
short property = wrapper.get(Type.SHORT, 0);
// Enchantment table
if (property >= 4 && property <= 6) {
short oldId = wrapper.get(Type.SHORT, 1);
wrapper.set(Type.SHORT, 1, (short) BackwardsMappings.enchantmentMappings.getNewId(oldId));
}
});
}
});
// Set Creative Slot // Set Creative Slot
protocol.in(State.PLAY, 0x24, 0x1B, new PacketRemapper() { protocol.in(State.PLAY, 0x24, 0x1B, new PacketRemapper() {