Java Code Examples for com.flowpowered.math.vector.Vector3i#getX()
The following examples show how to use
com.flowpowered.math.vector.Vector3i#getX() .
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: ChunkAnvil112.java From BlueMap with MIT License | 6 votes |
public String getBlockIdMeta(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 blockId = this.blocks[blockByteIndex] & 0xFF; if (this.add.length > 0) { blockId = blockId | (getByteHalf(this.add[blockHalfByteIndex], largeHalf) << 8); } int blockData = getByteHalf(this.data[blockHalfByteIndex], largeHalf); String forgeIdMapping = getWorld().getForgeBlockIdMapping(blockId); return blockId + ":" + blockData + " " + forgeIdMapping; }
Example 2
Source File: ChunkAnvil116.java From BlueMap with MIT License | 6 votes |
public BlockState getBlockState(Vector3i pos) { if (blocks.length == 0) return BlockState.AIR; int x = pos.getX() & 0xF; // Math.floorMod(pos.getX(), 16) int y = pos.getY() & 0xF; int z = pos.getZ() & 0xF; int blockIndex = y * 256 + z * 16 + x; int longIndex = blockIndex / blocksPerLong; int bitIndex = (blockIndex % blocksPerLong) * bitsPerBlock; long value = blocks[longIndex] >>> bitIndex; value = value & (0xFFFFFFFFFFFFFFFFL >>> -bitsPerBlock); if (value >= palette.length) { Logger.global.noFloodWarning("palettewarning", "Got palette value " + value + " but palette has size of " + palette.length + "! (Future occasions of this error will not be logged)"); return BlockState.MISSING; } return palette[(int) value]; }
Example 3
Source File: ChunkAnvil112.java From BlueMap with MIT License | 6 votes |
public BlockState getBlockState(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 blockId = this.blocks[blockByteIndex] & 0xFF; if (this.add.length > 0) { blockId = blockId | (getByteHalf(this.add[blockHalfByteIndex], largeHalf) << 8); } int blockData = getByteHalf(this.data[blockHalfByteIndex], largeHalf); String forgeIdMapping = getWorld().getForgeBlockIdMapping(blockId); if (forgeIdMapping != null) { return blockIdMapper.get(forgeIdMapping, blockId, blockData); } else { return blockIdMapper.get(blockId, blockData); } }
Example 4
Source File: ChunkAnvil115.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 5
Source File: ParticlesUtil.java From EagleFactions with MIT License | 5 votes |
public static Vector3d getChunkCenter(final World world, final Vector3i chunkPosition) { final double x = (chunkPosition.getX() << 4) + 8; final double z = (chunkPosition.getZ() << 4) + 8; final double y = world.getHighestYAt((int)x, (int)z); return new Vector3d(x, y, z); }
Example 6
Source File: MapUpdateHandler.java From BlueMap with MIT License | 5 votes |
private void updateChunk(UUID world, Vector2i chunkPos) { Vector3i min = new Vector3i(chunkPos.getX() * 16, 0, chunkPos.getY() * 16); Vector3i max = min.add(15, 255, 15); Vector3i xmin = new Vector3i(min.getX(), 0, max.getY()); Vector3i xmax = new Vector3i(max.getX(), 255, min.getY()); //update all corners so we always update all tiles containing this chunk synchronized (updateBuffer) { updateBlock(world, min); updateBlock(world, max); updateBlock(world, xmin); updateBlock(world, xmax); } }
Example 7
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 8
Source File: BlockUtils.java From GriefPrevention with MIT License | 5 votes |
public static int getClaimBlockCost(World world, Vector3i lesser, Vector3i greater, boolean cuboid) { final int claimWidth = greater.getX() - lesser.getX() + 1; final int claimHeight = greater.getY() - lesser.getY() + 1; final int claimLength = greater.getZ() - lesser.getZ() + 1; if (GriefPreventionPlugin.CLAIM_BLOCK_SYSTEM == ClaimBlockSystem.AREA) { return claimWidth * claimLength; } return claimLength * claimWidth * claimHeight; }
Example 9
Source File: World.java From BlueMap with MIT License | 5 votes |
/** * Returns the ChunkPosition for a BlockPosition */ public default Vector2i blockPosToChunkPos(Vector3i block) { return new Vector2i( block.getX() >> 4, block.getZ() >> 4 ); }
Example 10
Source File: BlockGetOperation.java From Web-API with MIT License | 5 votes |
@Override protected void processBlock(World world, Vector3i pos) { int x = pos.getX() - min.getX(); int y = pos.getY() - min.getY(); int z = pos.getZ() - min.getZ(); blockStates[x][y][z] = world.getBlock(pos).copy(); }
Example 11
Source File: ChunkAnvil115.java From BlueMap with MIT License | 5 votes |
@Override public Biome getBiome(Vector3i pos) { int x = (pos.getX() & 0xF) / 4; // Math.floorMod(pos.getX(), 16) int z = (pos.getZ() & 0xF) / 4; int y = pos.getY() / 4; int biomeIntIndex = y * 16 + z * 4 + x; return biomeIdMapper.get(biomes[biomeIntIndex]); }
Example 12
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 13
Source File: ChunkAnvil116.java From BlueMap with MIT License | 5 votes |
@Override public Biome getBiome(Vector3i pos) { int x = (pos.getX() & 0xF) / 4; // Math.floorMod(pos.getX(), 16) int z = (pos.getZ() & 0xF) / 4; int y = pos.getY() / 4; int biomeIntIndex = y * 16 + z * 4 + x; return biomeIdMapper.get(biomes[biomeIntIndex]); }
Example 14
Source File: PreventListener.java From FlexibleLogin with MIT License | 5 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onPlayerMove(MoveEntityEvent playerMoveEvent, @First Player player) { if (playerMoveEvent instanceof MoveEntityEvent.Teleport) { return; } Vector3i oldLocation = playerMoveEvent.getFromTransform().getPosition().toInt(); Vector3i newLocation = playerMoveEvent.getToTransform().getPosition().toInt(); if (oldLocation.getX() != newLocation.getX() || oldLocation.getZ() != newLocation.getZ()) { checkLoginStatus(playerMoveEvent, player); } }
Example 15
Source File: ChunkAnvil113.java From BlueMap with MIT License | 5 votes |
public BlockState getBlockState(Vector3i pos) { if (blocks.length == 0) return BlockState.AIR; int x = pos.getX() & 0xF; // Math.floorMod(pos.getX(), 16) int y = pos.getY() & 0xF; int z = pos.getZ() & 0xF; int blockIndex = y * 256 + z * 16 + x; int bitsPerBlock = blocks.length * 64 / 4096; //64 bits per long and 4096 blocks per section int index = blockIndex * bitsPerBlock; int firstLong = index >> 6; // index / 64 int bitoffset = index & 0x3F; // Math.floorMod(index, 64) long value = blocks[firstLong] >>> bitoffset; if (bitoffset > 0 && firstLong + 1 < blocks.length) { long value2 = blocks[firstLong + 1]; value2 = value2 << -bitoffset; value = value | value2; } value = value & (0xFFFFFFFFFFFFFFFFL >>> -bitsPerBlock); if (value >= palette.length) { Logger.global.noFloodWarning("palettewarning", "Got palette value " + value + " but palette has size of " + palette.length + " (Future occasions of this error will not be logged)"); return BlockState.MISSING; } return palette[(int) value]; }
Example 16
Source File: Vector3iView.java From Web-API with MIT License | 5 votes |
public Vector3iView(Vector3i value) { super(value); this.x = value.getX(); this.y = value.getY(); this.z = value.getZ(); }
Example 17
Source File: CommandClaimSpawn.java From GriefDefender with MIT License | 4 votes |
@CommandAlias("claimspawn") @Description("Teleports you to claim spawn if available.") @Syntax("[name] [user]") @Subcommand("claim spawn") public void execute(Player player, @Optional String claimName, @Optional OfflinePlayer targetPlayer) { final GDPlayerData srcPlayerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()); GDPlayerData targetPlayerData = null; if (targetPlayer != null) { targetPlayerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), targetPlayer.getUniqueId()); } else { targetPlayerData = srcPlayerData; } GDClaim claim = null; if (claimName != null) { for (Claim playerClaim : targetPlayerData.getInternalClaims()) { String name = null; Component component = playerClaim.getName().orElse(null); if (component != null) { name = PlainComponentSerializer.INSTANCE.serialize(component); if (claimName.equalsIgnoreCase(name)) { claim = (GDClaim) playerClaim; break; } } } if (claim == null) { GriefDefenderPlugin.sendMessage(player, GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.COMMAND_CLAIMNAME_NOT_FOUND, ImmutableMap.of("name", claimName))); return; } } else { claim = GriefDefenderPlugin.getInstance().dataStore.getClaimAtPlayer(targetPlayerData, player.getLocation()); } if (!srcPlayerData.canIgnoreClaim(claim) && !claim.isUserTrusted(player, TrustTypes.ACCESSOR) && !player.hasPermission(GDPermissions.COMMAND_DELETE_CLAIMS)) { GriefDefenderPlugin.sendMessage(player, GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.PERMISSION_ACCESS, ImmutableMap.of("player", claim.getOwnerDisplayName()))); return; } final Vector3i spawnPos = claim.getData().getSpawnPos().orElse(null); if (spawnPos == null) { GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().SPAWN_NOT_SET); return; } final Location spawnLocation = new Location(claim.getWorld(), spawnPos.getX(), spawnPos.getY(), spawnPos.getZ()); int teleportDelay = 0; if (GDOptions.isOptionEnabled(Options.PLAYER_TELEPORT_DELAY)) { teleportDelay = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Integer.class), player, Options.PLAYER_TELEPORT_DELAY, claim); } if (teleportDelay > 0) { srcPlayerData.teleportDelay = teleportDelay + 1; srcPlayerData.teleportLocation = spawnLocation; return; } player.teleport(spawnLocation); final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.SPAWN_TELEPORT, ImmutableMap.of( "location", spawnPos)); GriefDefenderPlugin.sendMessage(player, message); }
Example 18
Source File: GPClaim.java From GriefPrevention with MIT License | 4 votes |
public GPClaim(World world, Vector3i point1, Vector3i point2, ClaimType type, UUID ownerUniqueId, boolean cuboid, GPClaim parent) { int smallx, bigx, smally, bigy, smallz, bigz; int x1 = point1.getX(); int x2 = point2.getX(); int y1 = point1.getY(); int y2 = point2.getY(); int z1 = point1.getZ(); int z2 = point2.getZ(); // determine small versus big inputs if (x1 < x2) { smallx = x1; bigx = x2; } else { smallx = x2; bigx = x1; } if (y1 < y2) { smally = y1; bigy = y2; } else { smally = y2; bigy = y1; } if (z1 < z2) { smallz = z1; bigz = z2; } else { smallz = z2; bigz = z1; } // creative mode claims always go to bedrock if (GriefPreventionPlugin.instance.claimModeIsActive(world.getProperties(), ClaimsMode.Creative)) { smally = 2; } this.world = world; this.lesserBoundaryCorner = new Location<World>(world, smallx, smally, smallz); this.greaterBoundaryCorner = new Location<World>(world, bigx, bigy, bigz); if (ownerUniqueId != null) { this.ownerUniqueId = ownerUniqueId; this.ownerPlayerData = GriefPreventionPlugin.instance.dataStore.getOrCreatePlayerData(this.world, this.ownerUniqueId); } this.type = type; this.id = UUID.randomUUID(); this.context = new Context("gp_claim", this.id.toString()); this.cuboid = cuboid; this.parent = parent; this.hashCode = this.id.hashCode(); this.worldClaimManager = GriefPreventionPlugin.instance.dataStore.getClaimWorldManager(this.world.getProperties()); if (this.type == ClaimType.WILDERNESS) { this.wildernessClaim = this; } else { this.wildernessClaim = this.worldClaimManager.getWildernessClaim(); } }
Example 19
Source File: DynmapProvider.java From GriefDefender with MIT License | 4 votes |
private void updateClaimMarker(Claim claim, Map<String, AreaMarker> markerMap) { final World world = Sponge.getServer().getWorld(claim.getWorldUniqueId()).orElse(null); if (world == null) { return; } final String worldName = world.getName(); final String owner = ((GDClaim) claim).getOwnerName(); if (isVisible((GDClaim) claim, owner, worldName)) { final Vector3i lesserPos = claim.getLesserBoundaryCorner(); final Vector3i greaterPos = claim.getGreaterBoundaryCorner(); final double[] x = new double[4]; final double[] z = new double[4]; x[0] = lesserPos.getX(); z[0] = lesserPos.getZ(); x[1] = lesserPos.getX(); z[1] = greaterPos.getZ() + 1.0; x[2] = greaterPos.getX() + 1.0; z[2] = greaterPos.getZ() + 1.0; x[3] = greaterPos.getX() + 1.0; z[3] = lesserPos.getZ(); final UUID id = claim.getUniqueId(); final String markerid = "GD_" + id; AreaMarker marker = this.areaMarkers.remove(markerid); if (marker == null) { marker = this.set.createAreaMarker(markerid, owner, false, worldName, x, z, false); if (marker == null) { return; } } else { marker.setCornerLocations(x, z); marker.setLabel(owner); } if (this.cfg.use3dRegions) { marker.setRangeY(greaterPos.getY() + 1.0, lesserPos.getY()); } addOwnerStyle(owner, worldName, marker, claim); String desc = getWindowInfo(claim, marker); marker.setDescription(desc); markerMap.put(markerid, marker); } }
Example 20
Source File: WorldEditApiProvider.java From GriefPrevention with MIT License | 4 votes |
public Vector createVector(Vector3i point) { return new Vector(point.getX(), point.getY(), point.getZ()); }