Jump to content

Recommended Posts

Posted

Hi. I'm working on making a mod and in it I want there to be tools with really cool abilitys:

 

  • Sword that shoots fireballs
    Pickaxe with auto smelting
    Axe with a feature similar to TreeCapacitator

 

The only one I have any idea to go about making is the sword a bit but I still vould use some help

 

Any help please?

  • Replies 73
  • Created
  • Last Reply

Top Posters In This Topic

Posted

For pickaxe you'll want to change the way it handles blocks being harvested/destroyed. It should be handled to check whether the item being dropped has a smelting recipe, and if it does, it should drop that instead of the normal drop (look at FurnaceRecipes.java).

 

For axe just check all above blocks and see if they are also wood/logs, etc, and have them affected as well.

Posted

For pickaxe you'll want to change the way it handles blocks being harvested/destroyed. It should be handled to check whether the item being dropped has a smelting recipe, and if it does, it should drop that instead of the normal drop (look at FurnaceRecipes.java).

 

For axe just check all above blocks and see if they are also wood/logs, etc, and have them affected as well.

Is is possible you could send me a code example?

Posted

Once you start to get somewhere, come back and I'll help you.

I've started to do some research and figured out how i could do the axe but I don't know how to make it so it only happens when you use the axe any ideas?

Posted

What did you come up with?

I found a  tutorial about making your own mod block so it destorys all other blocks of the same block around it which you put in the block class, but how could i do this for a pre existing block and only putting it in my pickaxe class without editing base classes

Posted

Whoops, this is what I meant:

 

@Override
public boolean onBlockDestroyed(ItemStack stack, World world, int id, int i, int j, int k, EntityLivingBase entity)
{
        //code
return true;
}

Posted

Whoops, this is what I meant:

 

@Override
public boolean onBlockDestroyed(ItemStack stack, World world, int id, int i, int j, int k, EntityLivingBase entity)
{
        //code
return true;
}

Oh I see would I override this method in my axe class and then put the code for breaking the wood in this method?

 

Posted

You got it.

Ok is there anyway i could alter this code to work inside the method?

  @Override
        public void breakBlock(World world, int i, int j, int k, int par5, int par6){
                //Reading the gag's tile entity.
                TileEntityGag tileEntity = (TileEntityGag)world.getBlockTileEntity(i, j, k);
                //If not make this check, the game may crash if there's no tile entity at i, j, k.
                if (tileEntity != null){
                        //Actually destroys primary block.
                        world.destroyBlock(tileEntity.primary_x, tileEntity.primary_y, tileEntity.primary_z, false);
                        //Forces removing tile entity from primary block coordinates,
                        //cause sometimes minecraft forgets to do that.
                        world.removeBlockTileEntity(tileEntity.primary_x, tileEntity.primary_y, tileEntity.primary_z);
                }
                //Same as above, but for the gag block tile entity.
                world.removeBlockTileEntity(i, j, k);
        }
        //This method checks if primary block exists. 
        @Override
        public void onNeighborBlockChange(World world, int i, int j, int k, int par5){
                TileEntityGag tileEntity = (TileEntityGag)world.getBlockTileEntity(i, j, k);
                if (tileEntity != null){
                        //No need to check if block's Id matches the Id of our primary block, 
                        //because if a player want to change a block, he needs to brake it first, 
                        //and in this case block will be set to Air (Id = 0)
                        if(world.getBlockId(tileEntity.primary_x, tileEntity.primary_y, 
                                        tileEntity.primary_z) < 1){
                                world.destroyBlock(i, j, k, false);
                                world.removeBlockTileEntity(i, j, k);
                        }
                }
        }

Posted

You're trying to make an axe that destroys an entire tree, correct? I don't see how your code there with the TileEntity actually correlates to that concept, so I don't know what it does, let alone how it would be possible to put on an item.

Posted

You're trying to make an axe that destroys an entire tree, correct? I don't see how your code there with the TileEntity actually correlates to that concept, so I don't know what it does, let alone how it would be possible to put on an item.

oh ok do you have any idea how i could destory the tree then?

Posted

It'd be easiest to check an area, perhaps a 3x15x3 region to check if the blocks are logs, and then make them drop a log at that position (for-loops).

Posted

It'd be easiest to check an area, perhaps a 3x15x3 region to check if the blocks are logs, and then make them drop a log at that position (for-loops).

Ok I've never actually done anything with deleting blocks and checking areas I'll look some stuff up unless you can help me in any way

Posted

Nested for-loops, one for each x, y, and z range. Use -1 to <= 1 as each range for x and z, and 0 to <= 15 for y. Then check if(world.getBlockId(par4 + x, par5 + y, par6 + z) == Block.log.blockID), and then get the metadata, create a new ItemStack of Block, set the block to 0 and then spawn an EntityItem at par4 + x, par5 + y, par6 + z.

Posted

Nested for-loops, one for each x, y, and z range. Use -1 to <= 1 as each range for x and z, and 0 to <= 15 for y. Then check if(world.getBlockId(par4 + x, par5 + y, par6 + z) == Block.log.blockID), and then get the metadata, create a new ItemStack of Block, set the block to 0 and then spawn an EntityItem at par4 + x, par5 + y, par6 + z.

Ok well it would be nice if it was a bit simpler i cant really understand it exactly

Posted
if(world.getBlockId(i, j, k) == Block.wood.blockID)
	{
		for(int x = -1; x <= 1; x++)
		{
			for(int y = 0; y <= 15; y++)
			{
				for(int z = -1; z <= 1; z++)
				{
					if(world.getBlockId(i + x, j + y, k + z) == Block.wood.blockID)
					{
						int meta = world.getBlockMetadata(i + x, j + y, k + z);
						ItemStack drop = new ItemStack(Block.wood, 1, meta);
						EntityItem item = new EntityItem(world, i + x, j + y, k + z, drop);
						world.setBlock(i + x, j + y, k + z, 0);
						world.spawnEntityInWorld(item);
					}
				}
			}
		}
	}

Posted

if(world.getBlockId(i, j, k) == Block.wood.blockID)
	{
		for(int x = -1; x <= 1; x++)
		{
			for(int y = 0; y <= 15; y++)
			{
				for(int z = -1; z <= 1; z++)
				{
					if(world.getBlockId(i + x, j + y, k + z) == Block.wood.blockID)
					{
						int meta = world.getBlockMetadata(i + x, j + y, k + z);
						ItemStack drop = new ItemStack(Block.wood, 1, meta);
						EntityItem item = new EntityItem(world, i + x, j + y, k + z, drop);
						world.setBlock(i + x, j + y, k + z, 0);
						world.spawnEntityInWorld(item);
					}
				}
			}
		}
	}

Thanks so much for the help!

Posted

Nested for-loops, one for each x, y, and z range. Use -1 to <= 1 as each range for x and z, and 0 to <= 15 for y. Then check if(world.getBlockId(par4 + x, par5 + y, par6 + z) == Block.log.blockID), and then get the metadata, create a new ItemStack of Block, set the block to 0 and then spawn an EntityItem at par4 + x, par5 + y, par6 + z.

Ok for the auto smelting pickaxe what would i override in my pickaxe class?

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.