@Override public Chunk getChunk() { return location.getChunk(); }
/** * Registers the entity to this world. * * @param entity The entity. */ @SuppressWarnings("unchecked") void register(GlowEntity entity) { if (entity.entityId == 0) { throw new IllegalStateException("Entity has not been assigned an id."); } entities.put(entity.entityId, entity); groupedEntities.put(entity.getClass(), entity); ((GlowChunk) entity.location.getChunk()).getRawEntities().add(entity); }
/** * Notes that an entity has moved from one location to another for physics and storage purposes. * * @param entity The entity. * @param newLocation The new location. */ void move(GlowEntity entity, Location newLocation) { Chunk prevChunk = entity.location.getChunk(); Chunk newChunk = newLocation.getChunk(); if (prevChunk != newChunk) { ((GlowChunk) prevChunk).getRawEntities().remove(entity); ((GlowChunk) newChunk).getRawEntities().add(entity); } }
/** * Unregister the entity to this world. * * @param entity The entity. */ void unregister(GlowEntity entity) { EventFactory.getInstance().callEvent(new EntityRemoveFromWorldEvent(entity)); entities.remove(entity.entityId); groupedEntities.remove(entity.getClass(), entity); ((GlowChunk) entity.location.getChunk()).getRawEntities().remove(entity); }
@Override public void run() { Block block = location.getBlock(); if (block == null) { cancel(); return; } if (!location.getChunk().isLoaded()) { return; } if (block.getType() != originalMaterial) { cancel(); return; } ItemTable table = ItemTable.instance(); BlockType type = table.getBlock(originalMaterial); if (type != null) { type.receivePulse((GlowBlock) block); } } }
private GlowItem getFirstDroppedItem(Location location) { for (Entity entity : location.getChunk().getEntities()) { if (location.getBlockX() != entity.getLocation().getBlockX() || location.getBlockY() != entity.getLocation().getBlockY() || location.getBlockZ() != entity.getLocation().getBlockZ()) { continue; } if (entity.getType() != EntityType.DROPPED_ITEM) { continue; } return ((GlowItem) entity); } return null; }
return false; Chunk chunk = CommandUtils.getLocation(sender).getChunk(); sender .sendMessage(
.filter(player -> player.canSeeChunk(GlowChunk.Key.to(dugLocation.getChunk()))) .forEach(player -> player.sendBlockChange(dugLocation, Material.AIR, (byte) 0)); setDigging(null);
private void pulseTickMap() { ItemTable itemTable = ItemTable.instance(); for (Location location : tickMap) { GlowChunk chunk = (GlowChunk) location.getChunk(); if (!chunk.isLoaded()) { continue; } int typeId = chunk.getType( location.getBlockX() & 0xF, location.getBlockZ() & 0xF, location.getBlockY()); BlockType type = itemTable.getBlock(typeId); if (type == null) { cancelPulse(location); continue; } GlowBlock block = new GlowBlock(chunk, location.getBlockX(), location .getBlockY(), location.getBlockZ()); Integer speed = type.getPulseTickSpeed(block); boolean once = type.isPulseOnce(block); if (speed == 0) { continue; } if (fullTime % speed == 0) { type.receivePulse(block); if (once) { cancelPulse(location); } } } }
Chunk locationChunk = location.getChunk(); if (locationChunk.getX() == chunk.getX() && locationChunk.getZ() == chunk.getZ()) { int tileX = location.getBlockX();
protected BlockLight(Location location, long ticks) { this.block = location.getBlock(); this.chunk = location.getChunk(); this.originalLight = block.getLightLevel(); this.currentLight = originalLight; this.cachedLight = originalLight; this.removeLater(ticks); }
public boolean isInChunk(Location loc) { if (loc == null) { return false; } Chunk chunk = loc.getChunk(); return loc.getWorld().getName().equalsIgnoreCase(getWorldName()) && chunk.getX() == x && chunk.getZ() == z; }
private void resendChunkRadiusAt(Player player, int radius) { Chunk chunk = player.getLocation().getChunk(); World world = player.getWorld(); int chunkX = chunk.getX(); int chunkZ = chunk.getZ(); for (int x = chunkX - radius; x <= chunkX + radius; x++) { for (int z = chunkZ - radius; z <= chunkZ + radius; z++) { world.refreshChunk(x, z); } } } }
private static ArmorStand getArmorStand(Block b) { Location l = new Location(b.getWorld(), b.getX() + 0.5, b.getY() - 0.7F, b.getZ() + 0.5); for (Entity n: l.getChunk().getEntities()) { if (n instanceof ArmorStand) { if (n.getCustomName() != null && l.distanceSquared(n.getLocation()) < 0.4D) return (ArmorStand) n; } } ArmorStand hologram = ArmorStandFactory.createHidden(l); return hologram; }
private static ArmorStand getArmorStand(Block b) { Location l = new Location(b.getWorld(), b.getX() + 0.5, b.getY() - 0.7F, b.getZ() + 0.5); for (Entity n: l.getChunk().getEntities()) { if (n instanceof ArmorStand) { if (n.getCustomName() != null && l.distanceSquared(n.getLocation()) < 0.4D) return (ArmorStand) n; } } ArmorStand hologram = ArmorStandFactory.createHidden(l); return hologram; }
private Location getRelativeLocation(Player p) { Location playerLoc = p.getLocation(); double x = dd.getFromToLocation().getX() + (playerLoc.getX() - dd.getLocation().getX()); double y = dd.getFromToLocation().getY() + (playerLoc.getY() - dd.getLocation().getY()) + 1.1d; double z = dd.getFromToLocation().getZ() + (playerLoc.getZ() - dd.getLocation().getZ()); Location l = new Location(dd.getFromToLocation().getWorld(), x, y, z, playerLoc.getYaw(), playerLoc.getPitch()); while (!l.getChunk().isLoaded()) { l.getChunk().load(); } return l; }
public static ArmorStand getArmorStand(Location reactor) { Location l = new Location(reactor.getWorld(), reactor.getX() + 0.5, reactor.getY(), reactor.getZ() + 0.5); for (Entity n : l.getChunk().getEntities()) { if (n instanceof ArmorStand) { if (l.distanceSquared(n.getLocation()) < 0.4D) return (ArmorStand) n; } } ArmorStand hologram = ArmorStandFactory.createHidden(l); hologram.setCustomNameVisible(false); hologram.setCustomName(null); return hologram; }
public static ArmorStand getArmorStand(Block hopper) { Location l = new Location(hopper.getWorld(), hopper.getX() + 0.5, hopper.getY(), hopper.getZ() + 0.5); for (Entity n: l.getChunk().getEntities()) { if (n instanceof ArmorStand) { if (n.getCustomName() == null && l.distanceSquared(n.getLocation()) < 0.4D) return (ArmorStand) n; } } ArmorStand hologram = ArmorStandFactory.createHidden(l); hologram.setCustomNameVisible(false); hologram.setCustomName(null); return hologram; }
public static ArmorStand getArmorStand(Block hopper) { Location l = new Location(hopper.getWorld(), hopper.getX() + 0.5, hopper.getY() + offset, hopper.getZ() + 0.5); for (Entity n: l.getChunk().getEntities()) { if (n instanceof ArmorStand) { if (n.getCustomName() == null && l.distanceSquared(n.getLocation()) < 0.4D) return (ArmorStand) n; } } ArmorStand hologram = ArmorStandFactory.createHidden(l); hologram.setCustomNameVisible(false); hologram.setCustomName(null); return hologram; }