Posted November 18, 20159 yr Hey, public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) { if (par3EntityLivingBase.isSneaking()) { par3EntityLivingBase.dropItem(Waluta.instance, 1); par1ItemStack.damageItem(100, par3EntityLivingBase); return true; } par1ItemStack.damageItem(1, par3EntityLivingBase); return true; } How to make something similar like this but on pickaxe ? I was thinking about that if player is mining without holding shift diamond,iron,emerald,gold ore it drop normal items and subtract -1 durability, but when player will hold shift and than mine it will drop that (Waluta.instance, 1) item but it will also subtract -100 durability. Sorry for my english.
November 18, 20159 yr Author public boolean onBlockLeftClicked(ItemStack damage, EntityLivingBase player, PlayerInteractEvent event) { if (event.action != PlayerInteractEvent.Action.LEFT_CLICK_BLOCK){ if (player.isSneaking()) { player.dropItem(Waluta.instance, 1); damage.damageItem(100, player); return true; } } damage.damageItem(1, player); return true; } Is that right or not?
November 18, 20159 yr You would know if you just looked at ANY tutorial on google... Search Forge Events. You are missing @SubscribeEvent. Event method takes only one argument - Event itself. You pull data only from event. Exacly like you did with event.action... If event is client side you can also use client classes, e.g Minecraft.class#thePlayer. 1.7.10 is no longer supported by forge, you are on your own.
November 18, 20159 yr Author I had other idea and i made something like this : public boolean onBlockDestroyed(ItemStack damage, World world, Block block, int arg1, int arg2, int arg3, EntityLivingBase player) { if ((double)block.getBlockHardness(world, arg1, arg2, arg3) != 0.0D) { if (player.isSneaking()) { player.dropItem(Waluta.instance, 1); damage.damageItem(100, player); return true; } } damage.damageItem(1, player); return true; } It works fine.
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.