diff --git a/src/lib/java/de/teamlapen/lib/lib/util/RegisterHelper.java b/src/lib/java/de/teamlapen/lib/lib/util/RegisterHelper.java new file mode 100644 index 0000000000..e761e5fafc --- /dev/null +++ b/src/lib/java/de/teamlapen/lib/lib/util/RegisterHelper.java @@ -0,0 +1,25 @@ +package de.teamlapen.lib.lib.util; + +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.ItemLike; +import net.minecraft.world.level.block.*; + +public class RegisterHelper { + + public static T compostable(T item, float chance) { + ComposterBlock.COMPOSTABLES.put(item, chance); + return item; + } + + public static T flammable(T block, int encouragement, int flammability) { + FireBlock fireblock = (FireBlock) Blocks.FIRE; + fireblock.setFlammable(block, encouragement, flammability); + return block; + } + + public static T potted(T potBlock, ResourceLocation plant) { + FlowerPotBlock pot = (FlowerPotBlock) Blocks.FLOWER_POT; + pot.addPlant(plant, () -> potBlock); + return potBlock; + } +} diff --git a/src/main/java/de/teamlapen/vampirism/core/ModBlocks.java b/src/main/java/de/teamlapen/vampirism/core/ModBlocks.java index aa8c13eda8..b2a2d0e4a3 100755 --- a/src/main/java/de/teamlapen/vampirism/core/ModBlocks.java +++ b/src/main/java/de/teamlapen/vampirism/core/ModBlocks.java @@ -28,6 +28,8 @@ import java.util.function.Supplier; import java.util.stream.Collectors; +import static de.teamlapen.lib.lib.util.RegisterHelper.*; + /** * Handles all block registrations and reference. */ @@ -35,7 +37,6 @@ public class ModBlocks { public static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, REFERENCE.MODID); - //Blocks public static final RegistryObject ALCHEMICAL_CAULDRON = registerWithItem("alchemical_cauldron", AlchemicalCauldronBlock::new); public static final RegistryObject ALCHEMICAL_FIRE = BLOCKS.register("alchemical_fire", AlchemicalFireBlock::new); public static final RegistryObject ALTAR_INFUSION = registerWithItem("altar_infusion", AltarInfusionBlock::new); @@ -76,12 +77,8 @@ public class ModBlocks { public static final RegistryObject TOTEM_TOP_CRAFTED = registerWithItem("totem_top_crafted", () -> new TotemTopBlock(true, new ResourceLocation("none"))); public static final RegistryObject TOTEM_TOP_VAMPIRISM_VAMPIRE_CRAFTED = BLOCKS.register("totem_top_vampirism_vampire_crafted", () -> new TotemTopBlock(true, REFERENCE.VAMPIRE_PLAYER_KEY)); public static final RegistryObject TOTEM_TOP_VAMPIRISM_HUNTER_CRAFTED = BLOCKS.register("totem_top_vampirism_hunter_crafted", () -> new TotemTopBlock(true, REFERENCE.HUNTER_PLAYER_KEY)); - public static final RegistryObject VAMPIRE_ORCHID = registerWithItem("vampire_orchid", () -> new VampirismFlowerBlock(VampirismFlowerBlock.TYPE.ORCHID)); - public static final RegistryObject POTTED_VAMPIRE_ORCHID = BLOCKS.register("potted_vampire_orchid", () -> { - FlowerPotBlock block = new FlowerPotBlock(() -> (FlowerPotBlock) Blocks.FLOWER_POT, VAMPIRE_ORCHID, Block.Properties.of().noCollission().isViewBlocking(UtilLib::never).pushReaction(PushReaction.DESTROY).instabreak()); - ((FlowerPotBlock) Blocks.FLOWER_POT).addPlant(VAMPIRE_ORCHID.getId(), () -> block); - return block; - }); + public static final RegistryObject VAMPIRE_ORCHID = registerWithItem("vampire_orchid", () -> compostable(new VampirismFlowerBlock(VampirismFlowerBlock.TYPE.ORCHID), 0.65f)); + public static final RegistryObject POTTED_VAMPIRE_ORCHID = BLOCKS.register("potted_vampire_orchid", () -> potted(new FlowerPotBlock(() -> (FlowerPotBlock) Blocks.FLOWER_POT, VAMPIRE_ORCHID, Block.Properties.of().noCollission().isViewBlocking(UtilLib::never).pushReaction(PushReaction.DESTROY).instabreak()), VAMPIRE_ORCHID.getId())); public static final RegistryObject WEAPON_TABLE = registerWithItem("weapon_table", WeaponTableBlock::new); public static final RegistryObject POTION_TABLE = registerWithItem("potion_table", PotionTableBlock::new); public static final RegistryObject DARK_SPRUCE_LEAVES = registerWithItem("dark_spruce_leaves", DarkSpruceLeavesBlock::new); @@ -94,16 +91,8 @@ public class ModBlocks { public static final RegistryObject TOMBSTONE3 = registerWithItem("tombstone3", () -> new VampirismSplitBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE).pushReaction(PushReaction.DESTROY).strength(2, 6), BlockVoxelshapes.tomb3_base, BlockVoxelshapes.tomb3_top, true).markDecorativeBlock()); public static final RegistryObject GRAVE_CAGE = registerWithItem("grave_cage", () -> new VampirismHorizontalBlock(BlockBehaviour.Properties.of().mapColor(MapColor.METAL).strength(6, 8).requiresCorrectToolForDrops().sound(SoundType.METAL), BlockVoxelshapes.grave_cage).markDecorativeBlock()); public static final RegistryObject CURSED_GRASS = registerWithItem("cursed_grass", () -> new CursedGrass(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BLACK).randomTicks().strength(0.6F).sound(SoundType.GRASS))); - public static final RegistryObject CURSED_ROOTS = registerWithItem("cursed_roots", () -> { - BushBlock bush = new BushBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED).isViewBlocking(UtilLib::never).pushReaction(PushReaction.DESTROY).ignitedByLava().replaceable().noCollission().instabreak().sound(SoundType.GRASS)); - ((FireBlock) Blocks.FIRE).setFlammable(bush, 60, 100); - return bush; - }); - public static final RegistryObject POTTED_CURSED_ROOTS = BLOCKS.register("potted_cursed_roots", () -> { - FlowerPotBlock block = new FlowerPotBlock(() -> (FlowerPotBlock) Blocks.FLOWER_POT, CURSED_ROOTS, Block.Properties.of().noCollission().isViewBlocking(UtilLib::never).pushReaction(PushReaction.DESTROY).ignitedByLava().replaceable().instabreak().noOcclusion()); - ((FlowerPotBlock) Blocks.FLOWER_POT).addPlant(CURSED_ROOTS.getId(), () -> block); - return block; - }); + public static final RegistryObject CURSED_ROOTS = registerWithItem("cursed_roots", () -> flammable(new BushBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED).isViewBlocking(UtilLib::never).pushReaction(PushReaction.DESTROY).ignitedByLava().replaceable().noCollission().instabreak().sound(SoundType.GRASS)),60, 100)); + public static final RegistryObject POTTED_CURSED_ROOTS = BLOCKS.register("potted_cursed_roots", () -> potted(new FlowerPotBlock(() -> (FlowerPotBlock) Blocks.FLOWER_POT, CURSED_ROOTS, Block.Properties.of().noCollission().isViewBlocking(UtilLib::never).pushReaction(PushReaction.DESTROY).ignitedByLava().replaceable().instabreak().noOcclusion()), CURSED_ROOTS.getId())); public static final RegistryObject DARK_SPRUCE_PLANKS = registerWithItem("dark_spruce_planks", () -> new Block(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_GRAY).ignitedByLava().mapColor(MapColor.COLOR_GRAY).strength(2.0F, 3.0F).sound(SoundType.WOOD))); public static final RegistryObject CURSED_SPRUCE_PLANKS = registerWithItem("cursed_spruce_planks", () -> new Block(BlockBehaviour.Properties.of().ignitedByLava().mapColor(MapColor.CRIMSON_HYPHAE).strength(2.0F, 3.0F).sound(SoundType.WOOD))); public static final RegistryObject STRIPPED_DARK_SPRUCE_LOG = registerWithItem("stripped_dark_spruce_log", () -> new LogBlock(MapColor.COLOR_BLACK, MapColor.COLOR_GRAY)); diff --git a/src/main/java/de/teamlapen/vampirism/core/ModItems.java b/src/main/java/de/teamlapen/vampirism/core/ModItems.java index e6e4496d3d..9b3f82aec5 100755 --- a/src/main/java/de/teamlapen/vampirism/core/ModItems.java +++ b/src/main/java/de/teamlapen/vampirism/core/ModItems.java @@ -42,6 +42,8 @@ import java.util.function.Supplier; import java.util.stream.Collectors; +import static de.teamlapen.lib.lib.util.RegisterHelper.compostable; + /** * Handles all item registrations and reference. */ @@ -151,7 +153,7 @@ public boolean isFoil(ItemStack stack) { public static final RegistryObject INJECTION_SANGUINARE = register("injection_sanguinare", () -> new InjectionItem(InjectionItem.TYPE.SANGUINARE)); public static final RegistryObject IMPURE_BLOOD_BUCKET = register("impure_blood_bucket", CreativeModeTabs.TOOLS_AND_UTILITIES, () -> new BucketItem(ModFluids.IMPURE_BLOOD, new Item.Properties().craftRemainder(Items.BUCKET).stacksTo(1))); - public static final RegistryObject ITEM_GARLIC = register("item_garlic", GarlicItem::new); + public static final RegistryObject ITEM_GARLIC = register("item_garlic", () -> compostable(new GarlicItem(), 0.65F)); public static final RegistryObject GARLIC_BREAD = register("garlic_bread", GarlicBreadItem::new); public static final RegistryObject ITEM_ALCHEMICAL_FIRE = register("item_alchemical_fire", AlchemicalFireItem::new);