crwdns132533:0crwdne132533:0
crwdns132535:0crwdne132535:0
crwdns132537:0:javadoc:crwdnd132537:0:javadoc:crwdnd132537:0:javadoc:crwdne132537:0
import org.spongepowered.api.Sponge;
import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;
public Location<World> getBlockAt(String worldName, int posX, int posY, int posZ) {
World world = Sponge.getServer().getWorld(worldName).get();
Location<World> blockLoc = new Location<World>(world, posX, posY, posZ);
return blockLoc;
}
Warning
crwdns132539:0crwdne132539:0
crwdns132541:0crwdne132541:0
import org.spongepowered.api.block.BlockType;
import org.spongepowered.api.block.BlockTypes;
public boolean isBanner(Location<World> blockLoc) {
BlockType type = blockLoc.getBlock().getType();
return type.equals(BlockTypes.STANDING_BANNER)
|| type.equals(BlockTypes.WALL_BANNER);
}
Tip
crwdns132543:0:javadoc:crwdne132543:0
crwdns132545:0crwdne132545:0
crwdns132547:0:javadoc:crwdnd132547:0:javadoc:crwdne132547:0
import org.spongepowered.api.data.key.Keys;
import org.spongepowered.api.data.manipulator.mutable.block.DirectionalData;
public boolean isFacingNorth(Location<World> blockLoc) {
Optional<DirectionalData> optionalData = blockLoc.get(DirectionalData.class);
if (!optionalData.isPresent()) {
return false;
}
DirectionalData data = optionalData.get();
if (data.get(Keys.DIRECTION).get().equals(Direction.NORTH)) {
return true;
}
return false;
}
crwdns132549:0:javadoc:crwdnd132549:0:javadoc:crwdne132549:0
crwdns132551:0:doc:crwdne132551:0
Tip
crwdns132553:0crwdne132553:0
crwdns132555:0crwdne132555:0
crwdns132557:0:javadoc:crwdnd132557:0:javadoc:crwdnd132557:0:javadoc:crwdnd132557:0:javadoc:crwdne132557:0
import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.data.manipulator.immutable.ImmutableWetData;
public void isWet(Location blockLoc) {
BlockState sponge = blockLoc.getBlock();
if (!sponge.getType().equals(BlockTypes.SPONGE)) {
return false;
}
Optional<ImmutableWetData> wetness = sponge.get(ImmutableWetData.class);
return wetness.isPresent();
}
crwdns132559:0:doc:crwdne132559:0
crwdns132561:0crwdne132561:0
crwdns132563:0crwdne132563:0
import org.spongepowered.api.data.property.DoubleProperty;
import org.spongepowered.api.data.property.block.BlastResistanceProperty;
public boolean blastResistanceGreaterThanOne(Location<World> blockLoc) {
Optional<BlastResistanceProperty> optional =
blockLoc.getProperty(BlastResistanceProperty.class);
if(optional.isPresent()) {
BlastResistanceProperty resistance = optional.get();
DoubleProperty one = DoubleProperty.greaterThanOrEqual(1);
return one.matches(resistance);
}
return false;
}
crwdns132565:0:javadoc:crwdnd132565:0:javadoc:crwdne132565:0
crwdns132567:0:javadoc:crwdnd132567:0:javadoc:crwdne132567:0
import org.spongepowered.api.data.property.block.PoweredProperty;
public boolean areBlocksPowered(Location<World> blockLoc, Location<World> blockLoc2) {
Optional<PoweredProperty> optional = blockLoc.getProperty(PoweredProperty.class);
Optional<PoweredProperty> optional2 = blockLoc2.getProperty(PoweredProperty.class);
if(optional.isPresent() && optional2.isPresent()) {
PoweredProperty property1 = optional2.get();
PoweredProperty property2 = optional2.get();
BooleanProperty booleanProperty = BooleanProperty.of(property1);
BooleanProperty booleanProperty2 = BooleanProperty.of(true);
if(booleanProperty2.matches(property1)) {
return booleanProperty.matches(property2);
}
}
return false;
}
crwdns132569:0crwdne132569:0
crwdns132571:0:javadoc:crwdne132571:0
crwdns132573:0crwdne132573:0
crwdns132575:0:javadoc:crwdnd132575:0:javadoc:crwdne132575:0
import org.spongepowered.api.block.trait.BooleanTraits;
public boolean isBedOccupied(Location<World> blockLoc) {
if(blockLoc.getBlock().getType().equals(BlockTypes.BED)) {
return blockLoc.getBlock().getTraitValue(BooleanTraits.BED_OCCUPIED).get();
}
return false;
}
Warning
crwdns132577:0crwdne132577:0