Java 类net.minecraft.util.EnumActionResult 实例源码

项目:Backmemed    文件:ItemEnderPearl.java   
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
    ItemStack itemstack = worldIn.getHeldItem(playerIn);

    if (!worldIn.capabilities.isCreativeMode)
    {
        itemstack.func_190918_g(1);
    }

    itemStackIn.playSound((EntityPlayer)null, worldIn.posX, worldIn.posY, worldIn.posZ, SoundEvents.ENTITY_ENDERPEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
    worldIn.getCooldownTracker().setCooldown(this, 20);

    if (!itemStackIn.isRemote)
    {
        EntityEnderPearl entityenderpearl = new EntityEnderPearl(itemStackIn, worldIn);
        entityenderpearl.setHeadingFromThrower(worldIn, worldIn.rotationPitch, worldIn.rotationYaw, 0.0F, 1.5F, 1.0F);
        itemStackIn.spawnEntityInWorld(entityenderpearl);
    }

    worldIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
项目:Backmemed    文件:ItemLead.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY)
{
    Block block = playerIn.getBlockState(worldIn).getBlock();

    if (!(block instanceof BlockFence))
    {
        return EnumActionResult.PASS;
    }
    else
    {
        if (!playerIn.isRemote)
        {
            attachToFence(stack, playerIn, worldIn);
        }

        return EnumActionResult.SUCCESS;
    }
}
项目:uniquecrops    文件:ItemEnderSnooker.java   
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {

    List<EntityLivingBase> elb = acquireAllLookTargets(player, 32, 3);
    for (EntityLivingBase target : elb) {
        if (target.canEntityBeSeen(player) && !(target instanceof EntityPlayer)) {
            BlockPos targetpos = target.getPosition();
            BlockPos playerpos = player.getPosition();
            if (!world.isRemote) {
                target.setPositionAndUpdate(playerpos.getX(), playerpos.getY(), playerpos.getZ());
                player.setPositionAndUpdate(targetpos.getX(), targetpos.getY(), targetpos.getZ());
                if (target instanceof EntityWolf && world.rand.nextInt(100) == 0)
                    target.entityDropItem(UCItems.generic.createStack(EnumItems.DOGRESIDUE), 1);
                stack.damageItem(1, player);
                return new ActionResult(EnumActionResult.SUCCESS, stack);
            }
        }
    }
    return new ActionResult(EnumActionResult.PASS, stack);
}
项目:Adventurers-Toolbox    文件:HammerHandler.java   
@SubscribeEvent
public void onPlayerClickBlock(PlayerInteractEvent.RightClickBlock event) {

    if (event.getEntityPlayer() == null || !event.getEntityPlayer().isSneaking()) {
        return;
    }

    if (event.getItemStack().getItem() == ModItems.hammer && !event.getEntityPlayer().getCooldownTracker().hasCooldown(ModItems.hammer)) {

        if (!event.getWorld().isRemote) {
            BlockPos pos = event.getPos().offset(event.getFace());
            event.getWorld().createExplosion(event.getEntityPlayer(), pos.getX() + 0.5, pos.getY() + 0.5,
                    pos.getZ() + 0.5, 3, false);
        }

        event.getEntityPlayer().swingArm(event.getHand());
        event.getEntityPlayer().setActiveHand(event.getHand());
        event.getEntityPlayer().getCooldownTracker().setCooldown(ModItems.hammer, 200);
        ModItems.hammer.setDamage(event.getItemStack(), ModItems.hammer.getDamage(event.getItemStack()) - 10);

        event.setCancellationResult(EnumActionResult.SUCCESS);
        event.setResult(Event.Result.ALLOW);
        event.setCanceled(true);
    }

}
项目:pnc-repressurized    文件:ItemAmadronTablet.java   
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (hand != EnumHand.MAIN_HAND) return EnumActionResult.PASS;
    TileEntity te = worldIn.getTileEntity(pos);
    if (te == null) return EnumActionResult.PASS;
    if (te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing)) {
        if (!worldIn.isRemote) {
            setLiquidProvidingLocation(player.getHeldItemMainhand(), pos, worldIn.provider.getDimension());
            player.sendStatusMessage(new TextComponentTranslation("message.amadronTable.setLiquidProvidingLocation", pos.getX(), pos.getY(), pos.getZ(),
                    worldIn.provider.getDimension(), worldIn.provider.getDimensionType().toString()), false);
        }
    } else if (te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing)) {
        if (!worldIn.isRemote) {
            setItemProvidingLocation(player.getHeldItemMainhand(), pos, worldIn.provider.getDimension());
            player.sendStatusMessage(new TextComponentTranslation("message.amadronTable.setItemProvidingLocation", pos.getX(), pos.getY(), pos.getZ(),
                    worldIn.provider.getDimension(), worldIn.provider.getDimensionType().toString()), false);
        }
    } else {
        return EnumActionResult.PASS;
    }
    return EnumActionResult.SUCCESS;

}
项目:CustomWorldGen    文件:ItemEnderPearl.java   
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    if (!playerIn.capabilities.isCreativeMode)
    {
        --itemStackIn.stackSize;
    }

    worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_ENDERPEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
    playerIn.getCooldownTracker().setCooldown(this, 20);

    if (!worldIn.isRemote)
    {
        EntityEnderPearl entityenderpearl = new EntityEnderPearl(worldIn, playerIn);
        entityenderpearl.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
        worldIn.spawnEntityInWorld(entityenderpearl);
    }

    playerIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
