本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.setPositionAndUpdate方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.setPositionAndUpdate方法的具体用法?Java EntityPlayer.setPositionAndUpdate怎么用?Java EntityPlayer.setPositionAndUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.player.EntityPlayer
的用法示例。
在下文中一共展示了EntityPlayer.setPositionAndUpdate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: teleportToDimension
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static void teleportToDimension(EntityPlayer player, int dimension, double x, double y, double z) {
int oldDimension = player.getEntityWorld().provider.getDimension();
EntityPlayerMP entityPlayerMP = (EntityPlayerMP) player;
MinecraftServer server = player.getEntityWorld().getMinecraftServer();
WorldServer worldServer = server.getWorld(dimension);
player.addExperienceLevel(0);
worldServer.getMinecraftServer().getPlayerList().transferPlayerToDimension(entityPlayerMP, dimension, new RfToolsTeleporter(worldServer, x, y, z));
player.setPositionAndUpdate(x, y, z);
if (oldDimension == 1) {
// For some reason teleporting out of the end does weird things.
player.setPositionAndUpdate(x, y, z);
worldServer.spawnEntity(player);
worldServer.updateEntityWithOptionalForce(player, false);
}
}
示例2: 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);
}
示例3: teleportToDimension
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static void teleportToDimension(EntityPlayer player, int dimension, double x, double y, double z) {
int oldDimension = player.getEntityWorld().provider.getDimension();
EntityPlayerMP entityPlayerMP = (EntityPlayerMP) player;
MinecraftServer server = player.getEntityWorld().getMinecraftServer();
WorldServer worldServer = server.getWorld(dimension);
player.addExperienceLevel(0);
worldServer.getMinecraftServer().getPlayerList().transferPlayerToDimension(entityPlayerMP, dimension, new WhooshTeleporter(worldServer, x, y, z));
player.setPositionAndUpdate(x, y, z);
if (oldDimension == 1) {
// For some reason teleporting out of the end does weird things.
player.setPositionAndUpdate(x, y, z);
worldServer.spawnEntity(player);
worldServer.updateEntityWithOptionalForce(player, false);
}
}
示例4: moveMemberToReturnPoint
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public void moveMemberToReturnPoint(EntityPlayer player)
{
if (this.returnX == 0 && this.returnY == 0 && this.returnZ == 0) // No return point set
{
Main.sendMessageToPlayer(player, "Looks like no return point has been set set.");
return;
}
player.setPositionAndUpdate(this.returnX, this.returnY, this.returnZ);
// Different dimension, so transfering them
if (this.returnDim != player.dimension)
{
Transition.transferPlayerToDimension((EntityPlayerMP) player, this.returnDim, (int) this.returnY);
player.setPositionAndUpdate(this.returnX, this.returnY, this.returnZ); // Setting it again, just to make sure
}
}
示例5: performTeleport
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static boolean performTeleport(World world, EntityPlayer player, TeleportPosition target) {
BlockPos pos = target.position;
if(world.provider.getDimension() != target.dimension) {
teleportToDimension(player, target.dimension, pos.getX(), pos.getY(), pos.getZ());
}
else {
player.setPositionAndUpdate(pos.getX()+0.5, pos.getY()+1, pos.getZ()+0.5);
}
return true;
}
示例6: movePlayer
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
private static void movePlayer(Vec3d destination, EntityPlayer player, boolean keepMomentum) {
player.setPositionAndUpdate(destination.x, destination.y, destination.z);
if(keepMomentum) {
Vec3d velocity = player.getLookVec();
velocity = velocity.scale(0.25);
SPacketEntityVelocity p = new SPacketEntityVelocity(player.getEntityId(), velocity.x, velocity.y, velocity.z);
((EntityPlayerMP) player).connection.sendPacket(p);
}
}