BlockFamily.java

net.minecraft.data.BlockFamily

信息

  • 全限定名:net.minecraft.data.BlockFamily
  • 类型:public class
  • 包:net.minecraft.data
  • 源码路径:src/main/java/net/minecraft/data/BlockFamily.java
  • 起始行号:L10
  • 职责:

    TODO

字段/常量

  • baseBlock

    • 类型: Block
    • 修饰符: private final
    • 源码定位: L11
    • 说明:

      TODO

  • variants

    • 类型: Map<BlockFamily.Variant,Block>
    • 修饰符: private final
    • 源码定位: L12
    • 说明:

      TODO

  • generateModel

    • 类型: boolean
    • 修饰符: private
    • 源码定位: L13
    • 说明:

      TODO

  • generateCraftingRecipe

    • 类型: boolean
    • 修饰符: private
    • 源码定位: L14
    • 说明:

      TODO

  • generateStonecutterRecipe

    • 类型: boolean
    • 修饰符: private
    • 源码定位: L15
    • 说明:

      TODO

  • recipeGroupPrefix

    • 类型: String
    • 修饰符: private
    • 源码定位: L16
    • 说明:

      TODO

  • recipeUnlockedBy

    • 类型: String
    • 修饰符: private
    • 源码定位: L17
    • 说明:

      TODO

内部类/嵌套类型

  • net.minecraft.data.BlockFamily.Builder

    • 类型: class
    • 修饰符: public static
    • 源码定位: L55
    • 说明:

      TODO

  • net.minecraft.data.BlockFamily.Variant

    • 类型: enum
    • 修饰符: public static
    • 源码定位: L193
    • 说明:

      TODO

构造器

private BlockFamily(Block baseBlock) @ L19

  • 构造器名:BlockFamily
  • 源码定位:L19
  • 修饰符:private

参数:

  • baseBlock: Block

说明:

TODO

方法

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

public Block getBaseBlock() @ L23

  • 方法名:getBaseBlock
  • 源码定位:L23
  • 返回类型:Block
  • 修饰符:public

参数:

说明:

TODO

public Map<BlockFamily.Variant,Block> getVariants() @ L27

  • 方法名:getVariants
  • 源码定位:L27
  • 返回类型:Map<BlockFamily.Variant,Block>
  • 修饰符:public

参数:

说明:

TODO

public Block get(BlockFamily.Variant variant) @ L31

  • 方法名:get
  • 源码定位:L31
  • 返回类型:Block
  • 修饰符:public

参数:

  • variant: BlockFamily.Variant

说明:

TODO

public boolean shouldGenerateModel() @ L35

  • 方法名:shouldGenerateModel
  • 源码定位:L35
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

public boolean shouldGenerateCraftingRecipe() @ L39

  • 方法名:shouldGenerateCraftingRecipe
  • 源码定位:L39
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

public boolean shouldGenerateStonecutterRecipe() @ L43

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

参数:

说明:

TODO

public Optional<String> getRecipeGroupPrefix() @ L47

  • 方法名:getRecipeGroupPrefix
  • 源码定位:L47
  • 返回类型:Optional
  • 修饰符:public

参数:

说明:

TODO

public Optional<String> getRecipeUnlockedBy() @ L51

  • 方法名:getRecipeUnlockedBy
  • 源码定位:L51
  • 返回类型:Optional
  • 修饰符:public

参数:

说明:

TODO

代码

public class BlockFamily {
    private final Block baseBlock;
    private final Map<BlockFamily.Variant, Block> variants = Maps.newHashMap();
    private boolean generateModel = true;
    private boolean generateCraftingRecipe = true;
    private boolean generateStonecutterRecipe = false;
    private @Nullable String recipeGroupPrefix;
    private @Nullable String recipeUnlockedBy;
 
    private BlockFamily(Block baseBlock) {
        this.baseBlock = baseBlock;
    }
 
    public Block getBaseBlock() {
        return this.baseBlock;
    }
 
    public Map<BlockFamily.Variant, Block> getVariants() {
        return this.variants;
    }
 
    public Block get(BlockFamily.Variant variant) {
        return this.variants.get(variant);
    }
 
    public boolean shouldGenerateModel() {
        return this.generateModel;
    }
 
    public boolean shouldGenerateCraftingRecipe() {
        return this.generateCraftingRecipe;
    }
 
    public boolean shouldGenerateStonecutterRecipe() {
        return this.generateStonecutterRecipe;
    }
 
    public Optional<String> getRecipeGroupPrefix() {
        return StringUtil.isBlank(this.recipeGroupPrefix) ? Optional.empty() : Optional.of(this.recipeGroupPrefix);
    }
 
    public Optional<String> getRecipeUnlockedBy() {
        return StringUtil.isBlank(this.recipeUnlockedBy) ? Optional.empty() : Optional.of(this.recipeUnlockedBy);
    }
 
    public static class Builder {
        private final BlockFamily family;
 
        public Builder(Block baseBlock) {
            this.family = new BlockFamily(baseBlock);
        }
 
        public BlockFamily getFamily() {
            return this.family;
        }
 
        public BlockFamily.Builder button(Block button) {
            this.family.variants.put(BlockFamily.Variant.BUTTON, button);
            return this;
        }
 