项目:Firma    文件:ClayItem.java   
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer player, EnumHand handIn) {
    Mouse.setGrabbed(false); // TODO Remove debug
    ItemStack is = player.getHeldItem(handIn);
    if (player.getHeldItemMainhand().getCount() > 4) {
        if (worldIn.isRemote) {
            GuiKnapping.staticMaterial = CraftMat.CLAY;
            GuiKnapping.staticMaterialSub = this.getSubName(is.getItemDamage());

            player.openGui(FirmaMod.instance, GuiHandler.GUI_KNAPPING, player.world, (int) player.posX, (int) player.posY, (int) player.posZ);
        } else {
            PlayerData pd = PlayerData.getPlayerData(player.getUniqueID());
            pd.resetKnapCraft();
            pd.setItemStack(player.getHeldItemMainhand());
            pd.setCraftingMaterial(CraftMat.CLAY);
        }
    }
    return new ActionResult<ItemStack>(EnumActionResult.PASS, is);
}
项目:Firma    文件:PebbleItem.java   
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer player, EnumHand handIn) {
    ItemStack is = player.getHeldItem(handIn);
    if (player.getHeldItemMainhand().getCount() > 1) {
        if (worldIn.isRemote) {
            GuiKnapping.staticMaterial = CraftMat.STONE;
            GuiKnapping.staticMaterialSub = this.getSubName(is.getItemDamage());

        } else {
            PlayerData pd = PlayerData.getPlayerData(player.getUniqueID());
            pd.resetKnapCraft();
            pd.setItemStack(player.getHeldItemMainhand());
            pd.setCraftingMaterial(CraftMat.STONE);
        }
    }
    player.openGui(FirmaMod.instance, GuiHandler.GUI_KNAPPING, player.world, (int) player.posX, (int) player.posY, (int) player.posZ);
    return new ActionResult<ItemStack>(EnumActionResult.PASS, is);
}
项目:minecraft-territorialdealings    文件:ClaimTerritoryOrder.java   
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
   {
    if (world.isRemote) {  return new ActionResult(EnumActionResult.PASS, stack); } // Not doing this on client side

    if (stack.hasTagCompound() && stack.getTagCompound().getInteger("cooldown") > 0) { return new ActionResult(EnumActionResult.PASS, stack); } // Not yet

    if (TerritoryHandler.addChunkToFaction(player)) { stack.stackSize -= 1; }
    else    // Failed, so adding a cooldown
    {
        if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); }    // Init

        stack.getTagCompound().setInteger("cooldown", 20);  // Can only try once a second
    }

       return new ActionResult(EnumActionResult.PASS, stack);
   }
