/** * Callback for item usage. If the item does something special on right clicking, he will have one * of those. Return True if something happen and false if it don't. This is for ITEMS, not BLOCKS */ public boolean onItemUse( ItemStack var1, EntityPlayer var2, World var3, int var4, int var5, int var6, int var7, float var8, float var9, float var10) { if (!var2.canPlayerEdit(var4, var5, var6, var7, var1)) { return false; } else { UseHoeEvent var11 = new UseHoeEvent(var2, var1, var3, var4, var5, var6); if (MinecraftForge.EVENT_BUS.post(var11)) { return false; } else if (var11.getResult() == Result.ALLOW) { var1.damageItem(1, var2); return true; } else { int var12 = var3.getBlockId(var4, var5, var6); int var13 = var3.getBlockId(var4, var5 + 1, var6); if ((var7 == 0 || var13 != 0 || var12 != Block.grass.blockID) && var12 != Block.dirt.blockID) { return false; } else { Block var14 = Block.tilledField; var3.playSoundEffect( (double) ((float) var4 + 0.5F), (double) ((float) var5 + 0.5F), (double) ((float) var6 + 0.5F), var14.stepSound.getStepSound(), (var14.stepSound.getVolume() + 1.0F) / 2.0F, var14.stepSound.getPitch() * 0.8F); if (var3.isRemote) { return true; } else { var3.setBlock(var4, var5, var6, var14.blockID); var1.damageItem(1, var2); return true; } } } } }
@SubscribeEvent public void tillDirt(UseHoeEvent e) { e.setResult(Result.DEFAULT); if (e.world.getBlock(e.x, e.y + 1, e.z).isAir(e.world, e.x, e.y + 1, e.z) && (e.world.getBlock(e.x, e.y, e.z) == EnhancedBiomesBlocks.dirtEB || e.world.getBlock(e.x, e.y, e.z) == EnhancedBiomesBlocks.grassEB)) { e.world.setBlock( e.x, e.y, e.z, EnhancedBiomesBlocks.farmlandEB[e.world.getBlockMetadata(e.x, e.y, e.z)], 0, 2); e.setResult(Result.ALLOW); } }
@SubscribeEvent public void onHoeUseEvent(UseHoeEvent event) { if (EtFuturum.enableCoarseDirt) { World world = event.world; if (world.getBlock(event.x, event.y, event.z) == ModBlocks.coarse_dirt) { world.setBlock(event.x, event.y, event.z, Blocks.dirt); world.playSoundEffect( event.x + 0.5F, event.y + 0.5F, event.z + 0.5F, Block.soundTypeGravel.getStepResourcePath(), 1.0F, 0.8F); event.setResult(Result.ALLOW); } } }