Refine search
@Override public void sendSignChange(Location location, String[] lines) throws IllegalArgumentException { checkNotNull(location, "location cannot be null"); checkNotNull(lines, "lines cannot be null"); checkArgument(lines.length == 4, "lines.length must equal 4"); afterBlockChanges.add(UpdateSignMessage .fromPlainText(location.getBlockX(), location.getBlockY(), location .getBlockZ(), lines)); }
/** * Send a block entity change to the given location. * * @param location The location of the block entity. * @param type The type of block entity being sent. * @param nbt The NBT structure to send to the client. */ public void sendBlockEntityChange(Location location, GlowBlockEntity type, CompoundTag nbt) { checkNotNull(location, "Location cannot be null"); checkNotNull(type, "Type cannot be null"); checkNotNull(nbt, "NBT cannot be null"); afterBlockChanges.add(new UpdateBlockEntityMessage(location.getBlockX(), location .getBlockY(), location.getBlockZ(), type.getValue(), nbt)); }
protected BlockFace calculateFace(GlowPlayer player, GlowBlockState state) { Location playerLoc = player.getLocation(); // the location of the player Location blockLoc = state.getLocation(); // the location of the block if (Math.abs(playerLoc.getBlockX() - blockLoc.getBlockX()) < 2.0F && Math.abs(playerLoc.getBlockZ() - blockLoc.getBlockZ()) < 2.0F) { double offset = playerLoc.getBlockY() + player.getEyeHeight(); if (offset - blockLoc.getBlockY() > 2.0) { return BlockFace.UP; } if (blockLoc.getBlockY() - offset > 0.0) { return DOWN; } } return player.getCardinalFacing().getOppositeFace(); } }
/** * Attempts to grow this tree at its current location. If successful, the associated {@link * BlockStateDelegate} is instructed to set blocks to wood and leaves. * * @param loc the base of the trunk * @return true if successfully grown; false otherwise * @deprecated use {@link #generate(World, Random, int, int, int)} */ @Deprecated public boolean generate(Location loc) { return generate(loc.getWorld(), ThreadLocalRandom.current(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); }
private void createNewBoundingBox(Location location, Vector size) { Vector min = new Vector(location.getBlockX(), location.getBlockY(), location.getBlockZ()); Vector max = new Vector(location.getBlockX() + size.getBlockX() - 1, location.getBlockY() + size.getBlockY() - 1, location.getBlockZ() + size.getBlockZ() - 1); boundingBox = new StructureBoundingBox(min, max); }
@Override public List<Message> createSpawnMessage() { int x = location.getBlockX(); int y = location.getBlockY(); int z = location.getBlockZ(); return Lists.newArrayList( new SpawnObjectMessage( entityId, getUniqueId(), SpawnObjectMessage.LEASH_HITCH, x, y, z, 0, 0), new EntityMetadataMessage(entityId, metadata.getEntryList()) ); }
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; }
/** * Send a sign change, similar to {@link #sendSignChange(Location, String[])}, but using * complete TextMessages instead of strings. * * @param sign the sign * @param location the location of the sign * @param lines the new text on the sign or null to clear it * @throws IllegalArgumentException if location is null * @throws IllegalArgumentException if lines is non-null and has a length less than 4 */ public void sendSignChange(SignEntity sign, Location location, TextMessage[] lines) throws IllegalArgumentException { checkNotNull(location, "location cannot be null"); checkNotNull(lines, "lines cannot be null"); checkArgument(lines.length == 4, "lines.length must equal 4"); CompoundTag tag = new CompoundTag(); sign.saveNbt(tag); afterBlockChanges.add(new UpdateBlockEntityMessage(location.getBlockX(), location .getBlockY(), location.getBlockZ(), GlowBlockEntity.SIGN.getValue(), tag)); }
@Override public void setBeamTarget(Location location) { if (location == null) { metadata.set(MetadataIndex.ENDERCRYSTAL_BEAM_TARGET, (BlockVector) null); } else if (!location.getWorld().equals(getWorld())) { throw new IllegalArgumentException( "Cannot set beam target location to different world"); } else { metadata.set(MetadataIndex.ENDERCRYSTAL_BEAM_TARGET, new BlockVector(location.getBlockX(), location.getBlockY(), location.getBlockZ())); } } }
@Override public List<Message> createSpawnMessage() { int x = artCenter.getBlockX(); int y = artCenter.getBlockY(); int z = artCenter.getBlockZ(); String title = getArtTitle(); return Collections.singletonList( new SpawnPaintingMessage(this.getEntityId(), this.getUniqueId(), title, x, y, z, facing.ordinal()) ); }
/** * Creates a new region at the given corner with the same dimensions as this region. * @param lowCorner The corner to base the new region off of. * @return The new region. */ public RectangularRegion moveTo(Location lowCorner) { return new RectangularRegion( lowCorner, new Location( lowCorner.getWorld(), lowCorner.getBlockX() + widthX, lowCorner.getBlockY() + widthY, lowCorner.getBlockZ() + widthZ ) ); }
@Override public List<Message> createSpawnMessage() { int yaw = getYaw(); return Arrays.asList( new SpawnObjectMessage(entityId, getUniqueId(), SpawnObjectMessage.ITEM_FRAME, location.getBlockX(), location.getBlockY(), location.getBlockZ(), 0, yaw, HangingFace.getByBlockFace(getFacing()).ordinal()), new EntityMetadataMessage(entityId, metadata.getEntryList()) ); }
/** * 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())); }