Java Code Examples for org.bukkit.Location#getPitch()

The following examples show how to use org.bukkit.Location#getPitch() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public void marshalListItem(Element element, Location item) {
	Element worldElement = element.addElement("world");
	Element xElement = element.addElement("x");
	Element yElement = element.addElement("y");
	Element zElement = element.addElement("z");
	
	worldElement.addText(item.getWorld().getName());
	xElement.addText(String.valueOf(item.getX()));
	yElement.addText(String.valueOf(item.getY()));
	zElement.addText(String.valueOf(item.getZ()));
	
	if (item.getYaw() != 0f) {
		element.addElement("yaw").addText(String.valueOf(item.getYaw()));
	}
	if (item.getPitch() != 0f) {
		element.addElement("pitch").addText(String.valueOf(item.getPitch()));
	}
}
 
Example 2
Source Project: AnnihilationPro   File: Loc.java    License: MIT License 6 votes vote down vote up
public Loc(Location loc, boolean precise)
{
	this.world = loc.getWorld().getName();
	if(precise)
	{
		x = loc.getX();
		y = loc.getY();
		z = loc.getZ();
		pitch = loc.getPitch();
		yaw = loc.getYaw();
	}
	else
	{
		x = loc.getBlockX();
		y = loc.getBlockY();
		z = loc.getBlockZ();
		pitch = 0;
		yaw = 0;
	}
}
 
Example 3
public PacketPlayOutSpawnEntityLiving(int entityId, UUID uuid, int entityType, Location loc) {
	if (loc == null) throw new IllegalArgumentException("Location cannot be null");
	this.entityId = entityId;
	this.uuid = uuid;
	this.entityType = entityType;
	this.x = loc.getX();
	this.y = loc.getY();
	this.z = loc.getZ();
	this.yaw = loc.getYaw();
	this.pitch = loc.getPitch();
}
 
Example 4
Source Project: CloudNet   File: MobSelector.java    License: Apache License 2.0 5 votes vote down vote up
public MobPosition toPosition(String group, Location location) {
    return new MobPosition(group,
                           location.getWorld().getName(),
                           location.getX(),
                           location.getY(),
                           location.getZ(),
                           location.getYaw(),
                           location.getPitch());
}
 
Example 5
Source Project: TAB   File: MethodAPI_v1_5_R3.java    License: Apache License 2.0 5 votes vote down vote up
public Object newPacketPlayOutEntityTeleport(Object entityliving, Location loc) {
	EntityLiving entity = (EntityLiving) entityliving;
	entity.locX = loc.getX();
	entity.locY = loc.getY();
	entity.locZ = loc.getZ();
	entity.yaw = loc.getYaw();
	entity.pitch = loc.getPitch();
	return new Packet34EntityTeleport(entity);
}
 
Example 6
Source Project: TAB   File: MethodAPI_v1_14_R1.java    License: Apache License 2.0 5 votes vote down vote up
public Object newPacketPlayOutEntityTeleport(Object entityliving, Location loc) {
	EntityLiving entity = (EntityLiving) entityliving;
	entity.locX = loc.getX();
	entity.locY = loc.getY();
	entity.locZ = loc.getZ();
	entity.yaw = loc.getYaw();
	entity.pitch = loc.getPitch();
	return new PacketPlayOutEntityTeleport(entity);
}
 
Example 7
Source Project: TAB   File: MethodAPI_v1_13_R1.java    License: Apache License 2.0 5 votes vote down vote up
public Object newPacketPlayOutEntityTeleport(Object entityliving, Location loc) {
	EntityLiving entity = (EntityLiving) entityliving;
	entity.locX = loc.getX();
	entity.locY = loc.getY();
	entity.locZ = loc.getZ();
	entity.yaw = loc.getYaw();
	entity.pitch = loc.getPitch();
	return new PacketPlayOutEntityTeleport(entity);
}
 
Example 8
Source Project: TAB   File: MethodAPI_v1_11_R1.java    License: Apache License 2.0 5 votes vote down vote up
public Object newPacketPlayOutEntityTeleport(Object entityliving, Location loc) {
	EntityLiving entity = (EntityLiving) entityliving;
	entity.locX = loc.getX();
	entity.locY = loc.getY();
	entity.locZ = loc.getZ();
	entity.yaw = loc.getYaw();
	entity.pitch = loc.getPitch();
	return new PacketPlayOutEntityTeleport(entity);
}
 
Example 9
Source Project: TAB   File: MethodAPI_v1_6_R3.java    License: Apache License 2.0 5 votes vote down vote up
public Object newPacketPlayOutEntityTeleport(Object entityliving, Location loc) {
	EntityLiving entity = (EntityLiving) entityliving;
	entity.locX = loc.getX();
	entity.locY = loc.getY();
	entity.locZ = loc.getZ();
	entity.yaw = loc.getYaw();
	entity.pitch = loc.getPitch();
	return new Packet34EntityTeleport(entity);
}
 
Example 10
Source Project: TAB   File: MethodAPI_v1_5_R2.java    License: Apache License 2.0 5 votes vote down vote up
public Object newPacketPlayOutEntityTeleport(Object entityliving, Location loc) {
	EntityLiving entity = (EntityLiving) entityliving;
	entity.locX = loc.getX();
	entity.locY = loc.getY();
	entity.locZ = loc.getZ();
	entity.yaw = loc.getYaw();
	entity.pitch = loc.getPitch();
	return new Packet34EntityTeleport(entity);
}
 