项目:Bewitchment    文件:ItemRemedyTalisman.java   
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    if (!world.isRemote) {
        IBaublesItemHandler baubles = BaublesApi.getBaublesHandler(player);
        for (int i = 0; i < baubles.getSlots(); i++)
            if (baubles.getStackInSlot(i).isEmpty() && baubles.isItemValidForSlot(i, player.getHeldItem(hand), player)) {
                baubles.setStackInSlot(i, player.getHeldItem(hand).copy());
                if (!player.capabilities.isCreativeMode) {
                    player.setHeldItem(hand, ItemStack.EMPTY);
                }
                onEquipped(player.getHeldItem(hand), player);
                break;
            }
    }
    return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
项目:MooncakeCraft    文件:MooncakeMold.java   
@Override
@Nonnull
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack stack = player.getHeldItem(hand);
    if (!(stack.getItem() instanceof MooncakeMold))
        return EnumActionResult.PASS;

    if (!stack.hasTagCompound())
        return EnumActionResult.PASS;

    if (world.getBlockState(pos).getBlock() == Blocks.IRON_BLOCK) {
        if (!stack.getTagCompound().hasKey("hitCount"))
            stack.getTagCompound().setInteger("hitCount", 0);
        stack.getTagCompound().setInteger("hitCount", stack.getTagCompound().getInteger("hitCount") + 1);

        if (stack.getTagCompound().getInteger("hitCount") >= 5) {
            ItemHandlerHelper.giveItemToPlayer(player, new ItemStack(MooncakeConstants.RAW_MOONCAKE_ITEM, 1, stack.getTagCompound().getInteger("meta")));
            stack.setTagCompound(null);
        }

        return EnumActionResult.SUCCESS;
    }

    return EnumActionResult.PASS;
}
项目:uniquecrops    文件:ItemEdibleMetal.java   
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {

    ItemStack toConvert = convertEdibles(stack);
    if (!UniqueCrops.baublesLoaded) {
        if (!world.isRemote)
            player.setHeldItem(hand, toConvert);
        return ActionResult.newResult(EnumActionResult.PASS, toConvert);
    } else {
        ItemStack bauble = BaublesApi.getBaublesHandler(player).getStackInSlot(6);
        if (bauble == null || (bauble != null && bauble.getItem() != UCBaubles.emblemIronstomach)) {
            if (!world.isRemote) {
                player.setHeldItem(hand, toConvert);
            }
            return ActionResult.newResult(EnumActionResult.PASS, toConvert);
        }
    }
    return super.onItemRightClick(stack, world, player, hand);
   }
