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 am struggling on how to add XP after harvesting my custom ore. Any ideas?

Here is my ore class:

package com.pixxibunny.minecraftmod.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraftforge.common.ToolType;

import java.util.Random;

public class RoseOre extends Block {

    public RoseOre() {
        super(Properties.create(Material.ROCK)
                .hardnessAndResistance(3.0f,3.0f)
                .sound(SoundType.STONE)
                .harvestLevel(2)
                .harvestTool(ToolType.PICKAXE));
    }
}

 

  • Author

I'm pretty new to this stuff, so how would I go about overriding the experience?

package com.pixxibunny.minecraftmod.blocks;

import net.minecraft.block.OreBlock;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraftforge.common.ToolType;

public class RoseOre extends OreBlock {
    public RoseOre() {
        super(Properties.create(Material.ROCK)
                .hardnessAndResistance(3.0f,3.0f)
                .sound(SoundType.STONE)
                .harvestLevel(2)
                .harvestTool(ToolType.PICKAXE));
    }
}

 

@Override

public void onBlockHarvested(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) {

dropXpOnBlockBreak(worldIn,pos,250);

super.onBlockHarvested(worldIn, pos, state, player);

}

That's what I generally use

 

Edited by DangerousBlades

16 minutes ago, PixxiBunny said:

How would I do that exactly?

You would create a new instance of java.util.Random then use random.nextInt() * (max - min) + min to get a random integer between min and max (inclusive, exclusive).

 

Since you're new to modding and java, I strongly recommend taking a java course to learn about java.util.Random and more of the basics before you proceed. Modding Minecraft is not the best way of learning the language.

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.