Search in sources :

Example 41 with ActionResult

use of net.minecraft.util.ActionResult in project MorePlanets by SteveKunG.

the class ItemInfectedPurloniteBomb method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack itemStack = player.getHeldItem(hand);
    if (!player.capabilities.isCreativeMode) {
        itemStack.shrink(1);
    }
    world.playSound(null, player.getPosition(), SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
    player.swingArm(hand);
    if (!world.isRemote) {
        EntityInfectedPurloniteBomb bomb = new EntityInfectedPurloniteBomb(world, player);
        bomb.shoot(player, player.rotationPitch, player.rotationYaw, 0.0F, 1.5F, 1.0F);
        world.spawnEntity(bomb);
    }
    player.addStat(StatList.getObjectUseStats(this));
    return new ActionResult<>(EnumActionResult.SUCCESS, itemStack);
}
Also used : EnumActionResult(net.minecraft.util.EnumActionResult) ActionResult(net.minecraft.util.ActionResult) ItemStack(net.minecraft.item.ItemStack) EntityInfectedPurloniteBomb(stevekung.mods.moreplanets.planets.diona.entity.EntityInfectedPurloniteBomb)

Example 42 with ActionResult

use of net.minecraft.util.ActionResult in project MorePlanets by SteveKunG.

the class ItemInfectedEgg method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack itemStack = player.getHeldItem(hand);
    if (!player.capabilities.isCreativeMode) {
        itemStack.shrink(1);
    }
    world.playSound(null, player.getPosition(), SoundEvents.ENTITY_EGG_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
    player.swingArm(hand);
    if (!world.isRemote) {
        EntityInfectedEgg entityegg = new EntityInfectedEgg(world, player);
        entityegg.shoot(player, player.rotationPitch, player.rotationYaw, 0.0F, 1.5F, 1.0F);
        world.spawnEntity(entityegg);
    }
    player.addStat(StatList.getObjectUseStats(this));
    return new ActionResult<>(EnumActionResult.SUCCESS, itemStack);
}
Also used : EnumActionResult(net.minecraft.util.EnumActionResult) ActionResult(net.minecraft.util.ActionResult) EntityInfectedEgg(stevekung.mods.moreplanets.planets.nibiru.entity.projectile.EntityInfectedEgg) ItemStack(net.minecraft.item.ItemStack)

Example 43 with ActionResult

use of net.minecraft.util.ActionResult in project MorePlanets by SteveKunG.

the class ItemSpaceWarperCore method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack itemStack = player.getHeldItem(hand);
    if (!player.world.isRemote) {
        if (player.isSneaking()) {
            if (GCCoreUtil.getDimensionID(world) == 0 || world.provider instanceof IGalacticraftWorldProvider) {
                if (!itemStack.hasTagCompound()) {
                    itemStack.setTagCompound(new NBTTagCompound());
                    itemStack.getTagCompound().setInteger("DimensionID", GCCoreUtil.getDimensionID(world));
                    itemStack.getTagCompound().setString("DimensionName", WorldUtil.getProviderForDimensionServer(GCCoreUtil.getDimensionID(world)).getDimensionType().getName());
                    itemStack.getTagCompound().setInteger("X", MathHelper.floor(player.posX));
                    itemStack.getTagCompound().setInteger("Y", MathHelper.floor(player.posY));
                    itemStack.getTagCompound().setInteger("Z", MathHelper.floor(player.posZ));
                    itemStack.getTagCompound().setFloat("Pitch", player.rotationPitch);
                    itemStack.getTagCompound().setFloat("Yaw", player.rotationYaw);
                    player.sendMessage(JsonUtils.create(LangUtils.translate("gui.warp_core_data_add.message")));
                    return new ActionResult<>(EnumActionResult.SUCCESS, itemStack);
                } else {
                    player.sendMessage(JsonUtils.create(LangUtils.translate("gui.warp_core_data_add_fail.message")));
                }
            } else {
                player.sendMessage(JsonUtils.create(LangUtils.translate("gui.space_dimension_only.message")).setStyle(JsonUtils.red()));
            }
        }
    }
    return new ActionResult<>(EnumActionResult.PASS, itemStack);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 44 with ActionResult