项目:CustomWorldGen    文件:ItemRecord.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);

    if (iblockstate.getBlock() == Blocks.JUKEBOX && !((Boolean)iblockstate.getValue(BlockJukebox.HAS_RECORD)).booleanValue())
    {
        if (!worldIn.isRemote)
        {
            ((BlockJukebox)Blocks.JUKEBOX).insertRecord(worldIn, pos, iblockstate, stack);
            worldIn.playEvent((EntityPlayer)null, 1010, pos, Item.getIdFromItem(this));
            --stack.stackSize;
            playerIn.addStat(StatList.RECORD_PLAYED);
        }

        return EnumActionResult.SUCCESS;
    }
    else
    {
        return EnumActionResult.PASS;
    }
}
项目:uniquecrops    文件:ItemGeneric.java   
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {

    if (stack.getItemDamage() == EnumItems.TIMEMEAL.ordinal() && player.canPlayerEdit(pos, facing, stack)) {
        Block crops = world.getBlockState(pos).getBlock();
        if (crops != null && crops instanceof BlockCrops) {
            if (crops != UCBlocks.cropMerlinia)
                world.setBlockState(pos, ((BlockCrops)crops).withAge(0), 2);
            else if (crops == UCBlocks.cropMerlinia)
                ((Merlinia)crops).merliniaGrowth(world, pos, world.rand.nextInt(1) + 1);
            else if (crops instanceof BlockNetherWart)
                ((BlockNetherWart)crops).updateTick(world, pos, world.getBlockState(pos), world.rand);
            if (!player.capabilities.isCreativeMode && !player.worldObj.isRemote)
                stack.stackSize--;
            UCPacketHandler.sendToNearbyPlayers(world, pos, new PacketUCEffect(EnumParticleTypes.VILLAGER_HAPPY, pos.getX() - 0.5D, pos.getY(), pos.getZ() - 0.5D, 6));
            return EnumActionResult.SUCCESS;
        }
    }
    return super.onItemUse(stack, player, world, pos, hand, facing, hitX, hitY, hitZ);
}
项目:Halloween    文件:ItemCurseOrb.java   
@Override
    public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
    {
        ItemStack stack = player.getHeldItem(hand);

        if (!player.capabilities.isCreativeMode)
        {
            stack.shrink(1);
        }

        world.playSound((EntityPlayer)null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!world.isRemote)
        {
            EntityCurseOrb entity = new EntityCurseOrb(world, player);
            entity.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0.0F, 1.5F, 1.0F);
            world.spawnEntity(entity);
        }

//      playerIn.addStat(StatList.getObjectUseStats(this));
        return new ActionResult(EnumActionResult.SUCCESS, stack);
    }
项目:ArcaneMagic    文件:ItemIlluminator.java   
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing,
        float hitX, float hitY, float hitZ)
{
    IBlockState state = world.getBlockState(pos);
    String fancyDebug = "";
    for (NotebookCategory cat : ArcaneMagicAPI.getAnalyzer().getAnalysisResults(state))
    {
        fancyDebug += cat.getRegistryName() + ", ";
    }
    ArcaneMagic.LOGGER.info("State " + state.toString()
            + (fancyDebug.isEmpty() ? " reveals no categories." : " reveals categories " + fancyDebug));

    if (!player.isSneaking())
    {
        if (!ArcaneMagicAPI.getAnalyzer().getAnalysisResults(state).isEmpty())
        {
            ArcaneMagic.proxy.addIlluminatorParticle(this, world, pos, facing, hitX, hitY, hitZ);
            return EnumActionResult.SUCCESS;
        }
    }
    return EnumActionResult.PASS;
}
项目:Got-Wood    文件:ItemDates.java   
@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    IBlockState state = worldIn.getBlockState(pos);
    ItemStack heldItem = playerIn.getHeldItem(hand);

    if (heldItem.isEmpty()) {
        return super.onItemUse(playerIn, worldIn, pos, hand, facing, hitX, hitY, hitZ);
    }
    if (facing == EnumFacing.UP && playerIn.canPlayerEdit(pos.offset(facing), facing, heldItem) && (state.getBlock() == net.minecraft.init.Blocks.GRASS || state.getBlock() == net.minecraft.init.Blocks.DIRT || state.getBlock() == net.minecraft.init.Blocks.SAND) && worldIn.isAirBlock(pos.up())) {
        worldIn.setBlockState(pos.up(), BlockRegistry.palm_sapling.getDefaultState());
        heldItem.shrink(1);
        return EnumActionResult.SUCCESS;
    } else {
        return EnumActionResult.FAIL;
    }
}
项目:Got-Wood    文件:ItemSeed.java   
/**
    * Called when a Block is right-clicked with this Item
    */
@Override
   public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
   {
       net.minecraft.block.state.IBlockState state = worldIn.getBlockState(pos);

       if (facing == EnumFacing.UP && playerIn.canPlayerEdit(pos.offset(facing), facing, stack) && (state.getBlock()== net.minecraft.init.Blocks.GRASS ||state.getBlock()==net.minecraft.init.Blocks.DIRT|| state.getBlock()==net.minecraft.init.Blocks.FARMLAND) && worldIn.isAirBlock(pos.up()))
       {
        worldIn.setBlockState(pos.up(), this.getSaplingState());
           --stack.stackSize;
           return EnumActionResult.SUCCESS;
       }
       else
       {
           return EnumActionResult.FAIL;
       }
   }
项目:Backmemed    文件:ItemLingeringPotion.java   
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
    ItemStack itemstack = worldIn.getHeldItem(playerIn);
    ItemStack itemstack1 = worldIn.capabilities.isCreativeMode ? itemstack.copy() : itemstack.splitStack(1);
    itemStackIn.playSound((EntityPlayer)null, worldIn.posX, worldIn.posY, worldIn.posZ, SoundEvents.ENTITY_LINGERINGPOTION_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!itemStackIn.isRemote)
    {
        EntityPotion entitypotion = new EntityPotion(itemStackIn, worldIn, itemstack1);
        entitypotion.setHeadingFromThrower(worldIn, worldIn.rotationPitch, worldIn.rotationYaw, -20.0F, 0.5F, 1.0F);
        itemStackIn.spawnEntityInWorld(entitypotion);
    }

    worldIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
项目:Loot-Slash-Conquer    文件:ItemTest.java   
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
   {
    if (!player.getEntityWorld().isRemote)
    {
        return EnumActionResult.SUCCESS;
    }

    return EnumActionResult.FAIL;
   }
项目:Lector    文件:LectorManual.java   
@Override
protected ActionResult<ItemStack> clOnItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack stack = player.getHeldItem(hand);
    if (world.isRemote) {
        Lector.api.openManual(player);
        return new ActionResult<>(EnumActionResult.SUCCESS, stack);
    }
    return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
