Search in sources :

Example 6 with ActionResult

use of net.minecraft.util.ActionResult in project VoodooCraft by Mod-DevCafeTeam.

the class ItemChalk method onItemRightClick.

/**
	 * Changes glyphtype NBT, cycles through all in the {@link EnumGlyphType}
	 */
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
    if (playerIn.isSneaking()) {
        NBTTagCompound nbt = NBTHelper.getTagCompound(itemStackIn);
        EnumGlyphType newtype = EnumGlyphType.byIndex(nbt.getInteger(KEY_GLYPH)).next();
        nbt.setInteger(KEY_GLYPH, newtype.ordinal());
        itemStackIn.setTagCompound(nbt);
        return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn);
    }
    return super.onItemRightClick(itemStackIn, worldIn, playerIn, hand);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EnumGlyphType(mdc.voodoocraft.util.EnumGlyphType)

Example 7 with ActionResult

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

the class ItemPearcelArrow method onItemRightClick.

@Override
public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
    Random rand = new Random();
    if (player.inventory.hasItemStack(infItem)) {
        if (!stack.hasTagCompound()) {
            stack.setTagCompound(new NBTTagCompound());
            stack.getTagCompound().setBoolean("inf", true);
            player.inventory.clearMatchingItems(infItem.getItem(), 0, 1, null);
            player.playSound(SoundEvents.ENTITY_PLAYER_LEVELUP, 2.0F, rand.nextFloat() * 2.5F);
            if (!world.isRemote) {
                player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("chat.item.pearcel_arrow.upgraded.inf")));
            }
        } else {
            stack.getTagCompound().setBoolean("inf", true);
            player.inventory.clearMatchingItems(infItem.getItem(), 0, 1, null);
            player.playSound(SoundEvents.ENTITY_PLAYER_LEVELUP, 2.0F, rand.nextFloat() * 2.5F);
            if (!world.isRemote) {
                player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("chat.item.pearcel_arrow.upgraded.inf")));
            }
        }
    }
    if (player.inventory.hasItemStack(powItem)) {
        if (!stack.hasTagCompound()) {
            stack.setTagCompound(new NBTTagCompound());
            stack.getTagCompound().setBoolean("pow", true);
            player.inventory.clearMatchingItems(powItem.getItem(), 0, 1, null);
            player.playSound(SoundEvents.ENTITY_PLAYER_LEVELUP, 2.0F, rand.nextFloat() * 2.5F);
            if (!world.isRemote) {
                player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("chat.item.pearcel_arrow.upgraded.pow")));
            }
        } else {
            stack.getTagCompound().setBoolean("pow", true);
            player.inventory.clearMatchingItems(powItem.getItem(), 0, 1, null);
            player.playSound(SoundEvents.ENTITY_PLAYER_LEVELUP, 2.0F, rand.nextFloat() * 2.5F);
            if (!world.isRemote) {
                player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("chat.item.pearcel_arrow.upgraded.pow")));
            }
        }
    }
    if (player.inventory.hasItemStack(knockItem)) {
        if (!stack.hasTagCompound()) {
            stack.setTagCompound(new NBTTagCompound());
            stack.getTagCompound().setBoolean("knock", true);
            player.inventory.clearMatchingItems(knockItem.getItem(), 0, 1, null);
            player.playSound(SoundEvents.ENTITY_PLAYER_LEVELUP, 2.0F, rand.nextFloat() * 2.5F);
            if (!world.isRemote) {
                player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("chat.item.pearcel_arrow.upgraded.knock")));
            }
        } else {
            stack.getTagCompound().setBoolean("knock", true);
            player.inventory.clearMatchingItems(knockItem.getItem(), 0, 1, null);
            player.playSound(SoundEvents.ENTITY_PLAYER_LEVELUP, 2.0F, rand.nextFloat() * 2.5F);
            if (!world.isRemote) {
                player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("chat.item.pearcel_arrow.upgraded.knock")));
            }
        }
    }
    if (player.inventory.hasItemStack(zoomItem)) {
        if (!stack.hasTagCompound()) {
            stack.setTagCompound(new NBTTagCompound());
            stack.getTagCompound().setBoolean("zoom", true);
            player.inventory.clearMatchingItems(zoomItem.getItem(), 0, 1, null);
            player.playSound(SoundEvents.ENTITY_PLAYER_LEVELUP, 2.0F, rand.nextFloat() * 2.5F);
            if (!world.isRemote) {
                player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("chat.item.pearcel_arrow.upgraded.zoom")));
            }
        } else {
            stack.getTagCompound().setBoolean("zoom", true);
            player.inventory.clearMatchingItems(zoomItem.getItem(), 0, 1, null);
            player.playSound(SoundEvents.ENTITY_PLAYER_LEVELUP, 2.0F, rand.nextFloat() * 2.5F);
            if (!world.isRemote) {
                player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("chat.item.pearcel_arrow.upgraded.zoom")));
            }
        }
    }
    return new ActionResult(EnumActionResult.PASS, stack);
}
Also used : Random(java.util.Random) ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 8 with ActionResult

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