        public BlockFamily.Builder chiseled(Block chiseled) {
            this.family.variants.put(BlockFamily.Variant.CHISELED, chiseled);
            return this;
        }
 
        public BlockFamily.Builder mosaic(Block mosaic) {
            this.family.variants.put(BlockFamily.Variant.MOSAIC, mosaic);
            return this;
        }
 
        public BlockFamily.Builder cracked(Block cracked) {
            this.family.variants.put(BlockFamily.Variant.CRACKED, cracked);
            return this;
        }
 
        public BlockFamily.Builder tiles(Block tiles) {
            this.family.variants.put(BlockFamily.Variant.TILES, tiles);
            return this;
        }
 
        public BlockFamily.Builder cut(Block cut) {
            this.family.variants.put(BlockFamily.Variant.CUT, cut);
            return this;
        }
 
        public BlockFamily.Builder door(Block door) {
            this.family.variants.put(BlockFamily.Variant.DOOR, door);
            return this;
        }
 
        public BlockFamily.Builder customFence(Block fence) {
            this.family.variants.put(BlockFamily.Variant.CUSTOM_FENCE, fence);
            return this;
        }
 
        public BlockFamily.Builder fence(Block fence) {
            this.family.variants.put(BlockFamily.Variant.FENCE, fence);
            return this;
        }
 
        public BlockFamily.Builder customFenceGate(Block fenceGate) {
            this.family.variants.put(BlockFamily.Variant.CUSTOM_FENCE_GATE, fenceGate);
            return this;
        }
 
        public BlockFamily.Builder fenceGate(Block fenceGate) {
            this.family.variants.put(BlockFamily.Variant.FENCE_GATE, fenceGate);
            return this;
        }
 
        public BlockFamily.Builder sign(Block sign, Block wallSign) {
            this.family.variants.put(BlockFamily.Variant.SIGN, sign);
            this.family.variants.put(BlockFamily.Variant.WALL_SIGN, wallSign);
            return this;
        }
 
        public BlockFamily.Builder slab(Block slab) {
            this.family.variants.put(BlockFamily.Variant.SLAB, slab);
            return this;
        }
 
        public BlockFamily.Builder stairs(Block stairs) {
            this.family.variants.put(BlockFamily.Variant.STAIRS, stairs);
            return this;
        }
 
        public BlockFamily.Builder pressurePlate(Block pressurePlate) {
            this.family.variants.put(BlockFamily.Variant.PRESSURE_PLATE, pressurePlate);
            return this;
        }
 
        public BlockFamily.Builder polished(Block polished) {
            this.family.variants.put(BlockFamily.Variant.POLISHED, polished);
            return this;
        }
 
        public BlockFamily.Builder trapdoor(Block trapdoor) {
            this.family.variants.put(BlockFamily.Variant.TRAPDOOR, trapdoor);
            return this;
        }
 
        public BlockFamily.Builder wall(Block wall) {
            this.family.variants.put(BlockFamily.Variant.WALL, wall);
            return this;
        }
 
        public BlockFamily.Builder cobbled(Block cobble) {
            this.family.variants.put(BlockFamily.Variant.COBBLED, cobble);
            return this;
        }
 
        public BlockFamily.Builder bricks(Block bricks) {
            this.family.variants.put(BlockFamily.Variant.BRICKS, bricks);
            return this;
        }
 
        public BlockFamily.Builder dontGenerateModel() {
            this.family.generateModel = false;
            return this;
        }
 
        public BlockFamily.Builder dontGenerateCraftingRecipe() {
            this.family.generateCraftingRecipe = false;
            return this;
        }
 
        public BlockFamily.Builder generateStonecutterRecipe() {
            this.family.generateStonecutterRecipe = true;
            return this;
        }
 
        public BlockFamily.Builder recipeGroupPrefix(String recipeGroupPrefix) {
            this.family.recipeGroupPrefix = recipeGroupPrefix;
            return this;
        }
 
        public BlockFamily.Builder recipeUnlockedBy(String recipeUnlockedBy) {
            this.family.recipeUnlockedBy = recipeUnlockedBy;
            return this;
        }
    }
 
    public static enum Variant {
        BUTTON("button"),
        CHISELED("chiseled"),
        CRACKED("cracked"),
        CUT("cut"),
        DOOR("door"),
        CUSTOM_FENCE("fence"),
        FENCE("fence"),
        CUSTOM_FENCE_GATE("fence_gate"),
        FENCE_GATE("fence_gate"),
        MOSAIC("mosaic"),
        SIGN("sign"),
        SLAB("slab"),
        STAIRS("stairs"),
        PRESSURE_PLATE("pressure_plate"),
        POLISHED("polished"),
        TRAPDOOR("trapdoor"),
        WALL("wall"),
        WALL_SIGN("wall_sign"),
        BRICKS("bricks"),
        COBBLED("cobbled"),
        TILES("tiles");
 
        private final String recipeGroup;
 
        private Variant(String recipeGroup) {
            this.recipeGroup = recipeGroup;
        }
 
        public String getRecipeGroup() {
            return this.recipeGroup;
        }
    }
}

引用的其他类

  • StringUtil

    • 引用位置: 方法调用
    • 关联成员: StringUtil.isBlank()
  • Block

    • 引用位置: 参数/字段/返回值