3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 16:12:42 +01:00
Dieser Commit ist enthalten in:
creeper123123321 2018-04-19 19:39:30 -03:00
Ursprung 1e0113a58a
Commit e41f445e92
2 geänderte Dateien mit 48 neuen und 28 gelöschten Zeilen

Datei anzeigen

@ -1,5 +1,6 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data; package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data;
import com.google.common.base.Optional;
import com.google.common.collect.BiMap; import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap; import com.google.common.collect.HashBiMap;
@ -67,4 +68,9 @@ public class SpawnEggRewriter {
return 25100288; return 25100288;
return (383 << 16 | (spawnEggs.get(entityIdentifier) & 0xFFFF)); return (383 << 16 | (spawnEggs.get(entityIdentifier) & 0xFFFF));
} }
public static Optional<String> getEntityId(int spawnEggId) {
if (spawnEggId >> 16 != 383) return Optional.absent();
return Optional.fromNullable(spawnEggs.inverse().get(spawnEggId & 0xFFFF));
}
} }

Datei anzeigen

@ -250,8 +250,8 @@ public class InventoryPackets {
} }
if (!MappingData.oldToNewItems.containsKey(rawId)) { if (!MappingData.oldToNewItems.containsKey(rawId)) {
if (MappingData.oldToNewItems.containsKey(item.getId() << 4)) { if (MappingData.oldToNewItems.containsKey(rawId & ~0xF)) {
rawId = item.getId() << 4; rawId &= ~0xF; // Remove data
} else { } else {
System.out.println("FAILED TO GET 1.13 ITEM FOR " + item.getId()); // TODO: Make this nicer etc, perhaps fix issues with mapping :T System.out.println("FAILED TO GET 1.13 ITEM FOR " + item.getId()); // TODO: Make this nicer etc, perhaps fix issues with mapping :T
rawId = 16; // Stone rawId = 16; // Stone
@ -286,45 +286,59 @@ 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; // Handle spawn eggs
Optional<String> eggEntityId = SpawnEggRewriter.getEntityId(oldId);
if (eggEntityId.isPresent()) {
rawId = 383 << 16;
if (tag == null)
item.setTag(tag = new CompoundTag("tag"));
if (!tag.contains("EntityTag")) {
CompoundTag entityTag = new CompoundTag("EntityTag");
entityTag.put(new StringTag("id", eggEntityId.get()));
tag.put(entityTag);
}
} else {
rawId = (oldId >> 4) << 16 | oldId & 0xF;
}
break; break;
} }
} }
} }
if (rawId != null) { if (rawId == null) {
item.setId((short) (rawId >> 16)); System.out.println("FAILED TO GET 1.12 ITEM FOR " + item.getId());
item.setData((short) (rawId & 0xFFFF)); rawId = 0x10000; // Stone
}
if (tag != null) { item.setId((short) (rawId >> 16));
if (isDamageable(item.getId())) { item.setData((short) (rawId & 0xFFFF));
if (tag.get("Damage") instanceof IntTag) {
if (!gotRawIdFromTag) if (tag != null) {
item.setData((short) (int) tag.get("Damage").getValue()); if (isDamageable(item.getId())) {
tag.remove("Damage"); if (tag.get("Damage") instanceof IntTag) {
} 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.get("map") instanceof IntTag) { if (tag.get("map") instanceof IntTag) {
if (!gotRawIdFromTag) if (!gotRawIdFromTag)
item.setData((short) (int) tag.get("map").getValue()); item.setData((short) (int) tag.get("map").getValue());
tag.remove("map"); tag.remove("map");
}
} }
}
if (item.getId() == 442) { // shield if (item.getId() == 442) { // shield
if (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()); // invert color id base.setValue(15 - base.getValue()); // invert color id
}
} }
} }
} }
} else {
System.out.println("FAILED TO GET 1.12 ITEM FOR " + item.getId()); // TODO: Make this nicer etc, perhaps fix issues with mapping :T
} }
} }