Java Code Examples for net.minecraft.entity.player.EntityPlayer.setPositionAndUpdate()

The following are Jave code examples for showing how to use setPositionAndUpdate() of the net.minecraft.entity.player.EntityPlayer class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: tp-plus   File: CommandTPP.java   View Source Code Vote up 6 votes
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);
    }
}
 
Example 2
Project: uniquecrops   File: ItemEnderSnooker.java   View Source Code Vote up 6 votes
@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);
}
 
Example 3
Project: Whoosh   File: TeleportUtil.java   View Source Code Vote up 6 votes
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);
    }
}
 
Example 4
Project: minecraft-territorialdealings   File: _Territory.java   View Source Code Vote up 6 votes
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
	}
}
 
Example 5
Project: Whoosh   File: TeleportUtil.java   View Source Code Vote up 5 votes
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;
    }
 
Example 6
Project: Whoosh   File: TeleportUtil.java   View Source Code Vote up 5 votes
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);
        }
    }