Java Code Examples for org.spongepowered.api.block.BlockTypes#TALLGRASS
The following examples show how to use
org.spongepowered.api.block.BlockTypes#TALLGRASS .
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: PlayerEventHandler.java From GriefPrevention with MIT License | 5 votes |
private GPClaim findNearbyClaim(Player player) { int maxDistance = GriefPreventionPlugin.instance.maxInspectionDistance; BlockRay<World> blockRay = BlockRay.from(player).distanceLimit(maxDistance).build(); GPPlayerData playerData = GriefPreventionPlugin.instance.dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()); GPClaim claim = null; int count = 0; while (blockRay.hasNext()) { BlockRayHit<World> blockRayHit = blockRay.next(); Location<World> location = blockRayHit.getLocation(); claim = this.dataStore.getClaimAt(location); if (claim != null && !claim.isWilderness() && (playerData.visualBlocks == null || (claim.id != playerData.visualClaimId))) { playerData.lastValidInspectLocation = location; return claim; } BlockType blockType = location.getBlockType(); if (blockType != BlockTypes.AIR && blockType != BlockTypes.TALLGRASS) { break; } count++; } if (count == maxDistance) { GriefPreventionPlugin.sendMessage(player, GriefPreventionPlugin.instance.messageData.claimTooFar.toText()); } else if (claim != null && claim.isWilderness()){ GriefPreventionPlugin.sendMessage(player, GriefPreventionPlugin.instance.messageData.blockNotClaimed.toText()); } return claim; }
Example 2
Source File: BlockUtils.java From GriefPrevention with MIT License | 5 votes |
public static Optional<Location<World>> getTargetBlock(Player player, GPPlayerData playerData, int maxDistance, boolean ignoreAir) throws IllegalStateException { BlockRay<World> blockRay = BlockRay.from(player).distanceLimit(maxDistance).build(); GPClaim claim = null; if (playerData.visualClaimId != null) { claim = (GPClaim) GriefPreventionPlugin.instance.dataStore.getClaim(player.getWorld().getProperties(), playerData.visualClaimId); } while (blockRay.hasNext()) { BlockRayHit<World> blockRayHit = blockRay.next(); if (claim != null) { for (Vector3i corner : claim.getVisualizer().getVisualCorners()) { if (corner.equals(blockRayHit.getBlockPosition())) { return Optional.of(blockRayHit.getLocation()); } } } if (ignoreAir) { if (blockRayHit.getLocation().getBlockType() != BlockTypes.TALLGRASS) { return Optional.of(blockRayHit.getLocation()); } } else { if (blockRayHit.getLocation().getBlockType() != BlockTypes.AIR && blockRayHit.getLocation().getBlockType() != BlockTypes.TALLGRASS) { return Optional.of(blockRayHit.getLocation()); } } } return Optional.empty(); }