Posted September 17, 201411 yr 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
September 17, 201411 yr 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
September 17, 201411 yr Author 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
September 17, 201411 yr Author but i've compared itemstacks like this before and they have worked across the various damages...
September 17, 201411 yr Author i'll have to look into my code then to check thanks for pointing it out, so how would i compare my item properly? any suggestions?
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.