Java 类net.minecraftforge.event.entity.player.UseHoeEvent 实例源码

项目:Genesis    文件:GenesisEventHandler.java   
@SubscribeEvent
public static void onUseHoe(UseHoeEvent event) {
    EntityPlayer player = event.getEntityPlayer();
    World world = event.getWorld();
    BlockPos pos = event.getPos();
    IBlockState state = world.getBlockState(pos);
    Block block = state.getBlock();

    if (block == GenesisBlocks.HUMUS || block == GenesisBlocks.HUMUS_PATH) {
        world.playSound(player, pos, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F);

        if (!world.isRemote) {
            IBlockState farmland = GenesisBlocks.HUMUS_FARMLAND.getDefaultState();
            world.setBlockState(pos, farmland, WorldFlags.UPDATE_BLOCK_AND_CLIENT_AND_RERENDER_ON_MAIN);
        }

        event.setResult(Event.Result.ALLOW);
    }
}
项目:ExtraUtilities    文件:ItemTemporalHoe.java   
public boolean onItemUse(final ItemStack p_77648_1_, final EntityPlayer p_77648_2_, final World p_77648_3_, final int p_77648_4_, final int p_77648_5_, final int p_77648_6_, final int p_77648_7_, final float p_77648_8_, final float p_77648_9_, final float p_77648_10_) {
    if (!p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_)) {
        return false;
    }
    final UseHoeEvent event = new UseHoeEvent(p_77648_2_, p_77648_1_, p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_);
    if (MinecraftForge.EVENT_BUS.post((Event)event)) {
        return false;
    }
    if (event.getResult() == Event.Result.ALLOW) {
        return true;
    }
    final Block block = p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_);
    if (p_77648_7_ == 0 || !p_77648_3_.getBlock(p_77648_4_, p_77648_5_ + 1, p_77648_6_).isAir((IBlockAccess)p_77648_3_, p_77648_4_, p_77648_5_ + 1, p_77648_6_) || (block != Blocks.grass && block != Blocks.dirt)) {
        return false;
    }
    final Block block2 = Blocks.farmland;
    p_77648_3_.playSoundEffect((double)(p_77648_4_ + 0.5f), (double)(p_77648_5_ + 0.5f), (double)(p_77648_6_ + 0.5f), block2.stepSound.getStepResourcePath(), (block2.stepSound.getVolume() + 1.0f) / 2.0f, block2.stepSound.getPitch() * 0.8f);
    if (p_77648_3_.isRemote) {
        return true;
    }
    p_77648_3_.setBlock(p_77648_4_, p_77648_5_, p_77648_6_, block2);
    return true;
}
项目:RFDrills    文件:ToolHelper.java   
public static boolean hoeBlock(ItemStack stack, World world, int x, int y, int z, int sideHit, EntityPlayer player){
    Block block = world.getBlock(x, y, z);

    UseHoeEvent event = new UseHoeEvent(player, stack, world, x, y, z);
    if(MinecraftForge.EVENT_BUS.post(event)) //if the event got canceled
        return false;

    if (event.getResult() == Event.Result.ALLOW) //if another mod handled this block using the event
        return true;

    //vanilla hoe behaviour
    if (sideHit != 0 && world.isAirBlock(x, y + 1, z) && (block == Blocks.grass || block == Blocks.dirt) && player.canPlayerEdit(x, y, z, sideHit, stack)) {
        if (!world.isRemote)
            world.setBlock(x, y, z, Blocks.farmland);
        return true;
    }

    return false;
}
项目:vintagecraft    文件:BlockTopSoil.java   
@Override
public void hoeUsed(UseHoeEvent event) {
    EnumFertility fertility = getFertility(event.world, event.pos);

    IBlockState newState = BlocksVC.farmland.getDefaultState().withProperty(BlockFarmlandVC.fertility, fertility);

    event.world.playSoundEffect((double)((float)event.entityPlayer.posX + 0.5F), (double)((float)event.entityPlayer.posY + 0.5F), (double)((float)event.entityPlayer.posZ + 0.5F), newState.getBlock().stepSound.getStepSound(), (newState.getBlock().stepSound.getVolume() + 1.0F) / 2.0F, newState.getBlock().stepSound.getFrequency() * 0.8F);

    event.world.setBlockState(event.pos, newState);
    TEFarmland tileentity = (TEFarmland)event.world.getTileEntity(event.pos);
    if (tileentity != null) {
        tileentity.setFertility(fertility.getAsNumber());           
    } else {
        System.out.println("tileentity was not created?");
    }

    event.setResult(Result.ALLOW);

    event.entityPlayer.addExhaustion(0.1f);


    super.hoeUsed(event);
}
项目:The-Derpy-Shiz-Mod    文件:DerpyEvents.java   
@SubscribeEvent
public void onUseHoe(UseHoeEvent event) {
    Block oblock = event.world.getBlock(event.x, event.y, event.z);
    if (LongHoe.AOEEnabled && event.current.getItem() instanceof LongHoe && (oblock instanceof BlockDirt || oblock instanceof BlockGrass)) {
        LongHoe.AOEEnabled = false;
        for (int x = event.x - 3; x < event.x + 3; x++) {
            for (int z = event.z - 3; z < event.z + 3; z++) {
                Block block = event.world.getBlock(x, event.y, z);
                if ((!(x == event.x && z == event.z)) && (block instanceof BlockDirt || block instanceof BlockGrass) && (!MinecraftForge.EVENT_BUS.post(new UseHoeEvent(event.entityPlayer, event.current, event.world, x, event.y, z)))) {
                    event.world.setBlock(x, event.y, z, Blocks.farmland);
                    if (event.world.getBlock(x, event.y + 1, z).isReplaceable(event.world, x, event.y + 1, z)) {
                        event.world.setBlockToAir(x, event.y + 1, z);
                    }
                    DerpyItems.damageItem(event.current, 1, event.entityPlayer);
                }
            }
        }
        LongHoe.AOEEnabled = true;
    }
}
项目:connor41-etfuturum2    文件:CoarseDirt.java   
public static void onHoeEvent(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);
        }
    }
}
项目:CustomWorldGen    文件:ForgeEventFactory.java   
public static int onHoeUse(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos)
{
    UseHoeEvent event = new UseHoeEvent(player, stack, worldIn, pos);
    if (MinecraftForge.EVENT_BUS.post(event)) return -1;
    if (event.getResult() == Result.ALLOW)
    {
        stack.damageItem(1, player);
        return 1;
    }
    return 0;
}
项目:Toms-Mod    文件:EventHandler.java   
@SubscribeEvent
public void onHoe(UseHoeEvent event) {
    if (!event.getCurrent().isEmpty()) {
        if (disabledItems.contains(event.getCurrent().getItem()))
            event.setCanceled(true);
    }
}
项目:PopularMMOS-EpicProportions-Mod    文件:itemJenMultiTool.java   
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
    if (!player.canPlayerEdit(x, y, z, side, stack)) {
        return false;
    } else {
        UseHoeEvent event = new UseHoeEvent(player, stack, world, x, y, z);
        if (MinecraftForge.EVENT_BUS.post(event)) {
            return false;
        }

        if (event.getResult() == Result.ALLOW) {
            stack.damageItem(1, player);
            return true;
        }

        Block block = world.getBlock(x, y, z);

        if (side != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.grass || block == Blocks.dirt)) {
            Block block1 = Blocks.farmland;
            world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);

            if (world.isRemote) {
                return true;
            } else {
                world.setBlock(x, y, z, block1);
                stack.damageItem(1, player);
                return true;
            }
        } else {
            return false;
        }
    }
}
项目:PopularMMOS-EpicProportions-Mod    文件:itemSuperPatMultiTool.java   
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
    if (!player.canPlayerEdit(x, y, z, side, stack)) {
        return false;
    } else {
        UseHoeEvent event = new UseHoeEvent(player, stack, world, x, y, z);
        if (MinecraftForge.EVENT_BUS.post(event)) {
            return false;
        }

        if (event.getResult() == Result.ALLOW) {
            stack.damageItem(1, player);
            return true;
        }

        Block block = world.getBlock(x, y, z);

        if (side != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.grass || block == Blocks.dirt)) {
            Block block1 = Blocks.farmland;
            world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);

            if (world.isRemote) {
                return true;
            } else {
                world.setBlock(x, y, z, block1);
                stack.damageItem(1, player);
                return true;
            }
        } else {
            return false;
        }
    }
}
项目:PopularMMOS-EpicProportions-Mod    文件:itemSuperJenMultiTool.java   
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
    if (!player.canPlayerEdit(x, y, z, side, stack)) {
        return false;
    } else {
        UseHoeEvent event = new UseHoeEvent(player, stack, world, x, y, z);
        if (MinecraftForge.EVENT_BUS.post(event)) {
            return false;
        }

        if (event.getResult() == Result.ALLOW) {
            stack.damageItem(1, player);
            return true;
        }

        Block block = world.getBlock(x, y, z);

        if (side != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.grass || block == Blocks.dirt)) {
            Block block1 = Blocks.farmland;
            world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);

            if (world.isRemote) {
                return true;
            } else {
                world.setBlock(x, y, z, block1);
                stack.damageItem(1, player);
                return true;
            }
        } else {
            return false;
        }
    }
}
项目:PopularMMOS-EpicProportions-Mod    文件:itemPatMultiTool.java   
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
    if (!player.canPlayerEdit(x, y, z, side, stack)) {
        return false;
    } else {
        UseHoeEvent event = new UseHoeEvent(player, stack, world, x, y, z);
        if (MinecraftForge.EVENT_BUS.post(event)) {
            return false;
        }

        if (event.getResult() == Result.ALLOW) {
            stack.damageItem(1, player);
            return true;
        }

        Block block = world.getBlock(x, y, z);

        if (side != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.grass || block == Blocks.dirt)) {
            Block block1 = Blocks.farmland;
            world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);

            if (world.isRemote) {
                return true;
            } else {
                world.setBlock(x, y, z, block1);
                stack.damageItem(1, player);
                return true;
            }
        } else {
            return false;
        }
    }
}
项目:AquaMunda    文件:ForgeEventHandlers.java   
@SubscribeEvent
public void onUseHoeEvent(UseHoeEvent event) {
    if (ModBlocks.customFarmLand == null) {
        return;
    }

    World world = event.getWorld();
    BlockPos pos = event.getPos();
    EntityPlayer player = event.getEntityPlayer();
    ItemStack stack = event.getCurrent();

    IBlockState iblockstate = world.getBlockState(pos);
    Block block = iblockstate.getBlock();

    if (world.isAirBlock(pos.up())) {
        if (block == Blocks.GRASS) {
            event.setCanceled(true);
            useHoe(stack, player, world, pos, ModBlocks.customFarmLand.getDefaultState());
        } else if (block == Blocks.DIRT) {
            switch (iblockstate.getValue(BlockDirt.VARIANT)) {
                case DIRT:
                    event.setCanceled(true);
                    useHoe(stack, player, world, pos, ModBlocks.customFarmLand.getDefaultState());
                    break;
                case COARSE_DIRT:
                    event.setCanceled(true);
                    useHoe(stack, player, world, pos, Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT));
                    break;
            }
        }
    }
}
项目:DartCraft2    文件:ItemForceMitts.java   
@Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int blockMeta, float blockX, float blockY, float blockZ) { //Taken from vanilla code
    if (!player.canPlayerEdit(x, y, z, blockMeta, itemstack)) {
        return false;
    }
    else {
        UseHoeEvent event = new UseHoeEvent(player, itemstack, world, x, y, z);
        if (MinecraftForge.EVENT_BUS.post(event)) {
            return false;
        }

        if (event.getResult() == Event.Result.ALLOW) {
            itemstack.damageItem(1, player);
            return true;
        }

        Block block = world.getBlock(x, y, z);

        if (blockMeta != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.grass || block == Blocks.dirt)) {
            Block block1 = Blocks.farmland;
            world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);

            if (world.isRemote) {
                return true;
            }
            else {
                world.setBlock(x, y, z, block1);
                itemstack.damageItem(1, player);
                return true;
            }
        }
        else {
            return false;
        }
    }
}
项目:KeyCraft    文件:ItemAuroraIronHoe.java   
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int posX, int posY, int posZ, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) {
    if (!player.canPlayerEdit(posX, posY, posZ, p_77648_7_, stack)) {
        return false;
    } else {
        UseHoeEvent event = new UseHoeEvent(player, stack, world, posX, posY, posZ);
        if (MinecraftForge.EVENT_BUS.post(event)) {
            return false;
        }
        if (event.getResult() == Result.ALLOW) {
            if (stack.getItemDamage() >= this.getMaxDamage()) {
                player.setCurrentItemOrArmor(0, new ItemStack(Items.iron_hoe, 1, 0));
                return true;
            }
            stack.damageItem(1, player);
            return true;
        }
        Block block = world.getBlock(posX, posY, posZ);
        if (p_77648_7_ != 0 && world.getBlock(posX, posY + 1, posZ).isAir(world, posX, posY + 1, posZ) && (block == Blocks.grass || block == Blocks.dirt)) {
            Block block1 = Blocks.farmland;
            world.playSoundEffect((double)((float)posX + 0.5F), (double)((float)posZ + 0.5F), (double)((float)posZ + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);
            if (world.isRemote) {
                return true;
            } else {
                world.setBlock(posX, posY, posZ, block1);
                if (stack.getItemDamage() >= this.getMaxDamage()) {
                    player.setCurrentItemOrArmor(0, new ItemStack(Items.iron_hoe, 1, 0));
                    return true;
                }
                stack.damageItem(1, player);
                return true;
            }
        } else {
            return false;
        }
    }
}
项目:Et-Futurum    文件:CoarseDirt.java   
public static void onHoeEvent(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);
        }
    }
}
项目:vintagecraft    文件:VCraftWorld.java   
@SubscribeEvent
public void onEvent(UseHoeEvent event) {
    Block block = event.world.getBlockState(event.pos).getBlock();
    if (block instanceof BlockVC) {
        ((BlockVC)block).hoeUsed(event);
    }
}
项目:AbyssalCraft    文件:AbyssalCraftEventHooks.java   
@SubscribeEvent
public void onUseHoe(UseHoeEvent event){

    Block b = event.getWorld().getBlockState(event.getPos()).getBlock();

    if(b == ACBlocks.dreadlands_grass || b == ACBlocks.dreadlands_dirt){

        event.getWorld().playSound(event.getEntityPlayer(), event.getPos(), SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F);

        if(!event.getWorld().isRemote)
            event.getWorld().setBlockState(event.getPos(), Blocks.FARMLAND.getDefaultState());
        event.setResult(Result.ALLOW);
    }
}
项目:mcplus_mods    文件:EventHandlerBeetroot.java   
@SubscribeEvent
public void onHoeEvent(UseHoeEvent parEvent)
{
    if (parEvent.world.isRemote || parEvent.entityPlayer.capabilities.isCreativeMode) return;

    IBlockState block = parEvent.world.getBlockState(parEvent.pos);
    if (block.equals(Blocks.grass.getDefaultState()) || block.equals(Blocks.dirt.getDefaultState()))
    {
        if (parEvent.world.rand.nextInt(18) == 0)
        {
            parEvent.world.spawnEntityInWorld(new EntityItem(parEvent.world, parEvent.pos.getX(), parEvent.pos.getY(), parEvent.pos.getZ(), new ItemStack(_Beetroot.beetrootSeeds)));
        }
    }
}
项目:GardenCollection    文件:ForgeEventHandler.java   
@SubscribeEvent
public void useHoe (UseHoeEvent event) {
    Block block = event.world.getBlock(event.x, event.y, event.z);
    if (block instanceof BlockGarden) {
        if (((BlockGarden) block).applyHoe(event.world, event.x, event.y, event.z))
            event.setResult(Event.Result.ALLOW);
    }
}
项目:MyEssentials-Core    文件:ToolManager.java   
@SubscribeEvent
public void onUseHoe(UseHoeEvent ev) {
    for(Tool tool : tools) {
        if (ev.current == tool.getItemStack()) {
            ev.setCanceled(true);
            return;
        }
    }
}
项目:connor41-etfuturum2    文件:ServerEventHandler.java   
@SubscribeEvent
public void onHoeUseEvent(UseHoeEvent event) {
    CoarseDirt.onHoeEvent(event);
}
项目:amunra    文件:ItemNanotool.java   
/**
 * 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
 */
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
{
    if(this.hasEnoughEnergyAndMode(stack, energyCostUseSmall, Mode.HOE)) {
        //if(this.getMode(stack) == Mode.HOE) {
        if (!player.canPlayerEdit(x, y, z, side, stack))
        {
            return false;
        }
        else
        {
            UseHoeEvent event = new UseHoeEvent(player, stack, world, x, y, z);
            if (MinecraftForge.EVENT_BUS.post(event))
            {
                return false;
            }

            if (event.getResult() == Result.ALLOW)
            {
                this.consumePower(stack, player, energyCostUseSmall);
                //stack.damageItem(1, player);
                return true;
            }

            Block block = world.getBlock(x, y, z);

            if (side != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.grass || block == Blocks.dirt))
            {
                Block block1 = Blocks.farmland;
                world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);

                if (world.isRemote)
                {
                    return true;
                }
                else
                {
                    world.setBlock(x, y, z, block1);
                    //stack.damageItem(1, player);
                    this.consumePower(stack, player, energyCostUseSmall);
                    return true;
                }
            }
            else
            {
                return false;
            }
        }
    }
    return super.onItemUse(stack, player, world, x, y, z, side, hitX, hitY, hitZ);
}
项目:vsminecraft    文件:ItemMekanismHoe.java   
@Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int side, float entityX, float entityY, float entityZ)
{
    if(!entityplayer.canPlayerEdit(x, y, z, side, itemstack))
    {
        return false;
    }
    else {
        UseHoeEvent event = new UseHoeEvent(entityplayer, itemstack, world, x, y, z);

        if(MinecraftForge.EVENT_BUS.post(event))
        {
            return false;
        }

        if(event.getResult() == Result.ALLOW)
        {
            itemstack.damageItem(1, entityplayer);
            return true;
        }

        Block blockID = world.getBlock(x, y, z);
        Block aboveBlock = world.getBlock(x, y + 1, z);

        if((side == 0 || !aboveBlock.isAir(world, x, y, z+1) || blockID != Blocks.grass) && blockID != Blocks.dirt)
        {
            return false;
        }
        else {
            Block block = Blocks.farmland;
            world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.getStepResourcePath(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);

            if(world.isRemote)
            {
                return true;
            }
            else {
                world.setBlock(x, y, z, block);
                itemstack.damageItem(1, entityplayer);
                return true;
            }
        }
    }
}
项目:vsminecraft    文件:ItemAtomicDisassembler.java   
private boolean useHoe(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side)
{
    if(!player.canPlayerEdit(x, y, z, side, stack) || (!player.capabilities.isCreativeMode && getEnergy(stack) < HOE_USAGE))
    {
        return false;
    }
    else {
        UseHoeEvent event = new UseHoeEvent(player, stack, world, x, y, z);

        if(MinecraftForge.EVENT_BUS.post(event))
        {
            return false;
        }

        if(event.getResult() == Result.ALLOW)
        {
            setEnergy(stack, getEnergy(stack)-HOE_USAGE);
            return true;
        }

        Block block1 = world.getBlock(x, y, z);
        boolean air = world.isAirBlock(x, y + 1, z);

        if(side != 0 && air && (block1 == Blocks.grass || block1 == Blocks.dirt))
        {
            Block farm = Blocks.farmland;
            world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, farm.stepSound.getStepResourcePath(), (farm.stepSound.getVolume() + 1.0F) / 2.0F, farm.stepSound.getPitch() * 0.8F);

            if(world.isRemote)
            {
                return true;
            }
            else {
                world.setBlock(x, y, z, farm);

                if(!player.capabilities.isCreativeMode)
                {
                    setEnergy(stack, getEnergy(stack)-HOE_USAGE);
                }

                return true;
            }
        }
        else {
            return false;
        }
    }
}
项目:Skills    文件:EventHandler.java   
@SubscribeEvent
public void onHoeEvent(UseHoeEvent event)
{
    onEvent(event.entityPlayer, event);
}
项目:ComponentEquipment    文件:HoeItem.java   
@Override
  public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10)
  {
// TODO: Make sure this works right.. They can break from this.
      if ( !player.canPlayerEdit( x, y, z, par7, stack ) )
      {
          return false;
      }

      UseHoeEvent event = new UseHoeEvent( player, stack, world, x, y, z );
      if ( MinecraftForge.EVENT_BUS.post( event ) )
      {
          return false;
      }

      if ( event.getResult() == Result.ALLOW )
      {
          damageItemStack( player, stack, 1 );
          return true;
      }

      Block i1 = world.getBlock(x, y, z);
      Block j1 = world.getBlock(x, y + 1, z);

      if ((par7 == 0 || j1 != air || i1 != grass) && i1 != dirt)
      {
          return false;
      }
      else
      {
          Block block = farmland;
          world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), block.stepSound.soundName, (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);

          if (world.isRemote)
          {
              return true;
          }
          else
          {
              world.setBlock(x, y, z, block);
              damageItemStack( player, stack, 1 );
              return true;
          }
      }
  }
项目:Et-Futurum    文件:ServerEventHandler.java   
@SubscribeEvent
public void onHoeUseEvent(UseHoeEvent event) {
    CoarseDirt.onHoeEvent(event);
}
项目:M4Armory    文件:ToolHelper.java   
public static boolean hoeGround (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, Random random)
{
    if (!player.canPlayerEdit(x, y, z, side, stack))
    {
        return false;
    }
    else
    {
        UseHoeEvent event = new UseHoeEvent(player, stack, world, x, y, z);
        if (MinecraftForge.EVENT_BUS.post(event))
        {
            return false;
        }

        if (event.getResult() == Event.Result.ALLOW)
        {
            //damageTool(stack, 1, player, false);
            return true;
        }

        Block block = world.getBlock(x, y, z);

        if (side != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.grass || block == Blocks.dirt))
        {
            Block block1 = Blocks.farmland;
            world.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);

            if (world.isRemote)
            {
                return true;
            }
            else
            {
                world.setBlock(x, y, z, block1);
                //damageTool(stack, 1, player, false);
                return true;
            }
        }
        else
        {
            return false;
        }
    }
}
项目:IlluminatedBows    文件:ItemIlluminatedPotathoe.java   
@Override
public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_)
   {
       if (!p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_))
       {
           return false;
       }
       else
       {
           UseHoeEvent event = new UseHoeEvent(p_77648_2_, p_77648_1_, p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_);
           if (MinecraftForge.EVENT_BUS.post(event))
           {
               return false;
           }

           if (event.getResult() == Result.ALLOW)
           {
               p_77648_1_.damageItem(1, p_77648_2_);
               return true;
           }

           Block block = p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_);

           if (p_77648_7_ != 0 && p_77648_3_.getBlock(p_77648_4_, p_77648_5_ + 1, p_77648_6_).isAir(p_77648_3_, p_77648_4_, p_77648_5_ + 1, p_77648_6_) && (block == Blocks.grass || block == Blocks.dirt))
           {
               Block block1 = IlluminatedBlocks.illuminatedFarmland;
               p_77648_3_.playSoundEffect((double)((float)p_77648_4_ + 0.5F), (double)((float)p_77648_5_ + 0.5F), (double)((float)p_77648_6_ + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);

               if (p_77648_3_.isRemote)
               {
                   return true;
               }
               else
               {
                   p_77648_3_.setBlock(p_77648_4_, p_77648_5_, p_77648_6_, block1);
                   p_77648_1_.damageItem(1, p_77648_2_);
                   return true;
               }
           }
           else
           {
               return false;
           }
       }
   }
项目:BeanCraft    文件:ItemInfusedHoeOne.java   
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int i, float a, float b, float c)
{
    if (!player.canPlayerEdit(x, y, z, i, itemStack))
    {
        return false;
    }
    else
    {
        UseHoeEvent event = new UseHoeEvent(player, itemStack, world, x, y, z);
        if (MinecraftForge.EVENT_BUS.post(event))
        {
            return false;
        }

        if (event.getResult() == Event.Result.ALLOW)
        {
            itemStack.damageItem(1, player);
            return true;
        }

        Block block = world.getBlock(x, y, z);

        if (i != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.dirt || block == Blocks.grass))
        {
            Block block1 = ModBlocks.nuggetDirt;
            world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);

            if (world.isRemote)
            {
                return true;
            }
            else
            {
                world.setBlock(x, y + 1, z, block1);
                itemStack.damageItem(1, player);
                return true;
            }
        }
        else
        {
            return false;
        }
    }
}
项目:BeanCraft    文件:ItemInfusedHoe.java   
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int i, float a, float b, float c)
{
    if (!player.canPlayerEdit(x, y, z, i, itemStack))
    {
        return false;
    }
    else
    {
        UseHoeEvent event = new UseHoeEvent(player, itemStack, world, x, y, z);
        if (MinecraftForge.EVENT_BUS.post(event))
        {
            return false;
        }

        if (event.getResult() == Event.Result.ALLOW)
        {
            itemStack.damageItem(1, player);
            return true;
        }

        Block block = world.getBlock(x, y, z);

        if (i != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.dirt || block == Blocks.grass))
        {
            Block block1 = ModBlocks.chunkyDirt;
            world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);

            if (world.isRemote)
            {
                return true;
            }
            else
            {
                world.setBlock(x, y, z, block1);
                itemStack.damageItem(1, player);
                return true;
            }
        }
        else
        {
            return false;
        }
    }
}
项目:PeripheralsPlusPlus    文件:AbilityHelper.java   
public static boolean hoeGround (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, Random random)
{
    if (!player.canPlayerEdit(x, y, z, side, stack))
    {
        return false;
    }
    else
    {
        UseHoeEvent event = new UseHoeEvent(player, stack, world, x, y, z);
        if (MinecraftForge.EVENT_BUS.post(event))
        {
            return false;
        }

        if (event.getResult() == Result.ALLOW)
        {
            onBlockChanged(stack, world, 0, x, y, z, player, random);
            return true;
        }

        int bID = world.getBlockId(x, y, z);
        int bIDabove = world.getBlockId(x, y + 1, z);

        if ((side == 0 || bIDabove != 0 || bID != Block.grass.blockID) && bID != Block.dirt.blockID)
        {
            return false;
        }
        else
        {
            Block block = Block.tilledField;
            world.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), block.stepSound.getStepSound(),
                    (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);

            if (world.isRemote)
            {
                return true;
            }
            else
            {
                world.setBlock(x, y, z, block.blockID);
                onBlockChanged(stack, world, 0, x, y, z, player, random);
                return true;
            }
        }
    }
}
项目:ZeroQuest    文件:ItemNileHoe.java   
/**
 * 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 p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_)
{
    if (!p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_))
    {
        return false;
    }
    else
    {
        UseHoeEvent event = new UseHoeEvent(p_77648_2_, p_77648_1_, p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_);
        if (MinecraftForge.EVENT_BUS.post(event))
        {
            return false;
        }

        if (event.getResult() == Result.ALLOW)
        {
            p_77648_1_.damageItem(1, p_77648_2_);
            return true;
        }

        Block block = p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_);

        if (p_77648_7_ != 0 && p_77648_3_.getBlock(p_77648_4_, p_77648_5_ + 1, p_77648_6_).isAir(p_77648_3_, p_77648_4_, p_77648_5_ + 1, p_77648_6_) && (block == Blocks.grass || block == Blocks.dirt))
        {
            Block block1 = Blocks.farmland;
            p_77648_3_.playSoundEffect((double)((float)p_77648_4_ + 0.5F), (double)((float)p_77648_5_ + 0.5F), (double)((float)p_77648_6_ + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);

            if (p_77648_3_.isRemote)
            {
                return true;
            }
            else
            {
                p_77648_3_.setBlock(p_77648_4_, p_77648_5_, p_77648_6_, block1);
                p_77648_1_.damageItem(1, p_77648_2_);
                return true;
            }
        }
        else
        {
            return false;
        }
    }
}
项目:ZeroQuest    文件:ItemNileHoe.java   
/**
 * 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 par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
    if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack))
    {
        return false;
    }
    else
    {
        UseHoeEvent event = new UseHoeEvent(par2EntityPlayer, par1ItemStack, par3World, par4, par5, par6);
        if (MinecraftForge.EVENT_BUS.post(event))
        {
            return false;
        }

        if (event.getResult() == Result.ALLOW)
        {
            par1ItemStack.damageItem(1, par2EntityPlayer);
            return true;
        }

        int i1 = par3World.getBlockId(par4, par5, par6);
        boolean air = par3World.isAirBlock(par4, par5 + 1, par6);

        if (par7 != 0 && air && (i1 == Block.grass.blockID || i1 == Block.dirt.blockID))
        {
            Block block = Block.tilledField;
            par3World.playSoundEffect((double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), block.stepSound.getStepSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);

            if (par3World.isRemote)
            {
                return true;
            }
            else
            {
                par3World.setBlock(par4, par5, par6, block.blockID);
                par1ItemStack.damageItem(1, par2EntityPlayer);
                return true;
            }
        }
        else
        {
            return false;
        }
    }
}
项目:ZeroQuest    文件:ItemDarkHoe.java   
/**
 * 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 par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
    if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack))
    {
        return false;
    }
    else
    {
        UseHoeEvent event = new UseHoeEvent(par2EntityPlayer, par1ItemStack, par3World, par4, par5, par6);
        if (MinecraftForge.EVENT_BUS.post(event))
        {
            return false;
        }

        if (event.getResult() == Result.ALLOW)
        {
            par1ItemStack.damageItem(1, par2EntityPlayer);
            return true;
        }

        int i1 = par3World.getBlockId(par4, par5, par6);
        boolean air = par3World.isAirBlock(par4, par5 + 1, par6);

        if (par7 != 0 && air && (i1 == Block.grass.blockID || i1 == Block.dirt.blockID))
        {
            Block block = Block.tilledField;
            par3World.playSoundEffect((double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), block.stepSound.getStepSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);

            if (par3World.isRemote)
            {
                return true;
            }
            else
            {
                par3World.setBlock(par4, par5, par6, block.blockID);
                par1ItemStack.damageItem(1, par2EntityPlayer);
                return true;
            }
        }
        else
        {
            return false;
        }
    }
}
项目:Cauldron    文件:ItemHoe.java   
public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_)
{
    if (!p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_))
    {
        return false;
    }
    else
    {
        UseHoeEvent event = new UseHoeEvent(p_77648_2_, p_77648_1_, p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_);
        if (MinecraftForge.EVENT_BUS.post(event))
        {
            return false;
        }

        if (event.getResult() == Result.ALLOW)
        {
            p_77648_1_.damageItem(1, p_77648_2_);
            return true;
        }

        Block block = p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_);

        if (p_77648_7_ != 0 && p_77648_3_.getBlock(p_77648_4_, p_77648_5_ + 1, p_77648_6_).isAir(p_77648_3_, p_77648_4_, p_77648_5_ + 1, p_77648_6_) && (block == Blocks.grass || block == Blocks.dirt))
        {
            Block block1 = Blocks.farmland;
            p_77648_3_.playSoundEffect((double)((float)p_77648_4_ + 0.5F), (double)((float)p_77648_5_ + 0.5F), (double)((float)p_77648_6_ + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);

            if (p_77648_3_.isRemote)
            {
                return true;
            }
            else
            {
                p_77648_3_.setBlock(p_77648_4_, p_77648_5_, p_77648_6_, block1);
                p_77648_1_.damageItem(1, p_77648_2_);
                return true;
            }
        }
        else
        {
            return false;
        }
    }
}
项目:Cauldron    文件:ItemHoe.java   
public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_)
{
    if (!p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_))
    {
        return false;
    }
    else
    {
        UseHoeEvent event = new UseHoeEvent(p_77648_2_, p_77648_1_, p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_);
        if (MinecraftForge.EVENT_BUS.post(event))
        {
            return false;
        }

        if (event.getResult() == Result.ALLOW)
        {
            p_77648_1_.damageItem(1, p_77648_2_);
            return true;
        }

        Block block = p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_);

        if (p_77648_7_ != 0 && p_77648_3_.getBlock(p_77648_4_, p_77648_5_ + 1, p_77648_6_).isAir(p_77648_3_, p_77648_4_, p_77648_5_ + 1, p_77648_6_) && (block == Blocks.grass || block == Blocks.dirt))
        {
            Block block1 = Blocks.farmland;
            p_77648_3_.playSoundEffect((double)((float)p_77648_4_ + 0.5F), (double)((float)p_77648_5_ + 0.5F), (double)((float)p_77648_6_ + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);

            if (p_77648_3_.isRemote)
            {
                return true;
            }
            else
            {
                p_77648_3_.setBlock(p_77648_4_, p_77648_5_, p_77648_6_, block1);
                p_77648_1_.damageItem(1, p_77648_2_);
                return true;
            }
        }
        else
        {
            return false;
        }
    }
}
项目:VanillaImp    文件:ModHoe.java   
public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_)
{
    if (!p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_))
    {
        return false;
    }
    else
    {
        UseHoeEvent event = new UseHoeEvent(p_77648_2_, p_77648_1_, p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_);
        if (MinecraftForge.EVENT_BUS.post(event))
        {
            return false;
        }

        if (event.getResult() == Result.ALLOW)
        {
            p_77648_1_.damageItem(1, p_77648_2_);
            return true;
        }

        Block block = p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_);

        if (p_77648_7_ != 0 && p_77648_3_.getBlock(p_77648_4_, p_77648_5_ + 1, p_77648_6_).isAir(p_77648_3_, p_77648_4_, p_77648_5_ + 1, p_77648_6_) && (block == Blocks.grass || block == Blocks.dirt))
        {
            Block block1 = Blocks.farmland;
            p_77648_3_.playSoundEffect((double)((float)p_77648_4_ + 0.5F), (double)((float)p_77648_5_ + 0.5F), (double)((float)p_77648_6_ + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);

            if (p_77648_3_.isRemote)
            {
                return true;
            }
            else
            {
                p_77648_3_.setBlock(p_77648_4_, p_77648_5_, p_77648_6_, block1);
                p_77648_1_.damageItem(1, p_77648_2_);
                return true;
            }
        }
        else
        {
            return false;
        }
    }
}
项目:RuneCraftery    文件:ItemHoe.java   
/**
 * 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 par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
    if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack))
    {
        return false;
    }
    else
    {
        UseHoeEvent event = new UseHoeEvent(par2EntityPlayer, par1ItemStack, par3World, par4, par5, par6);
        if (MinecraftForge.EVENT_BUS.post(event))
        {
            return false;
        }

        if (event.getResult() == Result.ALLOW)
        {
            par1ItemStack.damageItem(1, par2EntityPlayer);
            return true;
        }

        int i1 = par3World.getBlockId(par4, par5, par6);
        boolean air = par3World.isAirBlock(par4, par5 + 1, par6);

        if (par7 != 0 && air && (i1 == Block.grass.blockID || i1 == Block.dirt.blockID))
        {
            Block block = Block.tilledField;
            par3World.playSoundEffect((double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), block.stepSound.getStepSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);

            if (par3World.isRemote)
            {
                return true;
            }
            else
            {
                par3World.setBlock(par4, par5, par6, block.blockID);
                par1ItemStack.damageItem(1, par2EntityPlayer);
                return true;
            }
        }
        else
        {
            return false;
        }
    }
}