当前位置: 首页>>代码示例>>Java>>正文


Java PlayerInteractEvent.RightClickItem方法代码示例

本文整理汇总了Java中net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickItem方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerInteractEvent.RightClickItem方法的具体用法?Java PlayerInteractEvent.RightClickItem怎么用?Java PlayerInteractEvent.RightClickItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraftforge.event.entity.player.PlayerInteractEvent的用法示例。


在下文中一共展示了PlayerInteractEvent.RightClickItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: rightClickEvent

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void rightClickEvent(PlayerInteractEvent.RightClickItem e)
{
    EntityPlayer player = e.getEntityPlayer();
    ItemStack RunicItem = null;
    if(EnchantmentHelper.getEnchantmentLevel(ModEnchantment.runicenchantment, player.getHeldItem(EnumHand.MAIN_HAND) )>0)
        RunicItem = player.getHeldItem(EnumHand.MAIN_HAND);
    else if(EnchantmentHelper.getEnchantmentLevel(ModEnchantment.runicenchantment, player.getHeldItem(EnumHand.OFF_HAND) )>0)
        RunicItem = player.getHeldItem(EnumHand.OFF_HAND);
    else return;

    CompiledSymbol[] script = ModDust.getScriptFromItem(RunicItem);
    if(script==null)return;

    if(player.isSneaking())
        new ScriptExecutor(script, player, RunicItem, ScriptExecutor.StartPoint.SNEAK_RIGHT);
    else
        new ScriptExecutor(script, player, RunicItem, ScriptExecutor.StartPoint.RIGHT_CLICK);

}
 
开发者ID:Drazuam,项目名称:RunicArcana,代码行数:21,代码来源:ScriptActivationEventHandler.java

示例2: onRightClick

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onRightClick(PlayerInteractEvent.RightClickItem e)
{
    if (e.getItemStack() != null && e.getItemStack().getItem() instanceof ItemGlassBottle && e.getEntityPlayer().isSneaking() && (e.getEntityPlayer().experienceLevel >= 1 || e.getEntityPlayer().isCreative())) {
        EntityPlayer player = e.getEntityPlayer();

        Vector3 origin = Vector3.fromEntity(player).add(0, player.getEyeHeight(), 0);
        Vector3 look = new Vector3(player.getLookVec());
        Vector3 end = origin.copy().add(look.copy().normalize().multiply(5));

        RayTraceResult rtr = player.worldObj.rayTraceBlocks(origin.toVec3D(), end.toVec3D(), true);
        IBlockState hitBlockState = null;
        if (rtr != null) hitBlockState = e.getWorld().getBlockState(rtr.getBlockPos());

        if (hitBlockState == null || hitBlockState.getBlock() != Blocks.water) {
            e.getItemStack().stackSize--;
            if (e.getItemStack().stackSize <= 0)
                e.getEntityPlayer().inventory.deleteStack(e.getItemStack());
            e.getEntityPlayer().inventory.addItemStackToInventory(new ItemStack(Items.experience_bottle));
            e.getEntityPlayer().removeExperienceLevel(1);
        }
    }
}
 
开发者ID:GamingsModding,项目名称:LittleThings-old,代码行数:24,代码来源:GetExpBottles.java

示例3: onRightClick

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onRightClick(PlayerInteractEvent.RightClickItem e)
{
    if (e.getItemStack() != null) {
        EntityPlayer player = e.getEntityPlayer();
        ItemStack stack = e.getItemStack();

        if (stack.getItem() instanceof ItemArmor) {
            EntityEquipmentSlot slot = EntityLiving.getSlotForItemStack(stack);
            ItemStack old = player.getItemStackFromSlot(slot);
            if (old != null) {
                old = old.copy();
                player.setItemStackToSlot(slot, stack.copy());
                stack.stackSize = 0;
                player.setHeldItem(e.getHand(), old);
            }
        }
    }
}
 
开发者ID:GamingsModding,项目名称:LittleThings-old,代码行数:20,代码来源:ReplaceArmor.java

示例4: RightClickItem

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void RightClickItem(PlayerInteractEvent.RightClickItem event) {
    World w = event.getWorld();
    BlockPos pos = event.getPos();
    ItemStack tool = event.getEntityPlayer().getHeldItemMainhand();
    if (!w.isRemote && TinkerUtil.hasTrait(TagUtil.getTagSafe(tool), identifier)) {
        NBTTagCompound tag = TagUtil.getExtraTag(tool);
        Data data = Data.read(tag);
        if (data.amount > 1f) {
            double d = Math.min(Utils.round2(random.nextDouble() * data.amount), max_power);
            w.newExplosion(event.getEntityPlayer(), pos.getX(), pos.getY(), pos.getZ(), (float) Math.pow((double) 1.2f, d), false, true);
            data.amount -= d;
            data.write(tag);
            TagUtil.setExtraTag(tool, tag);
            TagUtil.setEnchantEffect(tool, false);
        }
    }
}
 
