diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/ActuallyBlocks.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/ActuallyBlocks.java index 3093b71f6..6a568a998 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/ActuallyBlocks.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/ActuallyBlocks.java @@ -189,8 +189,6 @@ public final class ActuallyBlocks { public static final AABlockReg HEAT_COLLECTOR = new AABlockReg<>("heat_collector", BlockHeatCollector::new, (b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityHeatCollector::new); - - // Freakin-Lasers public static final AABlockReg LASER_RELAY = new AABlockReg<>("laser_relay", () -> new BlockLaserRelay(BlockLaserRelay.Type.ENERGY_BASIC), (b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityLaserRelayEnergy::new); @@ -206,33 +204,70 @@ public final class ActuallyBlocks { (b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityLaserRelayItemAdvanced::new); - //public static final RegistryObject WILD_PLANT = BLOCKS.register("wild", BlockWildPlant::new); //TODO: what is this? - public static final RegistryObject TINY_TORCH = BLOCKS.register("tiny_torch", BlockTinyTorch::new); - public static final RegistryObject ETHETIC_GREEN_BLOCK = BLOCKS.register("ethetic_green_block", BlockGeneric::new); - public static final RegistryObject ETHETIC_WHITE_BLOCK = BLOCKS.register("ethetic_white_block", BlockGeneric::new); - public static final RegistryObject ETHETIC_GREEN_STAIRS = BLOCKS.register("ethetic_green_stairs", () -> new StairsBlock(() -> ETHETIC_GREEN_BLOCK.get().getDefaultState(), AbstractBlock.Properties.from(ETHETIC_GREEN_BLOCK.get()))); - public static final RegistryObject ETHETIC_WHITE_STAIRS = BLOCKS.register("ethetic_white_stairs", () -> new StairsBlock(() -> ETHETIC_WHITE_BLOCK.get().getDefaultState(), AbstractBlock.Properties.from(ETHETIC_WHITE_BLOCK.get()))); - public static final RegistryObject ETHETIC_GREEN_SLAB = BLOCKS.register("ethetic_green_slab", () -> new SlabBlock(AbstractBlock.Properties.from(ETHETIC_GREEN_BLOCK.get()))); - public static final RegistryObject ETHETIC_WHITE_SLAB = BLOCKS.register("ethetic_white_slab", () -> new SlabBlock(AbstractBlock.Properties.from(ETHETIC_WHITE_BLOCK.get()))); - public static final RegistryObject ETHETIC_GREEN_WALL = BLOCKS.register("ethetic_green_wall", () -> new WallBlock(AbstractBlock.Properties.from(ETHETIC_GREEN_BLOCK.get()))); - public static final RegistryObject ETHETIC_WHITE_WALL = BLOCKS.register("ethetic_white_wall", () -> new WallBlock(AbstractBlock.Properties.from(ETHETIC_WHITE_BLOCK.get()))); - public static final RegistryObject RICE = BLOCKS.register("rice", () -> new BlockPlant(ActuallyItems.RICE_SEED.get()));// TODO: [port][replace] ensure values match these new BlockPlant(1, 2)); - public static final RegistryObject CANOLA = BLOCKS.register("canola", () -> new BlockPlant(ActuallyItems.CANOLA_SEED.get()));// TODO: [port][replace] ensure values match these new BlockPlant(2, 3)); - public static final RegistryObject FLAX = BLOCKS.register("flax", () -> new BlockPlant(ActuallyItems.FLAX_SEED.get()));// TODO: [port][replace] ensure values match these new BlockPlant(2, 4)); - public static final RegistryObject COFFEE = BLOCKS.register("coffee", () -> new BlockPlant(ActuallyItems.COFFEE_SEED.get()));// TODO: [port][replace] ensure values match these new BlockPlant(2, 2)); - public static final RegistryObject GREENHOUSE_GLASS = BLOCKS.register("greenhouse_glass", BlockGreenhouseGlass::new); - public static final RegistryObject BLACK_QUARTZ_BLOCK = BLOCKS.register("black_quartz_block", BlockGeneric::new); - public static final RegistryObject BLACK_QUARTZ_PILLAR_BLOCK = BLOCKS.register("black_quartz_pillar_block", BlockGeneric::new); - public static final RegistryObject CHISELED_BLACK_QUARTZ_BLOCK = BLOCKS.register("chiseled_black_quartz_block", BlockGeneric::new); - public static final RegistryObject BLACK_QUARTZ_WALL = BLOCKS.register("black_quartz_wall", () -> new WallBlock(AbstractBlock.Properties.from(blockMisc.get()))); - public static final RegistryObject CHISELED_BLACK_QUARTZ_WALL = BLOCKS.register("chiseled_black_quartz_wall", () -> new WallBlock(AbstractBlock.Properties.from(blockMisc.get()))); - public static final RegistryObject BLACK_QUARTZ_PILLAR_WALL = BLOCKS.register("black_quartz_pillar_wall", () -> new WallBlock(AbstractBlock.Properties.from(blockMisc.get()))); - public static final RegistryObject BLACK_QUARTZ_STAIR = BLOCKS.register("black_quartz_stair", () -> new StairsBlock(() -> blockMisc.get().getDefaultState(), AbstractBlock.Properties.from(blockMisc.get()))); - public static final RegistryObject CHISELED_BLACK_QUARTZ_STAIR = BLOCKS.register("chiseled_black_quartz_stair", () -> new StairsBlock(() -> blockMisc.get().getDefaultState(), AbstractBlock.Properties.from(blockMisc.get()))); - public static final RegistryObject BLACK_QUARTZ_PILLAR_STAIR = BLOCKS.register("black_quartz_pillar_stair", () -> new StairsBlock(() -> blockMisc.get().getDefaultState(), AbstractBlock.Properties.from(blockMisc.get()))); - public static final RegistryObject BLACK_QUARTZ_SLAB = BLOCKS.register("black_quartz_slab", () -> new SlabBlock(AbstractBlock.Properties.from(blockMisc.get()))); - public static final RegistryObject CHISELED_BLACK_QUARTZ_SLAB = BLOCKS.register("chiseled_black_quartz_slab", () -> new SlabBlock(AbstractBlock.Properties.from(blockMisc.get()))); - public static final RegistryObject BLACK_QUARTZ_PILLAR_SLAB = BLOCKS.register("black_quartz_pillar_slab", () -> new SlabBlock(AbstractBlock.Properties.from(blockMisc.get()))); + + // Misc building blocks + public static final AABlockReg ETHETIC_GREEN_BLOCK = new AABlockReg<>("ethetic_green_block", () -> new ActuallyBlock(miscBlockProperties), + (b) -> new AABlockItem(b, defaultBlockItemProperties)); + public static final AABlockReg ETHETIC_WHITE_BLOCK = new AABlockReg<>("ethetic_white_block", () -> new ActuallyBlock(miscBlockProperties), + (b) -> new AABlockItem(b, defaultBlockItemProperties)); + public static final AABlockReg BLACK_QUARTZ_BLOCK = new AABlockReg<>("black_quartz_block", () -> new ActuallyBlock(miscBlockProperties), + (b) -> new AABlockItem(b, defaultBlockItemProperties)); + public static final AABlockReg BLACK_QUARTZ_PILLAR_BLOCK = new AABlockReg<>("black_quartz_pillar_block", () -> new ActuallyBlock(miscBlockProperties), + (b) -> new AABlockItem(b, defaultBlockItemProperties)); + public static final AABlockReg CHISELED_BLACK_QUARTZ_BLOCK = new AABlockReg<>("chiseled_black_quartz_block", () -> new ActuallyBlock(miscBlockProperties), + (b) -> new AABlockItem(b, defaultBlockItemProperties)); + + public static final AABlockReg ETHETIC_GREEN_STAIRS = new AABlockReg<>("ethetic_green_stairs", () -> new StairsBlock(() -> ETHETIC_GREEN_BLOCK.get().getDefaultState(), AbstractBlock.Properties.from(ETHETIC_GREEN_BLOCK.get())), + (b) -> new AABlockItem(b, defaultBlockItemProperties)); + public static final AABlockReg ETHETIC_WHITE_STAIRS = new AABlockReg<>("ethetic_white_stairs", () -> new StairsBlock(() -> ETHETIC_WHITE_BLOCK.get().getDefaultState(), AbstractBlock.Properties.from(ETHETIC_WHITE_BLOCK.get())), + (b) -> new AABlockItem(b, defaultBlockItemProperties)); + public static final AABlockReg BLACK_QUARTZ_STAIR = new AABlockReg<>("black_quartz_stair", () -> new StairsBlock(() -> BLACK_QUARTZ_BLOCK.get().getDefaultState(), AbstractBlock.Properties.from(BLACK_QUARTZ_BLOCK.get())), + (b) -> new AABlockItem(b, defaultBlockItemProperties)); + public static final AABlockReg CHISELED_BLACK_QUARTZ_STAIR = new AABlockReg<>("chiseled_black_quartz_stair", () -> new StairsBlock(() -> CHISELED_BLACK_QUARTZ_BLOCK.get().getDefaultState(), AbstractBlock.Properties.from(CHISELED_BLACK_QUARTZ_BLOCK.get())), + (b) -> new AABlockItem(b, defaultBlockItemProperties)); + public static final AABlockReg BLACK_QUARTZ_PILLAR_STAIR = new AABlockReg<>("black_quartz_pillar_stair", () -> new StairsBlock(() -> BLACK_QUARTZ_PILLAR_BLOCK.get().getDefaultState(), AbstractBlock.Properties.from(BLACK_QUARTZ_PILLAR_BLOCK.get())), + (b) -> new AABlockItem(b, defaultBlockItemProperties)); + + public static final AABlockReg ETHETIC_GREEN_WALL = new AABlockReg<>("ethetic_green_wall", () -> new WallBlock(AbstractBlock.Properties.from(ETHETIC_GREEN_BLOCK.get())), + (b) -> new AABlockItem(b, defaultBlockItemProperties)); + public static final AABlockReg ETHETIC_WHITE_WALL = new AABlockReg<>("ethetic_white_wall", () -> new WallBlock(AbstractBlock.Properties.from(ETHETIC_WHITE_BLOCK.get())), + (b) -> new AABlockItem(b, defaultBlockItemProperties)); + public static final AABlockReg BLACK_QUARTZ_WALL = new AABlockReg<>("black_quartz_wall", () -> new WallBlock(AbstractBlock.Properties.from(BLACK_QUARTZ_BLOCK.get())), + (b) -> new AABlockItem(b, defaultBlockItemProperties)); + public static final AABlockReg CHISELED_BLACK_QUARTZ_WALL = new AABlockReg<>("chiseled_black_quartz_wall", () -> new WallBlock(AbstractBlock.Properties.from(CHISELED_BLACK_QUARTZ_BLOCK.get())), + (b) -> new AABlockItem(b, defaultBlockItemProperties)); + public static final AABlockReg BLACK_QUARTZ_PILLAR_WALL = new AABlockReg<>("black_quartz_pillar_wall", () -> new WallBlock(AbstractBlock.Properties.from(BLACK_QUARTZ_PILLAR_BLOCK.get())), + (b) -> new AABlockItem(b, defaultBlockItemProperties)); + + public static final AABlockReg ETHETIC_GREEN_SLAB = new AABlockReg<>("ethetic_green_slab", () -> new SlabBlock(AbstractBlock.Properties.from(ETHETIC_GREEN_BLOCK.get())), + (b) -> new AABlockItem(b, defaultBlockItemProperties)); + public static final AABlockReg ETHETIC_WHITE_SLAB = new AABlockReg<>("ethetic_white_slab", () -> new SlabBlock(AbstractBlock.Properties.from(ETHETIC_WHITE_BLOCK.get())), + (b) -> new AABlockItem(b, defaultBlockItemProperties)); + public static final AABlockReg BLACK_QUARTZ_SLAB = new AABlockReg<>("black_quartz_slab", () -> new SlabBlock(AbstractBlock.Properties.from(BLACK_QUARTZ_BLOCK.get())), + (b) -> new AABlockItem(b, defaultBlockItemProperties)); + public static final AABlockReg CHISELED_BLACK_QUARTZ_SLAB = new AABlockReg<>("chiseled_black_quartz_slab", () -> new SlabBlock(AbstractBlock.Properties.from(CHISELED_BLACK_QUARTZ_BLOCK.get())), + (b) -> new AABlockItem(b, defaultBlockItemProperties)); + public static final AABlockReg BLACK_QUARTZ_PILLAR_SLAB = new AABlockReg<>("black_quartz_pillar_slab", () -> new SlabBlock(AbstractBlock.Properties.from(BLACK_QUARTZ_PILLAR_BLOCK.get())), + (b) -> new AABlockItem(b, defaultBlockItemProperties)); + + + // Other Misc Blocks + public static final AABlockReg TINY_TORCH = new AABlockReg<>("tiny_torch", BlockTinyTorch::new, + (b) -> new AABlockItem(b, defaultBlockItemProperties)); + + //public static final AABlockReg<> WILD_PLANT = new AABlockReg<>("wild", BlockWildPlant::new); //TODO: what is this? + + //TODO: Are plants normal blocks / blockitems? i have no idea... news at 11... + public static final AABlockReg RICE = new AABlockReg<>("rice", () -> new BlockPlant(ActuallyItems.RICE_SEED.get()), + (b) -> new AABlockItem(b, defaultBlockItemProperties)); + public static final AABlockReg CANOLA = new AABlockReg<>("canola", () -> new BlockPlant(ActuallyItems.CANOLA_SEED.get()), + (b) -> new AABlockItem(b, defaultBlockItemProperties)); + public static final AABlockReg FLAX = new AABlockReg<>("flax", () -> new BlockPlant(ActuallyItems.FLAX_SEED.get()), + (b) -> new AABlockItem(b, defaultBlockItemProperties)); + public static final AABlockReg COFFEE = new AABlockReg<>("coffee", () -> new BlockPlant(ActuallyItems.COFFEE_SEED.get()), + (b) -> new AABlockItem(b, defaultBlockItemProperties)); + public static final AABlockReg GREENHOUSE_GLASS = new AABlockReg<>("greenhouse_glass", BlockGreenhouseGlass::new, + (b) -> new AABlockItem(b, defaultBlockItemProperties)); public static AbstractBlock.Properties defaultPickProps(int harvestLevel, float hardness, float resistance) { return AbstractBlock.Properties.create(Material.ROCK).harvestLevel(harvestLevel).harvestTool(ToolType.PICKAXE).hardnessAndResistance(hardness, resistance).sound(SoundType.STONE); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/metalists/TheWildPlants.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/metalists/TheWildPlants.java index 1393c65b1..35cad8991 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/metalists/TheWildPlants.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/metalists/TheWildPlants.java @@ -19,10 +19,10 @@ import net.minecraft.util.IStringSerializable; @Deprecated public enum TheWildPlants implements IStringSerializable { - CANOLA("canola", Rarity.RARE, ActuallyBlocks.CANOLA), - FLAX("flax", Rarity.RARE, ActuallyBlocks.FLAX), - RICE("rice", Rarity.RARE, ActuallyBlocks.RICE), - COFFEE("coffee", Rarity.RARE, ActuallyBlocks.COFFEE); + CANOLA("canola", Rarity.RARE, ActuallyBlocks.CANOLA.getBlock()), + FLAX("flax", Rarity.RARE, ActuallyBlocks.FLAX.getBlock()), + RICE("rice", Rarity.RARE, ActuallyBlocks.RICE.getBlock()), + COFFEE("coffee", Rarity.RARE, ActuallyBlocks.COFFEE.getBlock()); final String name; final Rarity rarity; diff --git a/src/main/java/de/ellpeck/actuallyadditions/registration/AABlockReg.java b/src/main/java/de/ellpeck/actuallyadditions/registration/AABlockReg.java new file mode 100644 index 000000000..9525f63bc --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/registration/AABlockReg.java @@ -0,0 +1,102 @@ +package de.ellpeck.actuallyadditions.registration; + +import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; +import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; +import net.minecraft.block.Block; +import net.minecraft.item.BlockItem; +import net.minecraft.item.Item; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityType; +import net.minecraftforge.fml.RegistryObject; + +import javax.annotation.Nonnull; +import java.util.Objects; +import java.util.function.Function; +import java.util.function.Supplier; + +public class AABlockReg implements Supplier { +//public class AABlock implements Supplier { + private final String name; + private final RegistryObject block; + private final RegistryObject item; + private RegistryObject> tileEntityType; + + public AABlockReg(String name, Supplier blockSupplier, Function itemSupplier, Supplier tileSupplier) { + this.name = name; + this.block = ActuallyBlocks.BLOCKS.register(name, blockSupplier); + this.item = ActuallyItems.ITEMS.register(name, () -> itemSupplier.apply(block.get())); + this.tileEntityType = ActuallyBlocks.TILES.register(name, () -> TileEntityType.Builder.create(tileSupplier, block.get()).build(null)); + } + public AABlockReg(String name, Supplier blockSupplier, Function itemSupplier) { + this.name = name; + this.block = ActuallyBlocks.BLOCKS.register(name, blockSupplier); + this.item = ActuallyItems.ITEMS.register(name, () -> itemSupplier.apply(block.get())); + } + + /* + public AABlock(BlockBuilder builder) { + this.name = builder.name; + this.block = ActuallyBlocks.BLOCKS.register(name, builder.blockSupplier); + this.item = ActuallyItems.ITEMS.register(name, () -> builder.itemSupplier.apply(block.get())); + if (builder.hasTile) + this.tileEntityType = ActuallyTiles.TILES.register(name, () -> TileEntityType.Builder.create(builder.tileSupplier, block.get()).build(null)); + } + + */ + + public String getName() {return name;} + + @Override + public Block get() { + return block.get(); + } + + public B getBlock() { + return block.get(); + } + + public I getItem() { + return item.get(); + } + + @Nonnull + public TileEntityType getTileEntityType() { return Objects.requireNonNull(tileEntityType.get());} + + + public static class BlockBuilder { + private final String name; + private Supplier blockSupplier; + private Function itemSupplier = (b) -> new BlockItem(b, ActuallyItems.defaultProps()); + private boolean hasTile = false; + private Supplier> tileSupplier; + + private BlockBuilder(String nameIn, Supplier blockSupplierIn) { + this.name = nameIn; + this.blockSupplier = blockSupplierIn; + } + + public static BlockBuilder block(String nameIn, Supplier blockSupplierIn) { + return new BlockBuilder(nameIn, blockSupplierIn); + } + + public BlockBuilder item(Function itemSupplierIn) { + itemSupplier = itemSupplierIn; + + return this; + } + + public BlockBuilder tile(Supplier> tileSupplierIn) { + tileSupplier = tileSupplierIn; + hasTile = true; + + return this; + } +/* + public AABlock build() { + return new AABlock(this); + } + + */ + + } +}