WallPropertyFix.java
net.minecraft.util.datafix.fixes.WallPropertyFix
信息
- 全限定名:net.minecraft.util.datafix.fixes.WallPropertyFix
- 类型:public class
- 包:net.minecraft.util.datafix.fixes
- 源码路径:src/main/java/net/minecraft/util/datafix/fixes/WallPropertyFix.java
- 起始行号:L12
- 继承:DataFix
- 职责:
TODO
字段/常量
WALL_BLOCKS- 类型:
Set<String> - 修饰符:
private static final - 源码定位:
L13 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public WallPropertyFix(Schema outputSchema, boolean changesType) @ L30
- 构造器名:WallPropertyFix
- 源码定位:L30
- 修饰符:public
参数:
- outputSchema: Schema
- changesType: boolean
说明:
TODO
方法
下面的方法块按源码顺序生成。
public TypeRewriteRule makeRule() @ L34
- 方法名:makeRule
- 源码定位:L34
- 返回类型:TypeRewriteRule
- 修饰符:public
参数:
- 无
说明:
TODO
private static String mapProperty(String value) @ L43
- 方法名:mapProperty
- 源码定位:L43
- 返回类型:String
- 修饰符:private static
参数:
- value: String
说明:
TODO
private static <T> Dynamic<T> fixWallProperty(Dynamic<T> state, String property) @ L47
- 方法名:fixWallProperty
- 源码定位:L47
- 返回类型:
Dynamic - 修饰符:private static
参数:
- state: Dynamic
- property: String
说明:
TODO
private static <T> Dynamic<T> upgradeBlockStateTag(Dynamic<T> state) @ L51
- 方法名:upgradeBlockStateTag
- 源码定位:L51
- 返回类型:
Dynamic - 修饰符:private static
参数:
- state: Dynamic
说明:
TODO
代码
public class WallPropertyFix extends DataFix {
private static final Set<String> WALL_BLOCKS = ImmutableSet.of(
"minecraft:andesite_wall",
"minecraft:brick_wall",
"minecraft:cobblestone_wall",
"minecraft:diorite_wall",
"minecraft:end_stone_brick_wall",
"minecraft:granite_wall",
"minecraft:mossy_cobblestone_wall",
"minecraft:mossy_stone_brick_wall",
"minecraft:nether_brick_wall",
"minecraft:prismarine_wall",
"minecraft:red_nether_brick_wall",
"minecraft:red_sandstone_wall",
"minecraft:sandstone_wall",
"minecraft:stone_brick_wall"
);
public WallPropertyFix(Schema outputSchema, boolean changesType) {
super(outputSchema, changesType);
}
@Override
public TypeRewriteRule makeRule() {
return this.fixTypeEverywhereTyped(
"WallPropertyFix",
this.getInputSchema().getType(References.BLOCK_STATE),
input -> input.update(DSL.remainderFinder(), WallPropertyFix::upgradeBlockStateTag)
);
}
private static String mapProperty(String value) {
return "true".equals(value) ? "low" : "none";
}
private static <T> Dynamic<T> fixWallProperty(Dynamic<T> state, String property) {
return state.update(property, value -> DataFixUtils.orElse(value.asString().result().map(WallPropertyFix::mapProperty).map(value::createString), value));
}
private static <T> Dynamic<T> upgradeBlockStateTag(Dynamic<T> state) {
boolean isWall = state.get("Name").asString().result().filter(WALL_BLOCKS::contains).isPresent();
return !isWall ? state : state.update("Properties", properties -> {
Dynamic<?> newState = fixWallProperty(properties, "east");
newState = fixWallProperty(newState, "west");
newState = fixWallProperty(newState, "north");
return fixWallProperty(newState, "south");
});
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数/返回值
- 引用位置: