Posted June 19, 201510 yr So I wanted to implement more tools, and making the way to iron a bit harder. Unfortunately Blocks.iron_ore.setHarvestLevel("pickaxe", 3) seemed to do nothing. So I tried using PlayerEvent.HarvestCheck to check if the block is iron and if it is check the harvestLevel. Problem is that HarvestCheck seems to not get fired when the player is harvesting with tools.. So I am out of ideas how to realize that iron is harder to mine. Any experiences? Greetz Failender
June 19, 201510 yr Author Yeah I realized that.. Any other way to realize what I am triing to do? Making iron ore only harvestable with a tool that has miningLevel 3?
June 20, 201510 yr Author For everyone interested, here's my solution @SubscribeEvent public void canHarvest(HarvestDropsEvent event) { if(event.state.getBlock().getUnlocalizedName().equals("tile.oreIron")) { ItemStack holding = event.harvester.inventory.getStackInSlot(event.harvester.inventory.currentItem); if(holding!=null && holding.getItem() instanceof ItemPickaxe) { if(holding.getItem().getHarvestLevel(holding, "pickaxe") <3) { event.drops.clear(); } } else { event.drops.clear(); } } } @SubscribeEvent public void breakSpeed(BreakSpeed speed) { if(speed.state.getBlock().getUnlocalizedName().equals("tile.oreIron")) { ItemStack holding = speed.entityPlayer.inventory.getStackInSlot(speed.entityPlayer.inventory.currentItem); if(holding!=null && holding.getItem() instanceof ItemPickaxe) { if(holding.getItem().getHarvestLevel(holding, "pickaxe") <3) { speed.newSpeed = speed.originalSpeed/5; } } else { speed.newSpeed = speed.originalSpeed/5; } } }
June 20, 201510 yr Instead of using event.state.getBlock().getUnlocalizedName().equals("tile.oreIron"), why don't you just do, event.state.getBlock() == Blocks.iron_ore
June 20, 201510 yr Author obviously bc i am dumb. I was just so deep in the code that I was like okay. minecraft is using one class for all the ores. so i should check for the unlocalized name. dumb me ill better go to bed now.
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.