3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 08:30:09 +01:00

Update mappings, change some things on item rewriter

Dieser Commit ist enthalten in:
creeper123123321 2018-04-04 14:58:20 -03:00
Ursprung feba8785d7
Commit b7fde6390e
3 geänderte Dateien mit 57 neuen und 35 gelöschten Zeilen

Datei anzeigen

@ -198,14 +198,39 @@ 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 originalId = (item.getId() << 16 | item.getData() & 0xFFFF); // create tag
// Save original id
CompoundTag tag = item.getTag(); CompoundTag tag = item.getTag();
if (tag == null) { if (tag == null) {
item.setTag(tag = new CompoundTag("tag")); item.setTag(tag = new CompoundTag("tag"));
} }
item.getTag().put(new IntTag(NBT_TAG_NAME, originalId));
// Save original id
int originalId = (item.getId() << 16 | item.getData() & 0xFFFF);
tag.put(new IntTag(NBT_TAG_NAME, originalId));
if (isDamageable(item.getId())) {
tag.put(new IntTag("Damage", item.getData()));
}
if (item.getId() == 358) { // map
tag.put(new IntTag("map", item.getData()));
}
if (item.getId() == 442) { // shield
if (tag.get("BlockEntityTag") instanceof CompoundTag) {
CompoundTag blockEntityTag = tag.get("BlockEntityTag");
if (blockEntityTag.get("Base") instanceof IntTag) {
IntTag base = blockEntityTag.get("Base");
base.setValue(15 - base.getValue()); // invert color id
}
}
}
// todo spawn egg
int rawId = (item.getId() << 4 | item.getData() & 0xF);
if (!MappingData.oldToNewItems.containsKey(rawId)) { if (!MappingData.oldToNewItems.containsKey(rawId)) {
if (MappingData.oldToNewItems.containsKey(item.getId() << 4)) { if (MappingData.oldToNewItems.containsKey(item.getId() << 4)) {
rawId = item.getId() << 4; rawId = item.getId() << 4;
@ -214,31 +239,19 @@ public class InventoryPackets {
rawId = 16; // Stone rawId = 16; // Stone
} }
} }
if (isDamageable(item.getId())) {
tag.put(new IntTag("Damage", item.getData()));
}
if (item.getId() == 358) { // map
tag.put(new IntTag("map", item.getData()));
}
if (item.getId() == 442) { // shield
if (tag.get("BlockEntityTag") instanceof CompoundTag) {
CompoundTag blockEntityTag = tag.get("BlockEntityTag");
if (blockEntityTag.get("Base") instanceof IntTag) {
IntTag base = blockEntityTag.get("Base");
base.setValue(15 - base.getValue());
}
}
}
// todo spawn egg
item.setId(MappingData.oldToNewItems.get(rawId).shortValue()); item.setId(MappingData.oldToNewItems.get(rawId).shortValue());
item.setData((short) 0); item.setData((short) 0);
} }
public static void toServer(Item item) { public static void toServer(Item item) {
if (item == null) return; if (item == null) return;
Integer rawId = null; Integer rawId = null;
boolean gotRawIdFromTag = false; boolean gotRawIdFromTag = false;
CompoundTag tag = item.getTag(); CompoundTag tag = item.getTag();
if (tag != null) { if (tag != null) {
// Check for valid tag // Check for valid tag
if (tag.contains(NBT_TAG_NAME)) { if (tag.contains(NBT_TAG_NAME)) {
@ -254,31 +267,40 @@ public class InventoryPackets {
for (Map.Entry<Integer, Integer> entry : MappingData.oldToNewItems.entrySet()) { for (Map.Entry<Integer, Integer> entry : MappingData.oldToNewItems.entrySet()) {
if (entry.getValue() == item.getId()) { if (entry.getValue() == item.getId()) {
int oldId = entry.getKey(); int oldId = entry.getKey();
rawId = oldId >> 4 << 16 | oldId & 0xF; rawId = (oldId >> 4) << 16 | oldId & 0xF;
break;
} }
} }
} }
if (rawId != null) { if (rawId != null) {
item.setId((short) (rawId >> 16)); item.setId((short) (rawId >> 16));
item.setData((short) (rawId & 0xFFFF)); item.setData((short) (rawId & 0xFFFF));
if (!gotRawIdFromTag) {
if (tag != null) {
if (isDamageable(item.getId())) { if (isDamageable(item.getId())) {
if (tag != null && tag.get("Damage") instanceof IntTag) { if (tag.get("Damage") instanceof IntTag) {
item.setData((short) (int) tag.get("Damage").getValue()); if (!gotRawIdFromTag)
item.setData((short) (int) tag.get("Damage").getValue());
tag.remove("Damage");
} }
} }
if (item.getId() == 358) { // map if (item.getId() == 358) { // map
if (tag != null && tag.get("map") instanceof IntTag) { if (tag.get("map") instanceof IntTag) {
item.setData((short) (int) tag.get("map").getValue()); if (!gotRawIdFromTag)
item.setData((short) (int) tag.get("map").getValue());
tag.remove("map");
} }
} }
}
if (item.getId() == 442) { // shield if (item.getId() == 442) { // shield
if (tag != null && tag.get("BlockEntityTag") instanceof CompoundTag) { if (tag.get("BlockEntityTag") instanceof CompoundTag) {
CompoundTag blockEntityTag = tag.get("BlockEntityTag"); CompoundTag blockEntityTag = tag.get("BlockEntityTag");
if (blockEntityTag.get("Base") instanceof IntTag) { if (blockEntityTag.get("Base") instanceof IntTag) {
IntTag base = blockEntityTag.get("Base"); IntTag base = blockEntityTag.get("Base");
base.setValue(15 - base.getValue()); base.setValue(15 - base.getValue()); // invert color id
}
} }
} }
} }

Datei anzeigen

@ -10,7 +10,6 @@ import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.BlockStora
public class SkullHandler implements BlockEntityProvider.BlockEntityHandler { public class SkullHandler implements BlockEntityProvider.BlockEntityHandler {
private final int SKULL_WALL_START = 5357; private final int SKULL_WALL_START = 5357;
private final int SKULL_END = 5476; private final int SKULL_END = 5476;
// remember to change blockstorage
@Override @Override
public int transform(UserConnection user, CompoundTag tag) { public int transform(UserConnection user, CompoundTag tag) {
BlockStorage storage = user.get(BlockStorage.class); BlockStorage storage = user.get(BlockStorage.class);

Datei anzeigen

@ -9170,6 +9170,7 @@
"763": "minecraft:music_disc_ward", "763": "minecraft:music_disc_ward",
"764": "minecraft:music_disc_11", "764": "minecraft:music_disc_11",
"765": "minecraft:music_disc_wait", "765": "minecraft:music_disc_wait",
"766": "minecraft:trident" "766": "minecraft:trident",
"767": "minecraft:phantom_membrane"
} }
} }