com.flowpowered.math.vector.Vector3i Java Examples
The following examples show how to use
com.flowpowered.math.vector.Vector3i.
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: CommandClaimSetSpawn.java From GriefDefender with MIT License | 6 votes |
@CommandAlias("claimsetspawn") @Description("Sets the spawn of claim.") @Subcommand("claim setspawn") public void execute(Player player) { final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()); final GDClaim claim = GriefDefenderPlugin.getInstance().dataStore.getClaimAtPlayer(playerData, player.getLocation()); final Component result = claim.allowEdit(player); if (result != null) { GriefDefenderPlugin.sendMessage(player, result); return; } final Vector3i pos = VecHelper.toVector3i(player.getLocation()); claim.getInternalClaimData().setSpawnPos(pos); final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.SPAWN_SET_SUCCESS, ImmutableMap.of( "location", pos)); GriefDefenderPlugin.sendMessage(player, message); }
Example #2
Source File: HiresModelManager.java From BlueMap with MIT License | 6 votes |
/** * Returns all tiles that the provided chunks are intersecting */ public Collection<Vector2i> getTilesForChunks(Iterable<Vector2i> chunks){ Set<Vector2i> tiles = new HashSet<>(); for (Vector2i chunk : chunks) { Vector3i minBlockPos = new Vector3i(chunk.getX() * 16, 0, chunk.getY() * 16); //loop to cover the case that a tile is smaller then a chunk, should normally only add one tile (at 0, 0) for (int x = 0; x < 15; x += getTileSize().getX()) { for (int z = 0; z < 15; z += getTileSize().getY()) { tiles.add(posToTile(minBlockPos.add(x, 0, z))); } } tiles.add(posToTile(minBlockPos.add(0, 0, 15))); tiles.add(posToTile(minBlockPos.add(15, 0, 0))); tiles.add(posToTile(minBlockPos.add(15, 0, 15))); } return tiles; }
Example #3
Source File: BlockUtils.java From GriefPrevention with MIT License | 6 votes |
public static boolean clickedClaimCorner(GPClaim claim, Vector3i clickedPos) { int clickedX = clickedPos.getX(); int clickedY = clickedPos.getY(); int clickedZ = clickedPos.getZ(); int lesserX = claim.getLesserBoundaryCorner().getBlockX(); int lesserY = claim.getLesserBoundaryCorner().getBlockY(); int lesserZ = claim.getLesserBoundaryCorner().getBlockZ(); int greaterX = claim.getGreaterBoundaryCorner().getBlockX(); int greaterY = claim.getGreaterBoundaryCorner().getBlockY(); int greaterZ = claim.getGreaterBoundaryCorner().getBlockZ(); if ((clickedX == lesserX || clickedX == greaterX) && (clickedZ == lesserZ || clickedZ == greaterZ) && (!claim.isCuboid() || (clickedY == lesserY || clickedY == greaterY))) { return true; } return false; }
Example #4
Source File: GDClaim.java From GriefDefender with MIT License | 6 votes |
@Override public boolean isInside(Claim claim) { final GDClaim otherClaim = (GDClaim) claim; if(!otherClaim.contains(this.lesserBoundaryCorner)) { return false; } if(!otherClaim.contains(this.greaterBoundaryCorner)) { return false; } if(!otherClaim.contains(new Vector3i(this.lesserBoundaryCorner.getX(), this.lesserBoundaryCorner.getY(), this.greaterBoundaryCorner.getZ()))) { return false; } if(!otherClaim.contains(new Vector3i(this.greaterBoundaryCorner.getX(), this.greaterBoundaryCorner.getY(), this.lesserBoundaryCorner.getZ()))) { return false; } return true; }
Example #5
Source File: GDClaim.java From GriefDefender with MIT License | 6 votes |
@Override public boolean isInside(Claim claim) { final GDClaim otherClaim = (GDClaim) claim; if(!otherClaim.contains(this.lesserBoundaryCorner)) { return false; } if(!otherClaim.contains(this.greaterBoundaryCorner)) { return false; } if(!otherClaim.contains(new Vector3i(this.lesserBoundaryCorner.getX(), this.lesserBoundaryCorner.getY(), this.greaterBoundaryCorner.getZ()))) { return false; } if(!otherClaim.contains(new Vector3i(this.greaterBoundaryCorner.getX(), this.greaterBoundaryCorner.getY(), this.lesserBoundaryCorner.getZ()))) { return false; } return true; }
Example #6
Source File: EconomyDataConfig.java From GriefDefender with MIT License | 6 votes |
@Override public @Nullable Vector3i getSaleSignPosition() { if (this.saleSignPos == null) { return null; } if (this.saleSignVec == null) { try { this.saleSignVec = BlockUtil.getInstance().posFromString(this.saleSignPos); } catch (Exception e) { e.printStackTrace(); } } return this.saleSignVec; }
Example #7
Source File: GDClaimManager.java From GriefDefender with MIT License | 6 votes |
public void createWildernessClaim(World world) { if (this.theWildernessClaim != null) { return; } final Vector3i lesserCorner = new Vector3i(-30000000, 0, -30000000); final Vector3i greaterCorner = new Vector3i(29999999, 255, 29999999); // Use world UUID as wilderness claim ID GDClaim wilderness = new GDClaim(world, lesserCorner, greaterCorner, world.getUniqueId(), ClaimTypes.WILDERNESS, null, false); wilderness.setOwnerUniqueId(GriefDefenderPlugin.WORLD_USER_UUID); wilderness.initializeClaimData(null); wilderness.claimData.save(); wilderness.claimStorage.save(); this.theWildernessClaim = wilderness; this.claimUniqueIdMap.put(wilderness.getUniqueId(), wilderness); }
Example #8
Source File: TileEntityServlet.java From Web-API with MIT License | 6 votes |
@GET @ExplicitDetails @Permission("list") @ApiOperation( value = "List tile entities", notes = "Get a list of all tile entities on the server (in all worlds, unless specified).") public Collection<CachedTileEntity> listTileEntities( @QueryParam("world") @ApiParam("The world to filter tile entities by") CachedWorld world, @QueryParam("type") @ApiParam("The type if of tile entities to filter by") String typeId, @QueryParam("min") @ApiParam("The minimum coordinates at which the tile entity must be, min=x|y|z") Vector3i min, @QueryParam("max") @ApiParam("The maximum coordinates at which the tile entity must be, max=x|y|z") Vector3i max, @QueryParam("limit") @ApiParam("The maximum amount of tile entities returned") int limit) { Predicate<TileEntity> filter = te -> typeId == null || te.getType().getId().equalsIgnoreCase(typeId); return cacheService.getTileEntities(world, min, max, filter, limit); }
Example #9
Source File: WorldsBase.java From EssentialCmds with MIT License | 6 votes |
@Override public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException { if (src instanceof Player) { Player player = (Player) src; Vector3i spawnPos = player.getWorld().getProperties().getSpawnPosition(); player.setLocation(new Location<>(player.getWorld(), spawnPos.getX(), spawnPos.getY(), spawnPos.getZ())); src.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Teleported to world spawn.")); } else { src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You cannot teleport, you are not a player!")); } return CommandResult.success(); }
Example #10
Source File: EconomyDataConfig.java From GriefDefender with MIT License | 6 votes |
@Override public @Nullable Vector3i getRentSignPosition() { if (this.rentSignPos == null) { return null; } if (this.rentSignVec == null) { try { this.rentSignVec = BlockUtil.getInstance().posFromString(this.rentSignPos); } catch (Exception e) { e.printStackTrace(); } } return this.rentSignVec; }
Example #11
Source File: RedstoneExtension.java From BlueMap with MIT License | 6 votes |
private String connection(MCAWorld world, Vector3i pos, boolean upBlocking, Direction direction) { Vector3i directionVector = direction.toVector(); BlockState next = world.getBlockState(pos.add(directionVector)); if (CONNECTIBLE.contains(next.getFullId())) return "side"; if (next.equals(BlockState.AIR)) { BlockState nextdown = world.getBlockState(pos.add(directionVector.getX(), directionVector.getY() - 1, directionVector.getZ())); if (nextdown.getFullId().equals("minecraft:redstone_wire")) return "side"; } if (!upBlocking) { BlockState nextup = world.getBlockState(pos.add(directionVector.getX(), directionVector.getY() + 1, directionVector.getZ())); if (nextup.getFullId().equals("minecraft:redstone_wire")) return "up"; } return "none"; }
Example #12
Source File: GDClaimManager.java From GriefDefender with MIT License | 6 votes |
private GDClaim findClaim(GDClaim claim, Vector3i pos, GDPlayerData playerData, boolean useBorderBlockRadius) { if (claim.contains(pos, playerData, useBorderBlockRadius)) { // when we find a top level claim, if the location is in one of its children, // return the child claim, not the top level claim for (Claim childClaim : claim.children) { GDClaim child = (GDClaim) childClaim; if (!child.children.isEmpty()) { GDClaim innerChild = findClaim(child, pos, playerData, useBorderBlockRadius); if (innerChild != null) { return innerChild; } } // check if child has children (Town -> Basic -> Subdivision) if (child.contains(pos, playerData, useBorderBlockRadius)) { return child; } } return claim; } return null; }
Example #13
Source File: ClaimDataConfig.java From GriefDefender with MIT License | 5 votes |
@Override public void setSpawnPos(Vector3i spawnPos) { if (spawnPos == null) { return; } this.requiresSave = true; this.spawnPos = spawnPos; this.claimSpawn = BlockUtil.getInstance().posToString(spawnPos); }
Example #14
Source File: ChunkAnvil112.java From BlueMap with MIT License | 5 votes |
@Override public LightData getLightData(Vector3i pos) { if (!hasLight) return LightData.SKY; int sectionY = MCAUtil.blockToChunk(pos.getY()); Section section = this.sections[sectionY]; if (section == null) return LightData.SKY; return section.getLightData(pos); }
Example #15
Source File: CommandClaimSpawn.java From GriefPrevention with MIT License | 5 votes |
@Override public CommandResult execute(CommandSource src, CommandContext ctx) { Player player; try { player = GriefPreventionPlugin.checkPlayer(src); } catch (CommandException e) { src.sendMessage(e.getText()); return CommandResult.success(); } final GPPlayerData playerData = GriefPreventionPlugin.instance.dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()); final GPClaim claim = GriefPreventionPlugin.instance.dataStore.getClaimAtPlayer(playerData, player.getLocation()); if (!playerData.canIgnoreClaim(claim) && !claim.isUserTrusted(player, TrustType.ACCESSOR) && !player.hasPermission(GPPermissions.COMMAND_DELETE_CLAIMS)) { GriefPreventionPlugin.sendMessage(src, GriefPreventionPlugin.instance.messageData.permissionAccess.toText()); return CommandResult.success(); } final Vector3i spawnPos = claim.getData().getSpawnPos().orElse(null); if (spawnPos == null) { GriefPreventionPlugin.sendMessage(src, GriefPreventionPlugin.instance.messageData.commandSpawnNotSet.toText()); return CommandResult.success(); } final Location<World> spawnLocation = new Location<World>(claim.getWorld(), spawnPos); player.setLocation(spawnLocation); final Text message = GriefPreventionPlugin.instance.messageData.commandSpawnTeleport .apply(ImmutableMap.of( "location", spawnPos)).build(); GriefPreventionPlugin.sendMessage(src, message); return CommandResult.success(); }
Example #16
Source File: SlicedWorld.java From BlueMap with MIT License | 5 votes |
private Block createAirBlock(Vector3i pos) { return new Block( this, BlockState.AIR, pos.getY() < this.min.getY() ? LightData.ZERO : LightData.SKY, Biome.DEFAULT, BlockProperties.TRANSPARENT, pos ); }
Example #17
Source File: ChunkAnvil112.java From BlueMap with MIT License | 5 votes |
public String getBlockIdMeta(Vector3i pos) { int sectionY = MCAUtil.blockToChunk(pos.getY()); Section section = this.sections[sectionY]; if (section == null) return "0:0"; return section.getBlockIdMeta(pos); }
Example #18
Source File: BlockColorCalculator.java From BlueMap with MIT License | 5 votes |
private Iterable<Biome> iterateAverageBiomes(Block block){ Vector3i pos = block.getPosition(); Vector3i radius = new Vector3i(2, 1, 2); final World world = block.getWorld(); final int sx = pos.getX() - radius.getX(), sy = pos.getY() - radius.getY(), sz = pos.getZ() - radius.getZ(); final int mx = pos.getX() + radius.getX(), my = pos.getY() + radius.getY(), mz = pos.getZ() + radius.getZ(); return () -> new Iterator<Biome>() { private int x = sx, y = sy, z = sz; @Override public boolean hasNext() { return z < mz || y < my || x < mx; } @Override public Biome next() { x++; if (x > mx) { x = sx; y++; } if (y > my) { y = sy; z++; } return world.getBiome(new Vector3i(x, y, z)); } }; }
Example #19
Source File: ChunkAnvil116.java From BlueMap with MIT License | 5 votes |
public LightData getLightData(Vector3i pos) { int x = pos.getX() & 0xF; // Math.floorMod(pos.getX(), 16) int y = pos.getY() & 0xF; int z = pos.getZ() & 0xF; int blockByteIndex = y * 256 + z * 16 + x; int blockHalfByteIndex = blockByteIndex >> 1; // blockByteIndex / 2 boolean largeHalf = (blockByteIndex & 0x1) != 0; // (blockByteIndex % 2) == 0 int blockLight = getByteHalf(this.blockLight[blockHalfByteIndex], largeHalf); int skyLight = getByteHalf(this.skyLight[blockHalfByteIndex], largeHalf); return new LightData(skyLight, blockLight); }
Example #20
Source File: FactionLogicImpl.java From EagleFactions with MIT License | 5 votes |
@Override public boolean isClaimed(final UUID worldUUID, final Vector3i chunk) { checkNotNull(worldUUID); checkNotNull(chunk); for(Claim claim : getAllClaims()) { if (claim.getWorldUUID().equals(worldUUID) && claim.getChunkPosition().equals(chunk)) return true; } return false; }
Example #21
Source File: DoublePlantExtension.java From BlueMap with MIT License | 5 votes |
@Override public BlockState extend(MCAWorld world, Vector3i pos, BlockState state) { if (Objects.equals(state.getProperties().get("half"), "upper")) { BlockState otherPlant = world.getBlockState(pos.add(Direction.DOWN.toVector())); return otherPlant.with("half", "upper"); } return state; }
Example #22
Source File: AABB.java From BlueMap with MIT License | 5 votes |
/** * Gets the size of the box. * * @return The size */ public Vector3i getSize() { if (this.size == null) { this.size = this.max.sub(this.min).add(Vector3i.ONE); } return this.size; }
Example #23
Source File: FactionLogicImpl.java From EagleFactions with MIT License | 5 votes |
@Override public void startClaiming(final Player player, final Faction faction, final UUID worldUUID, final Vector3i chunkPosition) { checkNotNull(player); checkNotNull(faction); checkNotNull(worldUUID); checkNotNull(chunkPosition); if(this.factionsConfig.shouldDelayClaim()) { player.sendMessage(Text.of(PluginInfo.PLUGIN_PREFIX, MessageLoader.parseMessage(Messages.STAY_IN_THE_CHUNK_FOR_NUMBER_SECONDS_TO_CLAIM_IT, TextColors.GREEN, Collections.singletonMap(Placeholders.NUMBER, Text.of(TextColors.GOLD, this.factionsConfig.getClaimDelay()))))); EagleFactionsScheduler.getInstance().scheduleWithDelayedInterval(new ClaimDelayTask(player, chunkPosition), 1, TimeUnit.SECONDS, 1, TimeUnit.SECONDS); } else { if(this.factionsConfig.shouldClaimByItems()) { boolean didSucceed = addClaimByItems(player, faction, worldUUID, chunkPosition); if(didSucceed) player.sendMessage(Text.of(PluginInfo.PLUGIN_PREFIX, Messages.LAND + " ", TextColors.GOLD, chunkPosition.toString(), TextColors.WHITE, " " + Messages.HAS_BEEN_SUCCESSFULLY + " ", TextColors.GOLD, Messages.CLAIMED, TextColors.WHITE, "!")); else player.sendMessage(Text.of(PluginInfo.ERROR_PREFIX, TextColors.RED, Messages.YOU_DONT_HAVE_ENOUGH_RESOURCES_TO_CLAIM_A_TERRITORY)); } else { player.sendMessage(Text.of(PluginInfo.PLUGIN_PREFIX, Messages.LAND + " ", TextColors.GOLD, chunkPosition.toString(), TextColors.WHITE, " " + Messages.HAS_BEEN_SUCCESSFULLY + " ", TextColors.GOLD, Messages.CLAIMED, TextColors.WHITE, "!")); addClaim(faction, new Claim(worldUUID, chunkPosition)); } } }
Example #24
Source File: ChunkAnvil116.java From BlueMap with MIT License | 5 votes |
@Override public BlockState getBlockState(Vector3i pos) { int sectionY = MCAUtil.blockToChunk(pos.getY()); Section section = this.sections[sectionY]; if (section == null) return BlockState.AIR; return section.getBlockState(pos); }
Example #25
Source File: EconomyDataConfig.java From GriefDefender with MIT License | 5 votes |
@Override public void setSaleSignPosition(Vector3i pos) { if (pos == null) { this.saleSignPos = null; return; } // force reset of vec this.saleSignVec = null; this.saleSignPos = BlockUtil.getInstance().posToString(pos); }
Example #26
Source File: DoubleChestExtension.java From BlueMap with MIT License | 5 votes |
@Override public BlockState extend(MCAWorld world, Vector3i pos, BlockState state) { Direction dir = Direction.fromString(state.getProperties().getOrDefault("facing", "north")); BlockState left = world.getBlockState(pos.add(dir.left().toVector())); if (left.getFullId().equals(state.getFullId())) return state.with("type", "right"); BlockState right = world.getBlockState(pos.add(dir.right().toVector())); if (right.getFullId().equals(state.getFullId())) return state.with("type", "left"); return state.with("type", "single"); }
Example #27
Source File: EntityServlet.java From Web-API with MIT License | 5 votes |
@GET @ExplicitDetails @Permission("list") @ApiOperation(value = "List entities", notes = "Get a list of all entities on the server (in all worlds).") public Collection<CachedEntity> listEntities( @QueryParam("world") @ApiParam("The world to filter the entities by") CachedWorld world, @QueryParam("type") @ApiParam("The type id of the entities to filter by") String typeId, @QueryParam("min") @ApiParam("The minimum coordinates at which the entity must be, min=x|y|z") Vector3i min, @QueryParam("max") @ApiParam("The maximum coordinates at which the entity must be, max=x|y|z") Vector3i max, @QueryParam("limit") @ApiParam("The maximum amount of entities returned") int limit) { Predicate<Entity> filter = e -> typeId == null || e.getType().getId().equalsIgnoreCase(typeId); return cacheService.getEntities(world, min, max, filter, limit); }
Example #28
Source File: SnowyExtension.java From BlueMap with MIT License | 5 votes |
@Override public BlockState extend(MCAWorld world, Vector3i pos, BlockState state) { BlockState above = world.getBlockState(pos.add(0, 1, 0)); if (above.getFullId().equals("minecraft:snow") || above.getFullId().equals("minecraft:snow_block")) { return state.with("snowy", "true"); } else { return state.with("snowy", "false"); } }
Example #29
Source File: BlockService.java From Web-API with MIT License | 5 votes |
/** * Gets the biome type ids for the specified area. The biome type is checked for every n-th block within the * region, where n is defined by {@link #BIOME_INTERVAL}. This means the resulting array will contain the * blocks indexed by x-direction first, with the array and sub-arrays being 1/n-th the size of the specified * region. * @param world The world to get the biome ids from * @param min The lowest point that defines the region. * @param max The highest point that defines the region. * @return A matrix containing the biome ids for every n-th block, indexed by x-coordinate first. */ public String[][] getBiomes(CachedWorld world, Vector3i min, Vector3i max) { return WebAPI.runOnMain(() -> { Optional<?> obj = world.getLive(); if (!obj.isPresent()) throw new InternalServerErrorException("Could not get live world"); World w = (World)obj.get(); BiomeVolume vol = w.getBiomeView(min, max).getRelativeBiomeView(); Vector3i size = vol.getBiomeSize(); int maxX = (int)Math.ceil(size.getX() / (float)BIOME_INTERVAL.getX()); int maxZ = (int)Math.ceil(size.getZ() / (float)BIOME_INTERVAL.getZ()); String[][] biomes = new String[maxX][maxZ]; for (int x = 0; x < maxX; x++) { for (int z = 0; z < maxZ; z++) { int newX = x * BIOME_INTERVAL.getX(); int newZ = z * BIOME_INTERVAL.getZ(); biomes[x][z] = vol.getBiome(newX, 0, newZ).getId(); if (biomes[x][z] == null) { WebAPI.getLogger().warn("Unknown biome at [" + (min.getX() + newX) + "," + (min.getZ() + newZ) + "]"); biomes[x][z] = UNKOWN_BIOME_ID; } } } return biomes; }); }
Example #30
Source File: RedstoneExtension.java From BlueMap with MIT License | 5 votes |
@Override public BlockState extend(MCAWorld world, Vector3i pos, BlockState state) { BlockState up = world.getBlockState(pos.add(0, 1, 0)); boolean upBlocking = !up.equals(BlockState.AIR); state = state .with("north", connection(world, pos, upBlocking, Direction.NORTH)) .with("east", connection(world, pos, upBlocking, Direction.EAST)) .with("south", connection(world, pos, upBlocking, Direction.SOUTH)) .with("west", connection(world, pos, upBlocking, Direction.WEST)); return state; }