Fix shields not being for the right entity >.> and also print out value for metadata

This commit is contained in:
Myles 2016-03-26 13:07:06 +00:00
parent f32d3211ed
commit f371419396
2 changed files with 120 additions and 111 deletions

View File

@ -21,6 +21,7 @@ public class MetadataRewriter {
for (Metadata entry : new ArrayList<>(list)) {
MetaIndex metaIndex = MetaIndex.getIndex(type, entry.getId());
try {
if (metaIndex != null) {
if (metaIndex.getNewType() != NewType.Discontinued) {
if (metaIndex.getNewType() != NewType.BlockID || id != -1 && data == -1 || id == -1 && data != -1) { // block ID is only written if we have both parts
entry.setId(metaIndex.getNewIndex());
@ -135,6 +136,9 @@ public class MetadataRewriter {
} else {
list.remove(entry);
}
} else {
throw new Exception("Could not find valid metadata");
}
} catch (Exception e) {
list.remove(entry);
if (!((ViaVersionPlugin) ViaVersion.getInstance()).isSuppressMetadataErrors()) {
@ -144,6 +148,7 @@ public class MetadataRewriter {
else
System.out.println("An error occurred with entity meta data for UNKNOWN_ENTITY OldID: " + entry.getId());
if (metaIndex != null) {
System.out.println("Value: " + entry.getValue());
System.out.println("Old ID: " + metaIndex.getIndex() + " New ID: " + metaIndex.getNewIndex());
System.out.println("Old Type: " + metaIndex.getOldType() + " New Type: " + metaIndex.getNewType());
}

View File

@ -54,6 +54,10 @@ public class EntityTracker extends StoredObject {
}
public void setSecondHand(Item item) {
setSecondHand(entityID, item);
}
public void setSecondHand(int entityID, Item item) {
PacketWrapper wrapper = new PacketWrapper(0x3C, null, getUser());
wrapper.write(Type.VAR_INT, entityID);
wrapper.write(Type.VAR_INT, 1); // slot
@ -106,10 +110,10 @@ public class EntityTracker extends StoredObject {
if ((data & 0x10) == 0x10) {
if (validBlocking.contains(entityID)) {
Item shield = new Item((short) 442, (byte) 1, (short) 0, null);
setSecondHand(shield);
setSecondHand(entityID, shield);
}
} else {
setSecondHand(null);
setSecondHand(entityID, null);
}
}
}