Jump to content

Special Ability Tools


kenoba10

Recommended Posts

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?

Link to comment
Share on other sites

  • Replies 73
  • Created
  • Last Reply

Top Posters In This Topic

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

 

Link to comment
Share on other sites

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);
                        }
                }
        }

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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);
					}
				}
			}
		}
	}

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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




  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I have done this now but have got the error:   'food(net.minecraft.world.food.FoodProperties)' in 'net.minecraft.world.item.Item.Properties' cannot be applied to                '(net.minecraftforge.registries.RegistryObject<net.minecraft.world.item.Item>)' public static final RegistryObject<Item> LEMON_JUICE = ITEMS.register( "lemon_juice", () -> new Item( new HoneyBottleItem.Properties().stacksTo(1).food( (new FoodProperties.Builder()) .nutrition(3) .saturationMod(0.25F) .effect(() -> new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 1500), 0.01f ) .build() ) )); The code above is from the ModFoods class, the one below from the ModItems class. public static final RegistryObject<Item> LEMON_JUICE = ITEMS.register("lemon_juice", () -> new Item(new Item.Properties().food(ModFoods.LEMON_JUICE)));   I shall keep going between them to try and figure out the cause. I am sorry if this is too much for you to help with, though I thank you greatly for your patience and all the effort you have put in to help me.
    • I have been following these exact tutorials for quite a while, I must agree that they are amazing and easy to follow. I have registered the item in the ModFoods class, I tried to do it in ModItems (Where all the items should be registered) but got errors, I think I may need to revert this and figure it out from there. Once again, thank you for your help! 👍 Just looking back, I have noticed in your code you added ITEMS.register, which I am guessing means that they are being registered in ModFoods, I shall go through the process of trial and error to figure this out.
    • ♈+2349027025197ஜ Are you a pastor, business man or woman, politician, civil engineer, civil servant, security officer, entrepreneur, Job seeker, poor or rich Seeking how to join a brotherhood for protection and wealth here’s is your opportunity, but you should know there’s no ritual without repercussions but with the right guidance and support from this great temple your destiny is certain to be changed for the better and equally protected depending if you’re destined for greatness Call now for enquiry +2349027025197☎+2349027025197₩™ I want to join ILLUMINATI occult without human sacrificeGREATORLDRADO BROTHERHOOD OCCULT , Is The Club of the Riches and Famous; is the world oldest and largest fraternity made up of 3 Millions Members. We are one Family under one father who is the Supreme Being. In Greatorldrado BROTHERHOOD we believe that we were born in paradise and no member should struggle in this world. Hence all our new members are given Money Rewards once they join in order to upgrade their lifestyle.; interested viewers should contact us; on. +2349027025197 ۝ஐℰ+2349027025197 ₩Greatorldrado BROTHERHOOD OCCULT IS A SACRED FRATERNITY WITH A GRAND LODGE TEMPLE SITUATED IN G.R.A PHASE 1 PORT HARCOURT NIGERIA, OUR NUMBER ONE OBLIGATION IS TO MAKE EVERY INITIATE MEMBER HERE RICH AND FAMOUS IN OTHER RISE THE POWERS OF GUARDIANS OF AGE+. +2349027025197   SEARCHING ON HOW TO JOIN THE Greatorldrado BROTHERHOOD MONEY RITUAL OCCULT IS NOT THE PROBLEM BUT MAKE SURE YOU'VE THOUGHT ABOUT IT VERY WELL BEFORE REACHING US HERE BECAUSE NOT EVERYONE HAS THE HEART TO DO WHAT IT TAKES TO BECOME ONE OF US HERE, BUT IF YOU THINK YOU'RE SERIOUS MINDED AND READY TO RUN THE SPIRITUAL RACE OF LIFE IN OTHER TO ACQUIRE ALL YOU NEED HERE ON EARTH CONTACT SPIRITUAL GRANDMASTER NOW FOR INQUIRY +2349027025197   +2349027025197 Are you a pastor, business man or woman, politician, civil engineer, civil servant, security officer, entrepreneur, Job seeker, poor or rich Seeking how to join
    • Hi, I'm trying to use datagen to create json files in my own mod. This is my ModRecipeProvider class. public class ModRecipeProvider extends RecipeProvider implements IConditionBuilder { public ModRecipeProvider(PackOutput pOutput) { super(pOutput); } @Override protected void buildRecipes(Consumer<FinishedRecipe> pWriter) { ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ModBlocks.COMPRESSED_DIAMOND_BLOCK.get()) .pattern("SSS") .pattern("SSS") .pattern("SSS") .define('S', ModItems.COMPRESSED_DIAMOND.get()) .unlockedBy(getHasName(ModItems.COMPRESSED_DIAMOND.get()), has(ModItems.COMPRESSED_DIAMOND.get())) .save(pWriter); ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ModItems.COMPRESSED_DIAMOND.get(),9) .requires(ModBlocks.COMPRESSED_DIAMOND_BLOCK.get()) .unlockedBy(getHasName(ModBlocks.COMPRESSED_DIAMOND_BLOCK.get()), has(ModBlocks.COMPRESSED_DIAMOND_BLOCK.get())) .save(pWriter); ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ModItems.COMPRESSED_DIAMOND.get()) .pattern("SSS") .pattern("SSS") .pattern("SSS") .define('S', Blocks.DIAMOND_BLOCK) .unlockedBy(getHasName(ModItems.COMPRESSED_DIAMOND.get()), has(ModItems.COMPRESSED_DIAMOND.get())) .save(pWriter); } } When I try to run the runData client, it shows an error:  Caused by: java.lang.IllegalStateException: Duplicate recipe compressed:compressed_diamond I know that it's caused by the fact that there are two recipes for the ModItems.COMPRESSED_DIAMOND. But I need both of these recipes, because I need a way to craft ModItems.COMPRESSED_DIAMOND_BLOCK and restore 9 diamond blocks from ModItems.COMPRESSED_DIAMOND. Is there a way to solve this?
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.