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

项目:Backmemed    文件:EntitySnowman.java   
protected boolean processInteract(EntityPlayer player, EnumHand hand)
{
    ItemStack itemstack = player.getHeldItem(hand);

    if (itemstack.getItem() == Items.SHEARS && this.isPumpkinEquipped() && !this.world.isRemote)
    {
        this.setPumpkinEquipped(false);
        itemstack.damageItem(1, player);
    }

    return super.processInteract(player, hand);
}
项目:CustomWorldGen    文件:ItemCarrotOnAStick.java   
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    if (playerIn.isRiding() && playerIn.getRidingEntity() instanceof EntityPig)
    {
        EntityPig entitypig = (EntityPig)playerIn.getRidingEntity();

        if (itemStackIn.getMaxDamage() - itemStackIn.getMetadata() >= 7 && entitypig.boost())
        {
            itemStackIn.damageItem(7, playerIn);

            if (itemStackIn.stackSize == 0)
            {
                ItemStack itemstack = new ItemStack(Items.FISHING_ROD);
                itemstack.setTagCompound(itemStackIn.getTagCompound());
                return new ActionResult(EnumActionResult.SUCCESS, itemstack);
            }

            return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
        }
    }

    playerIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.PASS, itemStackIn);
}
项目:Got-Wood    文件:ItemDates.java   
@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.SAND) && worldIn.isAirBlock(pos.up()))
    {
        worldIn.setBlockState(pos.up(), Block.REGISTRY.getObject(new ResourceLocation(GotWood.MODID, "palm_sapling")).getDefaultState());
        --stack.stackSize;
        return EnumActionResult.SUCCESS;
    }
    else
    {
        return EnumActionResult.FAIL;
    }
}
项目:Infernum    文件:RenderKnowledgeTome.java   
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void renderItem(RenderSpecificHandEvent event) {
    Minecraft minecraft = Minecraft.getMinecraft();
    if (event.getHand() == EnumHand.MAIN_HAND) {
        if (minecraft.gameSettings.thirdPersonView != 0
                || minecraft.player.getHeldItem(EnumHand.MAIN_HAND).func_190916_E() <= 0
                || minecraft.player.getHeldItem(EnumHand.MAIN_HAND).getItem() != InfernumItems.KNOWLEDGE_BOOK) {
            reset();
            return;
        }
        if ((minecraft.player.getHeldItem(EnumHand.OFF_HAND).equals(ItemStack.field_190927_a))) {
            event.setCanceled(true);
            try {
                ticksOpen++;
                doRender(event.getPartialTicks(), minecraft.player.getHeldItem(event.getHand()));
            } catch (Throwable throwable) {

            }
        } else {
            reset();
        }
    }
}
项目:BetterBeginningsReborn    文件:ItemRoastingStick.java   
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
{
    ItemStack stack = player.getHeldItem(hand);

    if (player.inventory.hasItemStack(new ItemStack(RegisterItems.marshmallow)))
    {
        stack.setCount(stack.getCount() - 1);
        ItemStack mallowStick = new ItemStack(RegisterItems.roastingStickRawMallow);
        if (!player.inventory.addItemStackToInventory(mallowStick))
        {
            EntityItem drop = new EntityItem(world, player.posX, player.posY, player.posZ, mallowStick);

            world.spawnEntity(drop);
        }

        stack.setCount(stack.getCount() - 1); // Why is this done twice?
        if (stack.getCount() <= 0)
        {
            player.inventory.setItemStack(ItemStack.EMPTY);
            ForgeEventFactory.onPlayerDestroyItem(player, stack, hand);
        }
    }
    player.inventoryContainer.detectAndSendChanges();
    return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
项目:Zombe-Modpack    文件:EntityPlayer.java   
protected void damageShield(float damage)
{
    if (damage >= 3.0F && this.activeItemStack.getItem() == Items.SHIELD)
    {
        int i = 1 + MathHelper.floor(damage);
        this.activeItemStack.damageItem(i, this);

        if (this.activeItemStack.func_190926_b())
        {
            EnumHand enumhand = this.getActiveHand();

            if (enumhand == EnumHand.MAIN_HAND)
            {
                this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ItemStack.field_190927_a);
            }
            else
            {
                this.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, ItemStack.field_190927_a);
            }

            this.activeItemStack = ItemStack.field_190927_a;
            this.playSound(SoundEvents.ITEM_SHIELD_BREAK, 0.8F, 0.8F + this.world.rand.nextFloat() * 0.4F);
        }
    }
}
项目:ModularMachinery    文件:ItemConstructTool.java   
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if(!worldIn.isRemote && player.isCreative() && worldIn.getMinecraftServer().getPlayerList().canSendCommands(player.getGameProfile())) {
        IBlockState clicked = worldIn.getBlockState(pos);
        Block block = clicked.getBlock();
        if(block.equals(BlocksMM.blockController)) {
            PlayerStructureSelectionHelper.finalizeSelection(clicked.getValue(BlockController.FACING), worldIn, pos, player);

            PlayerStructureSelectionHelper.purgeSelection(player);
            PlayerStructureSelectionHelper.sendSelection(player);
        } else {
            PlayerStructureSelectionHelper.toggleInSelection(player, pos);
            PlayerStructureSelectionHelper.sendSelection(player);
        }
    }
    return EnumActionResult.SUCCESS;
}
项目:Mods    文件:TF2Message.java   
@Override
public void fromBytes(ByteBuf buf) {
    slot = buf.readByte();
    this.hand = buf.readBoolean() ? EnumHand.MAIN_HAND : EnumHand.OFF_HAND;
    this.readData = new ArrayList<Object[]>();
    while (buf.readableBytes() > 0) {
        Object[] obj = new Object[3];
        obj[0] = buf.readInt();
        // obj[1]=buf.readFloat();
        // obj[2]=buf.readFloat();
        // obj[3]=buf.readFloat();
        obj[1] = buf.readBoolean();
        obj[2] = buf.readFloat();
        this.readData.add(obj);
    }
}
项目:Backmemed    文件:ItemFlintAndSteel.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)
{
    worldIn = worldIn.offset(hand);
    ItemStack itemstack = stack.getHeldItem(pos);

    if (!stack.canPlayerEdit(worldIn, hand, itemstack))
    {
        return EnumActionResult.FAIL;
    }
    else
    {
        if (playerIn.getBlockState(worldIn).getMaterial() == Material.AIR)
        {
            playerIn.playSound(stack, worldIn, SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, itemRand.nextFloat() * 0.4F + 0.8F);
            playerIn.setBlockState(worldIn, Blocks.FIRE.getDefaultState(), 11);
        }

        itemstack.damageItem(1, stack);
        return EnumActionResult.SUCCESS;
    }
}
项目:Anima-Mundi    文件:BlockSorter.java   
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    if(!player.getHeldItem(hand).isEmpty() && player.getHeldItem(hand).getItem() == AnimaItems.LINKER)
    {
        return false;
    }

    TileEntity te = world.getTileEntity(pos);

    if (!(te instanceof TileEntitySorter))
    {
        return false;
    }
    player.openGui(Anima.Instance, 0, world, pos.getX(), pos.getY(), pos.getZ());
    return true;
}
项目:minecraft-territorialdealings    文件:FactionOverviewCard.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 (!player.capabilities.isCreativeMode) { return new ActionResult(EnumActionResult.PASS, stack); } // Creative mode only

    if (player.isSneaking())
    {
        this.toggleChunkProtection(player);
    }
    else
    {
        this.getFactionInfo(player);
    }

    return new ActionResult(EnumActionResult.PASS, stack);
}
项目: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;
    }
}
项目:Mods    文件:EntityAIUseRangedWeapon.java   
/**
 * Resets the task
 */
