Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.mcreator.smithingplusmod.block;
- import net.minecraftforge.registries.ObjectHolder;
- import net.minecraftforge.common.ToolType;
- import net.minecraft.world.IBlockReader;
- import net.minecraft.util.math.BlockPos;
- import net.minecraft.loot.LootContext;
- import net.minecraft.item.ItemStack;
- import net.minecraft.item.ItemGroup;
- import net.minecraft.item.Item;
- import net.minecraft.item.BlockItem;
- import net.minecraft.block.material.Material;
- import net.minecraft.block.SoundType;
- import net.minecraft.block.BlockState;
- import net.minecraft.block.Block;
- import net.mcreator.smithingplusmod.SmithingPlusModModElements;
- import java.util.List;
- import java.util.Collections;
- @SmithingPlusModModElements.ModElement.Tag
- public class IronPlanksBlock extends SmithingPlusModModElements.ModElement {
- @ObjectHolder("smithing_plus_mod:iron_planks")
- public static final Block block = null;
- public IronPlanksBlock(SmithingPlusModModElements instance) {
- super(instance, 136);
- }
- @Override
- public void initElements() {
- elements.blocks.add(() -> new CustomBlock());
- elements.items
- .add(() -> new BlockItem(block, new Item.Properties().group(ItemGroup.BUILDING_BLOCKS)).setRegistryName(block.getRegistryName()));
- }
- public static class CustomBlock extends Block {
- public CustomBlock() {
- super(Block.Properties.create(Material.ROCK).sound(SoundType.METAL).hardnessAndResistance(2f, 30f).setLightLevel(s -> 0).harvestLevel(1)
- .harvestTool(ToolType.PICKAXE).setRequiresTool());
- setRegistryName("iron_planks");
- }
- @Override
- public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
- return 15;
- }
- @Override
- public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
- List<ItemStack> dropsOriginal = super.getDrops(state, builder);
- if (!dropsOriginal.isEmpty())
- return dropsOriginal;
- return Collections.singletonList(new ItemStack(this, 1));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement