Search in sources :

Example 36 with ActionResult

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

the class ItemRocketLauncher method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer player, EnumHand handIn) {
    ItemStack itemstack = player.getHeldItem(handIn);
    long clickMs = System.currentTimeMillis();
    if (clickTimePlayer.containsKey(player.getName())) {
        if (clickMs - clickTimePlayer.get(player.getName()) < firingDelay) {
            // TODO play weapon empty click audio to note the gun is reloading
            return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemstack);
        }
    }
    player.setActiveHand(handIn);
    return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) ItemStack(net.minecraft.item.ItemStack)

Example 37 with ActionResult

use of net.minecraft.util.ActionResult in project BuildCraft by BuildCraft.

the class PipeFlowFluids method tryExtractFluidInternal.

private ActionResult<FluidStack> tryExtractFluidInternal(int millibuckets, EnumFacing from, FluidExtractor extractor, boolean simulate) {
    if (from == null || millibuckets <= 0) {
        return FAILED_EXTRACT;
    }
    IFluidHandler fluidHandler = pipe.getHolder().getCapabilityFromPipe(from, CapUtil.CAP_FLUIDS);
    if (fluidHandler == null) {
        // FIXME: WRONG PLACE!!!
        return PASSED_EXTRACT;
    }
    Section section = sections.get(EnumPipePart.fromFacing(from));
    Section middle = sections.get(EnumPipePart.CENTER);
    millibuckets = Math.min(millibuckets, capacity * 2 - section.amount - middle.amount);
    if (millibuckets <= 0) {
        return FAILED_EXTRACT;
    }
    FluidStack toAdd = extractor.extract(millibuckets, currentFluid, fluidHandler);
    if (toAdd == null || toAdd.amount <= 0) {
        return FAILED_EXTRACT;
    }
    millibuckets = toAdd.amount;
    if (currentFluid == null && !simulate) {
        setFluid(toAdd);
    }
    int reallyFilled = section.fillInternal(millibuckets, !simulate);
    int leftOver = millibuckets - reallyFilled;
    reallyFilled += middle.fillInternal(leftOver, !simulate);
    if (!simulate) {
        section.ticksInDirection = COOLDOWN_INPUT;
    }
    if (reallyFilled != millibuckets) {
        BCLog.logger.warn(// 
        "[tryExtractFluidAdv] Filled " + reallyFilled + " != extracted " + millibuckets + " (handler = " + fluidHandler.getClass() + ") @" + pipe.getHolder().getPipePos());
    }
    return new ActionResult<>(EnumActionResult.SUCCESS, toAdd);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) FluidStack(net.minecraftforge.fluids.FluidStack) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler)

Example 38 with ActionResult

use of net.minecraft.util.ActionResult in project BuildCraft by BuildCraft.

the class ItemSchematicSingle method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack stack = StackUtil.asNonNull(player.getHeldItem(hand));
    if (world.isRemote) {
        return new ActionResult<>(EnumActionResult.PASS, stack);
    }
    if (player.isSneaking()) {
        NBTTagCompound itemData = NBTUtilBC.getItemData(stack);
        itemData.removeTag(NBT_KEY);
        if (itemData.hasNoTags()) {
            stack.setTagCompound(null);
        }
        stack.setItemDamage(DAMAGE_CLEAN);
        return new ActionResult<>(EnumActionResult.SUCCESS, stack);
    }
    return new ActionResult<>(EnumActionResult.PASS, stack);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 39 with ActionResult

use of net.minecraft.util.ActionResult in project BuildCraft by BuildCraft.

the class ItemMapLocation method clearMarkerData.

private static ActionResult<ItemStack> clearMarkerData(@Nonnull ItemStack stack) {
    if (MapLocationType.getFromStack(stack) == MapLocationType.CLEAN) {
        return new ActionResult<>(EnumActionResult.PASS, stack);
    }
    NBTTagCompound nbt = NBTUtilBC.getItemData(stack);
    for (String key : STORAGE_TAGS) {
        nbt.removeTag(key);
    }
    if (nbt.hasNoTags()) {
        stack.setTagCompound(null);
    }
    MapLocationType.CLEAN.setToStack(stack);
    return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 40 with ActionResult

use of net.minecraft.util.ActionResult in project Almura by AlmuraDev.

the class CollectorWand method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer player, EnumHand handIn) {
    if (!worldIn.isRemote) {
        final Player spongePlayer = (org.spongepowered.api.entity.living.player.Player) player;
        if (!spongePlayer.hasPermission("almura.item.collector_wand") || spongePlayer.hasPermission("almura.singleplayer") && MalisisCore.isObfEnv) {
            spongePlayer.sendMessage(Text.of(TextColors.WHITE + "Access denied, missing permission: ", TextColors.AQUA, "almura.item.light_repair_wand", TextColors.WHITE, "."));
            return new ActionResult<>(EnumActionResult.FAIL, player.getHeldItem(handIn));
        } else {
            double radius = 10;
            List<EntityItem> items = worldIn.getEntitiesWithinAABB(EntityItem.class, player.getEntityBoundingBox().grow(radius, radius, radius));
            for (EntityItem it : items) {
                double distX = player.posX - it.posX;
                double distZ = player.posZ - it.posZ;
                double distY = it.posY + 1.5D - player.posY;
                double dir = Math.atan2(distZ, distX);
                double speed = 1F / it.getDistance(player) * 2;
                if (distY < 0) {
                    it.motionY += speed;
                }
                it.motionX = Math.cos(dir) * speed;
                it.motionZ = Math.sin(dir) * speed;
            }
        }
    }
    return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(handIn));
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) Player(org.spongepowered.api.entity.living.player.Player) ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) EntityItem(net.minecraft.entity.item.EntityItem)

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