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


Java PlayerInteractEvent.getEntityPlayer方法代码示例

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


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

示例1: onRightClick

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@HarshenEvent
public void onRightClick(PlayerInteractEvent event)
{
	if(event.getEntityPlayer().world.isRemote && HarshenUtils.toArray(RightClickBlock.class, RightClickEmpty.class).contains(event.getClass()) &&
			event.getEntityPlayer().getHeldItemMainhand().isEmpty() && event.getEntityPlayer().isElytraFlying())
	{
		HarshenNetwork.sendToServer(new MessagePacketSummonFirework());

		Vec3d vec3d = event.getEntityPlayer().getLookVec();
		event.getEntityPlayer().motionX += vec3d.x * 0.1D + (vec3d.x * 2.5D - event.getEntityPlayer().motionX) * 0.5D;
		event.getEntityPlayer().motionY += vec3d.y * 0.1D + (vec3d.y * 2.5D - event.getEntityPlayer().motionY) * 0.5D;
		event.getEntityPlayer().motionZ += vec3d.z * 0.1D + (vec3d.z * 2.5D - event.getEntityPlayer().motionZ) * 0.5D;
	}
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:15,代码来源:ElytraPendant.java

示例2: onPlayerInteract

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onPlayerInteract(PlayerInteractEvent event) {
	EntityPlayer player = event.getEntityPlayer();
	if (player != null && player.getHealth() <= 0f) {
		if (!(event instanceof PlayerInteractEvent.RightClickEmpty || event instanceof PlayerInteractEvent.LeftClickEmpty)) {
			event.setCanceled(true);
		}
	}
}
 
开发者ID:blay09,项目名称:HardcoreRevival,代码行数:10,代码来源:RestrictionHandler.java

示例3: onBlockInteract

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onBlockInteract(PlayerInteractEvent event) {
    World world = event.getWorld();
    BlockPos pos = event.getPos();
    IBlockState blockstate = world.getBlockState(pos);
    EntityPlayer player = event.getEntityPlayer();

    if (blockstate.getBlock() instanceof BlockBanner) {
        EnumHand hand = EnumHand.MAIN_HAND;
        ItemStack stack = player.getHeldItemMainhand();
        BlockBanner bannerblock = (BlockBanner) blockstate.getBlock();

        if (stack.isEmpty() && player.isSneaking() && player.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty()) {
            ItemStack bannerstack = bannerblock.getItem(world, pos, blockstate);
            player.swingArm(hand);

            world.removeTileEntity(pos);
            world.setBlockToAir(pos);

            player.setItemStackToSlot(EntityEquipmentSlot.HEAD, bannerstack);

            if (!event.getWorld().isRemote) {
                event.setCanceled(true);
            }
        }
    }
}
 
开发者ID:DaedalusGame,项目名称:BetterWithAddons,代码行数:28,代码来源:AssortedHandler.java

示例4: onPlayerInteract

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@SubscribeEvent(priority = EventPriority.LOW)
	public void onPlayerInteract(PlayerInteractEvent event) {
		if(event.getEntityPlayer() !=null && event.getWorld() !=null && event instanceof RightClickBlock){
			BlockPos pos = EntityUtil.getEntityLookedBlock(event.getEntityPlayer(), (float)CrystalMod.proxy.getReachDistanceForPlayer(event.getEntityPlayer()));
			if(pos !=null){
				if(event.getWorld().isBlockLoaded(pos)){
					IBlockState state = event.getWorld().getBlockState(pos);
					if(state.getBlock() == Blocks.WOOL && ItemStackTools.isValid(event.getEntityPlayer().getHeldItem(event.getHand())) && ItemUtil.itemStackMatchesOredict(event.getEntityPlayer().getHeldItem(event.getHand()), "slimeball")){
						
						int waterCt = 0;
						for(EnumFacing face : EnumFacing.VALUES){
							IBlockState state2 = event.getWorld().getBlockState(pos.offset(face));
							if(state2 !=null && state2.getBlock().getMaterial(state2) == Material.WATER){
								waterCt++;
							}
						}
						
						if(waterCt >= 4){
							event.getWorld().setBlockState(pos, Blocks.SPONGE.getDefaultState());
							event.getEntityPlayer().swingArm(event.getHand());
							
							if (!event.getWorld().isRemote)
		                    {
								event.getWorld().playEvent(2001, pos, Block.getStateId(state));
		                    }
							
							if(!event.getEntityPlayer().capabilities.isCreativeMode)
							event.getEntityPlayer().setHeldItem(event.getHand(), ItemUtil.consumeItem(event.getEntityPlayer().getHeldItem(event.getHand())));
						}
					}
				}
			}
		}
	}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:36,代码来源:EventHandler.java

示例5: securityCanceler

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
/** This method will cancel unauthorized access to the storage system */
private void securityCanceler(PlayerInteractEvent e) {
	World w = e.getWorld();
	IBlockState state = w.getBlockState(e.getPos());
	Block b = state.getBlock();
	TileEntitySecurityBox tile;
	EntityPlayer p = e.getEntityPlayer();

	if (b instanceof StorageMultiblock) {
		if ((tile = EZStorageUtils.findSecurityBox(new BlockRef(b, e.getPos().getX(), e.getPos().getY(), e.getPos().getZ()), w, null)) != null) {
			if (!tile.isPlayerAllowed(p))
				e.setCanceled(true); // cancel everything
		}
	}
}
 
开发者ID:zerofall,项目名称:EZStorage2,代码行数:16,代码来源:SecurityEvents.java

示例6: stopBedUse

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void stopBedUse(PlayerInteractEvent e){
    if(!e.getWorld().isRemote) {
        if (e.getWorld().getBlockState(e.getPos()).getBlock() == Blocks.BED && ConfigurationFile.clickingBedSetsSpawnPoint) {
            e.getEntityPlayer().setSpawnPoint(e.getPos(), true);
            e.getEntityPlayer().bedLocation = e.getPos();
            e.getEntityPlayer().addChatComponentMessage(new TextComponentTranslation("Spawn point set!"));
            if (ConfigurationFile.stopBedUse && !e.getEntity().getEntityWorld().isDaytime()) {
                e.getEntityPlayer().addChatComponentMessage(new TextComponentTranslation("You don't feel tired enough to sleep.."));
                e.setCanceled(true);
            }
        }
    }
}
 
开发者ID:baileyholl,项目名称:Event-Tweaks,代码行数:15,代码来源:InteractEventHandler.java

示例7: onPlayerInteract

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onPlayerInteract(PlayerInteractEvent event) {
  if (signSkullName) {
    EntityPlayer entityPlayer = event.getEntityPlayer();
    BlockPos pos = event.getPos();
    World worldObj = event.getWorld();
    if (pos == null) {
      return;
    }
    // event has no hand??
    // and no item stack. and right click rarely works. known bug
    // http://www.minecraftforge.net/forum/index.php?topic=37416.0
    ItemStack held = entityPlayer.getHeldItemMainhand();
    if (held == null) {
      held = entityPlayer.getHeldItemOffhand();
    }
    TileEntity container = worldObj.getTileEntity(pos);
    if (held != null && held.getItem() == Items.SKULL && held.getItemDamage() == Const.skull_player && container != null && container instanceof TileEntitySign) {
      TileEntitySign sign = (TileEntitySign) container;
      String firstLine = sign.signText[0].getUnformattedText();
      if (firstLine == null) {
        firstLine = "";
      }
      if (firstLine.isEmpty() || firstLine.split(" ").length == 0) {
        held.setTagCompound(null);
      }
      else {
        firstLine = firstLine.split(" ")[0];
        NBTTagCompound nbt = UtilNBT.getItemStackNBT(held);
        nbt.setString(Const.SkullOwner, firstLine);
      }
    }
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:35,代码来源:PlayerAbilitiesModule.java

示例8: playerInteractEvent

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void playerInteractEvent(PlayerInteractEvent event)
{
    EntityPlayer player = event.getEntityPlayer();
    ItemStack stack = event.getItemStack();
    if (stack.isEmpty() || !Helper.shouldCare(player)) return;
    if (GlobalBanList.isBanned(player.dimension, stack))
    {
        player.sendStatusMessage(new TextComponentString(ItemBlacklist.message), true);
        if (ItemBlacklist.log) ItemBlacklist.getLogger().info("{} tried to use {} at {} ({})", player.getName(), stack.getDisplayName(), event.getPos(), event.getFace());
        if (event.isCancelable())
            event.setCanceled(true);
        GlobalBanList.process(player.dimension, player.inventory);
    }
}
 
开发者ID:DoubleDoorDevelopment,项目名称:ItemBlacklist,代码行数:16,代码来源:ServerEventHandlers.java

示例9: handleCodebreaking

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
private boolean handleCodebreaking(PlayerInteractEvent event) {
	World world = event.getEntityPlayer().worldObj;
	TileEntity tileEntity = event.getEntityPlayer().worldObj.getTileEntity(event.getPos());

	if(SecurityCraft.config.allowCodebreakerItem && event.getEntityPlayer().getHeldItem(event.getHand()).getItem() == SCContent.codebreaker) //safety so when codebreakers are disabled they can't take damage
		event.getEntityPlayer().getHeldItem(event.getHand()).damageItem(1, event.getEntityPlayer());

	if(tileEntity != null && tileEntity instanceof IPasswordProtected && new Random().nextInt(3) == 1)
		return ((IPasswordProtected) tileEntity).onCodebreakerUsed(world.getBlockState(event.getPos()), event.getEntityPlayer(), !SecurityCraft.config.allowCodebreakerItem);

	return false;
}
 
开发者ID:Geforce132,项目名称:SecurityCraft,代码行数:13,代码来源:SCEventHandler.java

示例10: handleCodebreaking

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
private boolean handleCodebreaking(PlayerInteractEvent event) {
	World world = event.getEntityPlayer().world;
	TileEntity tileEntity = event.getEntityPlayer().world.getTileEntity(event.getPos());

	if(SecurityCraft.config.allowCodebreakerItem && event.getEntityPlayer().getHeldItem(event.getHand()).getItem() == SCContent.codebreaker) //safety so when codebreakers are disabled they can't take damage
		event.getEntityPlayer().getHeldItem(event.getHand()).damageItem(1, event.getEntityPlayer());

	if(tileEntity != null && tileEntity instanceof IPasswordProtected && new Random().nextInt(3) == 1)
		return ((IPasswordProtected) tileEntity).onCodebreakerUsed(world.getBlockState(event.getPos()), event.getEntityPlayer(), !SecurityCraft.config.allowCodebreakerItem);

	return false;
}
 
开发者ID:Geforce132,项目名称:SecurityCraft,代码行数:13,代码来源:SCEventHandler.java

示例11: sendOffSwingEvent

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
public static void sendOffSwingEvent(PlayerInteractEvent player){
    if(!player.getEntityPlayer().isSwingInProgress) {
        PlayerEventChild.OffhandSwingEvent event = new PlayerEventChild.OffhandSwingEvent(copy(player));
        if (!event.mainHand.isEmpty() && BattlegearUtils.usagePriorAttack(event.mainHand, event.getPlayer(), false)) {
            event.setCanceled(true);
        }
        if (!MinecraftForge.EVENT_BUS.post(event)) {
            event.getEntityPlayer().swingArm(EnumHand.OFF_HAND);
        }
    }
}
 
开发者ID:Mine-and-blade-admin,项目名称:Battlegear2,代码行数:12,代码来源:BattlemodeHookContainerClass.java

示例12: onPlayerClick

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
    public void onPlayerClick(PlayerInteractEvent event) {
        if (event instanceof PlayerInteractEvent.RightClickEmpty) return;

        ItemStack heldItem = event.getEntityPlayer().getHeldItem(event.getHand());

        IBlockState interactedBlockState = event.getWorld().getBlockState(event.getPos());
        Block interactedBlock = interactedBlockState.getBlock();
        if (!event.getEntityPlayer().capabilities.isCreativeMode || !event.getEntityPlayer().canUseCommand(2, "securityStation")) {
            if (event.getWorld() != null && !event.getWorld().isRemote) {
                if (interactedBlock != Blockss.SECURITY_STATION || event instanceof PlayerInteractEvent.LeftClickBlock) {
                    boolean tryingToPlaceSecurityStation = heldItem.getItem() instanceof ItemBlock && ((ItemBlock) heldItem.getItem()).getBlock() == Blockss.SECURITY_STATION;
                    int blockingStations = PneumaticCraftUtils.getProtectingSecurityStations(event.getWorld(), event.getPos(), event.getEntityPlayer(), true, tryingToPlaceSecurityStation);
                    if (blockingStations > 0) {
                        event.setCanceled(true);
                        event.getEntityPlayer().sendStatusMessage(
                                new TextComponentTranslation(
                                        tryingToPlaceSecurityStation ? "message.securityStation.stationPlacementPrevented" : "message.securityStation.accessPrevented",
                                        blockingStations), false);
                    }
                }
            }
        }

        if (!event.isCanceled() && event instanceof PlayerInteractEvent.RightClickBlock && !event.getWorld().isRemote) {
            if (event.getEntityPlayer().isSneaking() && (interactedBlock == Blockss.ELEVATOR_CALLER || interactedBlock == Blockss.CHARGING_STATION)) {
                // work around the fact that Block#onBlockActivated doesn't get called server-side when sneaking
                event.setCanceled(interactedBlock.onBlockActivated(event.getWorld(), event.getPos(), interactedBlockState, event.getEntityPlayer(), event.getHand(), event.getFace(), 0, 0, 0));
            } else if (ModInteractionUtilImplementation.getInstance().isModdedWrench(heldItem)) {
                // when player clicks with a modded wrench, enforce our rotation behaviour and cancel default behaviour
                // (which is probably to call the "vanilla" rotateBlock(), which doesn't get any player information)
                if (interactedBlock instanceof IPneumaticWrenchable) {
                    ((IPneumaticWrenchable) interactedBlock).rotateBlock(event.getWorld(), event.getEntityPlayer(), event.getPos(), event.getFace());
                    event.setCanceled(true);
                }
            }
        }

//        if (!event.isCanceled() && interactedBlock == Blocks.COBBLESTONE) {
//            AdvancementUtils.checkFor9x9(event.getEntityPlayer(), event.getPos());
//        }
    }
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:43,代码来源:EventHandlerPneumaticCraft.java

示例13: createSword

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void createSword(PlayerInteractEvent event)
{
    World world = event.getEntityPlayer().worldObj;
    EntityPlayer player = event.getEntityPlayer();


    if (world.isRemote || player.getHeldItem(EnumHand.MAIN_HAND) == null) return;

    Block block;

    if (player.getHeldItem(EnumHand.MAIN_HAND).getItem() == ModItems.pureSoul)
    {
        block = world.getBlockState(event.getPos()).getBlock();

        if (TCCreateToolHelper.isSorted(world, event.getPos().getX(), event.getPos().getY(), event.getPos().getZ()))
        {
            if (block == ModBlocks.swordCore) {
                if (!player.capabilities.isCreativeMode) {
                    player.getHeldItem(EnumHand.MAIN_HAND).stackSize -= 1;
                }

                SoundHandler.onEntityPlay("createTool", event.getWorld(), event.getEntity(), 1, 1);
                world.spawnEntityInWorld(new EntityItem(world, event.getPos().getX(), event.getPos().getY(), event.getPos().getZ(), new ItemStack(ModItems.soulSword)));
                world.setBlockToAir(event.getPos());
            }

            if (block == ModBlocks.hoeCore) {
                if (!player.capabilities.isCreativeMode) {
                    player.getHeldItem(EnumHand.MAIN_HAND).stackSize -= 1;
                }

                SoundHandler.onEntityPlay("createTool", event.getWorld(), event.getEntity(), 1, 1);
                world.spawnEntityInWorld(new EntityItem(world, event.getPos().getX(), event.getPos().getY(), event.getPos().getZ(), new ItemStack(ModItems.soulHoe)));
                world.setBlockToAir(event.getPos());
            }

            if (block == ModBlocks.pickaxeCore) {
                if (!player.capabilities.isCreativeMode) {
                    player.getHeldItem(EnumHand.MAIN_HAND).stackSize -= 1;
                }

                SoundHandler.onEntityPlay("createTool", event.getWorld(), event.getEntity(), 1, 1);
                world.spawnEntityInWorld(new EntityItem(world, event.getPos().getX(), event.getPos().getY(), event.getPos().getZ(), new ItemStack(ModItems.soulPickaxe)));
                world.setBlockToAir(event.getPos());
            }

            if (block == ModBlocks.axeCore) {
                if (!player.capabilities.isCreativeMode) {
                    player.getHeldItem(EnumHand.MAIN_HAND).stackSize -= 1;
                }

                SoundHandler.onEntityPlay("createTool", event.getWorld(), event.getEntity(), 1, 1);
                world.spawnEntityInWorld(new EntityItem(world, event.getPos().getX(), event.getPos().getY(), event.getPos().getZ(), new ItemStack(ModItems.soulAxe)));
                world.setBlockToAir(event.getPos());
            }

            if (block == ModBlocks.shovelCore) {
                if (!player.capabilities.isCreativeMode) {
                    player.getHeldItem(EnumHand.MAIN_HAND).stackSize -= 1;
                }

                SoundHandler.onEntityPlay("createTool", event.getWorld(), event.getEntity(), 1, 1);
                world.spawnEntityInWorld(new EntityItem(world, event.getPos().getX(), event.getPos().getY(), event.getPos().getZ(), new ItemStack(ModItems.soulShovel)));
                world.setBlockToAir(event.getPos());
            }
        }
    }
}
 
开发者ID:Aviv871,项目名称:TombCraft,代码行数:70,代码来源:TCCreateToolEvent.java

示例14: playerInteract

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void playerInteract(PlayerInteractEvent event)
{
	if (!(event instanceof PlayerInteractEvent.LeftClickBlock || event instanceof PlayerInteractEvent.RightClickBlock) || event.getEntityPlayer().getHeldItemMainhand() == null || event.getEntityPlayer().getHeldItemMainhand().getItem() != TBFeatures.schematicTool) {
		return;
	}

	ItemStack tool = event.getEntityPlayer().getHeldItemMainhand();

	if (event instanceof PlayerInteractEvent.LeftClickBlock)
	{
		if (!tool.hasTagCompound()) tool.setTagCompound(new NBTTagCompound());
		if (tool.getTagCompound().getInteger("Pos1Y") == -1)
		{
			tool.getTagCompound().setInteger("Pos2X", event.getPos().getX());
			tool.getTagCompound().setInteger("Pos2Y", event.getPos().getY());
			tool.getTagCompound().setInteger("Pos2Z", event.getPos().getZ());
		}
		tool.getTagCompound().setInteger("Pos1X", event.getPos().getX());
		tool.getTagCompound().setInteger("Pos1Y", event.getPos().getY());
		tool.getTagCompound().setInteger("Pos1Z", event.getPos().getZ());
		event.getEntityPlayer().addChatComponentMessage(new TextComponentString("Pos1 Set"));
		event.setCanceled(true);
	}
	else if (event instanceof PlayerInteractEvent.RightClickBlock)
	{
		if (!tool.hasTagCompound()) tool.setTagCompound(new NBTTagCompound());
		if (tool.getTagCompound().getInteger("Pos1Y") == -1)
		{
			tool.getTagCompound().setInteger("Pos1X", event.getPos().getX());
			tool.getTagCompound().setInteger("Pos1Y", event.getPos().getY());
			tool.getTagCompound().setInteger("Pos1Z", event.getPos().getZ());
		}

		tool.getTagCompound().setInteger("Pos2X", event.getPos().getX());
		tool.getTagCompound().setInteger("Pos2Y", event.getPos().getY());
		tool.getTagCompound().setInteger("Pos2Z", event.getPos().getZ());
		if (event.getEntityPlayer().worldObj.isRemote)event.getEntityPlayer().addChatComponentMessage(new TextComponentString("Pos2 Set"));
		else event.setCanceled(true);
	}
}
 
开发者ID:brandon3055,项目名称:Town-Builder,代码行数:42,代码来源:ForgeEventHandler.java


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