EntityZombieSplitFix.java
net.minecraft.util.datafix.fixes.EntityZombieSplitFix
信息
- 全限定名:net.minecraft.util.datafix.fixes.EntityZombieSplitFix
- 类型:public class
- 包:net.minecraft.util.datafix.fixes
- 源码路径:src/main/java/net/minecraft/util/datafix/fixes/EntityZombieSplitFix.java
- 起始行号:L13
- 继承:EntityRenameFix
- 职责:
TODO
字段/常量
zombieVillagerType- 类型:
Supplier<Type<?>> - 修饰符:
private final - 源码定位:
L14 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public EntityZombieSplitFix(Schema outputSchema) @ L16
- 构造器名:EntityZombieSplitFix
- 源码定位:L16
- 修饰符:public
参数:
- outputSchema: Schema
说明:
TODO
方法
下面的方法块按源码顺序生成。
protected Pair<String,Typed<?>> fix(String name, Typed<?> entity) @ L20
- 方法名:fix
- 源码定位:L20
- 返回类型:Pair<String,Typed<?>>
- 修饰符:protected
参数:
- name: String
- entity: Typed<?>
说明:
TODO
private Typed<?> changeSchemaToZombieVillager(Typed<?> entity, int profession) @ L51
- 方法名:changeSchemaToZombieVillager
- 源码定位:L51
- 返回类型:Typed<?>
- 修饰符:private
参数:
- entity: Typed<?>
- profession: int
说明:
TODO
代码
public class EntityZombieSplitFix extends EntityRenameFix {
private final Supplier<Type<?>> zombieVillagerType = Suppliers.memoize(() -> this.getOutputSchema().getChoiceType(References.ENTITY, "ZombieVillager"));
public EntityZombieSplitFix(Schema outputSchema) {
super("EntityZombieSplitFix", outputSchema, true);
}
@Override
protected Pair<String, Typed<?>> fix(String name, Typed<?> entity) {
if (!name.equals("Zombie")) {
return Pair.of(name, entity);
} else {
Dynamic<?> tag = entity.getOptional(DSL.remainderFinder()).orElseThrow();
int type = tag.get("ZombieType").asInt(0);
String newName;
Typed<?> newEntity;
switch (type) {
case 1:
case 2:
case 3:
case 4:
case 5:
newName = "ZombieVillager";
newEntity = this.changeSchemaToZombieVillager(entity, type - 1);
break;
case 6:
newName = "Husk";
newEntity = entity;
break;
default:
newName = "Zombie";
newEntity = entity;
}
return Pair.of(newName, newEntity.update(DSL.remainderFinder(), e -> e.remove("ZombieType")));
}
}
private Typed<?> changeSchemaToZombieVillager(Typed<?> entity, int profession) {
return Util.writeAndReadTypedOrThrow(
entity, this.zombieVillagerType.get(), serializedEntity -> serializedEntity.set("Profession", serializedEntity.createInt(profession))
);
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Util.writeAndReadTypedOrThrow()
- 引用位置:
-
- 引用位置:
继承
- 引用位置: