File size: 6,163 Bytes
d46f4a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
package net.minecraft.data;

import com.google.common.collect.Maps;
import java.util.Map;
import java.util.Optional;
import javax.annotation.Nullable;
import net.minecraft.util.StringUtil;
import net.minecraft.world.level.block.Block;

public class BlockFamily {
    private final Block baseBlock;
    final Map<BlockFamily.Variant, Block> variants = Maps.newHashMap();
    boolean generateModel = true;
    boolean generateRecipe = true;
    @Nullable
    String recipeGroupPrefix;
    @Nullable
    String recipeUnlockedBy;

    BlockFamily(Block p_175950_) {
        this.baseBlock = p_175950_;
    }

    public Block getBaseBlock() {
        return this.baseBlock;
    }

    public Map<BlockFamily.Variant, Block> getVariants() {
        return this.variants;
    }

    public Block get(BlockFamily.Variant p_175953_) {
        return this.variants.get(p_175953_);
    }

    public boolean shouldGenerateModel() {
        return this.generateModel;
    }

    public boolean shouldGenerateRecipe() {
        return this.generateRecipe;
    }

    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 p_175961_) {
            this.family = new BlockFamily(p_175961_);
        }

        public BlockFamily getFamily() {
            return this.family;
        }

        public BlockFamily.Builder button(Block p_175964_) {
            this.family.variants.put(BlockFamily.Variant.BUTTON, p_175964_);
            return this;
        }

        public BlockFamily.Builder chiseled(Block p_175972_) {
            this.family.variants.put(BlockFamily.Variant.CHISELED, p_175972_);
            return this;
        }

        public BlockFamily.Builder mosaic(Block p_251947_) {
            this.family.variants.put(BlockFamily.Variant.MOSAIC, p_251947_);
            return this;
        }

        public BlockFamily.Builder cracked(Block p_175977_) {
            this.family.variants.put(BlockFamily.Variant.CRACKED, p_175977_);
            return this;
        }

        public BlockFamily.Builder cut(Block p_175979_) {
            this.family.variants.put(BlockFamily.Variant.CUT, p_175979_);
            return this;
        }

        public BlockFamily.Builder door(Block p_175981_) {
            this.family.variants.put(BlockFamily.Variant.DOOR, p_175981_);
            return this;
        }

        public BlockFamily.Builder customFence(Block p_248790_) {
            this.family.variants.put(BlockFamily.Variant.CUSTOM_FENCE, p_248790_);
            return this;
        }

        public BlockFamily.Builder fence(Block p_175983_) {
            this.family.variants.put(BlockFamily.Variant.FENCE, p_175983_);
            return this;
        }

        public BlockFamily.Builder customFenceGate(Block p_251301_) {
            this.family.variants.put(BlockFamily.Variant.CUSTOM_FENCE_GATE, p_251301_);
            return this;
        }

        public BlockFamily.Builder fenceGate(Block p_175985_) {
            this.family.variants.put(BlockFamily.Variant.FENCE_GATE, p_175985_);
            return this;
        }

        public BlockFamily.Builder sign(Block p_175966_, Block p_175967_) {
            this.family.variants.put(BlockFamily.Variant.SIGN, p_175966_);
            this.family.variants.put(BlockFamily.Variant.WALL_SIGN, p_175967_);
            return this;
        }

        public BlockFamily.Builder slab(Block p_175987_) {
            this.family.variants.put(BlockFamily.Variant.SLAB, p_175987_);
            return this;
        }

        public BlockFamily.Builder stairs(Block p_175989_) {
            this.family.variants.put(BlockFamily.Variant.STAIRS, p_175989_);
            return this;
        }

        public BlockFamily.Builder pressurePlate(Block p_175991_) {
            this.family.variants.put(BlockFamily.Variant.PRESSURE_PLATE, p_175991_);
            return this;
        }

        public BlockFamily.Builder polished(Block p_175993_) {
            this.family.variants.put(BlockFamily.Variant.POLISHED, p_175993_);
            return this;
        }

        public BlockFamily.Builder trapdoor(Block p_175995_) {
            this.family.variants.put(BlockFamily.Variant.TRAPDOOR, p_175995_);
            return this;
        }

        public BlockFamily.Builder wall(Block p_175997_) {
            this.family.variants.put(BlockFamily.Variant.WALL, p_175997_);
            return this;
        }

        public BlockFamily.Builder dontGenerateModel() {
            this.family.generateModel = false;
            return this;
        }

        public BlockFamily.Builder dontGenerateRecipe() {
            this.family.generateRecipe = false;
            return this;
        }

        public BlockFamily.Builder recipeGroupPrefix(String p_175969_) {
            this.family.recipeGroupPrefix = p_175969_;
            return this;
        }

        public BlockFamily.Builder recipeUnlockedBy(String p_175974_) {
            this.family.recipeUnlockedBy = p_175974_;
            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");

        private final String recipeGroup;

        private Variant(final String p_176019_) {
            this.recipeGroup = p_176019_;
        }

        public String getRecipeGroup() {
            return this.recipeGroup;
        }
    }
}