@Override public Location getLocation() { return location.clone(); }
@Override public Location getSpawnLocation() { return spawnLocation.clone(); }
public static Vector getRayBetween(Location target, Location source) { return target.clone().subtract(source).toVector(); } }
public Location getMountLocation() { return this.location.clone().add(0, this.getHeight(), 0); }
@Override public void setRawLocation(Location location, boolean fall) { // Also try to move the center of the painting along Location difference = location.subtract(artCenter); super.setRawLocation(location, fall); artCenter = location.clone().subtract(difference); } }
@Override public void setCenter(Location location) { center = location.clone(); broadcast(new WorldBorderMessage( WorldBorderMessage.Action.SET_CENTER, center.getX(), center.getZ())); }
private void spawnSnowman(Location location) { if (SNOWMAN_PATTERN.matches(location, true, 0, 0)) { location.getWorld() .spawnEntity(location.clone().subtract(-0.5, 2, -0.5), EntityType.SNOWMAN); } } }
@Override public void pulse() { super.pulse(); fuseTicks--; if (fuseTicks <= 0) { explode(); } else { world.playEffect(location.clone().add(0, 0.5, 0), Effect.SMOKE, 0); } }
/** * Launches a projectile from this entity. * * @param type the projectile class * @param vector the direction to shoot in * @param offset TODO: document this parameter * @param speed the speed for the first flight tick * @param <T> the projectile class * @return the launched projectile */ public <T extends Projectile> T launchProjectile(Class<? extends T> type, Vector vector, float offset, float speed) { if (vector == null) { vector = getVelocity(); } T projectile = launchProjectile(type, getEyeLocation().clone(), vector, offset, speed); projectile.setShooter(this); return projectile; }
@Override public boolean isInside(Location location) { Location max = center.clone().add(size / 2, 0, size / 2); Location min = center.clone().subtract(size / 2, 0, size / 2); return location.getX() <= max.getX() && location.getZ() <= max.getZ() && location.getX() >= min.getX() && location.getZ() >= min.getZ(); }
private boolean spawnIronGolem(Location location) { if (IRONGOLEM_PATTERN.matches(location, true, 1, 0)) { Entity entity = location.getWorld() .spawnEntity(location.clone().subtract(-0.5, 2, -0.5), EntityType.IRON_GOLEM); ((GlowIronGolem) entity).setPlayerCreated(true); return true; } return false; }
@Override protected void pulsePhysics() { if (location.getBlock().getType().isSolid()) { setRawLocation(location.clone().add(0, 0.2, 0), false); } super.pulsePhysics(); }
private Location getTopLeftCorner() { BlockFace left = getLeftFace(); Location topLeft = artCenter.clone(); int topMod = (int) getArtHeight(); int widthMod = (int) getArtWidth(); topLeft.add(left.getModX() * widthMod, topMod, left.getModZ() * widthMod); return topLeft; }
/** * Process random spawn chicks when collide with a block. * * @param block the block that the egg collides with */ @Override public void collide(Block block) { randomHatchSpawning(getLocation().clone()); getWorld().spawnParticle( Particle.ITEM_CRACK, location, 5, 0, 0, 0, 0.05, new ItemStack(Material.EGG)); remove(); }
/** * Teleport this entity to the spawn point of the main world. This is used to teleport out of * the End. * * @return {@code true} if the teleport was successful. */ protected boolean teleportToSpawn() { Location target = server.getWorlds().get(0).getSpawnLocation(); EntityPortalEvent event = EventFactory.getInstance() .callEvent(new EntityPortalEvent(this, location.clone(), target, null)); if (event.isCancelled()) { return false; } target = event.getTo(); teleport(target); return true; }
private void calculateRay(Vector direction, Collection<BlockVector> result) { Location current = location.clone(); float currentPower = calculateStartPower(); while (currentPower > 0) { GlowBlock block = world.getBlockAt(current); if (block.getType() != Material.AIR) { double blastDurability = getBlastDurability(block) / 5d; blastDurability += 0.3F; blastDurability *= 0.3F; currentPower -= blastDurability; if (currentPower > 0) { result.add(new BlockVector(block.getX(), block.getY(), block.getZ())); } } current.add(direction); currentPower -= 0.225f; } }
@Override protected boolean teleportToSpawn() { Location target = getBedSpawnLocation(); if (target == null) { target = server.getWorlds().get(0).getSpawnLocation(); } PlayerPortalEvent event = EventFactory.getInstance() .callEvent(new PlayerPortalEvent(this, location.clone(), target, null)); if (event.isCancelled()) { return false; } target = event.getTo(); spawnAt(target); teleported = true; awardAchievement(Achievement.THE_END, false); return true; }
private void kill(boolean dropArmorStand) { active = false; ((GlowWorld) location.getWorld()) .showParticle(location.clone().add(0, 1.317, 0), Effect.TILE_DUST, Material.WOOD.getId(), 0, 0.125f, 0.494f, 0.125f, 0.1f, 10, 10); for (ItemStack stack : equipment.getArmorContents()) { if (InventoryUtil.isEmpty(stack)) { continue; } getWorld().dropItemNaturally(location, stack); } if (dropArmorStand) { getWorld().dropItemNaturally(location, new ItemStack(Material.ARMOR_STAND)); } }
/** * Open the sign editor interface at the specified location. * * @param loc The location to open the editor at */ public void openSignEditor(Location loc) { signLocation = loc.clone(); signLocation.setX(loc.getBlockX()); signLocation.setY(loc.getBlockY()); signLocation.setZ(loc.getBlockZ()); signLocation.setYaw(0); signLocation.setPitch(0); // Client closes inventory when sign editor is opened if (!GlowInventoryView.isDefault(getOpenInventory())) { closeInventory(); } session.send(new SignEditorMessage(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); }