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

Hi! I made a bunch of new blocks using Minecraft Forge

 

Making the block in my main class:

 

 

public static Block myblock;

 

myblock= new myblock().setBlockName("myblock").setCreativeTab(myNewTabThingy).setBlockTextureName(modid +":"+ "myblock");

 

GameRegistry.registerBlock(myblock,"myblock");

 

 

 

and here is the myblock class:

 

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

 

public class myblock extends Block {

 

protected myblock () {

super(Material.ground);

this.setHardness(4F);

this.setHarvestLevel("pickaxe", 0);

this.setResistance(4F);

}

 

}

 

 

 

The code runs and works fine! There is just 2 things that I need help/teaching with

 

1) how to make the block drop a different block when you mine it

 

2) how to make the block drop nothing if its broke with your fist

 

Thanks

1) Override Block#getItemDropped(int, Random, int)

2) Change your block Material to one that requires a tool. (Material#setRequiresTool())

public class myblock extends Block {

 

2) how to... drop nothing if it's broken with your fist

 

Instead of extending the general Block class, consider extending the BlockOre class that is itself an extension of Block. Then, in your constructor, add a line like:

 

this.setHarvestLevel ("pickaxe", 2); // Iron or better pick

 

Look inside BlockOre to see what it adds to Block functionality. If you see something (like quantityDroppedWithBonus) that you want imitate, then override it with code for your subclass of ore.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

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.