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

Merge pull request #890 from creeper123123321/master

Remove redundant tags
Dieser Commit ist enthalten in:
Myles 2018-07-20 15:13:44 +01:00 committet von GitHub
Commit 8b0eb9c9d0
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
4 geänderte Dateien mit 34 neuen und 16 gelöschten Zeilen

Datei anzeigen

@ -64,7 +64,8 @@ public class SpawnEggRewriter {
public static int getSpawnEggId(String entityIdentifier) { public static int getSpawnEggId(String entityIdentifier) {
// Fallback to bat // Fallback to bat
if (!spawnEggs.containsKey(entityIdentifier)) if (!spawnEggs.containsKey(entityIdentifier))
return 25100288; //return 25100288;
return -1;
return (383 << 16 | (spawnEggs.get(entityIdentifier) & 0xFFFF)); return (383 << 16 | (spawnEggs.get(entityIdentifier) & 0xFFFF));
} }

Datei anzeigen

@ -265,6 +265,8 @@ public class InventoryPackets {
// Save original id // Save original id
int originalId = (item.getId() << 16 | item.getData() & 0xFFFF); int originalId = (item.getId() << 16 | item.getData() & 0xFFFF);
int rawId = (item.getId() << 4 | item.getData() & 0xF);
// NBT Additions // NBT Additions
if (isDamageable(item.getId())) { if (isDamageable(item.getId())) {
if (tag == null) item.setTag(tag = new CompoundTag("tag")); if (tag == null) item.setTag(tag = new CompoundTag("tag"));
@ -343,17 +345,20 @@ public class InventoryPackets {
tag.remove("StoredEnchantments"); tag.remove("StoredEnchantments");
tag.put(newStoredEnch); tag.put(newStoredEnch);
} }
}
int rawId = (item.getId() << 4 | item.getData() & 0xF);
// Handle SpawnEggs // Handle SpawnEggs
if (item.getId() == 383) { if (item.getId() == 383) {
if (tag != null && tag.get("EntityTag") instanceof CompoundTag) { if (tag.get("EntityTag") instanceof CompoundTag) {
CompoundTag entityTag = tag.get("EntityTag"); CompoundTag entityTag = tag.get("EntityTag");
if (entityTag.get("id") instanceof StringTag) { if (entityTag.get("id") instanceof StringTag) {
StringTag identifier = entityTag.get("id"); StringTag identifier = entityTag.get("id");
rawId = SpawnEggRewriter.getSpawnEggId(identifier.getValue()); rawId = SpawnEggRewriter.getSpawnEggId(identifier.getValue());
if (rawId == -1) {
rawId = 25100288; // Bat fallback
} else {
entityTag.remove("id");
if (entityTag.isEmpty())
tag.remove("EntityTag");
}
} else { } else {
// Fallback to bat // Fallback to bat
rawId = 25100288; rawId = 25100288;
@ -363,6 +368,10 @@ public class InventoryPackets {
rawId = 25100288; rawId = 25100288;
} }
} }
if (tag.isEmpty()) {
item.setTag(tag = null);
}
}
if (!MappingData.oldToNewItems.containsKey(rawId)) { if (!MappingData.oldToNewItems.containsKey(rawId)) {
if (!isDamageable(item.getId()) && item.getId() != 358) { // Map if (!isDamageable(item.getId()) && item.getId() != 358) { // Map

Datei anzeigen

@ -171,6 +171,14 @@ public class WorldPackets {
} }
} }
// Rewrite biome id 255 to plains
if (chunk.isBiomeData()) {
for (int i = 0; i < 256; i++) {
if (chunk.getBiomeData()[i] == -1)
chunk.getBiomeData()[i] = 1;
}
}
// Rewrite BlockEntities to normal blocks // Rewrite BlockEntities to normal blocks
BlockEntityProvider provider = Via.getManager().getProviders().get(BlockEntityProvider.class); BlockEntityProvider provider = Via.getManager().getProviders().get(BlockEntityProvider.class);
for (CompoundTag tag : chunk.getBlockEntities()) { for (CompoundTag tag : chunk.getBlockEntities()) {

Datei anzeigen

@ -101,7 +101,7 @@ public class Chunk1_13Type extends PartialType<Chunk, ClientWorld> {
// Write biome data // Write biome data
if (chunk.isBiomeData()) { if (chunk.isBiomeData()) {
for (byte value : chunk.getBiomeData()) { for (byte value : chunk.getBiomeData()) {
output.writeInt(0); // This is a temporary workaround, we'll look into fixing this soon :) output.writeInt(value & 0xFF); // This is a temporary workaround, we'll look into fixing this soon :)
} }
} }