-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathMetaBlocks.java
More file actions
510 lines (448 loc) · 24.4 KB
/
Copy pathMetaBlocks.java
File metadata and controls
510 lines (448 loc) · 24.4 KB
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
package gregtech.common.blocks;
import com.google.common.collect.ImmutableMap;
import gnu.trove.map.TIntObjectMap;
import gregtech.api.GTValues;
import gregtech.api.GregTechAPI;
import gregtech.api.block.machines.BlockMachine;
import gregtech.api.metatileentity.MetaTileEntityHolder;
import gregtech.api.render.MetaTileEntityRenderer;
import gregtech.api.render.MetaTileEntityTESR;
import gregtech.api.unification.OreDictUnifier;
import gregtech.api.unification.material.MarkerMaterials;
import gregtech.api.unification.material.Materials;
import gregtech.api.unification.material.type.DustMaterial;
import gregtech.api.unification.material.type.DustMaterial.MatFlags;
import gregtech.api.unification.material.type.IngotMaterial;
import gregtech.api.unification.material.type.Material;
import gregtech.api.unification.material.type.SolidMaterial;
import gregtech.api.unification.ore.OrePrefix;
import gregtech.api.unification.ore.StoneType;
import gregtech.common.blocks.foam.BlockFoam;
import gregtech.common.blocks.foam.BlockPetrifiedFoam;
import gregtech.common.blocks.modelfactories.BakedModelHandler;
import gregtech.common.blocks.surfacerock.BlockSurfaceRockDeprecated;
import gregtech.common.blocks.surfacerock.BlockSurfaceRockNew;
import gregtech.common.blocks.surfacerock.TileEntitySurfaceRock;
import gregtech.common.blocks.tileentity.TileEntityCrusherBlade;
import gregtech.common.blocks.wood.BlockGregLeaves;
import gregtech.common.blocks.wood.BlockGregLog;
import gregtech.common.blocks.wood.BlockGregSapling;
import gregtech.common.pipelike.cable.BlockCable;
import gregtech.common.pipelike.cable.Insulation;
import gregtech.common.pipelike.cable.WireProperties;
import gregtech.common.pipelike.cable.tile.TileEntityCable;
import gregtech.common.pipelike.cable.tile.TileEntityCableTickable;
import gregtech.common.pipelike.fluidpipe.BlockFluidPipe;
import gregtech.common.pipelike.fluidpipe.FluidPipeProperties;
import gregtech.common.pipelike.fluidpipe.FluidPipeType;
import gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipe;
import gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipeTickable;
import gregtech.common.render.CableRenderer;
import gregtech.common.render.FluidPipeRenderer;
import gregtech.common.render.tesr.TileEntityCrusherBladeRenderer;
import gregtech.common.render.tesr.TileEntityRendererBase.TileEntityRenderBaseItem;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLog.EnumAxis;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.DefaultStateMapper;
import net.minecraft.client.renderer.block.statemap.IStateMapper;
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fluids.BlockFluidBase;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.ArrayUtils;
import java.util.*;
import java.util.Map.Entry;
import java.util.function.BiConsumer;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import static gregtech.api.unification.material.type.SolidMaterial.MatFlags.GENERATE_FRAME;
import static gregtech.common.ClientProxy.*;
public class MetaBlocks {
private MetaBlocks() {
}
public static BlockMachine MACHINE;
public static BlockCable CABLE;
public static BlockFluidPipe FLUID_PIPE;
public static BlockBoilerCasing BOILER_CASING;
public static BlockFireboxCasing BOILER_FIREBOX_CASING;
public static BlockMetalCasing METAL_CASING;
public static BlockTurbineCasing TURBINE_CASING;
public static BlockMachineCasing MACHINE_CASING;
public static BlockMultiblockCasing MUTLIBLOCK_CASING;
public static BlockWireCoil WIRE_COIL;
public static BlockWarningSign WARNING_SIGN;
public static BlockGranite GRANITE;
public static BlockMineral MINERAL;
public static BlockConcrete CONCRETE;
public static BlockFoam FOAM;
public static BlockFoam REINFORCED_FOAM;
public static BlockPetrifiedFoam PETRIFIED_FOAM;
public static BlockPetrifiedFoam REINFORCED_PETRIFIED_FOAM;
public static BlockGregLog LOG;
public static BlockGregLeaves LEAVES;
public static BlockGregSapling SAPLING;
public static BlockCrusherBlade CRUSHER_BLADE;
public static Map<DustMaterial, BlockCompressed> COMPRESSED = new HashMap<>();
public static Map<IngotMaterial, BlockSurfaceRockDeprecated> SURFACE_ROCKS = new HashMap<>();
public static BlockSurfaceRockNew SURFACE_ROCK_NEW;
public static Map<SolidMaterial, BlockFrame> FRAMES = new HashMap<>();
public static Collection<BlockOre> ORES = new HashSet<>();
public static Collection<BlockFluidBase> FLUID_BLOCKS = new HashSet<>();
public static void init() {
GregTechAPI.MACHINE = MACHINE = new BlockMachine();
MACHINE.setRegistryName("machine");
CABLE = new BlockCable();
CABLE.setRegistryName("cable");
FLUID_PIPE = new BlockFluidPipe();
FLUID_PIPE.setRegistryName("fluid_pipe");
BOILER_CASING = new BlockBoilerCasing();
BOILER_CASING.setRegistryName("boiler_casing");
BOILER_FIREBOX_CASING = new BlockFireboxCasing();
BOILER_FIREBOX_CASING.setRegistryName("boiler_firebox_casing");
METAL_CASING = new BlockMetalCasing();
METAL_CASING.setRegistryName("metal_casing");
TURBINE_CASING = new BlockTurbineCasing();
TURBINE_CASING.setRegistryName("turbine_casing");
MACHINE_CASING = new BlockMachineCasing();
MACHINE_CASING.setRegistryName("machine_casing");
MUTLIBLOCK_CASING = new BlockMultiblockCasing();
MUTLIBLOCK_CASING.setRegistryName("multiblock_casing");
WIRE_COIL = new BlockWireCoil();
WIRE_COIL.setRegistryName("wire_coil");
WARNING_SIGN = new BlockWarningSign();
WARNING_SIGN.setRegistryName("warning_sign");
GRANITE = new BlockGranite();
GRANITE.setRegistryName("granite");
MINERAL = new BlockMineral();
MINERAL.setRegistryName("mineral");
CONCRETE = new BlockConcrete();
CONCRETE.setRegistryName("concrete");
FOAM = new BlockFoam(false);
FOAM.setRegistryName("foam");
REINFORCED_FOAM = new BlockFoam(true);
REINFORCED_FOAM.setRegistryName("reinforced_foam");
PETRIFIED_FOAM = new BlockPetrifiedFoam(false);
PETRIFIED_FOAM.setRegistryName("petrified_foam");
REINFORCED_PETRIFIED_FOAM = new BlockPetrifiedFoam(true);
REINFORCED_PETRIFIED_FOAM.setRegistryName("reinforced_petrified_foam");
LOG = new BlockGregLog();
LOG.setRegistryName("log");
LEAVES = new BlockGregLeaves();
LEAVES.setRegistryName("leaves");
SAPLING = new BlockGregSapling();
SAPLING.setRegistryName("sapling");
CRUSHER_BLADE = new BlockCrusherBlade();
CRUSHER_BLADE.setRegistryName("crusher_blade");
SURFACE_ROCK_NEW = new BlockSurfaceRockNew();
SURFACE_ROCK_NEW.setRegistryName("surface_rock_new");
StoneType.init();
createGeneratedBlock(
material -> material instanceof DustMaterial && !OrePrefix.block.isIgnored(material),
MetaBlocks::createCompressedBlock);
createGeneratedBlock(
material -> material instanceof IngotMaterial && material.hasFlag(MatFlags.GENERATE_ORE),
MetaBlocks::createSurfaceRockBlock);
for (Material material : Material.MATERIAL_REGISTRY) {
if (material instanceof DustMaterial &&
material.hasFlag(DustMaterial.MatFlags.GENERATE_ORE)) {
createOreBlock((DustMaterial) material);
}
if (material instanceof SolidMaterial && material.hasFlag(GENERATE_FRAME)) {
BlockFrame blockFrame = new BlockFrame((SolidMaterial) material);
blockFrame.setRegistryName("frame_" + material.toString());
FRAMES.put((SolidMaterial) material, blockFrame);
}
if (material instanceof IngotMaterial) {
IngotMaterial metalMaterial = (IngotMaterial) material;
if (metalMaterial.cableProperties != null) {
CABLE.addCableMaterial(metalMaterial, metalMaterial.cableProperties);
}
if (metalMaterial.fluidPipeProperties != null) {
FLUID_PIPE.addPipeMaterial(metalMaterial, metalMaterial.fluidPipeProperties);
}
}
}
FLUID_PIPE.addPipeMaterial(Materials.Wood, new FluidPipeProperties(310, 20, false));
CABLE.addCableMaterial(MarkerMaterials.Tier.Superconductor, new WireProperties(Integer.MAX_VALUE, 4, 0));
registerTileEntity();
//not sure if that's a good place for that, but i don't want to make a dedicated method for that
//could possibly override block methods, but since these props don't depend on state why not just use nice and simple vanilla method
Blocks.FIRE.setFireInfo(LOG, 5, 5);
Blocks.FIRE.setFireInfo(LEAVES, 30, 60);
}
/**
* Deterministically populates a category of MetaBlocks based on the unique registry ID of each qualifying Material.
*
* @param materialPredicate a filter for determining if a Material qualifies for generation in the category.
* @param blockGenerator a function which accepts a Materials set to pack into a MetaBlock, and the ordinal this
* MetaBlock should have within its category.
*/
protected static void createGeneratedBlock(Predicate<Material> materialPredicate,
BiConsumer<Material[], Integer> blockGenerator) {
Map<Integer, Material[]> blocksToGenerate = new TreeMap<>();
for(Material material : Material.MATERIAL_REGISTRY)
if(materialPredicate.test(material)) {
int id = Material.MATERIAL_REGISTRY.getIDForObject(material);
int metaBlockID = id / 16;
int subBlockID = id % 16;
if (!blocksToGenerate.containsKey(metaBlockID)) {
Material[] materials = new Material[16];
Arrays.fill(materials, Materials._NULL);
blocksToGenerate.put(metaBlockID, materials);
}
blocksToGenerate.get(metaBlockID)[subBlockID] = material;
}
blocksToGenerate.forEach((key, value) -> blockGenerator.accept(value, key));
}
private static void createSurfaceRockBlock(Material[] materials, int index) {
BlockSurfaceRockDeprecated block = new BlockSurfaceRockDeprecated(materials);
block.setRegistryName("meta_block_surface_rock_" + index);
for (Material material : materials) {
if (material instanceof IngotMaterial) {
SURFACE_ROCKS.put((IngotMaterial) material, block);
}
}
}
private static void createCompressedBlock(Material[] materials, int index) {
BlockCompressed block = new BlockCompressed(materials);
block.setRegistryName("meta_block_compressed_" + index);
for (Material material : materials) {
if (material instanceof DustMaterial) {
COMPRESSED.put((DustMaterial) material, block);
}
}
}
private static void createOreBlock(DustMaterial material) {
StoneType[] stoneTypeBuffer = new StoneType[16];
int generationIndex = 0;
for (StoneType stoneType : StoneType.STONE_TYPE_REGISTRY) {
int id = StoneType.STONE_TYPE_REGISTRY.getIDForObject(stoneType), index = id / 16;
if (index > generationIndex) {
createOreBlock(material, copyNotNull(stoneTypeBuffer), generationIndex);
Arrays.fill(stoneTypeBuffer, null);
}
stoneTypeBuffer[id % 16] = stoneType;
generationIndex = index;
}
createOreBlock(material, copyNotNull(stoneTypeBuffer), generationIndex);
}
private static <T> T[] copyNotNull(T[] src) {
int nullIndex = ArrayUtils.indexOf(src, null);
return Arrays.copyOfRange(src, 0, nullIndex == -1 ? src.length : nullIndex);
}
private static void createOreBlock(DustMaterial material, StoneType[] stoneTypes, int index) {
BlockOre block = new BlockOre(material, stoneTypes);
block.setRegistryName("ore_" + material + "_" + index);
for (StoneType stoneType : stoneTypes) {
GregTechAPI.oreBlockTable.computeIfAbsent(material, m -> new HashMap<>()).put(stoneType, block);
}
ORES.add(block);
}
public static void registerTileEntity() {
GameRegistry.registerTileEntity(MetaTileEntityHolder.class, new ResourceLocation(GTValues.MODID, "machine"));
GameRegistry.registerTileEntity(TileEntityCrusherBlade.class, new ResourceLocation(GTValues.MODID, "crusher_blade"));
GameRegistry.registerTileEntity(TileEntityCable.class, new ResourceLocation(GTValues.MODID, "cable"));
GameRegistry.registerTileEntity(TileEntityCableTickable.class, new ResourceLocation(GTValues.MODID, "cable_tickable"));
GameRegistry.registerTileEntity(TileEntityFluidPipe.class, new ResourceLocation(GTValues.MODID, "fluid_pipe"));
GameRegistry.registerTileEntity(TileEntityFluidPipeTickable.class, new ResourceLocation(GTValues.MODID, "fluid_pipe_active"));
GameRegistry.registerTileEntity(TileEntitySurfaceRock.class, new ResourceLocation(GTValues.MODID, "surface_rock"));
}
@SideOnly(Side.CLIENT)
public static void registerItemModels() {
ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(MACHINE), stack -> MetaTileEntityRenderer.MODEL_LOCATION);
ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(CABLE), stack -> CableRenderer.MODEL_LOCATION);
ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(FLUID_PIPE), stack -> FluidPipeRenderer.MODEL_LOCATION);
registerItemModel(BOILER_CASING);
registerItemModel(BOILER_FIREBOX_CASING);
registerItemModel(METAL_CASING);
registerItemModel(TURBINE_CASING);
registerItemModel(MACHINE_CASING);
registerItemModel(MUTLIBLOCK_CASING);
registerItemModel(WIRE_COIL);
registerItemModel(WARNING_SIGN);
registerItemModel(GRANITE);
registerItemModel(MINERAL);
registerItemModel(CONCRETE);
registerItemModelWithOverride(LOG, ImmutableMap.of(BlockGregLog.LOG_AXIS, EnumAxis.Y));
registerItemModel(LEAVES);
ModelBakery.registerItemVariants(Item.getItemFromBlock(SAPLING), new ResourceLocation(GTValues.MODID, "sapling_rubber"));
ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(SAPLING), stack -> new ModelResourceLocation(new ResourceLocation(GTValues.MODID, "sapling_rubber"), "inventory"));
COMPRESSED.values().stream().distinct().forEach(MetaBlocks::registerItemModel);
FRAMES.values().forEach(it -> registerItemModelWithFilteredProperties(it));
ORES.stream().distinct().forEach(MetaBlocks::registerItemModel);
}
@SideOnly(Side.CLIENT)
private static void registerItemModel(Block block) {
for (IBlockState state : block.getBlockState().getValidStates()) {
//noinspection ConstantConditions
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block),
block.getMetaFromState(state),
new ModelResourceLocation(block.getRegistryName(),
statePropertiesToString(state.getProperties())));
}
}
@SideOnly(Side.CLIENT)
private static void registerItemModelWithFilteredProperties(Block block, IProperty<?>... filteredProperties) {
for (IBlockState state : block.getBlockState().getValidStates()) {
HashMap<IProperty<?>, Comparable<?>> stringProperties = new HashMap<>();
for (IProperty<?> property : filteredProperties) {
stringProperties.put(property, state.getValue(property));
}
//noinspection ConstantConditions
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block),
block.getMetaFromState(state),
new ModelResourceLocation(block.getRegistryName(),
statePropertiesToString(stringProperties)));
}
}
@SideOnly(Side.CLIENT)
private static void registerItemModelWithOverride(Block block, Map<IProperty<?>, Comparable<?>> stateOverrides) {
for (IBlockState state : block.getBlockState().getValidStates()) {
HashMap<IProperty<?>, Comparable<?>> stringProperties = new HashMap<>(state.getProperties());
stringProperties.putAll(stateOverrides);
//noinspection ConstantConditions
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block),
block.getMetaFromState(state),
new ModelResourceLocation(block.getRegistryName(),
statePropertiesToString(stringProperties)));
}
}
@SideOnly(Side.CLIENT)
public static void registerStateMappers() {
ModelLoader.setCustomStateMapper(MACHINE, new DefaultStateMapper() {
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
return MetaTileEntityRenderer.MODEL_LOCATION;
}
});
ModelLoader.setCustomStateMapper(CABLE, new DefaultStateMapper() {
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
return CableRenderer.MODEL_LOCATION;
}
});
ModelLoader.setCustomStateMapper(FLUID_PIPE, new DefaultStateMapper() {
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
return FluidPipeRenderer.MODEL_LOCATION;
}
});
IStateMapper normalStateMapper = new StateMapperBase() {
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
return new ModelResourceLocation(Block.REGISTRY.getNameForObject(state.getBlock()), "normal");
}
};
ModelLoader.setCustomStateMapper(FOAM, normalStateMapper);
ModelLoader.setCustomStateMapper(REINFORCED_FOAM, normalStateMapper);
ModelLoader.setCustomStateMapper(PETRIFIED_FOAM, normalStateMapper);
ModelLoader.setCustomStateMapper(REINFORCED_PETRIFIED_FOAM, normalStateMapper);
FRAMES.values().forEach(it -> ModelLoader.setCustomStateMapper(it, normalStateMapper));
BakedModelHandler modelHandler = new BakedModelHandler();
MinecraftForge.EVENT_BUS.register(modelHandler);
FLUID_BLOCKS.forEach(modelHandler::addFluidBlock);
SURFACE_ROCKS.values().stream().distinct().forEach(block -> modelHandler.addBuiltInBlock(block, "stone"));
modelHandler.addBuiltInBlock(SURFACE_ROCK_NEW, "stone_andesite");
modelHandler.addBuiltInBlock(CRUSHER_BLADE, "iron_block");
Item.getItemFromBlock(CRUSHER_BLADE).setTileEntityItemStackRenderer(new TileEntityRenderBaseItem<>(TileEntityCrusherBlade.class));
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCrusherBlade.class, new TileEntityCrusherBladeRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(MetaTileEntityHolder.class, new MetaTileEntityTESR());
}
@SideOnly(Side.CLIENT)
public static void registerColors() {
Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(
FOAM_BLOCK_COLOR, FOAM, REINFORCED_FOAM, PETRIFIED_FOAM, REINFORCED_PETRIFIED_FOAM);
MetaBlocks.COMPRESSED.values().stream().distinct().forEach(block -> {
Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(COMPRESSED_BLOCK_COLOR, block);
Minecraft.getMinecraft().getItemColors().registerItemColorHandler(COMPRESSED_ITEM_COLOR, block);
});
MetaBlocks.FRAMES.values().forEach(block -> {
Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(FRAME_BLOCK_COLOR, block);
Minecraft.getMinecraft().getItemColors().registerItemColorHandler(FRAME_ITEM_COLOR, block);
});
MetaBlocks.ORES.stream().distinct().forEach(block -> {
Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(ORE_BLOCK_COLOR, block);
Minecraft.getMinecraft().getItemColors().registerItemColorHandler(ORE_ITEM_COLOR, block);
});
MetaBlocks.SURFACE_ROCKS.values().stream().distinct().forEach(block ->
Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(SURFACE_ROCK_COLOR, block));
}
public static void registerOreDict() {
OreDictUnifier.registerOre(new ItemStack(LOG, 1, GTValues.W), OrePrefix.log, Materials.Wood);
OreDictUnifier.registerOre(new ItemStack(LEAVES, 1, GTValues.W), "treeLeaves");
OreDictUnifier.registerOre(new ItemStack(SAPLING, 1, GTValues.W), "treeSapling");
GameRegistry.addSmelting(LOG, new ItemStack(Items.COAL, 1, 1), 0.15F);
for (Entry<DustMaterial, BlockCompressed> entry : COMPRESSED.entrySet()) {
DustMaterial material = entry.getKey();
BlockCompressed block = entry.getValue();
ItemStack itemStack = block.getItem(material);
OreDictUnifier.registerOre(itemStack, OrePrefix.block, material);
}
for (Entry<SolidMaterial, BlockFrame> entry : FRAMES.entrySet()) {
SolidMaterial material = entry.getKey();
BlockFrame block = entry.getValue();
for (int i = 0; i < 16; i++) {
ItemStack itemStack = new ItemStack(block, 1, i);
OreDictUnifier.registerOre(itemStack, OrePrefix.frameGt, material);
}
}
for (BlockOre blockOre : ORES) {
DustMaterial material = blockOre.material;
for (StoneType stoneType : blockOre.STONE_TYPE.getAllowedValues()) {
if (stoneType == null) continue;
ItemStack normalStack = blockOre.getItem(blockOre.getDefaultState()
.withProperty(blockOre.STONE_TYPE, stoneType));
OreDictUnifier.registerOre(normalStack, stoneType.processingPrefix, material);
}
}
for (Material pipeMaterial : CABLE.getEnabledMaterials()) {
for (Insulation insulation : Insulation.values()) {
ItemStack itemStack = CABLE.getItem(insulation, pipeMaterial);
OreDictUnifier.registerOre(itemStack, insulation.getOrePrefix(), pipeMaterial);
}
}
for (Material pipeMaterial : FLUID_PIPE.getEnabledMaterials()) {
for (FluidPipeType fluidPipeType : FluidPipeType.values()) {
ItemStack itemStack = FLUID_PIPE.getItem(fluidPipeType, pipeMaterial);
OreDictUnifier.registerOre(itemStack, fluidPipeType.getOrePrefix(), pipeMaterial);
}
}
}
private static String statePropertiesToString(Map<IProperty<?>, Comparable<?>> properties) {
StringBuilder stringbuilder = new StringBuilder();
List<Entry<IProperty<?>, Comparable<?>>> entries = properties.entrySet().stream()
.sorted(Comparator.comparing(c -> c.getKey().getName()))
.collect(Collectors.toList());
for (Map.Entry<IProperty<?>, Comparable<?>> entry : entries) {
if (stringbuilder.length() != 0) {
stringbuilder.append(",");
}
IProperty<?> property = entry.getKey();
stringbuilder.append(property.getName());
stringbuilder.append("=");
stringbuilder.append(getPropertyName(property, entry.getValue()));
}
if (stringbuilder.length() == 0) {
stringbuilder.append("normal");
}
return stringbuilder.toString();
}
@SuppressWarnings("unchecked")
private static <T extends Comparable<T>> String getPropertyName(IProperty<T> property, Comparable<?> value) {
return property.getName((T) value);
}
}