项目:Melodium    文件:ItemTempSpellCaster.java   
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
{
    ItemStack itemstack = playerIn.getHeldItem(handIn);
    playerIn.setActiveHand(handIn);
    spell.songStarted(playerIn, itemstack);

    return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
项目:MineCamera    文件:ItemPictureBook.java   
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn,
        EnumHand hand) {
    playerIn.setActiveHand(hand);
    if (!worldIn.isRemote) {
        BlockPos pos = playerIn.getPosition();
        int id = GuiElementLoader.GUI_PICTURE_BOOK;
        playerIn.openGui(MineCamera.instance, id, worldIn, pos.getX(), pos.getY(), pos.getZ());
    }
    return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
项目:UniversalRemote    文件:EntityPlayerMPProxy.java   
@Override
public EnumActionResult interactOn(Entity p_190775_1_, EnumHand p_190775_2_) {
    if (m_realPlayer == null) {
        return super.interactOn(p_190775_1_, p_190775_2_);
    } else {
        syncToRealPlayer();
        return syncPublicFieldsFromRealAndReturn(m_realPlayer.interactOn(p_190775_1_, p_190775_2_));
    }
}
项目:Backmemed    文件:DemoWorldManager.java   
public EnumActionResult processRightClick(EntityPlayer player, World worldIn, ItemStack stack, EnumHand hand)
{
    if (this.demoTimeExpired)
    {
        this.sendDemoReminder();
        return EnumActionResult.PASS;
    }
    else
    {
        return super.processRightClick(player, worldIn, stack, hand);
    }
}
项目:Mods    文件:ItemChargingTarge.java   
@Override
public ActionResult<ItemStack> onItemRightClick( World world, EntityPlayer living, EnumHand hand) {
    //if (!living.getCapability(TF2weapons.WEAPONS_CAP, null).effectsCool.containsKey("Charging")) {
    ItemStack stack=living.getHeldItem(hand);
        if (!world.isRemote)
            living.addPotionEffect(new PotionEffect(TF2weapons.charging, 40));
        living.getCooldownTracker().setCooldown(this, (int) (280f/TF2Attribute.getModifier("Charge Recharge", stack, 1, living)));
        //living.getCapability(TF2weapons.WEAPONS_CAP, null).effectsCool.put("Charging", 280);
    //}
    return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}
项目:pnc-repressurized    文件:ItemPneumaticWrench.java   
@Override
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
    ItemStack stack = player.getHeldItem(hand);
    if (!world.isRemote) {
        IBlockState state = world.getBlockState(pos);
        Block block = state.getBlock();

        IPneumaticWrenchable wrenchable;
        if (block instanceof IPneumaticWrenchable) {
            wrenchable = (IPneumaticWrenchable) block;
        } else {
            wrenchable = ModInteractionUtils.getInstance().getWrenchable(world.getTileEntity(pos));
        }
        boolean didWork = true;
        float pressure = ((ItemPneumaticWrench) Itemss.PNEUMATIC_WRENCH).getPressure(stack);
        if (wrenchable != null && pressure > 0) {
            if (wrenchable.rotateBlock(world, player, pos, side)) {
                if (!player.capabilities.isCreativeMode)
                    ((ItemPneumaticWrench) Itemss.PNEUMATIC_WRENCH).addAir(stack, -PneumaticValues.USAGE_PNEUMATIC_WRENCH);
            }
        } else {
            // rotating normal blocks doesn't use pressure
            didWork = block.rotateBlock(world, pos, side);
        }
        if (didWork) playWrenchSound(world, pos);
        return didWork ? EnumActionResult.SUCCESS : EnumActionResult.PASS;
    } else {
        // client-side: prevent GUI's opening etc.
        return EnumActionResult.SUCCESS;
    }
}
项目:pnc-repressurized    文件:ItemDrone.java   
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (hand != EnumHand.MAIN_HAND) return EnumActionResult.PASS;

    if (!world.isRemote) {
        ItemStack iStack = player.getHeldItemMainhand();
        EntityDrone drone = new EntityDrone(world, player);

        BlockPos placePos = pos.offset(facing);
        drone.setPosition(placePos.getX() + 0.5, placePos.getY() + 0.5, placePos.getZ() + 0.5);
        world.spawnEntity(drone);

        NBTTagCompound stackTag = iStack.getTagCompound();
        NBTTagCompound entityTag = new NBTTagCompound();
        drone.writeEntityToNBT(entityTag);
        if (stackTag != null) {
            entityTag.setTag("widgets", stackTag.getTagList("widgets", 10).copy());
            entityTag.setFloat("currentAir", stackTag.getFloat("currentAir"));
            entityTag.setInteger("color", stackTag.getInteger("color"));
            entityTag.setTag(ChargeableItemHandler.NBT_UPGRADE_TAG, stackTag.getCompoundTag(ChargeableItemHandler.NBT_UPGRADE_TAG));
        }
        drone.readEntityFromNBT(entityTag);
        if (iStack.hasDisplayName()) drone.setCustomNameTag(iStack.getDisplayName());

        drone.naturallySpawned = false;
        //TODO 1.8 check if valid replacement drone.onSpawnWithEgg(null);
        drone.onInitialSpawn(world.getDifficultyForLocation(placePos), null);
        iStack.shrink(1);
    }
    return EnumActionResult.SUCCESS;
}
项目:Mods    文件:ItemFlameThrower.java   
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn,
        EnumHand hand) {
    ItemStack itemStackIn = playerIn.getHeldItem(hand);
    if (TF2Attribute.getModifier("Rage Crit", itemStackIn, 0, playerIn)!=0 &&playerIn.getCapability(TF2weapons.WEAPONS_CAP, null).getPhlogRage()>=20f) {
        playerIn.setActiveHand(hand);
        return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemStackIn);
    }
    return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
}
项目:pnc-repressurized    文件:ItemBlockOmnidirectionalHopper.java   
@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    EnumActionResult result = super.onItemUse(playerIn, worldIn, pos, hand, side, hitX, hitY, hitZ);
    if (result == EnumActionResult.SUCCESS) {
        TileEntity te = worldIn.getTileEntity(pos.offset(side));
        if (te instanceof TileEntityOmnidirectionalHopper) {
            ((TileEntityOmnidirectionalHopper) te).setRotation(side.getOpposite());
        }
    }
    return result;
}
项目:CustomWorldGen    文件:ItemFireball.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    if (worldIn.isRemote)
    {
        return EnumActionResult.SUCCESS;
    }
    else
    {
        pos = pos.offset(facing);

        if (!playerIn.canPlayerEdit(pos, facing, stack))
        {
            return EnumActionResult.FAIL;
        }
        else
        {
            if (worldIn.getBlockState(pos).getMaterial() == Material.AIR)
            {
                worldIn.playSound((EntityPlayer)null, pos, SoundEvents.ITEM_FIRECHARGE_USE, SoundCategory.BLOCKS, 1.0F, (itemRand.nextFloat() - itemRand.nextFloat()) * 0.2F + 1.0F);
                worldIn.setBlockState(pos, Blocks.FIRE.getDefaultState());
            }

            if (!playerIn.capabilities.isCreativeMode)
            {
                --stack.stackSize;
            }

            return EnumActionResult.SUCCESS;
        }
    }
}
项目:genera    文件:ItemBurdockSeeds.java   
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    IBlockState state = worldIn.getBlockState(pos);
    IBlockState stateUp = worldIn.getBlockState(pos.up());

    if (state.getBlock().canSustainPlant(state, worldIn, pos, facing, this) && stateUp.getBlock() == Blocks.AIR) {
        worldIn.setBlockState(pos.up(), GeneraBlocks.BlockBurdockCrop.getDefaultState());
        player.getHeldItem(hand).setCount(player.getHeldItem(hand).getCount() - 1);
    }

    return EnumActionResult.PASS;
}
项目:Backmemed    文件:ItemSlab.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY)
{
    ItemStack itemstack = stack.getHeldItem(pos);

    if (!itemstack.func_190926_b() && stack.canPlayerEdit(worldIn.offset(hand), hand, itemstack))
    {
        Comparable<?> comparable = this.singleSlab.getTypeForItem(itemstack);
        IBlockState iblockstate = playerIn.getBlockState(worldIn);

        if (iblockstate.getBlock() == this.singleSlab)
        {
            IProperty<?> iproperty = this.singleSlab.getVariantProperty();
            Comparable<?> comparable1 = iblockstate.getValue(iproperty);
            BlockSlab.EnumBlockHalf blockslab$enumblockhalf = (BlockSlab.EnumBlockHalf)iblockstate.getValue(BlockSlab.HALF);

            if ((hand == EnumFacing.UP && blockslab$enumblockhalf == BlockSlab.EnumBlockHalf.BOTTOM || hand == EnumFacing.DOWN && blockslab$enumblockhalf == BlockSlab.EnumBlockHalf.TOP) && comparable1 == comparable)
            {
                IBlockState iblockstate1 = this.makeState(iproperty, comparable1);
                AxisAlignedBB axisalignedbb = iblockstate1.getCollisionBoundingBox(playerIn, worldIn);

                if (axisalignedbb != Block.NULL_AABB && playerIn.checkNoEntityCollision(axisalignedbb.offset(worldIn)) && playerIn.setBlockState(worldIn, iblockstate1, 11))
                {
                    SoundType soundtype = this.doubleSlab.getSoundType();
                    playerIn.playSound(stack, worldIn, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
                    itemstack.func_190918_g(1);
                }

                return EnumActionResult.SUCCESS;
            }
        }

        return this.tryPlace(stack, itemstack, playerIn, worldIn.offset(hand), comparable) ? EnumActionResult.SUCCESS : super.onItemUse(stack, playerIn, worldIn, pos, hand, facing, hitX, hitY);
    }
    else
    {
        return EnumActionResult.FAIL;
    }
}
项目:Mods    文件:ItemWrench.java   
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer living, EnumHand hand) {
    ItemStack stack=living.getHeldItem(hand);
    if(living.getCapability(TF2weapons.WEAPONS_CAP, null).getMetal()>=20 && TF2Attribute.getModifier("Weapon Mode", stack, 0, living) != 0) {
        living.setActiveHand(hand);
        return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
    }
    return super.onItemRightClick(world, living, hand);
}
项目:Industrial-Foregoing    文件:EnergyFieldAddon.java   
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (worldIn.getBlockState(pos).getBlock() instanceof EnergyFieldProviderBlock) { //TODO
        setLinkedPos(pos, player.getHeldItem(hand));
        return EnumActionResult.SUCCESS;
    }
    return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ);
}
项目:FoodCraft-Reloaded    文件:ItemVegetableJuice.java   
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (worldIn.getBlockState(pos).getBlock() instanceof BlockCake) {
        worldIn.setBlockState(pos, FoodCraftReloaded.getLoader(VegetableEnumLoader.class).get().getInstanceMap(BlockVegetableCake.class).get(vegetableType).getDefaultState().withProperty(BlockCake.BITES, worldIn.getBlockState(pos).getValue(BlockCake.BITES)));
        player.setHeldItem(hand, new ItemStack(FCRItems.GLASS_BOTTLE));
        return EnumActionResult.SUCCESS;
    }
    return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ);
}
项目:Mods    文件:ItemJar.java   
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn,
        EnumHand hand) {
    ItemStack itemStackIn= playerIn.getHeldItem(hand);
    /*Integer value = playerIn.getCapability(TF2weapons.WEAPONS_CAP, null).effectsCool
            .get(getData(itemStackIn).getName());*/
    if (itemStackIn.getTagCompound().getBoolean("IsEmpty") /*&& (value == null || value <= 0)*/) {
        playerIn.setActiveHand(hand);
        return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemStackIn);
    }
    return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
}
项目:CustomWorldGen    文件:DemoWorldManager.java   
public EnumActionResult processRightClickBlock(EntityPlayer player, World worldIn, @Nullable ItemStack stack, EnumHand hand, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    if (this.demoTimeExpired)
    {
        this.sendDemoReminder();
        return EnumActionResult.PASS;
    }
    else
    {
        return super.processRightClickBlock(player, worldIn, stack, hand, pos, facing, hitX, hitY, hitZ);
    }
}
项目:Thermionics    文件:ItemChunkUnloader.java   
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    if (world.isRemote) return ActionResult.newResult(EnumActionResult.PASS, player.getHeldItem(hand));

    ItemStack stack = player.getHeldItem(hand);

    boolean success = unloadChunk(stack);
    if (success) {
        //TODO: Sound and/or particles to indicate chunk unloading.
        //System.out.println("Chunk Unloaded.");
    }

    return ActionResult.newResult(EnumActionResult.PASS, player.getHeldItem(hand));
}
项目:Mods    文件:ItemCloak.java   
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer living, EnumHand hand) {
    ItemStack stack=living.getHeldItem(hand);
    if (living.isInvisible() || (!isFeignDeath(stack, living) && stack.getItemDamage() < 528)) {
        this.setCloak(!WeaponsCapability.get(living).isInvisible(), stack, living, world);
        return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
    }
    else if(!living.isInvisible() && this.isFeignDeath(stack, living) && stack.getItemDamage() == 0) {
        WeaponsCapability.get(living).setFeign(!WeaponsCapability.get(living).isFeign());
        if(WeaponsCapability.get(living).isFeign())
            living.playSound(getSound(stack, PropertyType.CHARGE_SOUND), 1.0f, 1.0f);
        return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
    }
    return new ActionResult<ItemStack>(EnumActionResult.PASS, stack);
}