Search in sources :

Example 11 with ActionResult

use of net.minecraft.util.ActionResult in project ConvenientAdditions by Necr0.

the class ItemEnderPlate method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack itemStack = player.getHeldItem(hand);
    int dmg = itemStack.getItemDamage();
    if (!world.isRemote)
        if (dmg == 0) {
            itemStack.setItemDamage(1);
        } else
            itemStack.setItemDamage(0);
    return new ActionResult<>(EnumActionResult.SUCCESS, itemStack);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) ItemStack(net.minecraft.item.ItemStack)

Example 12 with ActionResult

use of net.minecraft.util.ActionResult in project ConvenientAdditions by Necr0.

the class ItemSunstone method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack itemStack = player.getHeldItem(hand);
    int dmg = itemStack.getItemDamage();
    if (!world.isRemote)
        if (dmg == 0) {
            itemStack.setItemDamage(1);
        } else
            itemStack.setItemDamage(0);
    return new ActionResult<>(EnumActionResult.SUCCESS, itemStack);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) ItemStack(net.minecraft.item.ItemStack)

Example 13 with ActionResult

use of net.minecraft.util.ActionResult in project Pearcel-Mod by MiningMark48.

the class ItemExperiencePearcel method onItemRightClick.

@Override
public ActionResult onItemRightClick(ItemStack item, World world, EntityPlayer player, EnumHand hand) {
    if (!item.hasTagCompound()) {
        item.setTagCompound(new NBTTagCompound());
        item.getTagCompound().setInteger("playerXP", 0);
    }
    if (!player.isSneaking()) {
        int xpToGather = player.experienceLevel + item.getTagCompound().getInteger("playerXP");
        player.experienceLevel = xpToGather;
        item.getTagCompound().setInteger("playerXP", 0);
        player.playSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, 0.2F, rand.nextFloat() * 2.5F);
        return new ActionResult(EnumActionResult.PASS, item);
    } else {
        int xpToStore = player.experienceLevel + item.getTagCompound().getInteger("playerXP");
        item.getTagCompound().setInteger("playerXP", xpToStore);
        player.experienceLevel = 0;
        player.playSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, 0.2F, rand.nextFloat() * 2.5F);
        player.addStat(Achievements.achievement_use_experience_pearcel);
        return new ActionResult(EnumActionResult.PASS, item);
    }
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 14 with ActionResult

use of net.minecraft.util.ActionResult in project Pearcel-Mod by MiningMark48.

the class ItemLivingMagnet method onItemRightClick.

@Override
public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
    if (!stack.hasTagCompound()) {
        stack.setTagCompound(new NBTTagCompound());
        stack.getTagCompound().setBoolean("enabled", false);
        stack.getTagCompound().setString("mode", "Attracts");
    }
    if (!world.isRemote) {
        if (!player.isSneaking()) {
            if (stack.getTagCompound().getBoolean("enabled")) {
                stack.getTagCompound().setBoolean("enabled", false);
                player.sendMessage(new TextComponentString(TextFormatting.DARK_RED + Translate.toLocal("chat.item.living_magnet.disabled")));
            } else {
                stack.getTagCompound().setBoolean("enabled", true);
                player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("chat.item.living_magnet.enabled")));
            }
        } else {
            if (stack.getTagCompound().getString("mode").equalsIgnoreCase("attracts")) {
                stack.getTagCompound().setString("mode", "Repels");
                player.sendMessage(new TextComponentString(TextFormatting.RED + Translate.toLocal("chat.item.living_magnet.repels")));
            } else {
                stack.getTagCompound().setString("mode", "Attracts");
                player.sendMessage(new TextComponentString(TextFormatting.GREEN + Translate.toLocal("chat.item.living_magnet.attracts")));
            }
        }
    }
    return new ActionResult(EnumActionResult.SUCCESS, stack);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 15 with ActionResult

use of net.minecraft.util.ActionResult in project Pearcel-Mod by MiningMark48.

the class ItemMatterFabricator method onItemRightClick.

@Override
public ActionResult onItemRightClick(ItemStack item, World world, EntityPlayer player, EnumHand hand) {
    if (player.isSneaking()) {
        if (!item.hasTagCompound()) {
            item.setTagCompound(new NBTTagCompound());
            item.getTagCompound().setInteger("mode", 1);
        } else {
            if (item.getTagCompound().getInteger("mode") == 1) {
                item.getTagCompound().setInteger("mode", 2);
                if (!world.isRemote) {
                    player.sendMessage(new TextComponentTranslation(TextFormatting.GOLD + (Translate.toLocal("chat.item.mf.modeChange"))));
                }
            } else {
                item.getTagCompound().setInteger("mode", 1);
                if (!world.isRemote) {
                    player.sendMessage(new TextComponentTranslation(TextFormatting.GOLD + (Translate.toLocal("chat.item.mf.modeChange"))));
                }
            }
        }
        return new ActionResult(EnumActionResult.PASS, item);
    } else {
        return new ActionResult(EnumActionResult.PASS, item);
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Aggregations

ActionResult (net.minecraft.util.ActionResult)25 EnumActionResult (net.minecraft.util.EnumActionResult)25 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)16 ItemStack (net.minecraft.item.ItemStack)12 TextComponentString (net.minecraft.util.text.TextComponentString)7 BlockPos (net.minecraft.util.math.BlockPos)4 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)4 DimensionInformation (mcjty.rftoolsdim.dimensions.DimensionInformation)2 RfToolsDimensionManager (mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)2 RayTraceResult (net.minecraft.util.math.RayTraceResult)2 Vec3d (net.minecraft.util.math.Vec3d)2 Connection (blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection)1 EntityEnderPearcel (com.miningmark48.pearcelmod.entity.EntityEnderPearcel)1 EnumBeeChromosome (forestry.api.apiculture.EnumBeeChromosome)1 Random (java.util.Random)1 Nonnull (javax.annotation.Nonnull)1 DimensionStorage (mcjty.rftoolsdim.dimensions.DimensionStorage)1 EnumGlyphType (mdc.voodoocraft.util.EnumGlyphType)1 Block (net.minecraft.block.Block)1 Entity (net.minecraft.entity.Entity)1