Java Code Examples for org.bukkit.Location#getYaw()
The following examples show how to use
org.bukkit.Location#getYaw() .
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
Source File: Uncarried.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
public Uncarried(Flag flag, Post post, @Nullable Location location) { super(flag, post); if (location == null) location = flag.getReturnPoint(post); this.location = new Location( location.getWorld(), location.getBlockX() + 0.5, location.getBlockY(), location.getBlockZ() + 0.5, location.getYaw(), location.getPitch()); Block block = this.location.getBlock(); if (block.getType() == Material.STANDING_BANNER) { // Banner may already be here at match start this.oldBlock = BlockStates.cloneWithMaterial(block, Material.AIR); } else { this.oldBlock = block.getState(); } this.oldBase = block.getRelative(BlockFace.DOWN).getState(); }
Example 2
Source File: Loc.java From AnnihilationPro with MIT License | 6 votes |
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
Source File: MethodAPI_v1_13_R2.java From TAB with Apache License 2.0 | 5 votes |
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 4
Source File: MethodAPI_v1_7_R3.java From TAB with Apache License 2.0 | 5 votes |
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 5
Source File: MethodAPI_v1_10_R1.java From TAB with Apache License 2.0 | 5 votes |
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 6
Source File: MethodAPI_v1_13_R1.java From TAB with Apache License 2.0 | 5 votes |
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 File: Template.java From civcraft with GNU General Public License v2.0 | 5 votes |
public static String parseDirection(Location loc){ double rotation = (loc.getYaw() - 90) % 360; if (rotation < 0) { rotation += 360.0; } if (0 <= rotation && rotation < 22.5) { return "east"; //S > E } else if (22.5 <= rotation && rotation < 67.5) { return "east"; //SW > SE } else if (67.5 <= rotation && rotation < 112.5) { return "south"; //W > E } else if (112.5 <= rotation && rotation < 157.5) { return "west"; //NW > SW } else if (157.5 <= rotation && rotation < 202.5) { return "west"; //N > W } else if (202.5 <= rotation && rotation < 247.5) { return "west"; //NE > NW } else if (247.5 <= rotation && rotation < 292.5) { return "north"; //E > N } else if (292.5 <= rotation && rotation < 337.5) { return "east"; //SE > NE } else if (337.5 <= rotation && rotation < 360.0) { return "east"; //S > E } else { return null; } }
Example 8
Source File: Dragon.java From AnnihilationPro with MIT License | 5 votes |
@Override public Packet getTeleportPacket(Location loc) { // Class<?> PacketPlayOutEntityTeleport = Util.getCraftClass("PacketPlayOutEntityTeleport"); // // Object packet = null; // // try { // packet = PacketPlayOutEntityTeleport.getConstructor(new Class<?>[] { int.class, int.class, int.class, int.class, byte.class, byte.class }).newInstance(this.id, loc.getBlockX() * 32, loc.getBlockY() * 32, loc.getBlockZ() * 32, (byte) ((int) loc.getYaw() * 256 / 360), (byte) ((int) loc.getPitch() * 256 / 360)); // } catch (IllegalArgumentException e) { // //e.printStackTrace(); // } catch (SecurityException e) { // //e.printStackTrace(); // } catch (InstantiationException e) { // //e.printStackTrace(); // } catch (IllegalAccessException e) { // //e.printStackTrace(); // } catch (InvocationTargetException e) { // //e.printStackTrace(); // } catch (NoSuchMethodException e) { // //e.printStackTrace(); // } //return new PacketPlayOutEntityTeleport(this.id, loc.getBlockX() * 32, loc.getBlockY() * 32, loc.getBlockZ() * 32, (byte) ((int) loc.getYaw() * 256 / 360), (byte) ((int) loc.getPitch() * 256 / 360)); try { return new PacketPlayOutEntityTeleport(this.id, loc.getBlockX() * 32, loc.getBlockY() * 32, loc.getBlockZ() * 32, (byte) ((int) loc.getYaw() * 256 / 360), (byte) ((int) loc.getPitch() * 256 / 360), false); } catch (NoSuchMethodError e) { try { return PacketPlayOutEntityTeleport.class.getConstructor(Integer.TYPE,Integer.TYPE,Integer.TYPE,Integer.TYPE,Byte.TYPE,Byte.TYPE).newInstance(this.id, loc.getBlockX() * 32, loc.getBlockY() * 32, loc.getBlockZ() * 32, (byte) ((int) loc.getYaw() * 256 / 360), (byte) ((int) loc.getPitch() * 256 / 360)); } catch(Throwable t) { return null; } } }
Example 9
Source File: Utils.java From BedwarsRel with GNU General Public License v3.0 | 5 votes |
public static BlockFace getCardinalDirection(Location location) { double rotation = (location.getYaw() - 90) % 360; if (rotation < 0) { rotation += 360.0; } if (0 <= rotation && rotation < 22.5) { return BlockFace.NORTH; } else if (22.5 <= rotation && rotation < 67.5) { return BlockFace.NORTH_EAST; } else if (67.5 <= rotation && rotation < 112.5) { return BlockFace.EAST; } else if (112.5 <= rotation && rotation < 157.5) { return BlockFace.SOUTH_EAST; } else if (157.5 <= rotation && rotation < 202.5) { return BlockFace.SOUTH; } else if (202.5 <= rotation && rotation < 247.5) { return BlockFace.SOUTH_WEST; } else if (247.5 <= rotation && rotation < 292.5) { return BlockFace.WEST; } else if (292.5 <= rotation && rotation < 337.5) { return BlockFace.NORTH_WEST; } else if (337.5 <= rotation && rotation < 360.0) { return BlockFace.NORTH; } else { return BlockFace.NORTH; } }
Example 10
Source File: MethodAPI_v1_5_R1.java From TAB with Apache License 2.0 | 5 votes |
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
Source File: MethodAPI_v1_6_R2.java From TAB with Apache License 2.0 | 5 votes |
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 12
Source File: LocationBuilder.java From AstralEdit with Apache License 2.0 | 5 votes |
/** * Initializes a new LocationBuilder from the given BukkitLocation * * @param location location */ public LocationBuilder(Location location) { super(); if (location == null) throw new IllegalArgumentException("Location cannot be null!"); this.world = location.getWorld().getName(); this.x = location.getX(); this.y = location.getY(); this.z = location.getZ(); this.yaw = location.getYaw(); this.pitch = location.getPitch(); }
Example 13
Source File: MethodAPI_v1_5_R3.java From TAB with Apache License 2.0 | 5 votes |
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 14
Source File: Camp.java From civcraft with GNU General Public License v2.0 | 5 votes |
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 (dir.equalsIgnoreCase("east")) { loc.setZ(loc.getZ() - (z_size / 2)); loc.setX(loc.getX() + SHIFT_OUT); } else if (dir.equalsIgnoreCase("west")) { loc.setZ(loc.getZ() - (z_size / 2)); loc.setX(loc.getX() - (SHIFT_OUT+x_size)); } else if (dir.equalsIgnoreCase("north")) { loc.setX(loc.getX() - (x_size / 2)); loc.setZ(loc.getZ() - (SHIFT_OUT+z_size)); } else if (dir.equalsIgnoreCase("south")) { loc.setX(loc.getX() - (x_size / 2)); loc.setZ(loc.getZ() + SHIFT_OUT); } return loc; }
Example 15
Source File: MobSelector.java From CloudNet with Apache License 2.0 | 5 votes |
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 16
Source File: PacketPlayOutSpawnEntityLiving.java From TAB with Apache License 2.0 | 5 votes |
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 17
Source File: Tools.java From ce with GNU Lesser General Public License v3.0 | 5 votes |
private static String getPlayerDirection(Location loc) { double rotation = (loc.getYaw() - 90) % 360; if (rotation < 0) { rotation += 360.0; } if (0 <= rotation && rotation < 22.5) { return "W"; } else if (22.5 <= rotation && rotation < 67.5) { return "NW"; } else if (67.5 <= rotation && rotation < 112.5) { return "N"; } else if (112.5 <= rotation && rotation < 157.5) { return "NE"; } else if (157.5 <= rotation && rotation < 202.5) { return "E"; // E } else if (202.5 <= rotation && rotation < 247.5) { return "SE"; } else if (247.5 <= rotation && rotation < 292.5) { return "S"; } else if (292.5 <= rotation && rotation < 337.5) { return "SW"; } else if (337.5 <= rotation && rotation < 360.0) { return "W"; } else { return null; } }
Example 18
Source File: Flag.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
protected Flag(Match match, FlagDefinition definition, ImmutableSet<Net> nets) throws ModuleLoadException { super(definition, match); this.nets = nets; final TeamMatchModule tmm = match.getMatchModule(TeamMatchModule.class); this.owner = definition.owner() .map(def -> tmm.team(def)) // Do not use a method ref here, it will NPE if tmm is null .orElse(null); this.capturers = Lazy.from( () -> Optionals.stream(match.module(TeamMatchModule.class)) .flatMap(TeamMatchModule::teams) .filter(team -> getDefinition().canPickup(team) && canCapture(team)) .collect(Collectors.toSet()) ); this.controllers = Lazy.from( () -> nets.stream() .flatMap(net -> Optionals.stream(net.returnPost() .flatMap(Post::owner))) .map(def -> tmm.team(def)) .collect(Collectors.toSet()) ); this.completers = Lazy.from( () -> nets.stream() .flatMap(net -> Optionals.stream(net.returnPost())) .filter(Post::isPermanent) .flatMap(post -> Optionals.stream(post.owner())) .map(def -> tmm.team(def)) .collect(Collectors.toSet()) ); Banner banner = null; pointLoop: for(PointProvider returnPoint : definition.getDefaultPost().getReturnPoints()) { Region region = returnPoint.getRegion(); if(region instanceof PointRegion) { // Do not require PointRegions to be at the exact center of the block. // It might make sense to just override PointRegion.getBlockVectors() to // always do this, but it does technically violate the contract of that method. banner = toBanner(((PointRegion) region).getPosition().toLocation(match.getWorld()).getBlock()); if(banner != null) break pointLoop; } else { for(BlockVector pos : returnPoint.getRegion().getBlockVectors()) { banner = toBanner(pos.toLocation(match.getWorld()).getBlock()); if(banner != null) break pointLoop; } } } if(banner == null) { throw new ModuleLoadException("Flag '" + getName() + "' must have a banner at its default post"); } final Location location = Banners.getLocationWithYaw(banner); bannerInfo = new BannerInfo(location, Banners.getItemMeta(banner), new ItemStack(Material.BANNER), new StaticAngleProvider(location.getYaw())); bannerInfo.item.setItemMeta(bannerInfo.meta); match.registerEvents(this); this.state = new Returned(this, this.getDefinition().getDefaultPost(), bannerInfo.location); this.state.enterState(); }
Example 19
Source File: Buildable.java From civcraft with GNU General Public License v2.0 | 4 votes |
public static Location repositionCenterStatic(Location center, ConfigBuildableInfo info, 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 (info.tile_improvement) { // 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 (info.templateYShift != 0) { // Y-Shift based on the config, this allows templates to be built underground. loc.setY(loc.getY() + info.templateYShift); if (loc.getY() < 1) { throw new CivException("Cannot build here, too close to bedrock."); } } return loc; }
Example 20
Source File: MathUtils.java From NoteBlockAPI with GNU Lesser General Public License v3.0 | 2 votes |
/** * Calculate new location for stereo * @param location origin location * @param distance negative for left side, positive for right side * @return */ public static Location stereoPan(Location location, float distance){ float yaw = location.getYaw(); return location.clone().add( getCos()[(int) (yaw + 360) % 360] * distance, 0, getSin()[(int) (yaw + 360) % 360] * distance); }