本文整理匯總了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);
}
示例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);
}
}
}
示例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);
}
}
}
}
示例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);
}
}
}
示例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));
}
}
}
}
示例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);
}
示例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);
}
}
}
示例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);
}
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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());
}
}
}
示例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());
}
}
}
}
示例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);
}
}
}
示例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()));
}
}