Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.