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

Hey there, I wanted to make a block which is essentially a cobble generator (for reasons), and I was going to do this by making a block that when right clicked it would spit out a cobblestone block.

 

Does anyone have any idea how I might be able to do this?

Why bother?

Simply create custom block. I don't remember exact method name but you should fin something like "onBlockClicked" or something inside Block class. (I am not on my PC now).

Then you'll need to check if side is server (world.isRemote stuff) and run code that:

1. Either add new item to player.inventory.

2. Spawn new EntityItem in world with x,y,z of block.

 

Thats the outline of the "idea", provide some basic code for more help.

1.7.10 is no longer supported by forge, you are on your own.

  • Author

Alright, I got this far, but I don't really know where to go from here :/ (I have never done more than basic blocks/items/tools/armour)

package com.jordsta.stuff.blocks;

import com.jordsta.stuff.JordTab;
import com.jordsta.stuff.Reference;
import com.jordsta.stuff.helpers.RegisterHelper;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;

public class cobbleGen extends Block {

public cobbleGen() {
	super(Material.rock);
	setBlockName("cobbleGen");
	setBlockTextureName(Reference.MODID + ":" + getUnlocalizedName().substring(5));
	setCreativeTab(JordTab.JordTab);
	setHardness(4.0f);
	setResistance(4.0f);
	RegisterHelper.registerBlock(this);
}

void onBlockClicked(){

}

}

 

I put void as that is what eclipse told me to do.

 

I looked at mob spawner code to try and figure out what I am supposed to do, but I have no idea how to read the messy code that is Minecraft. That, and it makes no sense :/

Why bother?

  • Author

The method is called onBlockActivated. I suggest you use your IDE to override it.

So I do:

void onBlockActivated(){

????

}

 

What do I need to put in here?

 

Eclipse told me to remove the @Override when I tried to add it...

Why bother?

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.