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


Java EntityPlayer.getPosition方法代码示例

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


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

示例1: onLivingUpdate

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) {
    if (!(event.getEntity() instanceof EntityPlayer)) {
        return;
    }
    EntityPlayer player = (EntityPlayer) event.getEntity();
    if (player.isDead) {
        this.hueManager.adjustColor(new Color(255, 0, 0));
        return;
    }
    BlockPos pos = player.getPosition();
    Chunk chunk = this.world.getChunkFromBlockCoords(pos);
    Biome biome = chunk.getBiome(pos, this.world.getBiomeProvider());
    String color = this.biomeMap.get(biome.getRegistryName().getResourcePath());
    if (color != null) {
        this.hueManager.adjustColor(color);
    }
}
 
开发者ID:remcohaszing,项目名称:minecraft-hue,代码行数:19,代码来源:EventListener.java

示例2: onCastTick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onCastTick(World world, EntityPlayer player, ItemStack stack) {
	if (!world.isRemote) {
		BlockPos centerPos = player.getPosition();
		AxisAlignedBB area = new AxisAlignedBB(centerPos).expandXyz(3F);
		for (Entity entity : world.getEntitiesWithinAABBExcludingEntity(player, area)) {
			if (entity instanceof EntityLivingBase) {
				WorldServer worldServer = (WorldServer) world;
				if (player.getItemInUseCount() % 10 == 0 && consumePower(player)) {
					MessageSoulDrainFX message = new MessageSoulDrainFX(entity.posX,
							entity.posY + (entity.height / 2.0F), entity.posZ, player.posX,
							player.posY + (player.height / 2.0F), player.posZ);
					PacketHandler.INSTANCE.sendToAllAround(message, new NetworkRegistry.TargetPoint(
							player.dimension, player.posX, player.posY, player.posZ, 128));
					entity.attackEntityFrom(DamageSource.magic, 1);
					world.spawnEntity(new EntityXPOrb(world, entity.posX, entity.posY + 0.5, entity.posZ, 1));
				}
			}
		}
	}
}
 
开发者ID:the-realest-stu,项目名称:Infernum,代码行数:22,代码来源:SpellSoulDrain.java

示例3: onItemRightClick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
	
	List<EntityLivingBase> elb = acquireAllLookTargets(player, 32, 3);
	for (EntityLivingBase target : elb) {
		if (target.canEntityBeSeen(player) && !(target instanceof EntityPlayer)) {
			BlockPos targetpos = target.getPosition();
			BlockPos playerpos = player.getPosition();
			if (!world.isRemote) {
				target.setPositionAndUpdate(playerpos.getX(), playerpos.getY(), playerpos.getZ());
				player.setPositionAndUpdate(targetpos.getX(), targetpos.getY(), targetpos.getZ());
				if (target instanceof EntityWolf && world.rand.nextInt(100) == 0)
					target.entityDropItem(UCItems.generic.createStack(EnumItems.DOGRESIDUE), 1);
				stack.damageItem(1, player);
				return new ActionResult(EnumActionResult.SUCCESS, stack);
			}
		}
	}
	return new ActionResult(EnumActionResult.PASS, stack);
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:21,代码来源:ItemEnderSnooker.java

