Jump to content

Recommended Posts

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?

Posted

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.

Posted

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?

Posted

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

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