本文整理匯總了Java中net.minecraft.entity.player.EntityPlayerMP.getPosition方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityPlayerMP.getPosition方法的具體用法?Java EntityPlayerMP.getPosition怎麽用?Java EntityPlayerMP.getPosition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.entity.player.EntityPlayerMP
的用法示例。
在下文中一共展示了EntityPlayerMP.getPosition方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: processCommand
import net.minecraft.entity.player.EntityPlayerMP; //導入方法依賴的package包/類
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
if (args.length > 1 && args.length < 4)
{
throw new WrongUsageException("commands.spawnpoint.usage", new Object[0]);
}
else
{
EntityPlayerMP entityplayermp = args.length > 0 ? getPlayer(sender, args[0]) : getCommandSenderAsPlayer(sender);
BlockPos blockpos = args.length > 3 ? parseBlockPos(sender, args, 1, true) : entityplayermp.getPosition();
if (entityplayermp.worldObj != null)
{
entityplayermp.setSpawnPoint(blockpos, true);
notifyOperators(sender, this, "commands.spawnpoint.success", new Object[] {entityplayermp.getName(), Integer.valueOf(blockpos.getX()), Integer.valueOf(blockpos.getY()), Integer.valueOf(blockpos.getZ())});
}
}
}
示例2: spawnParticle
import net.minecraft.entity.player.EntityPlayerMP; //導入方法依賴的package包/類
/**
* Spawns the desired particle and sends the necessary packets to the relevant connected players.
*/
public void spawnParticle(EnumParticleTypes particleType, boolean longDistance, double xCoord, double yCoord, double zCoord, int numberOfParticles, double xOffset, double yOffset, double zOffset, double particleSpeed, int... p_180505_18_)
{
Packet packet = new S2APacketParticles(particleType, longDistance, (float)xCoord, (float)yCoord, (float)zCoord, (float)xOffset, (float)yOffset, (float)zOffset, (float)particleSpeed, numberOfParticles, p_180505_18_);
for (int i = 0; i < this.playerEntities.size(); ++i)
{
EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntities.get(i);
BlockPos blockpos = entityplayermp.getPosition();
double d0 = blockpos.distanceSq(xCoord, yCoord, zCoord);
if (d0 <= 256.0D || longDistance && d0 <= 65536.0D)
{
entityplayermp.playerNetServerHandler.sendPacket(packet);
}
}
}
示例3: execute
import net.minecraft.entity.player.EntityPlayerMP; //導入方法依賴的package包/類
/**
* Callback for when the command is executed
*/
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length > 1 && args.length < 4)
{
throw new WrongUsageException("commands.spawnpoint.usage", new Object[0]);
}
else
{
EntityPlayerMP entityplayermp = args.length > 0 ? getPlayer(server, sender, args[0]) : getCommandSenderAsPlayer(sender);
BlockPos blockpos = args.length > 3 ? parseBlockPos(sender, args, 1, true) : entityplayermp.getPosition();
if (entityplayermp.world != null)
{
entityplayermp.setSpawnPoint(blockpos, true);
notifyCommandListener(sender, this, "commands.spawnpoint.success", new Object[] {entityplayermp.getName(), Integer.valueOf(blockpos.getX()), Integer.valueOf(blockpos.getY()), Integer.valueOf(blockpos.getZ())});
}
}
}
示例4: execute
import net.minecraft.entity.player.EntityPlayerMP; //導入方法依賴的package包/類
/**
* Callback for when the command is executed
*/
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length > 1 && args.length < 4)
{
throw new WrongUsageException("commands.spawnpoint.usage", new Object[0]);
}
else
{
EntityPlayerMP entityplayermp = args.length > 0 ? getPlayer(server, sender, args[0]) : getCommandSenderAsPlayer(sender);
BlockPos blockpos = args.length > 3 ? parseBlockPos(sender, args, 1, true) : entityplayermp.getPosition();
if (entityplayermp.worldObj != null)
{
entityplayermp.setSpawnPoint(blockpos, true);
notifyCommandListener(sender, this, "commands.spawnpoint.success", new Object[] {entityplayermp.getName(), Integer.valueOf(blockpos.getX()), Integer.valueOf(blockpos.getY()), Integer.valueOf(blockpos.getZ())});
}
}
}
示例5: teleportPlayerToDimension
import net.minecraft.entity.player.EntityPlayerMP; //導入方法依賴的package包/類
private static void teleportPlayerToDimension(EntityPlayerMP playerIn, int suggestedDimensionId, double x, double y, double z) {
WorldServer fromWorld = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(playerIn.dimension);
WorldServer toWorld = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(suggestedDimensionId);
playerIn.dimension = toWorld.provider.getDimension();
ChunkPos pos = new ChunkPos(playerIn.getPosition());
toWorld.getChunkProvider().loadChunk(pos.x, pos.z);
final int dimensionId = playerIn.dimension;
if (fromWorld != toWorld && fromWorld.provider.getDimensionType() == toWorld.provider.getDimensionType()) {
playerIn.connection.sendPacket(new SPacketRespawn((dimensionId >= 0 ? -1 : 0), toWorld.getDifficulty(), toWorld.getWorldInfo().getTerrainType(), playerIn.interactionManager.getGameType()));
}
playerIn.connection.sendPacket(new SPacketRespawn(dimensionId, toWorld.getDifficulty(), toWorld.getWorldInfo().getTerrainType(), playerIn.interactionManager.getGameType()));
fromWorld.removeEntityDangerously(playerIn);
playerIn.isDead = false;
playerIn.connection.setPlayerLocation(x, y, z, playerIn.rotationYaw, playerIn.rotationPitch);
playerIn.world = toWorld;
playerIn.setWorld(toWorld);
toWorld.spawnEntity(playerIn);
toWorld.updateEntityWithOptionalForce(playerIn, false);
WorldServer worldserver = playerIn.getServerWorld();
fromWorld.getPlayerChunkMap().removePlayer(playerIn);
worldserver.getPlayerChunkMap().addPlayer(playerIn);
worldserver.getChunkProvider().provideChunk((int)playerIn.posX >> 4, (int)playerIn.posZ >> 4);
playerIn.connection.setPlayerLocation(playerIn.posX, playerIn.posY, playerIn.posZ, playerIn.rotationYaw, playerIn.rotationPitch);
playerIn.interactionManager.setWorld(toWorld);
WorldBorder worldborder = FMLCommonHandler.instance().getMinecraftServerInstance().worlds[0].getWorldBorder();
playerIn.connection.sendPacket(new SPacketWorldBorder(worldborder, SPacketWorldBorder.Action.INITIALIZE));
playerIn.connection.sendPacket(new SPacketTimeUpdate(toWorld.getTotalWorldTime(), toWorld.getWorldTime(), toWorld.getGameRules().getBoolean("doDaylightCycle")));
if (toWorld.isRaining()) {
playerIn.connection.sendPacket(new SPacketChangeGameState(1, 0.0F));
playerIn.connection.sendPacket(new SPacketChangeGameState(7, toWorld.getRainStrength(1.0F)));
playerIn.connection.sendPacket(new SPacketChangeGameState(8, toWorld.getThunderStrength(1.0F)));
}
playerIn.sendContainerToPlayer(playerIn.inventoryContainer);
playerIn.setPlayerHealthUpdated();
playerIn.connection.sendPacket(new SPacketHeldItemChange(playerIn.inventory.currentItem));
}
示例6: sendPacketWithinDistance
import net.minecraft.entity.player.EntityPlayerMP; //導入方法依賴的package包/類
private void sendPacketWithinDistance(EntityPlayerMP player, boolean longDistance, double x, double y, double z, Packet<?> packetIn)
{
BlockPos blockpos = player.getPosition();
double d0 = blockpos.distanceSq(x, y, z);
if (d0 <= 1024.0D || longDistance && d0 <= 262144.0D)
{
player.connection.sendPacket(packetIn);
}
}