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


Java EntityPlayer.equals方法代码示例

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


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

示例1: onReceived

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onReceived(MessagePacketRingUpdate message, EntityPlayer player) {
	if(message.ringType < 2)
	{
		ArrayList<Item> ringTypeItem = new ArrayList<Item>();
		ringTypeItem.add(HarshenItems.TELERING);
		ringTypeItem.add(HarshenItems.MINERING);
		if(HarshenUtils.containsItem(player,ringTypeItem.get(message.ringType)))
		{
			World world = player.world;
			Vec3d vec = new Vec3d(player.posX + (player.getLookVec().x * 4f),
					player.posY + (player.getLookVec().y * 4f), player.posZ + (player.getLookVec().z* 4f));
			BlockPos blockpos = message.ringType == 0? HarshenUtils.getTopBlock(world, vec) : HarshenUtils.getBottomBlockAir(world, vec);
			Vec3d vecPos = new Vec3d(blockpos).addVector(0.5, 0, 0.5);
			if(blockpos.getY() != -1 && player.getFoodStats().getFoodLevel() > 0)
			{
				((EntityPlayerMP)player).velocityChanged = true;
				((EntityPlayerMP)player).fallDistance = 0;
				HarshenNetwork.sendToPlayer(player, new MessagePacketPlayerTeleportEffects(vecPos));
				((EntityPlayerMP)player).setPositionAndUpdate(vecPos.x, vecPos.y, vecPos.z);
				world.playSound((EntityPlayer)null, player.posX, player.posY, player.posZ, SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F);
                player.playSound(SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, 1.0F, 1.0F);
                player.addExhaustion(0.5F);
                HarshenUtils.damageFirstOccuringItem(player, ringTypeItem.get(message.ringType));
			}
		}			
	}
	else if(message.ringType == 2 && HarshenUtils.containsItem(player, HarshenItems.COMBAT_PENDANT))
	{
		EntityLivingBase entityToAttack = HarshenUtils.getFirstEntityInDirection(player.world, player.getPositionVector(), player.getLookVec().normalize(), 5, EntityLivingBase.class);
		if(entityToAttack == null)
		{
			List<EntityLivingBase> list = player.world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(player.posX - 4d, player.posY - 4d, player.posZ - 4d, player.posX + 4d, player.posY + 4d, player.posZ + 4d));
			if(!list.isEmpty())
				entityToAttack = list.get(0);
		}
		if(!player.equals(entityToAttack) && (entityToAttack != null || (entityToAttack instanceof EntityPlayerMP && player.canAttackPlayer((EntityPlayerMP)entityToAttack)
				&& HarshenUtils.toArray(GameType.SURVIVAL, GameType.ADVENTURE).contains(((EntityPlayerMP)entityToAttack).interactionManager.getGameType()))))
		{
			Vec3d position = entityToAttack.getPositionVector();
			Vec3d playerPosNoY = position.addVector(movePos(), 0, movePos());
			Vec3d pos = new Vec3d(playerPosNoY.x, HarshenUtils.getTopBlock(player.world, new BlockPos(playerPosNoY)).getY(), playerPosNoY.z);
			double d0 = position.x - pos.x;
            double d1 = position.y - (pos.y + (double)player.getEyeHeight() - entityToAttack.height / 2f + 0.1f);
            double d2 = position.z - pos.z;
            double d3 = (double)MathHelper.sqrt(d0 * d0 + d2 * d2);
            float yaw = (float)(MathHelper.atan2(d2, d0) * (180D / Math.PI)) - 90.0F;
            float pitch = (float)(-(MathHelper.atan2(d1, d3) * (180D / Math.PI)));
			((EntityPlayerMP)player).velocityChanged = true;
			((EntityPlayerMP)player).connection.setPlayerLocation(pos.x, pos.y, pos.z, yaw, pitch);
		}
	}
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:54,代码来源:MessagePacketRingUpdate.java

示例2: isLocalPlayer

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Use EntityUtils::isLocalPlayer
 */
@Deprecated
public static boolean isLocalPlayer(Entity player) {
    EntityPlayer localPlayer = getLocalPlayer();
    return localPlayer != null && localPlayer.equals(player);
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:9,代码来源:PlayerUtils.java


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