@Override
public void resetTask() {
    if ((this.entityHost.getHeldItem(EnumHand.MAIN_HAND).getItem() instanceof ItemWeapon) &&this.entityHost.getCapability(TF2weapons.WEAPONS_CAP, null).state != 0) {
        pressed = false;
        ((ItemWeapon) this.entityHost.getHeldItem(EnumHand.MAIN_HAND).getItem()).endUse(
                this.entityHost.getHeldItem(EnumHand.MAIN_HAND), this.entityHost, this.entityHost.world,
                this.entityHost.getCapability(TF2weapons.WEAPONS_CAP, null).state, 0);
        this.entityHost.getCapability(TF2weapons.WEAPONS_CAP, null).state = 0;
        TF2Util.sendTracking(new TF2Message.ActionMessage(0, entityHost), entityHost);
    }
    if (this.jump)
        this.entityHost.jump = false;
    this.attackTarget = null;
    this.comeCloser = 0;
    this.rangedAttackTime = -1;
}
项目:pnc-repressurized    文件:SemiBlockManager.java   
@SubscribeEvent
public void onInteraction(PlayerInteractEvent.RightClickBlock event) {
    ItemStack curItem = event.getEntityPlayer().getHeldItemMainhand();
    if (!event.getWorld().isRemote && event.getHand() == EnumHand.MAIN_HAND) {
        if (curItem.getItem() instanceof ISemiBlockItem) {
            boolean success = interact(event, curItem, event.getPos());

            //If the block can't be placed in the pos, then try to place it next to the block.
            if(!success && event.getFace() != null)
                success = interact(event, curItem, event.getPos().offset(event.getFace()));

            if(success) event.setCanceled(true);
        }
    } else if (event.getWorld().isRemote && curItem.getItem() instanceof ISemiBlockItem) {
        event.setCancellationResult(EnumActionResult.SUCCESS);
        event.setCanceled(true);
    }
}
项目:CustomWorldGen    文件:EntityLivingBase.java   
public void setActiveHand(EnumHand hand)
{
    ItemStack itemstack = this.getHeldItem(hand);

    if (itemstack != null && !this.isHandActive())
    {
        int duration = net.minecraftforge.event.ForgeEventFactory.onItemUseStart(this, itemstack, itemstack.getMaxItemUseDuration());
        if (duration <= 0) return;
        this.activeItemStack = itemstack;
        this.activeItemStackUseCount = duration;

        if (!this.worldObj.isRemote)
        {
            int i = 1;

            if (hand == EnumHand.OFF_HAND)
            {
                i |= 2;
            }

            this.dataManager.set(HAND_STATES, Byte.valueOf((byte)i));
        }
    }
}
项目:CustomWorldGen    文件:EntityLivingBase.java   
public void swingArm(EnumHand hand)
{
    ItemStack stack = this.getHeldItem(hand);
    if (stack != null && stack.getItem() != null)
    {
        if (stack.getItem().onEntitySwing(this, stack)) return;
    }
    if (!this.isSwingInProgress || this.swingProgressInt >= this.getArmSwingAnimationEnd() / 2 || this.swingProgressInt < 0)
    {
        this.swingProgressInt = -1;
        this.isSwingInProgress = true;
        this.swingingHand = hand;

        if (this.worldObj instanceof WorldServer)
        {
            ((WorldServer)this.worldObj).getEntityTracker().sendToAllTrackingEntity(this, new SPacketAnimation(this, hand == EnumHand.MAIN_HAND ? 0 : 3));
        }
    }
}
项目:RunicArcana    文件:ScriptActivationEventHandler.java   
@SubscribeEvent
public void rightClickEvent(PlayerInteractEvent.RightClickItem e)
{
    EntityPlayer player = e.getEntityPlayer();
    ItemStack RunicItem = null;
    if(EnchantmentHelper.getEnchantmentLevel(ModEnchantment.runicenchantment, player.getHeldItem(EnumHand.MAIN_HAND) )>0)
        RunicItem = player.getHeldItem(EnumHand.MAIN_HAND);
    else if(EnchantmentHelper.getEnchantmentLevel(ModEnchantment.runicenchantment, player.getHeldItem(EnumHand.OFF_HAND) )>0)
        RunicItem = player.getHeldItem(EnumHand.OFF_HAND);
    else return;

    CompiledSymbol[] script = ModDust.getScriptFromItem(RunicItem);
    if(script==null)return;

    if(player.isSneaking())
        new ScriptExecutor(script, player, RunicItem, ScriptExecutor.StartPoint.SNEAK_RIGHT);
    else
        new ScriptExecutor(script, player, RunicItem, ScriptExecutor.StartPoint.RIGHT_CLICK);

}
项目:Industrial-Foregoing    文件:BlockPlacerTile.java   
@Override
public float work() {
    if (WorkUtils.isDisabled(this.getBlockType())) return 0;
    List<BlockPos> blockPosList = BlockUtils.getBlockPosInAABB(getWorkingArea());
    for (BlockPos pos : blockPosList) {
        if (this.world.isAirBlock(pos)) {
            ItemStack stack = getFirstStackHasBlock();
            if (stack.isEmpty()) return 0;
            if (this.world.isAirBlock(pos)) {
                FakePlayer player = IndustrialForegoing.getFakePlayer(this.world);
                player.setHeldItem(EnumHand.MAIN_HAND, stack);
                EnumActionResult result = ForgeHooks.onPlaceItemIntoWorld(stack, player, world, pos, EnumFacing.UP, 0, 0, 0, EnumHand.MAIN_HAND);
                return result == EnumActionResult.SUCCESS ? 1 : 0;
            }
        }
    }

    return 0;
}
项目:Backmemed    文件:BlockSign.java   
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY)
{
    if (worldIn.isRemote)
    {
        return true;
    }
    else
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);
        return tileentity instanceof TileEntitySign ? ((TileEntitySign)tileentity).executeCommand(playerIn) : false;
    }
}
项目:Zombe-Modpack    文件:PlayerControllerMP.java   
public EnumActionResult processRightClick(EntityPlayer player, World worldIn, EnumHand stack)
{
    if (this.currentGameType == GameType.SPECTATOR)
    {
        return EnumActionResult.PASS;
    }
    else
    {
        this.syncCurrentPlayItem();
        this.connection.sendPacket(new CPacketPlayerTryUseItem(stack));
        ItemStack itemstack = player.getHeldItem(stack);

        if (player.getCooldownTracker().hasCooldown(itemstack.getItem()))
        {
            return EnumActionResult.PASS;
        }
        else
        {
            int i = itemstack.func_190916_E();
            ActionResult<ItemStack> actionresult = itemstack.useItemRightClick(worldIn, player, stack);
            ItemStack itemstack1 = actionresult.getResult();

            if (itemstack1 != itemstack || itemstack1.func_190916_E() != i)
            {
                player.setHeldItem(stack, itemstack1);
            }

            return actionresult.getType();
        }
    }
}
项目:Mods    文件:BlockCabinet.java   
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
        EnumHand hand, @Nullable EnumFacing side, float hitX, float hitY, float hitZ) {
    if (!worldIn.isRemote)
        FMLNetworkHandler.openGui(playerIn, TF2weapons.instance, 1, worldIn, pos.getX(), pos.getY(), pos.getZ());
    return true;
}
项目:Got-Wood    文件:BlockTreeTap.java   
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state,EntityPlayer playerIn, EnumHand hand, ItemStack heldItem,EnumFacing side, float hitX, float hitY, float hitZ) {
    super.onBlockActivated(worldIn, pos, state, playerIn, hand, heldItem,side, hitX, hitY, hitZ);
    if(worldIn.isRemote) {
          return false;
        }
    if(this.hasTileEntity(this.getDefaultState())){
        if(playerIn.getActiveHand() != null){
        ItemStack stack = playerIn.getHeldItem(playerIn.getActiveHand());
        if(stack != null){
            System.out.println("yep");
            if(stack.getItem() == Items.BUCKET){
                if(stack.stackSize > 0){
                    --stack.stackSize;

                    TileEntity te = worldIn.getTileEntity(pos);
                    if(te instanceof TileTreeTap){
                        ((TileTreeTap)te).hasBucket = true;
                        worldIn.setBlockState(pos, worldIn.getBlockState(pos).withProperty(HASBUCKET, true), 3);
                        return true;
                    }
                }
            }
        }
        }
    }
    return false;
}
项目:Randores2    文件:CraftiniumConverter.java   
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (!worldIn.isRemote) {
        playerIn.openGui(Randores.INSTANCE, RandoresGuiType.CONVERTER.ordinal(), worldIn, pos.getX(), pos.getY(), pos.getZ());
    }
    return true;
}
项目:TheOink    文件:OinkEntityEvents.java   
@SubscribeEvent
public static void baconInteract(PlayerInteractEvent.EntityInteract e) {
    EntityPlayer player = e.getEntityPlayer();
    if (!player.world.isRemote) {
        if (e.getTarget() instanceof OinkBacon) {
            if (player.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND).isEmpty() && player.isSneaking() && e.getHand() == EnumHand.MAIN_HAND && baconGlow) {
                baconGlow = false;
            } else if (player.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND).isEmpty() && player.isSneaking() && e.getHand() == EnumHand.MAIN_HAND && !baconGlow) {
                baconGlow = true;
            }
        }
    }
}
项目:Mods    文件:TF2Message.java   
@Override
public void toBytes(ByteBuf buf) {
    buf.writeDouble(x);
    buf.writeDouble(y);
    buf.writeDouble(z);
    buf.writeFloat(pitch);
    buf.writeFloat(yaw);
    buf.writeBoolean(hand == EnumHand.MAIN_HAND);
    buf.writeByte(state);
    if (target != null)
        for (RayTraceResult mop : target) {
            if (mop.entityHit != null) {
                buf.writeBoolean(true);
                buf.writeInt(mop.entityHit.getEntityId());
                // if(mop.hitVec!=null){
                // buf.writeFloat((float) mop.hitVec.x);
                // buf.writeFloat((float) mop.hitVec.y);
                // buf.writeFloat((float) mop.hitVec.z);
                // }
                // buf.writeInt(mop.entityHit.getEntityId());
                buf.writeBoolean(((float[]) mop.hitInfo)[0] == 1);
            } else {
                buf.writeBoolean(false);
                buf.writeInt(mop.getBlockPos().getX());
                buf.writeInt(mop.getBlockPos().getY());
                buf.writeInt(mop.getBlockPos().getZ());
            }
            buf.writeFloat(((float[]) mop.hitInfo)[1]);

        }
}
项目:CustomWorldGen    文件:BlockRedstoneRepeater.java   
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (!playerIn.capabilities.allowEdit)
    {
        return false;
    }
    else
    {
        worldIn.setBlockState(pos, state.cycleProperty(DELAY), 3);
        return true;
    }
}
项目:PurificatiMagicae    文件:BlockAbstractSingleItemHorizontal.java   
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer p, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    TileEntity te = worldIn.getTileEntity(pos);
    if (te != null && te instanceof TileAbstractSingleItem)
    {
        TileAbstractSingleItem tasi = (TileAbstractSingleItem) te;
        IItemHandler handler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
        ItemStack held = p.getHeldItem(hand);
        if (!p.isSneaking() && (tasi.isItemValid(held)))
        {
            ItemStack st = handler.insertItem(0, held, false);
            if(!ItemStack.areItemStacksEqualUsingNBTShareTag(st, held))
            {
                p.setHeldItem(hand, st);
                return true;
            }
        }
        if (p.isSneaking() && !handler.getStackInSlot(0).isEmpty())
        {
            p.inventory.addItemStackToInventory(handler.getStackInSlot(0));
            ItemStackUtils.extractAll(handler, 0);
            return true;
        }
        openClientGui(worldIn, pos, state, p, hand, facing, hitX, hitY, hitZ, tasi);
        return true;
    }
    return false;
}
项目:Defier    文件:DefierBlock.java   
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    if (world.isRemote) {
        return true;
    }
    TileEntity te = world.getTileEntity(pos);
    if (!(te instanceof DefierTileEntity)) {
        return false;
    }
    player.openGui(Defier.INSTANCE, 0, world, pos.getX(), pos.getY(), pos.getZ());
    return true;
}
项目:harshencastle    文件:BloodCollector.java   
public boolean remove(EntityPlayer player, EnumHand hand, int amount)
{

    if(player.capabilities.isCreativeMode)
        return true;
    ItemStack stack = player.getHeldItem(hand);
    NBTTagCompound nbt = getNBT(stack);
    if(nbt.getInteger("Blood") - amount < 0)
        return false;
    nbt.setInteger("Blood", nbt.getInteger("Blood") - amount);
    stack.setItemDamage(metaChange(nbt));
    return true;
}
项目:refinedstorageaddons    文件:BlockInfiniteWirelessTransmitter.java   
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    if (!world.isRemote) {
        tryOpenNetworkGui(RSAddonsGui.INFINITE_WIRELESS_TRANSMITTER, player, world, pos, side);
    }

    return true;
}
项目:Backmemed    文件:BlockWorkbench.java   
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY)
{
    if (worldIn.isRemote)
    {
        return true;
    }
    else
    {
        playerIn.displayGui(new BlockWorkbench.InterfaceCraftingTable(worldIn, pos));
        playerIn.addStat(StatList.CRAFTING_TABLE_INTERACTION);
        return true;
    }
}
项目:Backmemed    文件:BlockTrapDoor.java   
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY)
{
    if (this.blockMaterial == Material.IRON)
    {
        return false;
    }
    else
    {
        state = state.cycleProperty(OPEN);
        worldIn.setBlockState(pos, state, 2);
        this.playSound(playerIn, worldIn, pos, ((Boolean)state.getValue(OPEN)).booleanValue());
        return true;
    }
}
项目:MineCamera    文件:EventLoader.java   
@SubscribeEvent
public void entityInteract(EntityInteract event) {
    if (event.getEntityPlayer().getEntityData().hasKey("renderViewCamera")) {
        event.setCanceled(true);
        if (event.getSide().isClient() && event.getHand().equals(EnumHand.MAIN_HAND)
                && event.getItemStack() == null) {
            System.out.println("EntityInteract,HandType=" + event.getHand());
            ActiveTripod(Minecraft.getMinecraft().thePlayer.getName(),
                    ((EntityTripod) event.getWorld()
                            .getEntityByID(event.getEntityPlayer().getEntityData().getInteger("renderViewCamera")))
                                    .getDelay());
        }
        return;
    }
    if (event.getTarget() instanceof EntityTripod) {
        Entity target = ((PlayerInteractEvent.EntityInteract) event).getTarget();
        EntityPlayer player = event.getEntityPlayer();
        if (!player.isSneaking()) {
            if (player.inventory.armorInventory[3] != null
                    && player.inventory.armorInventory[3].getItem() instanceof ItemGlassesHelmet) {
                if (player.getEntityWorld().isRemote) {
                    // System.out.println("123");
                    Minecraft.getMinecraft().setRenderViewEntity(target);
                    Minecraft.getMinecraft().ingameGUI.setRecordPlaying(new TextComponentTranslation("chat.tripod.info"), false);
                }
                player.getEntityData().setInteger("renderViewCamera", target.getEntityId());
            }else if(!event.getWorld().isRemote&&event.getHand().equals(EnumHand.MAIN_HAND)){
                player.addChatComponentMessage(new TextComponentTranslation("chat.tripod.mustuseglass"));
            }
        } else {
            player.getEntityData().setInteger("usingGui", target.getEntityId());
            player.openGui(MineCamera.instance, GuiElementLoader.GUI_TRIPOD_CAMERA, target.getEntityWorld(),
                    (int) target.posX, (int) target.posY, (int) target.posZ);
        }
    }
}
项目:UniversalRemote    文件:EntityPlayerProxy.java   
@Override
public void setActiveHand(EnumHand hand) {
    if (m_realPlayer == null) {
        super.setActiveHand(hand);
    } else {
        m_realPlayer.setActiveHand(hand);
    }
}
项目:Defier    文件:CompressorBlock.java   
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    if (world.isRemote) {
        return true;
    }
    TileEntity te = world.getTileEntity(pos);
    if (!(te instanceof CompressorTileEntity)) {
        return false;
    }
    player.openGui(Defier.INSTANCE, 0, world, pos.getX(), pos.getY(), pos.getZ());
    return true;
}
项目:harshencastle    文件:GlassContainer.java   
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand,
        EnumFacing facing, float hitX, float hitY, float hitZ) {
    if(player.getHeldItem(hand).getMetadata() != 0)
        return EnumActionResult.PASS;
    if(pos.getY() == 0)
        player.setHeldItem(hand, new ItemStack(this, 1, 1));
    return EnumActionResult.SUCCESS;
}
项目: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);
}
项目:Mods    文件:SpinToWin.java   
@SideOnly(Side.CLIENT)
public boolean addToBlacklist(ItemStack stack){
    if(stack.useItemRightClick(Minecraft.getMinecraft().world, new EntityOtherPlayerMP(Minecraft.getMinecraft().world, new GameProfile(null, "fake")), EnumHand.MAIN_HAND).getType()!=EnumActionResult.PASS){
        Property blackList=conf.get("config", "Blacklist items", new String[0]);
        blackList.set(Arrays.copyOf(blackList.getStringList(),blackList.getStringList().length+1));
        blackList.getStringList()[blackList.getStringList().length-1]=stack.getItem().getRegistryName().toString();
        syncConfig();
        return true;
    }
    return false;
}
项目:Randores2    文件:RandoresItemHelper.java   
public static IBlockState getStateForOrePlacementImpl(Block self, World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) {
    ItemStack stack = placer.getHeldItem(hand);
    if (RandoresItemData.hasData(stack)) {
        return RandoresWorldData.delegate(new RandoresItemData(stack), def -> self.getDefaultState().withProperty(RandoresOre.HARVEST_LEVEL, def.getOre().getHarvestLevel()), self::getDefaultState);
    }
    return self.getDefaultState();
}
项目:MeeCreeps    文件:CreepCubeItem.java   
public static ItemStack getCube(EntityPlayer player) {
    ItemStack heldItem = player.getHeldItem(EnumHand.MAIN_HAND);
    if (heldItem.getItem() != ModItems.creepCubeItem) {
        heldItem = player.getHeldItem(EnumHand.OFF_HAND);
        if (heldItem.getItem() != ModItems.creepCubeItem) {
            // Something went wrong
            return ItemStack.EMPTY;
        }
    }
    return heldItem;
}