示例4: onItemRightClick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn,
		EnumHand hand) {
	playerIn.setActiveHand(hand);
	if (!worldIn.isRemote) {
		BlockPos pos = playerIn.getPosition();
		int id = GuiElementLoader.GUI_PICTURE_BOOK;
		playerIn.openGui(MineCamera.instance, id, worldIn, pos.getX(), pos.getY(), pos.getZ());
	}
	return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
 
开发者ID:PorPit,项目名称:MineCamera,代码行数:12,代码来源:ItemPictureBook.java

示例5: getCamouflageableBlockPos

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
static Set<BlockPos> getCamouflageableBlockPos(World worldIn, EntityPlayer entityIn) {
    if (worldIn == null) return Collections.emptySet();

    if (lastPlayerPos == null || teSet == null || entityIn.getDistanceSq(lastPlayerPos) > 9) {
        lastPlayerPos = entityIn.getPosition();
        teSet = worldIn.loadedTileEntityList.stream()
                .filter(te -> te instanceof ICamouflageableTE && te.getPos().distanceSq(entityIn.posX, entityIn.posY, entityIn.posZ) < 144
                )
                .map(TileEntity::getPos)
                .collect(Collectors.toSet());
    }
    return teSet;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:14,代码来源:CamoTECache.java

示例6: onItemRightClick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
    BlockPos pos = playerIn.getPosition();
    if (playerIn.isSneaking()) {
        RayTraceResult result = rayTrace(worldIn, playerIn, false);
        if (result != null && result.typeOfHit == RayTraceResult.Type.BLOCK) {
            pos = result.getBlockPos();
        }
    }
    playerIn.openGui(IndustrialForegoing.instance, GuiHandler.BOOK, worldIn, pos.getX(), pos.getY(), pos.getZ());
    return new ActionResult<>(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn));
}
 
开发者ID:Buuz135,项目名称:Industrial-Foregoing,代码行数:13,代码来源:BookManualItem.java