Example 11
@Override
protected void readServerData(ByteBuf serverdata) {
	xOrig = x = serverdata.readDouble();
	yOrig = y = serverdata.readDouble();
	zOrig = z = serverdata.readDouble();
	yawOrig = yaw = serverdata.readFloat();
	pitchOrig = pitch = serverdata.readFloat();
	flags = serverdata.readByte();
	if (flags != 0) {
		Location location = connection.getPlayer().getLocation();
		if ((flags & 0x01) != 0) {
			x += location.getX();
		}
		if ((flags & 0x02) != 0) {
			y += location.getY();
		}
		if ((flags & 0x04) != 0) {
			z += location.getX();
		}
		if ((flags & 0x08) != 0) {
			pitch += location.getPitch();
		}
		if ((flags & 0x10) != 0) {
			yaw += location.getYaw();
		}
	}
	teleportConfirmId = VarNumberSerializer.readVarInt(serverdata);
}
 
Example 12
Source Project: TAB   File: MethodAPI_v1_7_R3.java    License: Apache License 2.0 5 votes vote down vote up
public Object newPacketPlayOutEntityTeleport(Object entityliving, Location loc) {
	EntityLiving entity = (EntityLiving) entityliving;
	entity.locX = loc.getX();
	entity.locY = loc.getY();
	entity.locZ = loc.getZ();
	entity.yaw = loc.getYaw();
	entity.pitch = loc.getPitch();
	return new PacketPlayOutEntityTeleport(entity);
}
 
Example 13
Source Project: TAB   File: MethodAPI_v1_12_R1.java    License: Apache License 2.0 5 votes vote down vote up
public Object newPacketPlayOutEntityTeleport(Object entityliving, Location loc) {
	EntityLiving entity = (EntityLiving) entityliving;
	entity.locX = loc.getX();
	entity.locY = loc.getY();
	entity.locZ = loc.getZ();
	entity.yaw = loc.getYaw();
	entity.pitch = loc.getPitch();
	return new PacketPlayOutEntityTeleport(entity);
}
 
Example 14
Source Project: TAB   File: MethodAPI_v1_10_R1.java    License: Apache License 2.0 5 votes vote down vote up
public Object newPacketPlayOutEntityTeleport(Object entityliving, Location loc) {
	EntityLiving entity = (EntityLiving) entityliving;
	entity.locX = loc.getX();
	entity.locY = loc.getY();
	entity.locZ = loc.getZ();
	entity.yaw = loc.getYaw();
	entity.pitch = loc.getPitch();
	return new PacketPlayOutEntityTeleport(entity);
}
 
Example 15
/**
 * Determines if two {@link Location}s are facing in the same direction, i.e. the yaw and pitch are the same.
 */
public static boolean sameDirection(final Location one, final Location two)
{
    return one.getYaw() == two.getYaw() && one.getPitch() == two.getPitch();
}
 
Example 16
Source Project: civcraft   File: Buildable.java    License: GNU General Public License v2.0 4 votes vote down vote up
protected Location repositionCenter(Location center, String dir, double x_size, double z_size) throws CivException {
	Location loc = new Location(center.getWorld(), 
			center.getX(), center.getY(), center.getZ(), 
			center.getYaw(), center.getPitch());
	
	
	// Reposition tile improvements
	if (this.isTileImprovement()) {
		// just put the center at 0,0 of this chunk?
		loc = center.getChunk().getBlock(0, center.getBlockY(), 0).getLocation();
	} else {  
		if (dir.equalsIgnoreCase("east")) {
			loc.setZ(loc.getZ() - (z_size / 2));
			loc = center.getChunk().getBlock(0, center.getBlockY(), 0).getLocation();
			loc.setX(loc.getX() + SHIFT_OUT);
		}
		else if (dir.equalsIgnoreCase("west")) {
			loc.setZ(loc.getZ() - (z_size / 2));
			loc = center.getChunk().getBlock(0, center.getBlockY(), 0).getLocation();
			loc.setX(loc.getX() - (SHIFT_OUT+x_size));
		}
		else if (dir.equalsIgnoreCase("north")) {
			loc.setX(loc.getX() - (x_size / 2));
			loc = center.getChunk().getBlock(0, center.getBlockY(), 0).getLocation();
			loc.setZ(loc.getZ() - (SHIFT_OUT+z_size));
		}
		else if (dir.equalsIgnoreCase("south")) {
			loc.setX(loc.getX() - (x_size / 2));
			loc = center.getChunk().getBlock(0, center.getBlockY(), 0).getLocation();
			loc.setZ(loc.getZ() + SHIFT_OUT);
		}
	}  
	if (this.getTemplateYShift() != 0) {
		// Y-Shift based on the config, this allows templates to be built underground.
		loc.setY(loc.getY() + this.getTemplateYShift());
		
		if (loc.getY() < 1) {
			throw new CivException("Cannot build here, too close to bedrock.");
		}
	}
			
	return loc;
}
 
Example 17
public String serializeLocation(Location location) {
    return location.getX() + " " + location.getY() + " " + location.getZ() + " " + location.getYaw() + " " + location.getPitch();
}
 
Example 18
public boolean wasOrphan(Location loc) {
    return loc != null && loc.getYaw() == ORPHAN_YAW && loc.getPitch() == ORPHAN_PITCH;
}
 
Example 19
public static String setLocationToString(Location location) {
    return location.getX() + ";" + location.getY() + ";" + location.getZ() + ";" + location.getYaw() + ";"
            + location.getPitch();
}
 
Example 20
Source Project: Holograms   File: LocationUtil.java    License: MIT License 2 votes vote down vote up
/**
 * Converts a Location into a String
 *
 * @param location A location to be converted
 * @return A string representation of the Location
 */
public static String locationAsString(Location location) {
    return location.getWorld().getName() + ";" + location.getX() + ";" + location.getY()
            + ";" + location.getZ() + ";" + location.getPitch() + ";" + location.getYaw();
}