Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 00:22:51 +01:00
Fix block and item rewriting
Dieser Commit ist enthalten in:
Ursprung
f56971e5ac
Commit
9fe187c049
@ -198,7 +198,7 @@ public class InventoryPackets {
|
|||||||
|
|
||||||
public static void toClient(Item item) {
|
public static void toClient(Item item) {
|
||||||
if (item == null) return;
|
if (item == null) return;
|
||||||
int rawId = (item.getId() << 4 | item.getData() & 0xF);
|
int rawId = (item.getId() << 16 | item.getData() & 0xFFFF);
|
||||||
int originalId = rawId;
|
int originalId = rawId;
|
||||||
if (!MappingData.oldToNewItems.containsKey(rawId)) {
|
if (!MappingData.oldToNewItems.containsKey(rawId)) {
|
||||||
if (MappingData.oldToNewItems.containsKey(item.getId() << 4)) {
|
if (MappingData.oldToNewItems.containsKey(item.getId() << 4)) {
|
||||||
@ -219,32 +219,29 @@ public class InventoryPackets {
|
|||||||
|
|
||||||
public static void toServer(Item item) {
|
public static void toServer(Item item) {
|
||||||
if (item == null) return;
|
if (item == null) return;
|
||||||
int rawId = -1;
|
|
||||||
if (item.getTag() != null) {
|
if (item.getTag() != null) {
|
||||||
CompoundTag tag = item.getTag();
|
CompoundTag tag = item.getTag();
|
||||||
// Check for valid tag
|
// Check for valid tag
|
||||||
if (tag.contains(NBT_TAG_NAME)) {
|
if (tag.contains(NBT_TAG_NAME)) {
|
||||||
if (tag.get(NBT_TAG_NAME) instanceof IntTag) {
|
if (tag.get(NBT_TAG_NAME) instanceof IntTag) {
|
||||||
rawId = (int) tag.get(NBT_TAG_NAME).getValue();
|
int rawId = (int) tag.get(NBT_TAG_NAME).getValue();
|
||||||
// Remove the tag
|
// Remove the tag
|
||||||
tag.remove(NBT_TAG_NAME);
|
tag.remove(NBT_TAG_NAME);
|
||||||
|
item.setId((short) (rawId >> 16));
|
||||||
|
item.setData((short) (rawId & 0xFFFF));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rawId == -1){
|
int itemID = item.getId();
|
||||||
int itemID = item.getId();
|
for (Map.Entry<Integer,Integer> entry : MappingData.oldToNewItems.entrySet()){
|
||||||
for (Map.Entry<Integer,Integer> entry : MappingData.oldToNewItems.entrySet()){
|
if (entry.getValue() == itemID){
|
||||||
if (entry.getValue() == itemID){
|
int rawId = entry.getKey();
|
||||||
rawId = entry.getKey();
|
item.setId((short) (rawId >> 4));
|
||||||
break;
|
item.setData((short) (rawId & 0xF));
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rawId != -1) {
|
System.out.println("FAILED TO GET 1.12 ITEM FOR " + item.getId()); // TODO: Make this nicer etc, perhaps fix issues with mapping :T
|
||||||
item.setId((short) (rawId >> 4));
|
|
||||||
item.setData((short) (rawId & 0xF));
|
|
||||||
} else {
|
|
||||||
System.out.println("FAILED TO GET 1.12 ITEM FOR " + item.getId()); // TODO: Make this nicer etc, perhaps fix issues with mapping :T
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ public class WorldPackets {
|
|||||||
if (storage.contains(position))
|
if (storage.contains(position))
|
||||||
storage.get(position).setReplacement(newId);
|
storage.get(position).setReplacement(newId);
|
||||||
|
|
||||||
chunk.getSections()[y >> 4].setFlatBlock(x & 0xF, y, z & 0xF, newId);
|
chunk.getSections()[y >> 4].setFlatBlock(x & 0xF, y & 0xF, z & 0xF, newId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ public class SkullHandler implements BlockEntityProvider.BlockEntityHandler {
|
|||||||
id += (byte) tag.get("SkullType").getValue() * 20 + (byte) tag.get("Rot").getValue();
|
id += (byte) tag.get("SkullType").getValue() * 20 + (byte) tag.get("Rot").getValue();
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Why does this block have the skull block entity? :(" + tag);
|
System.out.println("Why does this block have the skull block entity? :(" + tag);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren