RedstoneWireConnectionsFix.java
net.minecraft.util.datafix.fixes.RedstoneWireConnectionsFix
信息
- 全限定名:net.minecraft.util.datafix.fixes.RedstoneWireConnectionsFix
- 类型:public class
- 包:net.minecraft.util.datafix.fixes
- 源码路径:src/main/java/net/minecraft/util/datafix/fixes/RedstoneWireConnectionsFix.java
- 起始行号:L9
- 继承:DataFix
- 职责:
TODO
字段/常量
- 无
内部类/嵌套类型
- 无
构造器
public RedstoneWireConnectionsFix(Schema outputSchema) @ L10
- 构造器名:RedstoneWireConnectionsFix
- 源码定位:L10
- 修饰符:public
参数:
- outputSchema: Schema
说明:
TODO
方法
下面的方法块按源码顺序生成。
protected TypeRewriteRule makeRule() @ L14
- 方法名:makeRule
- 源码定位:L14
- 返回类型:TypeRewriteRule
- 修饰符:protected
参数:
- 无
说明:
TODO
private <T> Dynamic<T> updateRedstoneConnections(Dynamic<T> state) @ L24
- 方法名:updateRedstoneConnections
- 源码定位:L24
- 返回类型:
Dynamic - 修饰符:private
参数:
- state: Dynamic
说明:
TODO
private static boolean isConnected(String connectionType) @ L49
- 方法名:isConnected
- 源码定位:L49
- 返回类型:boolean
- 修饰符:private static
参数:
- connectionType: String
说明:
TODO
代码
public class RedstoneWireConnectionsFix extends DataFix {
public RedstoneWireConnectionsFix(Schema outputSchema) {
super(outputSchema, false);
}
@Override
protected TypeRewriteRule makeRule() {
Schema inputSchema = this.getInputSchema();
return this.fixTypeEverywhereTyped(
"RedstoneConnectionsFix",
inputSchema.getType(References.BLOCK_STATE),
input -> input.update(DSL.remainderFinder(), this::updateRedstoneConnections)
);
}
private <T> Dynamic<T> updateRedstoneConnections(Dynamic<T> state) {
boolean isRedstone = state.get("Name").asString().result().filter("minecraft:redstone_wire"::equals).isPresent();
return !isRedstone
? state
: state.update(
"Properties",
props -> {
String east = props.get("east").asString("none");
String west = props.get("west").asString("none");
String north = props.get("north").asString("none");
String south = props.get("south").asString("none");
boolean eastwest = isConnected(east) || isConnected(west);
boolean northsouth = isConnected(north) || isConnected(south);
String newEast = !isConnected(east) && !northsouth ? "side" : east;
String newWest = !isConnected(west) && !northsouth ? "side" : west;
String newNorth = !isConnected(north) && !eastwest ? "side" : north;
String newSouth = !isConnected(south) && !eastwest ? "side" : south;
return props.update("east", value -> value.createString(newEast))
.update("west", value -> value.createString(newWest))
.update("north", value -> value.createString(newNorth))
.update("south", value -> value.createString(newSouth));
}
);
}
private static boolean isConnected(String connectionType) {
return !"none".equals(connectionType);
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数/返回值
- 引用位置: