Posted January 9, 201510 yr 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?
January 9, 201510 yr 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.
January 9, 201510 yr 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?
January 9, 201510 yr 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.