Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-08 17:20:24 +01:00
Fix handling of unknown container ids (#2384)
Dieser Commit ist enthalten in:
Ursprung
08763a92ab
Commit
7f8052c3cd
@ -1,10 +1,6 @@
|
|||||||
package us.myles.ViaVersion.protocols.protocol1_14to1_13_2.packets;
|
package us.myles.ViaVersion.protocols.protocol1_14to1_13_2.packets;
|
||||||
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.*;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.DoubleTag;
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
@ -55,7 +51,7 @@ public class InventoryPackets {
|
|||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
Short windowsId = wrapper.read(Type.UNSIGNED_BYTE);
|
Short windowId = wrapper.read(Type.UNSIGNED_BYTE);
|
||||||
String type = wrapper.read(Type.STRING);
|
String type = wrapper.read(Type.STRING);
|
||||||
JsonElement title = wrapper.read(Type.COMPONENT);
|
JsonElement title = wrapper.read(Type.COMPONENT);
|
||||||
COMPONENT_REWRITER.processText(title);
|
COMPONENT_REWRITER.processText(title);
|
||||||
@ -64,19 +60,15 @@ public class InventoryPackets {
|
|||||||
if (type.equals("EntityHorse")) {
|
if (type.equals("EntityHorse")) {
|
||||||
wrapper.setId(0x1F);
|
wrapper.setId(0x1F);
|
||||||
int entityId = wrapper.read(Type.INT);
|
int entityId = wrapper.read(Type.INT);
|
||||||
wrapper.write(Type.UNSIGNED_BYTE, windowsId);
|
wrapper.write(Type.UNSIGNED_BYTE, windowId);
|
||||||
wrapper.write(Type.VAR_INT, slots.intValue());
|
wrapper.write(Type.VAR_INT, slots.intValue());
|
||||||
wrapper.write(Type.INT, entityId);
|
wrapper.write(Type.INT, entityId);
|
||||||
} else {
|
} else {
|
||||||
wrapper.setId(0x2E);
|
wrapper.setId(0x2E);
|
||||||
wrapper.write(Type.VAR_INT, windowsId.intValue());
|
wrapper.write(Type.VAR_INT, windowId.intValue());
|
||||||
|
|
||||||
int typeId = -1;
|
int typeId = -1;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "minecraft:container":
|
|
||||||
case "minecraft:chest":
|
|
||||||
typeId = slots / 9 - 1;
|
|
||||||
break;
|
|
||||||
case "minecraft:crafting_table":
|
case "minecraft:crafting_table":
|
||||||
typeId = 11;
|
typeId = 11;
|
||||||
break;
|
break;
|
||||||
@ -108,6 +100,13 @@ public class InventoryPackets {
|
|||||||
case "minecraft:shulker_box":
|
case "minecraft:shulker_box":
|
||||||
typeId = 19;
|
typeId = 19;
|
||||||
break;
|
break;
|
||||||
|
case "minecraft:container":
|
||||||
|
case "minecraft:chest":
|
||||||
|
default:
|
||||||
|
if (slots > 0 && slots <= 54) {
|
||||||
|
typeId = slots / 9 - 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeId == -1) {
|
if (typeId == -1) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren