3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-03 14:50:30 +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;
import com.google.common.base.Optional;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
@ -67,4 +68,9 @@ public class SpawnEggRewriter {
return 25100288;
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(item.getId() << 4)) {
rawId = item.getId() << 4;
if (MappingData.oldToNewItems.containsKey(rawId & ~0xF)) {
rawId &= ~0xF; // Remove data
} else {
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
@ -286,13 +286,30 @@ public class InventoryPackets {
for (Map.Entry<Integer, Integer> entry : MappingData.oldToNewItems.entrySet()) {
if (entry.getValue() == item.getId()) {
int oldId = entry.getKey();
// 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;
}
}
}
if (rawId != null) {
if (rawId == null) {
System.out.println("FAILED TO GET 1.12 ITEM FOR " + item.getId());
rawId = 0x10000; // Stone
}
item.setId((short) (rawId >> 16));
item.setData((short) (rawId & 0xFFFF));
@ -323,9 +340,6 @@ public class InventoryPackets {
}
}
}
} else {
System.out.println("FAILED TO GET 1.12 ITEM FOR " + item.getId()); // TODO: Make this nicer etc, perhaps fix issues with mapping :T
}
}
public static boolean isDamageable(int id) {