本文整理汇总了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);
}
}
示例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));
}
}
}
}
}
示例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);
}
示例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);
}
示例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;
}
示例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));
}
示例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);
}
示例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();
}
示例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;
}
示例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 -> {});
}
}
}
示例11: VirtualAnvil
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public VirtualAnvil(EntityPlayer entityHuman) {
this(entityHuman, entityHuman.getPosition());
}
示例12: VirtualWorkbench
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public VirtualWorkbench(EntityPlayer entityHuman) {
super(entityHuman.inventory, entityHuman.world, entityHuman.getPosition());
}
示例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());
}
示例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));
}
示例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));
}