the class ItemPearcelBlockPlacer 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.pbp.modeChange"))));
                }
            } else {
                item.getTagCompound().setInteger("mode", 1);
                if (!world.isRemote) {
                    player.sendMessage(new TextComponentTranslation(TextFormatting.GOLD + (Translate.toLocal("chat.item.pbp.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)

Example 9 with ActionResult

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

the class ItemEnderPearcel method onItemRightClick.

@Override
public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
    float velocity = ConfigurationHandler.enderPearcelVelocity;
    if (!player.isCreative()) {
        if (hasEnoughEnergy(stack, ConfigurationHandler.rfPerUse_enderPearcel, player)) {
            useEnergy(stack, ConfigurationHandler.rfPerUse_enderPearcel, false, player);
        } else {
            stack.damageItem(1, player);
        }
    }
    if (ConfigurationHandler.doEnderPearcelCooldown) {
        player.getCooldownTracker().setCooldown(this, ConfigurationHandler.enderPearcelCooldownTime * 20);
    }
    world.playSound(player, player.getPosition(), SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 0.5F, 0.4F);
    if (!world.isRemote) {
        EntityEnderPearcel pearl = new EntityEnderPearcel(world, player);
        pearl.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0.0F, velocity, 0.0F);
        world.spawnEntity(pearl);
    }
    return new ActionResult(EnumActionResult.SUCCESS, stack);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) EntityEnderPearcel(com.miningmark48.pearcelmod.entity.EntityEnderPearcel)

Example 10 with ActionResult

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

the class ItemPlayerChannelModule method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack item = player.getHeldItem(hand);
    if (!world.isRemote) {
        if (!item.hasTagCompound())
            item.setTagCompound(new NBTTagCompound());
        NBTTagCompound t = item.getTagCompound();
        if (!player.isSneaking()) {
            t.setString("MATCHER_PLAYER_ID", player.getUniqueID().toString());
            t.setString("MATCHER_PLAYER_NAME", player.getDisplayNameString());
            player.sendMessage(new TextComponentString(Helper.localize("message." + ModConstants.Mod.MODID + ":playerSetTo", player.getDisplayNameString())));
            new ActionResult<>(EnumActionResult.SUCCESS, item);
        } else {
            t.removeTag("MATCHER_PLAYER_ID");
            t.removeTag("MATCHER_PLAYER_NAME");
            player.sendMessage(new TextComponentString(Helper.localize("message." + ModConstants.Mod.MODID + ":playerReset")));
            new ActionResult<>(EnumActionResult.SUCCESS, item);
        }
    }
    return new ActionResult<>(EnumActionResult.PASS, item);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) TextComponentString(net.minecraft.util.text.TextComponentString)

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