示例7: showProblem

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static void showProblem(String message, String... parameters) {
    EntityPlayer player = MeeCreeps.proxy.getClientPlayer();
    World worldIn = MeeCreeps.proxy.getClientWorld();
    BlockPos pos = player.getPosition();
    String translated = I18n.format(message, parameters);
    BalloonRenderer.addMessage(translated);
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:8,代码来源:ClientActionManager.java

示例8: findSuitablePositionNearPlayer

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static BlockPos findSuitablePositionNearPlayer(@Nonnull EntityMeeCreeps meeCreep, @Nonnull EntityPlayer player, double distance) {
    Vec3d playerPos = player.getPositionVector();
    Vec3d entityPos = meeCreep.getPositionVector();

    if (entityPos.distanceTo(playerPos) < (distance * 1.2)) {
        // No need to move
        return meeCreep.getPosition();
    }

    double dx = playerPos.x - entityPos.x;
    double dy = playerPos.x - entityPos.x;
    double dz = playerPos.x - entityPos.x;
    Vec3d v = new Vec3d(-dx, -dy, -dz);
    v = v.normalize();
    Vec3d pos = new Vec3d(playerPos.x + v.x * distance, playerPos.y + v.y * distance, playerPos.z + v.z * distance);
    // First find a good spot at the specific location
    World world = player.getEntityWorld();

    float width = meeCreep.width;
    float eyeHeight = meeCreep.getEyeHeight();

    // First try on the prefered spot
    BlockPos p = scanSuitablePos(new BlockPos(pos.x, pos.y + .5, pos.z), world, width, eyeHeight);
    if (p != null) return p;
    // No good spot to stand on found. Try other spots around the prefered spot
    p = scanAround(pos, world, width, eyeHeight);
    if (p != null) return p;
    // No good spot to stand on found. Try other spots around the player
    p = scanAround(playerPos, world, width, eyeHeight);
    if (p != null) return p;

    // If all else fails we go stand where the player is
    return player.getPosition();
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:35,代码来源:WorkerHelper.java

示例9: VirtualEnchantingTable

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public VirtualEnchantingTable(EntityPlayer entityHuman, float power) {
    super(entityHuman.inventory, entityHuman.world, entityHuman.getPosition());
    this.worldPointer = entityHuman.world;
    this.position = entityHuman.getPosition();
    this.rand = new Random();
    this.entityHumans = entityHuman;
    this.power = power;
}
 
开发者ID:poqdavid,项目名称:VirtualTool,代码行数:9,代码来源:VirtualEnchantingTable.java

示例10: tick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void tick(boolean timeToWrapUp) {
    IMeeCreep entity = helper.getMeeCreep();
    EntityMeeCreeps meeCreep = (EntityMeeCreeps) entity;
    EntityPlayer player = options.getPlayer();

    if (timeToWrapUp) {
        helper.done();
    } else if (player == null) {
        helper.taskIsDone();
    } else if (player.getEntityWorld().provider.getDimension() != meeCreep.getEntityWorld().provider.getDimension()) {
        // Wrong dimension, do nothing as this is handled by ServerActionManager
    } else {
        BlockPos position = player.getPosition();
        AxisAlignedBB box = new AxisAlignedBB(position.add(-6, -4, -6), position.add(6, 4, 6));
        List<EntityItem> items = entity.getWorld().getEntitiesWithinAABB(EntityItem.class, box, input -> {
            if (!input.getItem().isEmpty()) {
                if (input.getItem().getItem() instanceof ItemBlock) {
                    if (DigTunnelActionWorker.isNotInterestedIn(((ItemBlock) input.getItem().getItem()).getBlock())) {
                        return false;
                    }
                }
            }
            return true;
        });
        if (!items.isEmpty()) {
            items.sort((o1, o2) -> {
                double d1 = position.distanceSq(o1.posX, o1.posY, o1.posZ);
                double d2 = position.distanceSq(o2.posX, o2.posY, o2.posZ);
                return Double.compare(d1, d2);
            });
            EntityItem entityItem = items.get(0);
            helper.navigateTo(entityItem, (pos) -> helper.pickup(entityItem));
        } else if (entity.hasStuffInInventory()) {
            helper.navigateTo(helper.findSuitablePositionNearPlayer(1.0), blockPos -> helper.giveToPlayerOrDrop());
        } else {
            // Find a spot close to the player where we can navigate too
            BlockPos p = helper.findSuitablePositionNearPlayer(4.0);
            helper.navigateTo(p, blockPos -> {});
        }
    }
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:43,代码来源:FollowAndPickupActionWorker.java

示例11: VirtualAnvil

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public VirtualAnvil(EntityPlayer entityHuman) {
    this(entityHuman, entityHuman.getPosition());
}
 
开发者ID:poqdavid,项目名称:VirtualTool,代码行数:4,代码来源:VirtualAnvil.java

示例12: VirtualWorkbench

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public VirtualWorkbench(EntityPlayer entityHuman) {
    super(entityHuman.inventory, entityHuman.world, entityHuman.getPosition());
}
 
开发者ID:poqdavid,项目名称:VirtualTool,代码行数:4,代码来源:VirtualWorkbench.java

示例13: createUseBed

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static PacketUseBed createUseBed(Player player) {
    EntityPlayer p = (EntityPlayer)player;

    return (PacketUseBed)new SPacketUseBed(p, p.getPosition());
}
 
开发者ID:Guichaguri,项目名称:PacketControl,代码行数:6,代码来源:PacketControlFactory.java

示例14: outputByRange

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
private double outputByRange(EntityPlayer player, double energy, BlockPos pos) {

        BlockPos playerPos = player.getPosition();
        double distance = Math.floor(pos.getDistance(playerPos.getX(), playerPos.getY(), playerPos.getZ()));

        return (energy / (1D + (Config.wirelessRangeEnergyRate / 1000D) * distance));
    }
 
开发者ID:CreeperShift,项目名称:WirelessCharger,代码行数:8,代码来源:TileWirelessCharger.java

示例15: costByRange

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
private double costByRange(EntityPlayer player, double cost, BlockPos pos) {

        BlockPos playerPos = player.getPosition();
        double distance = Math.floor(pos.getDistance(playerPos.getX(), playerPos.getY(), playerPos.getZ()));

        return (cost * (1D + (Config.wirelessRangeEnergyRate / 1000D) * distance));
    }
 
开发者ID:CreeperShift,项目名称:WirelessCharger,代码行数:8,代码来源:TileWirelessCharger.java


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