BlockEntityIdFix.java

net.minecraft.util.datafix.fixes.BlockEntityIdFix

信息

  • 全限定名:net.minecraft.util.datafix.fixes.BlockEntityIdFix
  • 类型:public class
  • 包:net.minecraft.util.datafix.fixes
  • 源码路径:src/main/java/net/minecraft/util/datafix/fixes/BlockEntityIdFix.java
  • 起始行号:L12
  • 继承:DataFix
  • 职责:

    TODO

字段/常量

  • ID_MAP
    • 类型: Map<String,String>
    • 修饰符: public static final
    • 源码定位: L13
    • 说明:

      TODO

内部类/嵌套类型

构造器

public BlockEntityIdFix(Schema outputSchema, boolean changesType) @ L39

  • 构造器名:BlockEntityIdFix
  • 源码定位:L39
  • 修饰符:public

参数:

  • outputSchema: Schema
  • changesType: boolean

说明:

TODO

方法

下面的方法块按源码顺序生成。

public TypeRewriteRule makeRule() @ L43

  • 方法名:makeRule
  • 源码定位:L43
  • 返回类型:TypeRewriteRule
  • 修饰符:public

参数:

说明:

TODO

代码

public class BlockEntityIdFix extends DataFix {
    public static final Map<String, String> ID_MAP = DataFixUtils.make(Maps.newHashMap(), map -> {
        map.put("Airportal", "minecraft:end_portal");
        map.put("Banner", "minecraft:banner");
        map.put("Beacon", "minecraft:beacon");
        map.put("Cauldron", "minecraft:brewing_stand");
        map.put("Chest", "minecraft:chest");
        map.put("Comparator", "minecraft:comparator");
        map.put("Control", "minecraft:command_block");
        map.put("DLDetector", "minecraft:daylight_detector");
        map.put("Dropper", "minecraft:dropper");
        map.put("EnchantTable", "minecraft:enchanting_table");
        map.put("EndGateway", "minecraft:end_gateway");
        map.put("EnderChest", "minecraft:ender_chest");
        map.put("FlowerPot", "minecraft:flower_pot");
        map.put("Furnace", "minecraft:furnace");
        map.put("Hopper", "minecraft:hopper");
        map.put("MobSpawner", "minecraft:mob_spawner");
        map.put("Music", "minecraft:noteblock");
        map.put("Piston", "minecraft:piston");
        map.put("RecordPlayer", "minecraft:jukebox");
        map.put("Sign", "minecraft:sign");
        map.put("Skull", "minecraft:skull");
        map.put("Structure", "minecraft:structure_block");
        map.put("Trap", "minecraft:dispenser");
    });
 
    public BlockEntityIdFix(Schema outputSchema, boolean changesType) {
        super(outputSchema, changesType);
    }
 
    @Override
    public TypeRewriteRule makeRule() {
        Type<?> oldItemStackType = this.getInputSchema().getType(References.ITEM_STACK);
        Type<?> newItemStackType = this.getOutputSchema().getType(References.ITEM_STACK);
        TaggedChoiceType<String> oldType = (TaggedChoiceType<String>)this.getInputSchema().findChoiceType(References.BLOCK_ENTITY);
        TaggedChoiceType<String> newType = (TaggedChoiceType<String>)this.getOutputSchema().findChoiceType(References.BLOCK_ENTITY);
        return TypeRewriteRule.seq(
            this.convertUnchecked("item stack block entity name hook converter", oldItemStackType, newItemStackType),
            this.fixTypeEverywhere("BlockEntityIdFix", oldType, newType, ops -> input -> input.mapFirst(id -> ID_MAP.getOrDefault(id, id)))
        );
    }
}

引用的其他类