开发者ID:TeamFRM,项目名称:TAIGA,代码行数:19,代码来源:TraitTantrum.java

示例5: onItemRightClick

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onItemRightClick(PlayerInteractEvent.RightClickItem event) {
	if (event.getItemStack().getItem() == Items.GLASS_BOTTLE) {
		if (event.getEntityPlayer().experienceLevel >= 1) {
			int j = 26 / (3 + event.getWorld().rand.nextInt(5) + event.getWorld().rand.nextInt(5));
			if (j >= event.getEntityPlayer().getActiveItemStack().getCount()) {
				event.getEntityPlayer().removeExperienceLevel(1);
				event.getEntityPlayer().attackEntityFrom(DamageSource.GENERIC, 0.1f);
				event.getEntityPlayer().heal(0.1f);
				Utils.itemExchange(event.getItemStack(), j, event.getEntityPlayer(),
						new ItemStack(Items.EXPERIENCE_BOTTLE, j));
			}
		}
	}
}
 
开发者ID:IvanSteklow,项目名称:VanillaExtras,代码行数:16,代码来源:ModEventHandler.java

示例6: stopUsing

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void stopUsing(PlayerInteractEvent.RightClickItem event) {
	ItemStack item = event.getEntityPlayer().getHeldItem(event.getHand());
	if (!TF2Util.canInteract(event.getEntityLiving()) && !(item.getItem() instanceof ItemDisguiseKit)
			&& !(item.getItem() instanceof ItemCloak && (item.getTagCompound().getBoolean("Active") 
			|| (WeaponsCapability.get(event.getEntity()).isFeign() && TF2Attribute.getModifier("Weapon Mode", item, 0, event.getEntityLiving()) == 1)))) {
		event.setCanceled(true);
		return;
	}
	if (WeaponsCapability.get(event.getEntity()).isDisguised() 
			&& !(item.getItem() instanceof ItemFood || item.getItem() instanceof ItemCloak || item.getItem() instanceof ItemDisguiseKit)) {
		disguise(event.getEntityPlayer(), false);
	}
	event.getEntityPlayer().removePotionEffect(TF2weapons.charging);
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:16,代码来源:TF2EventsCommon.java

示例7: onInteractRightClickItem

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onInteractRightClickItem(PlayerInteractEvent.RightClickItem event)
{
	if (event.getEntityPlayer() != null)
	{
		if (event.getEntityPlayer().isPotionActive(ExPPotions.stunned))
		{
			event.setCanceled(true);
		}
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:12,代码来源:ExPHandlerServer.java

示例8: onRightClick

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onRightClick(PlayerInteractEvent event) {
    if(event.getEntityPlayer().equals(Minecraft.getMinecraft().player) &&
            (event instanceof PlayerInteractEvent.RightClickBlock ||
            event instanceof PlayerInteractEvent.RightClickEmpty ||
            event instanceof PlayerInteractEvent.RightClickItem)) {
        if(ClientProxy.renderHelper.placePreview()) {
            event.setCancellationResult(EnumActionResult.FAIL);
            if(event.isCancelable()) {
                event.setCanceled(true);
            }
        }
    }
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:15,代码来源:SelectionBoxRenderHelper.java

示例9: onClickItem

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onClickItem(PlayerInteractEvent.RightClickItem event) {
    EntityPlayer player = event.getEntityPlayer();
    PossessivePlayer possessivePlayer = PossessHandler.get(player);
    if (possessivePlayer != null) {
        for (EntityPossessHandler handler : PossessHandler.getPossessHandlers(possessivePlayer.getPossessing())) {
            handler.onClickAir(possessivePlayer, player);
        }
    }
}
 
开发者ID:Fararise,项目名称:Possessed,代码行数:11,代码来源:ServerEventHandler.java

示例10: rightClickItem

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void rightClickItem(PlayerInteractEvent.RightClickItem event){
	EntityPlayer player = event.getEntityPlayer();
	ItemStack stack = event.getItemStack();
	EnumHand hand = event.getHand();
	
	if(player.isInsideOfMaterial(Material.WATER)){
		if(ItemStackTools.isValid(stack) && stack.getItem() == Items.GLASS_BOTTLE){
			player.setActiveHand(hand);
			event.setCanceled(true);
		}
	}
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:14,代码来源:EventHandler.java

示例11: onRightClickItem

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onRightClickItem(PlayerInteractEvent.RightClickItem event) {
    World w = event.getWorld();
    ItemStack tool = event.getEntityPlayer().getHeldItemMainhand();
    if (!w.isRemote && TinkerUtil.hasTrait(TagUtil.getTagSafe(tool), identifier)) {
        NBTTagCompound tag = TagUtil.getExtraTag(tool);
        Utils.GeneralNBTData data = Utils.GeneralNBTData.read(tag);
        NBTTagCompound root = TagUtil.getTagSafe(tool);
        StatNBT distributed = getBonus(root);
        ToolNBT stat = TagUtil.getToolStats(tool);
        if (data.active) {
            data.active = false;
            TagUtil.setEnchantEffect(root, false);
            TagUtil.setExtraTag(root, tag);
            data.write(tag);

        } else {
            stat.durability -= 10;
            distributed.durability -= 10;
            TagUtil.setToolTag(root, stat.get());
            setBonus(root, distributed);
            data.active = true;
            data.write(tag);

            TagUtil.setExtraTag(root, tag);
            data.write(tag);
        }

    }
}
 
开发者ID:TeamFRM,项目名称:TAIGA,代码行数:31,代码来源:TraitBerserk.java

示例12: onRightClickItem

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onRightClickItem(PlayerInteractEvent.RightClickItem event) {
    World w = event.getWorld();
    ItemStack tool = event.getEntityPlayer().getHeldItemMainhand();
    if (!w.isRemote && TinkerUtil.hasTrait(TagUtil.getTagSafe(tool), identifier)) {
        NBTTagCompound tag = TagUtil.getExtraTag(tool);
        Utils.GeneralNBTData data = Utils.GeneralNBTData.read(tag);
        if ((int) data.radius >= 1) {
            int r = Math.min((int) data.radius, 8);
            for (int x = -r; x <= r; x++) {
                for (int y = -r; y <= r; y++) {
                    for (int z = -r; z <= r; z++) {
                        if (MathHelper.sqrt(x * x + y * y + z * z) > r) {
                            continue;
                        }
                        BlockPos nPos = new BlockPos(event.getPos().getX() + x, event.getPos().getY() + y, event.getPos().getZ() + z);
                        if (!(event.getWorld().getBlockState(nPos).equals(Blocks.WATER.getDefaultState()) || event.getWorld().getBlockState(nPos).equals(Blocks.FLOWING_WATER.getDefaultState())))
                            continue;
                        event.getWorld().destroyBlock(nPos, false);
                    }
                }
            }
            data.radius -= r;
            data.write(tag);
            TagUtil.setExtraTag(tool, tag);
            TagUtil.setEnchantEffect(tool, false);
            ToolHelper.damageTool(tool, 2 * r, event.getEntityPlayer());
        }

    }
}
 
开发者ID:TeamFRM,项目名称:TAIGA,代码行数:32,代码来源:TraitWhirl.java

示例13: onRightClickItem

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onRightClickItem(PlayerInteractEvent.RightClickItem event) {
    World w = event.getWorld();
    BlockPos pos = event.getEntityPlayer().getPosition();
    ItemStack tool = event.getEntityPlayer().getHeldItemMainhand();
    if (!w.isRemote && TinkerUtil.hasTrait(TagUtil.getTagSafe(tool), identifier)) {
        NBTTagCompound tag = TagUtil.getExtraTag(tool);
        Data data = Data.read(tag);
        if (!data.mobClass.isEmpty()) {
            Entity ent = null;
            try {
                ent = (Entity) Class.forName(data.mobClass).getConstructor(World.class).newInstance(w);
            } catch (Exception e) {
                System.out.println(e.toString());
            }

            if (ent != null) {
                ent.setPosition(pos.getX(), pos.getY(), pos.getZ()); // TODO: set to player view target
                w.spawnEntity(ent);
                event.getEntityPlayer().playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0F);
                data.mobClass = "";
                data.mobName = "";
                data.write(tag);
                TagUtil.setExtraTag(tool, tag);
                ToolHelper.damageTool(tool, random.nextInt((int) (ToolHelper.getCurrentDurability(tool) * costMulti)), event.getEntityPlayer());
            }
        }
    }
}
 
开发者ID:TeamFRM,项目名称:TAIGA,代码行数:30,代码来源:TraitCatcher.java

示例14: onItemUse

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onItemUse(@Nonnull final PlayerInteractEvent.RightClickItem event) {
	if (event.getEntityPlayer() == null || event.getEntityPlayer().world == null || event.getItemStack() == null)
		return;

	if (event.getEntityPlayer().world.isRemote && this.itemRegistry.doBowSound(event.getItemStack())) {
		final ItemStack currentItem = event.getEntityPlayer().getHeldItem(event.getHand());
		final SoundEffect soundEffect = this.itemRegistry.getUseSound(currentItem);
		if (soundEffect != null) {
			final BasicSound<?> sound = makeSound(soundEffect);
			sound.setRoutable(DSurround.isInstalledOnServer());
			SoundEffectHandler.INSTANCE.playSound(sound);
		}
	}
}
 
开发者ID:OreCruncher,项目名称:DynamicSurroundings,代码行数:16,代码来源:PlayerActionHandler.java

示例15: onItemUse

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onItemUse(PlayerInteractEvent.RightClickItem event)
{
    EntityPlayer player = event.getEntityPlayer();
    List<Action> events = CommonProxy.manager.getActions(player);

    if (!player.worldObj.isRemote && events != null)
    {
        events.add(new ItemUseAction(event.getHand()));
    }
}
 
开发者ID:mchorse,项目名称:blockbuster,代码行数:12,代码来源:ActionHandler.java


注:本文中的net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。