use of com.viaversion.viaversion.api.minecraft.entities.Entity1_11Types.EntityType in project ViaVersion by ViaVersion.
the class MetadataRewriter1_11To1_10 method rewriteEntityType.
public static EntityType rewriteEntityType(int numType, List<Metadata> metadata) {
Optional<EntityType> optType = EntityType.findById(numType);
if (!optType.isPresent()) {
Via.getManager().getPlatform().getLogger().severe("Error: could not find Entity type " + numType + " with metadata: " + metadata);
return null;
}
EntityType type = optType.get();
try {
if (type.is(EntityType.GUARDIAN)) {
// ElderGuardian - 4
Optional<Metadata> options = getById(metadata, 12);
if (options.isPresent()) {
if ((((byte) options.get().getValue()) & 0x04) == 0x04) {
return EntityType.ELDER_GUARDIAN;
}
}
}
if (type.is(EntityType.SKELETON)) {
// WitherSkeleton - 5
// Stray - 6
Optional<Metadata> options = getById(metadata, 12);
if (options.isPresent()) {
if (((int) options.get().getValue()) == 1) {
return EntityType.WITHER_SKELETON;
}
if (((int) options.get().getValue()) == 2) {
return EntityType.STRAY;
}
}
}
if (type.is(EntityType.ZOMBIE)) {
// ZombieVillager - 27
// Husk - 23
Optional<Metadata> options = getById(metadata, 13);
if (options.isPresent()) {
int value = (int) options.get().getValue();
if (value > 0 && value < 6) {
// Add profession type to new metadata
metadata.add(new Metadata(16, MetaType1_9.VarInt, value - 1));
return EntityType.ZOMBIE_VILLAGER;
}
if (value == 6) {
return EntityType.HUSK;
}
}
}
if (type.is(EntityType.HORSE)) {
// SkeletonHorse - 28
// ZombieHorse - 29
// Donkey - 31
// Mule - 32
Optional<Metadata> options = getById(metadata, 14);
if (options.isPresent()) {
if (((int) options.get().getValue()) == 0) {
return EntityType.HORSE;
}
if (((int) options.get().getValue()) == 1) {
return EntityType.DONKEY;
}
if (((int) options.get().getValue()) == 2) {
return EntityType.MULE;
}
if (((int) options.get().getValue()) == 3) {
return EntityType.ZOMBIE_HORSE;
}
if (((int) options.get().getValue()) == 4) {
return EntityType.SKELETON_HORSE;
}
}
}
} catch (Exception e) {
if (!Via.getConfig().isSuppressMetadataErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("An error occurred with entity type rewriter");
Via.getPlatform().getLogger().warning("Metadata: " + metadata);
e.printStackTrace();
}
}
return type;
}
Aggregations