Merge pull request #2038 from RaphiMC/master

Fixed 1.9 -> 1.8 enderman held item metadata translation
This commit is contained in:
Nassim 2020-08-25 17:28:13 +02:00 committed by GitHub
commit 28219a3993
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 15 deletions

View File

@ -43,6 +43,14 @@ public class MetadataRewriter1_13To1_12_2 extends MetadataRewriter {
}
}
// Remap held block to match new format for remapping to flat block
if (type == Entity1_13Types.EntityType.ENDERMAN && metadata.getId() == 12) {
int stateId = (int) metadata.getValue();
int id = stateId & 4095;
int data = stateId >> 12 & 15;
metadata.setValue((id << 4) | (data & 0xF));
}
// 1.13 changed item to flat item (no data)
if (metadata.getMetaType() == MetaType1_13.Slot) {
metadata.setMetaType(MetaType1_13.Slot);

View File

@ -68,8 +68,8 @@ public enum MetaIndex {
// villager
VILLAGER_PROFESSION(VILLAGER, 16, MetaType1_8.Int, 12, MetaType1_9.VarInt),
// enderman
ENDERMAN_BLOCK(ENDERMAN, 16, MetaType1_8.Short, 11, MetaType1_9.BlockID), // special case
ENDERMAN_BLOCKDATA(ENDERMAN, 17, MetaType1_8.Byte, 11, MetaType1_9.BlockID), // special case
ENDERMAN_BLOCKSTATE(ENDERMAN, 16, MetaType1_8.Short, 11, MetaType1_9.BlockID),
ENDERMAN_BLOCKDATA(ENDERMAN, 17, MetaType1_8.Byte, MetaType1_9.Discontinued), //always 0 when sent, never read by the client
ENDERMAN_ISSCREAMING(ENDERMAN, 18, MetaType1_8.Byte, 12, MetaType1_9.Boolean),
// zombie
ZOMBIE_ISCHILD(ZOMBIE, 12, MetaType1_8.Byte, 11, MetaType1_9.Boolean),

View File

@ -39,19 +39,6 @@ public class MetadataRewriter1_9To1_8 extends MetadataRewriter {
metadata.setId(metaIndex.getNewIndex());
metadata.setMetaType(metaIndex.getNewType());
if (type == Entity1_10Types.EntityType.ENDERMAN && metaIndex.getNewType() == MetaType1_9.BlockID) {
if (metaIndex.getOldType() == MetaType1_8.Short) {
int id = (Short) metadata.getValue();
Metadata meta = getMetaByIndex(17, metadatas);
int data = meta != null ? (Byte) meta.getValue() : 0;
int combined = (id << 4) | (data & 0xF);
metadata.setValue(combined);
} else {
metadatas.remove(metadata);
}
return;
}
Object value = metadata.getValue();
switch (metaIndex.getNewType()) {
case Byte:
@ -124,6 +111,10 @@ public class MetadataRewriter1_9To1_8 extends MetadataRewriter {
value = Protocol1_9To1_8.fixJson(value.toString());
metadata.setValue(value);
break;
case BlockID:
// Convert from int, short, byte
metadata.setValue(((Number) value).intValue());
break;
default:
metadatas.remove(metadata);
throw new Exception("Unhandled MetaDataType: " + metaIndex.getNewType());