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


Java EntityPlayer.getDistance方法代码示例

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


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

示例1: syncToClients

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public void syncToClients(){
    if(this.world != null && !this.world.isRemote){
        if(world.getTotalWorldTime() % 10 == 0){
            NBTTagCompound syncTag = new NBTTagCompound();
            this.writeNBT(syncTag, NBTType.SYNC);
            for(EntityPlayer player : this.world.playerEntities){
                if(player instanceof EntityPlayerMP && player.getDistance(pos.getX(), pos.getY(), pos.getZ()) <= 64){
                    NetworkHandler.NET.sendTo(new PacketSyncTile(syncTag, this.pos), (EntityPlayerMP) player);
                }
            }
            this.isSyncDirty = false;
        } else {
            this.isSyncDirty = true;
        }
    }
}
 
开发者ID:canitzp,项目名称:Metalworks,代码行数:17,代码来源:TileBase.java

示例2: onWorldTick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@SubscribeEvent
public void onWorldTick(TickEvent.WorldTickEvent e) {
    if (!e.world.isRemote && e.phase == TickEvent.Phase.START && e.world.provider.getDimension() == 0) {
        long now = Instant.now().getEpochSecond();
        if (now - lastCheck > checkInterval) {
            BlockPos spawn = e.world.getSpawnPoint();
            for (int i = 0; i < e.world.playerEntities.size(); i++)
            {
                EntityPlayer p = e.world.playerEntities.get(i);
                // If the user is inside the zone radius, force them back to creative
                if (p.getDistance(spawn.getX(), p.posY, spawn.getZ()) < zoneRadius) {
                    p.setGameType(GameType.CREATIVE);
                } else {
                    // Otherwise, the user is outside the radius and we need to force
                    // them back to survival (assuming they're not on the whitelist)
                    if (!whitelist.contains(p.getName())) {
                        p.setGameType(GameType.SURVIVAL);
                    }
                }
            }
            lastCheck = now;
        }
    }
}
 
开发者ID:dizzyd,项目名称:creativezone,代码行数:25,代码来源:CreativeZoneMod.java

示例3: getPickBlock

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
	double viewDistance = 0D;
	double currentDistance = player.getDistance(x + 0.5D, y + 0.5D, z + 0.5D);
	boolean hasVisualAcuity = false;
	boolean hasWarpVisualAcuity = false;
	boolean canView = false;
	if (player != null) {
		hasVisualAcuity = ThaumUtils.isComplete(player, TOThaum.riVisualAcuity);
		hasWarpVisualAcuity = ThaumUtils.isComplete(player, TOThaum.riWarpVisualAcuity);
		if ((player.inventory.armorItemInSlot(3) != null)
				&& (player.inventory.armorItemInSlot(3).getItem() instanceof IRevealer)
				&& (((IRevealer) player.inventory.armorItemInSlot(3).getItem())
						.showNodes(player.inventory.armorItemInSlot(3), player))) {
			canView = true;
			viewDistance = hasVisualAcuity ? 32.0D : 16.0D;
		} else if ((player.inventory.getCurrentItem() != null)
				&& (player.inventory.getCurrentItem().getItem() instanceof ItemThaumometer)
				&& (UtilsFX.isVisibleTo(0.44F, player, x, y, z))) {
			canView = true;
			viewDistance = hasVisualAcuity ? 16.0D : 8.0D;
		}
		if (hasWarpVisualAcuity) {
			int warp = ThaumUtils.getWarp(player);
			canView = true;
			double warpViewDistance = warp * TOConfig.generalWarpVisualAcuityModifier;
			if (warpViewDistance > viewDistance)
				viewDistance = warpViewDistance;
		}
	}
	if (canView && currentDistance <= viewDistance) {
		return new ItemStack(this, 1, world.getBlockMetadata(x, y, z));
	} else
		return new ItemStack(baseBlock, 1, baseMeta);
}
 
开发者ID:MJaroslav,项目名称:ThaumOres,代码行数:36,代码来源:BlockInfusedBlockOre.java


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