use of net.minecraft.util.ActionResult in project MorePlanets by SteveKunG.

the class ItemCreativeSpaceKit method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    if (player instanceof EntityPlayerMP) {
        GCPlayerStats stats = GCPlayerStats.get(player);
        InventoryExtended inv = stats.getExtendedInventory();
        // Oxygen Mask
        inv.setInventorySlotContents(0, new ItemStack(GCItems.oxMask));
        // Oxygen Gear
        inv.setInventorySlotContents(1, new ItemStack(GCItems.oxygenGear));
        // Creative Oxygen Tank
        inv.setInventorySlotContents(2, new ItemStack(GCItems.oxygenCanisterInfinite));
        // Creative Oxygen Tank
        inv.setInventorySlotContents(3, new ItemStack(GCItems.oxygenCanisterInfinite));
        // Parachute
        inv.setInventorySlotContents(4, new ItemStack(GCItems.parachute));
        // Frequency Module
        inv.setInventorySlotContents(5, new ItemStack(GCItems.basicItem, 1, 19));
        // Thermal Armor Tier 2
        inv.setInventorySlotContents(6, new ItemStack(VenusItems.thermalPaddingTier2, 1, 0));
        // Thermal Armor Tier 2
        inv.setInventorySlotContents(7, new ItemStack(VenusItems.thermalPaddingTier2, 1, 1));
        // Thermal Armor Tier 2
        inv.setInventorySlotContents(8, new ItemStack(VenusItems.thermalPaddingTier2, 1, 2));
        // Thermal Armor Tier 2
        inv.setInventorySlotContents(9, new ItemStack(VenusItems.thermalPaddingTier2, 1, 3));
        // Shield Controller
        inv.setInventorySlotContents(10, new ItemStack(VenusItems.basicItem, 1, 0));
    }
    return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand));
}
Also used : InventoryExtended(micdoodle8.mods.galacticraft.core.inventory.InventoryExtended) ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack)

Example 45 with ActionResult

use of net.minecraft.util.ActionResult in project Gaspunk by Ladysnake.

the class ItemGlassTube method onItemRightClick.

@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, @Nonnull EnumHand handIn) {
    ItemStack itemstack = playerIn.getHeldItem(handIn);
    RayTraceResult raytraceresult = this.rayTrace(worldIn, playerIn, true);
    // noinspection ConstantConditions
    if (raytraceresult == null) {
        return new ActionResult<>(EnumActionResult.PASS, itemstack);
    } else {
        if (raytraceresult.typeOfHit == RayTraceResult.Type.BLOCK) {
            BlockPos blockpos = raytraceresult.getBlockPos();
            if (!worldIn.isBlockModifiable(playerIn, blockpos) || !playerIn.canPlayerEdit(blockpos.offset(raytraceresult.sideHit), raytraceresult.sideHit, itemstack)) {
                return new ActionResult<>(EnumActionResult.PASS, itemstack);
            }
            if (worldIn.getBlockState(blockpos).getMaterial() == Material.WATER) {
                worldIn.playSound(playerIn, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ITEM_BOTTLE_FILL, SoundCategory.NEUTRAL, 1.0F, 1.0F);
                return new ActionResult<>(EnumActionResult.SUCCESS, this.turnBottleIntoItem(itemstack, playerIn, ((ItemGasTube) ModItems.GAS_TUBE).getItemStackFor(ModGases.AIR)));
            }
        }
        return new ActionResult<>(EnumActionResult.PASS, itemstack);
    }
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) RayTraceResult(net.minecraft.util.math.RayTraceResult) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

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