BlockEntityBlockStateFix.java
net.minecraft.util.datafix.fixes.BlockEntityBlockStateFix
信息
- 全限定名:net.minecraft.util.datafix.fixes.BlockEntityBlockStateFix
- 类型:public class
- 包:net.minecraft.util.datafix.fixes
- 源码路径:src/main/java/net/minecraft/util/datafix/fixes/BlockEntityBlockStateFix.java
- 起始行号:L10
- 继承:NamedEntityFix
- 职责:
TODO
字段/常量
- 无
内部类/嵌套类型
- 无
构造器
public BlockEntityBlockStateFix(Schema outputSchema, boolean changesType) @ L11
- 构造器名:BlockEntityBlockStateFix
- 源码定位:L11
- 修饰符:public
参数:
- outputSchema: Schema
- changesType: boolean
说明:
TODO
方法
下面的方法块按源码顺序生成。
protected Typed<?> fix(Typed<?> entity) @ L15
- 方法名:fix
- 源码定位:L15
- 返回类型:Typed<?>
- 修饰符:protected
参数:
- entity: Typed<?>
说明:
TODO
代码
public class BlockEntityBlockStateFix extends NamedEntityFix {
public BlockEntityBlockStateFix(Schema outputSchema, boolean changesType) {
super(outputSchema, changesType, "BlockEntityBlockStateFix", References.BLOCK_ENTITY, "minecraft:piston");
}
@Override
protected Typed<?> fix(Typed<?> entity) {
Type<?> newType = this.getOutputSchema().getChoiceType(References.BLOCK_ENTITY, "minecraft:piston");
Type<?> blockStateType = newType.findFieldType("blockState");
OpticFinder<?> blockStateF = DSL.fieldFinder("blockState", blockStateType);
Dynamic<?> tag = entity.get(DSL.remainderFinder());
int block = tag.get("blockId").asInt(0);
tag = tag.remove("blockId");
int data = tag.get("blockData").asInt(0) & 15;
tag = tag.remove("blockData");
Dynamic<?> blockStateTag = BlockStateData.getTag(block << 4 | data);
Typed<?> output = newType.pointTyped(entity.getOps()).orElseThrow(() -> new IllegalStateException("Could not create new piston block entity."));
return output.set(DSL.remainderFinder(), tag)
.set(
blockStateF,
blockStateType.readTyped(blockStateTag)
.result()
.orElseThrow(() -> new IllegalStateException("Could not parse newly created block state tag."))
.getFirst()
);
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
BlockStateData.getTag()
- 引用位置:
-
- 引用位置:
继承
- 引用位置: