Jump to content

Recommended Posts

Posted (edited)

I'm trying to create a loot table for my custom block to drop my custom item but seems doesn't works.

Main Class:

@Mod(SwordMod.MODID)
public class SwordMod {
    
    public static final String MODID = "swordmod";
    private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, SwordMod.MODID);
    private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, SwordMod.MODID);
    
    public static final RegistryObject<Item> EXAMPLE_ITEM = ITEMS.register("swordskylibur_item", () -> new Item(
            new Item.Properties().tab(CreativeModeTab.TAB_COMBAT)));
    public static final RegistryObject<Block> EXAMPLE_BLOCK = BLOCKS.register("rockstone_block", () -> new Block(BlockBehaviour.Properties
                .of(Material.STONE, MaterialColor.COLOR_BLUE)
                .strength(1.5f, 15f).harvestTool(ToolType.PICKAXE)
                .harvestLevel(1).sound(SoundType.WOOD) // Wood sound just for test
                .requiresCorrectToolForDrops()));
    public static final RegistryObject<BlockItem> CUSTOM_BLOCK = ITEMS.register("rockstone_item", () -> new BlockItem(EXAMPLE_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_BUILDING_BLOCKS)));
    
    public SwordMod() {
        IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
        
        BLOCKS.register(bus);
        ITEMS.register(bus);

        MinecraftForge.EVENT_BUS.register(this);
    }
    
}

 

loot table file (generated by misode.github.io)

{
  "type": "minecraft:block",
  "pools": [
    {
      "rolls": 1,
      "bonus_rolls": 0,
      "entries": [
        {
          "type": "minecraft:alternatives",
          "children": [
            {
              "type": "minecraft:item",
              "name": "swordmod:rockstone_block",
              "conditions": [
                {
                  "condition": "minecraft:match_tool",
                  "predicate": {
                    "enchantments": [
                      {
                        "enchantment": "minecraft:silk_touch",
                        "levels": {
                          "min": 1
                        }
                      }
                    ]
                  }
                }
              ]
            },
            {
              "type": "minecraft:item",
              "name": "swordmod:rockstone_item",
              "functions": [
                {
                  "function": "minecraft:apply_bonus",
                  "enchantment": "minecraft:fortune",
                  "formula": "minecraft:ore_drops"
                },
                {
                  "function": "minecraft:explosion_decay"
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

And an image of my project:

image.png.f9ab88e9b65eccbb3dc8ee57cf072e01.png

 

I hope you can help me :(

Edited by diesieben07
code formatting
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.