Jump to content

making an ore drop a different item based on the players Item (MC 1.7.10)


theoneandonly2004

Recommended Posts

Ok so I am currently writing a basic ore doubling tool that will act sort of like a pickaxe however instead of dropping he block as an ore I want it to drop 2 dusts instead.

 

My question is how would I make the block drop the dusts when the player is using tmy doubling item but still act normally when using any other normal pickaxe.

 

Thanks for any help with this

Link to comment
Share on other sites

Hello

 

That is not as hard as you think. You need to just use "BlockEvent.HarvestDropsEvent" event, where you will just check the used item.

Jabelar has a good tutorial on events here: "http://jabelarminecraft.blogspot.sk/p/minecraft-forge-172-event-handling.html"

I come here to ask only after several hours of struggling, forum browsing and googling. Please be kind :)

Link to comment
Share on other sites

Ok I got some of the block class setup and it now responds whenever a player breaks a block...but it isn't realising that the player is using my item to perform the code...here's what I have so far, and i'm almost 90% certain it's something super simple i've overlooked...it always is

 

package handlers;

 

import cpw.mods.fml.common.eventhandler.SubscribeEvent;

import items.daftcraftItems;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.init.Blocks;

import net.minecraft.item.ItemStack;

import net.minecraftforge.event.world.BlockEvent;

import net.minecraftforge.oredict.OreDictionary;

 

public class BlockBreakEvent

{

  @SubscribeEvent

  public void onBreak(BlockEvent.HarvestDropsEvent event)

  {

 

      if(event.harvester!=null)

      {

        EntityPlayer player=event.harvester;

        System.out.println("there was a harvester");

        if(player.getCurrentEquippedItem()== new ItemStack(daftcraftItems.doubler,1,OreDictionary.WILDCARD_VALUE))

//1 ore doubler any damage?

        {

            System.out.println("you used the ore doubler");

            if(event.block== Blocks.iron_ore)

            {

              event.drops.clear();//will this permenantly clear the items when used by doubler once?

              event.drops.add(new ItemStack(daftcraftItems.ironDust));

            }

            else  if(event.block== Blocks.gold_ore)

            {

              event.drops.clear();

              event.drops.add(new ItemStack(daftcraftItems.goldDust));

            }

                  else  if(event.block== Blocks.diamond_ore)

                  {

                    event.drops.clear();

                    event.drops.add(new ItemStack(daftcraftItems.diamondDust));

                  }

        }

        else

        {

            System.out.println("you used item " + event.harvester.getHeldItem());

        }

      }

  }

 

}//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



×
×
  • Create New...

Important Information

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