3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-08 17:20:24 +01:00

fixed 1.9 -> 1.8 enderman held item metadata translation

Dieser Commit ist enthalten in:
RaphiMC 2020-08-25 15:43:21 +02:00
Ursprung 4b6b904361
Commit 0070485d2e
3 geänderte Dateien mit 22 neuen und 15 gelöschten Zeilen

Datei anzeigen

@ -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) // 1.13 changed item to flat item (no data)
if (metadata.getMetaType() == MetaType1_13.Slot) { if (metadata.getMetaType() == MetaType1_13.Slot) {
metadata.setMetaType(MetaType1_13.Slot); metadata.setMetaType(MetaType1_13.Slot);

Datei anzeigen

@ -68,8 +68,8 @@ public enum MetaIndex {
// villager // villager
VILLAGER_PROFESSION(VILLAGER, 16, MetaType1_8.Int, 12, MetaType1_9.VarInt), VILLAGER_PROFESSION(VILLAGER, 16, MetaType1_8.Int, 12, MetaType1_9.VarInt),
// enderman // enderman
ENDERMAN_BLOCK(ENDERMAN, 16, MetaType1_8.Short, 11, MetaType1_9.BlockID), // special case ENDERMAN_BLOCKSTATE(ENDERMAN, 16, MetaType1_8.Short, 11, MetaType1_9.BlockID),
ENDERMAN_BLOCKDATA(ENDERMAN, 17, MetaType1_8.Byte, 11, MetaType1_9.BlockID), // special case 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), ENDERMAN_ISSCREAMING(ENDERMAN, 18, MetaType1_8.Byte, 12, MetaType1_9.Boolean),
// zombie // zombie
ZOMBIE_ISCHILD(ZOMBIE, 12, MetaType1_8.Byte, 11, MetaType1_9.Boolean), ZOMBIE_ISCHILD(ZOMBIE, 12, MetaType1_8.Byte, 11, MetaType1_9.Boolean),

Datei anzeigen

@ -39,19 +39,6 @@ public class MetadataRewriter1_9To1_8 extends MetadataRewriter {
metadata.setId(metaIndex.getNewIndex()); metadata.setId(metaIndex.getNewIndex());
metadata.setMetaType(metaIndex.getNewType()); 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(); Object value = metadata.getValue();
switch (metaIndex.getNewType()) { switch (metaIndex.getNewType()) {
case Byte: case Byte:
@ -124,6 +111,18 @@ public class MetadataRewriter1_9To1_8 extends MetadataRewriter {
value = Protocol1_9To1_8.fixJson(value.toString()); value = Protocol1_9To1_8.fixJson(value.toString());
metadata.setValue(value); metadata.setValue(value);
break; break;
case BlockID:
// convert from int, short, byte
if (metaIndex.getOldType() == MetaType1_8.Byte) {
metadata.setValue(((Byte) value).intValue());
}
if (metaIndex.getOldType() == MetaType1_8.Short) {
metadata.setValue(((Short) value).intValue());
}
if (metaIndex.getOldType() == MetaType1_8.Int) {
metadata.setValue(value);
}
break;
default: default:
metadatas.remove(metadata); metadatas.remove(metadata);
throw new Exception("Unhandled MetaDataType: " + metaIndex.getNewType()); throw new Exception("Unhandled MetaDataType: " + metaIndex.getNewType());