Skip to content

Commit cd54599

Browse files
committed
settings factories for block/item registries
1 parent 1cd01a0 commit cd54599

File tree

3 files changed

+168
-200
lines changed

3 files changed

+168
-200
lines changed

src/main/java/com/github/thedeathlycow/frostiful/registry/FBlocks.java

+71-53
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
import net.minecraft.registry.Registry;
1212
import net.minecraft.sound.BlockSoundGroup;
1313

14+
import java.util.function.Function;
15+
1416
public class FBlocks {
1517

1618
public static final Block ICICLE = register(
1719
"icicle",
18-
new IcicleBlock(
19-
AbstractBlock.Settings.create()
20+
settings -> new IcicleBlock(
21+
settings
2022
.mapColor(MapColor.CYAN)
2123
.nonOpaque()
2224
.sounds(BlockSoundGroup.GLASS)
@@ -31,9 +33,9 @@ public class FBlocks {
3133

3234
public static final Block COLD_SUN_LICHEN = register(
3335
"cold_sun_lichen",
34-
new SunLichenBlock(
36+
settings -> new SunLichenBlock(
3537
SunLichenBlock.COLD_LEVEL,
36-
AbstractBlock.Settings.create()
38+
settings
3739
.replaceable()
3840
.mapColor(MapColor.RED)
3941
.pistonBehavior(PistonBehavior.DESTROY)
@@ -47,9 +49,9 @@ public class FBlocks {
4749
);
4850
public static final Block COOL_SUN_LICHEN = register(
4951
"cool_sun_lichen",
50-
new SunLichenBlock(
52+
settings -> new SunLichenBlock(
5153
SunLichenBlock.COOL_LEVEL,
52-
AbstractBlock.Settings.create()
54+
settings
5355
.replaceable()
5456
.mapColor(MapColor.RED)
5557
.pistonBehavior(PistonBehavior.DESTROY)
@@ -63,9 +65,9 @@ public class FBlocks {
6365
);
6466
public static final Block WARM_SUN_LICHEN = register(
6567
"warm_sun_lichen",
66-
new SunLichenBlock(
68+
settings -> new SunLichenBlock(
6769
SunLichenBlock.WARM_LEVEL,
68-
AbstractBlock.Settings.create()
70+
settings
6971
.replaceable()
7072
.mapColor(MapColor.RED)
7173
.pistonBehavior(PistonBehavior.DESTROY)
@@ -79,9 +81,9 @@ public class FBlocks {
7981
);
8082
public static final Block HOT_SUN_LICHEN = register(
8183
"hot_sun_lichen",
82-
new SunLichenBlock(
84+
settings -> new SunLichenBlock(
8385
SunLichenBlock.HOT_LEVEL,
84-
AbstractBlock.Settings.create()
86+
settings
8587
.replaceable()
8688
.mapColor(MapColor.RED)
8789
.pistonBehavior(PistonBehavior.DESTROY)
@@ -96,8 +98,8 @@ public class FBlocks {
9698

9799
public static final Block FROZEN_TORCH = register(
98100
"frozen_torch",
99-
new FrozenTorchBlock(
100-
AbstractBlock.Settings.create()
101+
settings -> new FrozenTorchBlock(
102+
settings
101103
.noCollision()
102104
.breakInstantly()
103105
.pistonBehavior(PistonBehavior.DESTROY)
@@ -107,16 +109,17 @@ public class FBlocks {
107109

108110
public static final Block FROZEN_WALL_TORCH = register(
109111
"frozen_wall_torch",
110-
new FrozenWallTorchBlock(
111-
AbstractBlock.Settings.copy(FROZEN_TORCH)
112+
settings -> new FrozenWallTorchBlock(
113+
settings
112114
.dropsLike(FROZEN_TORCH)
113-
)
115+
),
116+
AbstractBlock.Settings.copy(FROZEN_TORCH)
114117
);
115118

116119
public static final Block PACKED_SNOW = register(
117120
"packed_snow",
118-
new PackedSnowBlock(
119-
AbstractBlock.Settings.create()
121+
settings -> new PackedSnowBlock(
122+
settings
120123
.mapColor(MapColor.WHITE)
121124
.replaceable()
122125
.notSolid()
@@ -133,8 +136,8 @@ public class FBlocks {
133136

134137
public static final Block PACKED_SNOW_BLOCK = register(
135138
"packed_snow_block",
136-
new Block(
137-
AbstractBlock.Settings.create()
139+
settings -> new Block(
140+
settings
138141
.mapColor(MapColor.WHITE_GRAY)
139142
.requiresTool()
140143
.strength(1.5f, 6.0f)
@@ -144,8 +147,8 @@ public class FBlocks {
144147

145148
public static final Block PACKED_SNOW_BRICKS = register(
146149
"packed_snow_bricks",
147-
new Block(
148-
AbstractBlock.Settings.create()
150+
settings -> new Block(
151+
settings
149152
.mapColor(MapColor.WHITE_GRAY)
150153
.requiresTool()
151154
.strength(1.5f, 6.0f)
@@ -155,26 +158,29 @@ public class FBlocks {
155158

156159
public static final Block PACKED_SNOW_BRICK_STAIRS = register(
157160
"packed_snow_brick_stairs",
158-
new StairsBlock(
161+
settings -> new StairsBlock(
159162
PACKED_SNOW_BRICKS.getDefaultState(),
160-
AbstractBlock.Settings.copy(PACKED_SNOW_BRICKS)
161-
)
163+
settings
164+
),
165+
AbstractBlock.Settings.copy(PACKED_SNOW_BRICKS)
162166
);
163167

164168
public static final Block PACKED_SNOW_BRICK_SLAB = register(
165169
"packed_snow_brick_slab",
166-
new SlabBlock(AbstractBlock.Settings.copy(PACKED_SNOW_BRICKS))
170+
settings -> new SlabBlock(settings),
171+
AbstractBlock.Settings.copy(PACKED_SNOW_BRICKS)
167172
);
168173

169174
public static final Block PACKED_SNOW_BRICK_WALL = register(
170175
"packed_snow_brick_wall",
171-
new WallBlock(AbstractBlock.Settings.copy(PACKED_SNOW_BRICKS))
176+
settings -> new WallBlock(settings),
177+
AbstractBlock.Settings.copy(PACKED_SNOW_BRICKS)
172178
);
173179

174180
public static final Block ICE_PANE = register(
175181
"ice_pane",
176-
new IcePaneBlock(
177-
AbstractBlock.Settings.create()
182+
settings -> new IcePaneBlock(
183+
settings
178184
.mapColor(MapColor.PALE_PURPLE)
179185
.strength(0.5f)
180186
.ticksRandomly()
@@ -187,8 +193,8 @@ public class FBlocks {
187193

188194
public static final Block CUT_PACKED_ICE = register(
189195
"cut_packed_ice",
190-
new Block(
191-
AbstractBlock.Settings.create()
196+
settings -> new Block(
197+
settings
192198
.mapColor(MapColor.PALE_PURPLE)
193199
.instrument(NoteBlockInstrument.CHIME)
194200
.slipperiness(0.98f)
@@ -200,55 +206,62 @@ public class FBlocks {
200206

201207
public static final Block CUT_PACKED_ICE_STAIRS = register(
202208
"cut_packed_ice_stairs",
203-
new StairsBlock(
209+
settings -> new StairsBlock(
204210
CUT_PACKED_ICE.getDefaultState(),
205-
AbstractBlock.Settings.copy(CUT_PACKED_ICE)
206-
)
211+
settings
212+
),
213+
AbstractBlock.Settings.copy(CUT_PACKED_ICE)
207214
);
208215

209216
public static final Block CUT_PACKED_ICE_SLAB = register(
210217
"cut_packed_ice_slab",
211-
new SlabBlock(AbstractBlock.Settings.copy(CUT_PACKED_ICE))
218+
settings -> new SlabBlock(settings),
219+
AbstractBlock.Settings.copy(CUT_PACKED_ICE)
212220
);
213221

214222
public static final Block CUT_PACKED_ICE_WALL = register(
215223
"cut_packed_ice_wall",
216-
new WallBlock(AbstractBlock.Settings.copy(CUT_PACKED_ICE))
224+
settings -> new WallBlock(settings),
225+
AbstractBlock.Settings.copy(CUT_PACKED_ICE)
217226
);
218227

219228
public static final Block CUT_BLUE_ICE = register(
220229
"cut_blue_ice",
221-
new Block(AbstractBlock.Settings.create()
222-
.mapColor(MapColor.PALE_PURPLE)
223-
.slipperiness(0.989f)
224-
.strength(2.8f)
225-
.requiresTool()
226-
.sounds(BlockSoundGroup.GLASS)
230+
settings -> new Block(
231+
settings
232+
.mapColor(MapColor.PALE_PURPLE)
233+
.slipperiness(0.989f)
234+
.strength(2.8f)
235+
.requiresTool()
236+
.sounds(BlockSoundGroup.GLASS)
227237
)
228238
);
229239

230240
public static final Block CUT_BLUE_ICE_STAIRS = register(
231241
"cut_blue_ice_stairs",
232-
new StairsBlock(
242+
settings -> new StairsBlock(
233243
CUT_BLUE_ICE.getDefaultState(),
234-
AbstractBlock.Settings.copy(CUT_BLUE_ICE)
235-
)
244+
settings
245+
),
246+
AbstractBlock.Settings.copy(CUT_BLUE_ICE)
236247
);
237248

238249
public static final Block CUT_BLUE_ICE_SLAB = register(
239250
"cut_blue_ice_slab",
240-
new SlabBlock(AbstractBlock.Settings.copy(CUT_BLUE_ICE))
251+
settings -> new SlabBlock(settings),
252+
AbstractBlock.Settings.copy(CUT_BLUE_ICE)
241253
);
242254

243255
public static final Block CUT_BLUE_ICE_WALL = register(
244256
"cut_blue_ice_wall",
245-
new WallBlock(AbstractBlock.Settings.copy(CUT_BLUE_ICE))
257+
settings -> new WallBlock(settings),
258+
AbstractBlock.Settings.copy(CUT_BLUE_ICE)
246259
);
247260

248261
public static final Block ICY_TRIAL_SPAWNER = register(
249262
"icy_trial_spawner",
250-
new TrialSpawnerBlock(
251-
AbstractBlock.Settings.create()
263+
settings -> new TrialSpawnerBlock(
264+
settings
252265
.mapColor(MapColor.DARK_AQUA)
253266
.instrument(NoteBlockInstrument.BASEDRUM)
254267
.luminance(state -> state.get(TrialSpawnerBlock.TRIAL_SPAWNER_STATE).getLuminance())
@@ -260,8 +273,8 @@ public class FBlocks {
260273
);
261274
public static final Block ICY_VAULT = register(
262275
"icy_vault",
263-
new VaultBlock(
264-
AbstractBlock.Settings.create()
276+
settings -> new VaultBlock(
277+
settings
265278
.mapColor(MapColor.DARK_AQUA)
266279
.instrument(NoteBlockInstrument.BASEDRUM)
267280
.nonOpaque()
@@ -274,8 +287,8 @@ public class FBlocks {
274287

275288
public static final Block BRITTLE_ICE = register(
276289
"brittle_ice",
277-
new BrittleIceBlock(
278-
AbstractBlock.Settings.create()
290+
settings -> new BrittleIceBlock(
291+
settings
279292
.mapColor(MapColor.PALE_PURPLE)
280293
.slipperiness(0.98f)
281294
.ticksRandomly()
@@ -295,7 +308,12 @@ public static void initialize() {
295308
BlockEntityType.VAULT.addSupportedBlock(ICY_VAULT);
296309
}
297310

298-
private static Block register(String id, Block block) {
311+
private static Block register(String id, Function<AbstractBlock.Settings, Block> blockFactory) {
312+
return register(id, blockFactory, AbstractBlock.Settings.create());
313+
}
314+
315+
private static Block register(String id, Function<AbstractBlock.Settings, Block> blockFactory, AbstractBlock.Settings settings) {
316+
Block block = blockFactory.apply(settings);
299317
return Registry.register(Registries.BLOCK, Frostiful.id(id), block);
300318
}
301319

src/main/java/com/github/thedeathlycow/frostiful/registry/FItemGroups.java

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
import net.minecraft.text.Text;
1212

1313
public class FItemGroups {
14-
15-
1614
public static final ItemGroup FROSTIFUL = Registry.register(
1715
Registries.ITEM_GROUP,
1816
Frostiful.id("main"),

0 commit comments

Comments
 (0)