Skip to content

Commit

Permalink
make garlic and vampire orchid compostable
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheaterpaul committed Oct 21, 2023
1 parent 0ca5261 commit 12ec10f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 18 deletions.
25 changes: 25 additions & 0 deletions src/lib/java/de/teamlapen/lib/lib/util/RegisterHelper.java
Original file line number Diff line number Diff line change
@@ -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 extends ItemLike> T compostable(T item, float chance) {
ComposterBlock.COMPOSTABLES.put(item, chance);
return item;
}

public static <T extends Block> T flammable(T block, int encouragement, int flammability) {
FireBlock fireblock = (FireBlock) Blocks.FIRE;
fireblock.setFlammable(block, encouragement, flammability);
return block;
}

public static <T extends Block> T potted(T potBlock, ResourceLocation plant) {
FlowerPotBlock pot = (FlowerPotBlock) Blocks.FLOWER_POT;
pot.addPlant(plant, () -> potBlock);
return potBlock;
}
}
23 changes: 6 additions & 17 deletions src/main/java/de/teamlapen/vampirism/core/ModBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@
import java.util.function.Supplier;
import java.util.stream.Collectors;

import static de.teamlapen.lib.lib.util.RegisterHelper.*;

/**
* Handles all block registrations and reference.
*/
@SuppressWarnings("unused")
public class ModBlocks {
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, REFERENCE.MODID);

//Blocks
public static final RegistryObject<AlchemicalCauldronBlock> ALCHEMICAL_CAULDRON = registerWithItem("alchemical_cauldron", AlchemicalCauldronBlock::new);
public static final RegistryObject<AlchemicalFireBlock> ALCHEMICAL_FIRE = BLOCKS.register("alchemical_fire", AlchemicalFireBlock::new);
public static final RegistryObject<AltarInfusionBlock> ALTAR_INFUSION = registerWithItem("altar_infusion", AltarInfusionBlock::new);
Expand Down Expand Up @@ -76,12 +77,8 @@ public class ModBlocks {
public static final RegistryObject<TotemTopBlock> TOTEM_TOP_CRAFTED = registerWithItem("totem_top_crafted", () -> new TotemTopBlock(true, new ResourceLocation("none")));
public static final RegistryObject<TotemTopBlock> TOTEM_TOP_VAMPIRISM_VAMPIRE_CRAFTED = BLOCKS.register("totem_top_vampirism_vampire_crafted", () -> new TotemTopBlock(true, REFERENCE.VAMPIRE_PLAYER_KEY));
public static final RegistryObject<TotemTopBlock> TOTEM_TOP_VAMPIRISM_HUNTER_CRAFTED = BLOCKS.register("totem_top_vampirism_hunter_crafted", () -> new TotemTopBlock(true, REFERENCE.HUNTER_PLAYER_KEY));
public static final RegistryObject<VampirismFlowerBlock> VAMPIRE_ORCHID = registerWithItem("vampire_orchid", () -> new VampirismFlowerBlock(VampirismFlowerBlock.TYPE.ORCHID));
public static final RegistryObject<FlowerPotBlock> 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<VampirismFlowerBlock> VAMPIRE_ORCHID = registerWithItem("vampire_orchid", () -> compostable(new VampirismFlowerBlock(VampirismFlowerBlock.TYPE.ORCHID), 0.65f));
public static final RegistryObject<FlowerPotBlock> 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<WeaponTableBlock> WEAPON_TABLE = registerWithItem("weapon_table", WeaponTableBlock::new);
public static final RegistryObject<PotionTableBlock> POTION_TABLE = registerWithItem("potion_table", PotionTableBlock::new);
public static final RegistryObject<DarkSpruceLeavesBlock> DARK_SPRUCE_LEAVES = registerWithItem("dark_spruce_leaves", DarkSpruceLeavesBlock::new);
Expand All @@ -94,16 +91,8 @@ public class ModBlocks {
public static final RegistryObject<VampirismBlock> 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<VampirismBlock> 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<CursedGrass> 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<BushBlock> 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<Block> 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<BushBlock> 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<Block> 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<Block> 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<Block> 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<LogBlock> STRIPPED_DARK_SPRUCE_LOG = registerWithItem("stripped_dark_spruce_log", () -> new LogBlock(MapColor.COLOR_BLACK, MapColor.COLOR_GRAY));
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/de/teamlapen/vampirism/core/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -151,7 +153,7 @@ public boolean isFoil(ItemStack stack) {
public static final RegistryObject<InjectionItem> INJECTION_SANGUINARE = register("injection_sanguinare", () -> new InjectionItem(InjectionItem.TYPE.SANGUINARE));

public static final RegistryObject<BucketItem> 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<GarlicItem> ITEM_GARLIC = register("item_garlic", GarlicItem::new);
public static final RegistryObject<GarlicItem> ITEM_GARLIC = register("item_garlic", () -> compostable(new GarlicItem(), 0.65F));
public static final RegistryObject<GarlicBreadItem> GARLIC_BREAD = register("garlic_bread", GarlicBreadItem::new);
public static final RegistryObject<AlchemicalFireItem> ITEM_ALCHEMICAL_FIRE = register("item_alchemical_fire", AlchemicalFireItem::new);

Expand Down

0 comments on commit 12ec10f

Please sign in to comment.