Skip to content

Commit

Permalink
add condition for blockItem registering
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasPlacentino committed Feb 3, 2023
1 parent 2b68c5c commit fc0bd5c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/obsilab/mcsc/MCSC.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,15 @@ private void addCreative(CreativeModeTabEvent.BuildContents event) {
event.accept(new ItemStack(mod_item.get()));
}
for (RegistryObject<Block> mod_block : ModBlocksList) {
//check if the block is a crop block => needed? since did not register blockItem for crop blocks
/*
if (mod_block.get() instanceof CrystalIngotBlock) { // if(mod_block.get().getName().equals("crystal_ingot"))
//continue; // remove crop block, prevents crashing
} else {
event.accept(new ItemStack(mod_block.get()));
}
*/
event.accept(new ItemStack(mod_block.get())); // all from the list
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/obsilab/mcsc/block/ModBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ public class ModBlocks {
DeferredRegister.create(ForgeRegistries.BLOCKS, MCSC.MOD_ID);


public static final RegistryObject<Block> FOUP_STORAGE_BLOCK = registerBlock(true,
"foup_storage",
() -> new Block(BlockBehaviour.Properties
.of(Material.METAL)
.strength(6f)
.requiresCorrectToolForDrops()
));

public static final RegistryObject<Block> BORAX_ORE = registerBlock(true, // => boric acid => boron for p-type doping
"borax_ore",
() -> new DropExperienceBlock(BlockBehaviour.Properties
.of(Material.STONE)
Expand All @@ -46,6 +48,7 @@ public class ModBlocks {
));


public static final RegistryObject<Block> PHOSPHATE_ORE = registerBlock(true,
"phosphate_ore",
() -> new DropExperienceBlock(BlockBehaviour.Properties
.of(Material.STONE)
Expand All @@ -54,20 +57,23 @@ public class ModBlocks {
UniformInt.of(2,4)
));

public static final RegistryObject<Block> TEST_BLOCK_BLOCK = registerBlock(true,
"test_block",
() -> new TestBlock(BlockBehaviour.Properties
.of(Material.METAL)
.strength(6f)
.lightLevel(state -> state.getValue(TestBlock.ACTIVE) ? 8 : 0) // light level of 8 if block's ACTIVE property is true, else light level of 0
));

public static final RegistryObject<LiquidBlock> TEST_FLUID_BLOCK = registerBlock(true,
"test_fluid_block",
() -> new LiquidBlock(
ModFluids.SOURCE_TEST_FLUID,
BlockBehaviour.Properties
.copy(Blocks.WATER)
));

public static final RegistryObject<Block> CRYSTAL_INGOT_BLOCK = registerBlock(false, // crop block, so do not register BlockItem
"crystal_ingot",
() -> new CrystalIngotBlock(BlockBehaviour.Properties
.copy(Blocks.WHEAT)
Expand All @@ -78,8 +84,12 @@ public class ModBlocks {



private static <T extends Block> RegistryObject<T> registerBlock(Boolean register_block_item, String name, Supplier<T> block){
LOGGER.info("MCSC: Registering Block >> {} : {}", name, block.get()); //? .get() ?
RegistryObject<T> toReturn = BLOCKS.register(name, block);
if (register_block_item) {
registerBlockItem(name, toReturn);
}
return toReturn;
}

Expand Down

0 comments on commit fc0bd5c

Please # to comment.