Search in sources :

Example 31 with ActionResult

use of net.minecraft.util.ActionResult in project LogisticsPipes by RS485.

the class ItemHUDArmor method onItemRightClick.

@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand handIn) {
    ItemStack stack = player.getHeldItem(handIn);
    if (MainProxy.isClient(world)) {
        return new ActionResult<>(EnumActionResult.PASS, stack);
    }
    useItem(player, world);
    return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Example 32 with ActionResult

use of net.minecraft.util.ActionResult in project LogisticsPipes by RS485.

the class ItemPipeController method onItemRightClick.

@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand handIn) {
    ItemStack stack = player.getHeldItem(handIn);
    if (MainProxy.isClient(world)) {
        return new ActionResult<>(EnumActionResult.PASS, stack);
    }
    useItem(player, world);
    return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
Also used : EnumActionResult(net.minecraft.util.EnumActionResult) ActionResult(net.minecraft.util.ActionResult) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Example 33 with ActionResult

use of net.minecraft.util.ActionResult in project ImmersiveEngineering by BluSunrize.

the class ItemSkyhook method onItemRightClick.

/*@Override
	public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack)
	{
		Multimap multimap = super.getAttributeModifiers(slot, stack);
		if(slot == EntityEquipmentSlot.MAINHAND)
		{
			float dmg = 5 + ItemNBTHelper.getFloat(stack, "fallDamageBoost");
			multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", dmg, 0));
		}
		return multimap;
	}*/
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
    ItemStack stack = player.getHeldItem(hand);
    if (player.getCooldownTracker().hasCooldown(this))
        return new ActionResult<>(EnumActionResult.PASS, stack);
    if (player.isSneaking()) {
        boolean limitSpeed = toggleSpeedLimit(stack);
        if (limitSpeed)
            player.sendStatusMessage(new TextComponentTranslation("chat.immersiveengineering.info.skyhookLimited"), true);
        else
            player.sendStatusMessage(new TextComponentTranslation("chat.immersiveengineering.info.skyhookUnlimited"), true);
    } else {
        SkyhookUserData data = player.getCapability(SKYHOOK_USER_DATA, EnumFacing.UP);
        assert data != null;
        if (data.hook != null && !world.isRemote) {
            data.dismount();
            IELogger.logger.info("Player left voluntarily");
        } else {
            data.startHolding();
            player.setActiveHand(hand);
        }
    }
    return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) SkyhookUserData(blusunrize.immersiveengineering.api.CapabilitySkyhookData.SkyhookUserData) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Example 34 with ActionResult

use of net.minecraft.util.ActionResult in project ICBM-Classic by BuiltBrokenModding.

the class ItemAntidote method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
    ItemStack itemstack = playerIn.getHeldItem(handIn);
    playerIn.setActiveHand(handIn);
    return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack);
}
Also used : EnumActionResult(net.minecraft.util.EnumActionResult) ActionResult(net.minecraft.util.ActionResult) ItemStack(net.minecraft.item.ItemStack)

Example 35 with ActionResult

use of net.minecraft.util.ActionResult in project ICBM-Classic by BuiltBrokenModding.

the class ItemRadarGun method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand handIn) {
    if (// also clear the gps coord if the play is shift-rightclicking in the air
    player.isSneaking()) {
        if (!world.isRemote) {
            ItemStack stack = player.getHeldItem(handIn);
            stack.setTagCompound(null);
            stack.setItemDamage(0);
            LanguageUtility.addChatToPlayer(player, "gps.cleared.name");
            player.inventoryContainer.detectAndSendChanges();
        }
        return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, player.getHeldItem(handIn));
    }
    if (world.isRemote) {
        RayTraceResult objectMouseOver = player.rayTrace(200, 1);
        if (objectMouseOver.typeOfHit != RayTraceResult.Type.MISS) {
            // TODO add message saying that the gps target is out of range.
            final TileEntity tileEntity = world.getTileEntity(objectMouseOver.getBlockPos());
            if (!(ICBMClassicHelpers.isLauncher(tileEntity, null))) {
                ICBMClassic.packetHandler.sendToServer(new PacketPlayerItem(player).addData(objectMouseOver.getBlockPos()));
            }
        }
    }
    return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, player.getHeldItem(handIn));
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) RayTraceResult(net.minecraft.util.math.RayTraceResult) ItemStack(net.minecraft.item.ItemStack) PacketPlayerItem(icbm.classic.lib.network.packet.PacketPlayerItem)

Aggregations

ActionResult (net.minecraft.util.ActionResult)311 ItemStack (net.minecraft.item.ItemStack)240 EnumActionResult (net.minecraft.util.EnumActionResult)221 BlockPos (net.minecraft.util.math.BlockPos)56 Nonnull (javax.annotation.Nonnull)46 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)45 RayTraceResult (net.minecraft.util.math.RayTraceResult)39 Vec3d (net.minecraft.util.math.Vec3d)18 IBlockState (net.minecraft.block.state.IBlockState)16 TextComponentString (net.minecraft.util.text.TextComponentString)16 Entity (net.minecraft.entity.Entity)15 Inject (org.spongepowered.asm.mixin.injection.Inject)15 Block (net.minecraft.block.Block)14 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)14 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)14 World (net.minecraft.world.World)13 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)11 EntityPlayer (net.minecraft.entity.player.EntityPlayer)10 PlayerEntity (net.minecraft.entity.player.PlayerEntity)8 CompoundNBT (net.minecraft.nbt.CompoundNBT)8