use of org.spongepowered.api.world.World in project Skree by Skelril.
the class GoldRushInstance method randomizeLevers.
private void randomizeLevers() {
if (System.currentTimeMillis() - lastLeverSwitch >= TimeUnit.SECONDS.toMillis(14)) {
for (Location<World> entry : leverBlocks.keySet()) {
BlockState state = entry.getBlock();
entry.getExtent().setBlock(entry.getBlockPosition(), state.withTrait(BooleanTraits.LEVER_POWERED, false).orElse(state), Cause.source(SkreePlugin.container()).build());
leverBlocks.put(entry, !Probability.getChance(3));
}
lastLeverSwitch = System.currentTimeMillis();
randomizeLevers();
} else if (System.currentTimeMillis() - lastLeverSwitch == 0) {
for (Location<World> entry : leverBlocks.keySet()) {
Location<World> targLoc = entry.add(0, -2, 0);
targLoc.getExtent().setBlockType(targLoc.getBlockPosition(), BlockTypes.STONEBRICK, Cause.source(SkreePlugin.container()).build());
}
Task.builder().execute(() -> {
for (Map.Entry<Location<World>, Boolean> entry : leverBlocks.entrySet()) {
Location<World> targLoc = entry.getKey().add(0, -2, 0);
targLoc.getExtent().setBlockType(targLoc.getBlockPosition(), entry.getValue() ? BlockTypes.REDSTONE_BLOCK : BlockTypes.STONEBRICK, Cause.source(SkreePlugin.container()).build());
}
Task.builder().execute(this::randomizeLevers).delayTicks(15).submit(SkreePlugin.inst());
}).delayTicks(15).submit(SkreePlugin.inst());
} else {
for (Location<World> entry : leverBlocks.keySet()) {
Location<World> targLoc = entry.add(0, -2, 0);
targLoc.getExtent().setBlockType(targLoc.getBlockPosition(), BlockTypes.STONEBRICK, Cause.source(SkreePlugin.container()).build());
}
}
}
use of org.spongepowered.api.world.World in project Skree by Skelril.
the class JungleRaidInstance method getRandomLocation.
public Location<World> getRandomLocation() {
Vector3i offset = getRegion().getMinimumPoint();
Vector3i boundingBox = getRegion().getBoundingBox();
while (true) {
Vector3i randomDest = new Vector3i(Probability.getRandom(boundingBox.getX()), Probability.getRangedRandom(16, 80), Probability.getRandom(boundingBox.getZ())).add(offset);
Optional<Location<World>> optSafeDest = SafeTeleportHelper.getSafeDest(new Location<>(getRegion().getExtent(), randomDest));
if (optSafeDest.isPresent()) {
Location<World> safeDest = optSafeDest.get();
if (16 < safeDest.getY() && safeDest.getY() < 79) {
return safeDest.add(.5, 0, .5);
}
}
}
}
use of org.spongepowered.api.world.World in project Skree by Skelril.
the class GoldRushInstance method flood.
private void flood() {
if (getTimeSinceStart() >= getTimeTilFlood()) {
for (Location<World> floodBlock : floodBlocks) {
floodBlock.getExtent().setBlockType(floodBlock.getBlockPosition(), floodBlockType, Cause.source(SkreePlugin.container()).build());
}
if (System.currentTimeMillis() - lastFlood >= TimeUnit.SECONDS.toMillis(30 / getPlayerMod())) {
Vector3i min = flashMemoryRoom.getMinimumPoint();
Vector3i max = flashMemoryRoom.getMaximumPoint();
int minX = min.getX();
int minZ = min.getZ();
int minY = min.getY();
int maxX = max.getX();
int maxZ = max.getZ();
int maxY = max.getY();
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) {
for (int y = minY; y <= maxY; y++) {
BlockType type = getRegion().getExtent().getBlockType(x, y, z);
if (type == BlockTypes.AIR) {
getRegion().getExtent().setBlockType(x, y, z, floodBlockType, Cause.source(SkreePlugin.container()).build());
break;
}
}
}
}
lastFlood = System.currentTimeMillis();
}
}
}
use of org.spongepowered.api.world.World in project Skree by Skelril.
the class GoldRushInstance method checkKeys.
public boolean checkKeys() {
if (!checkingKeys) {
return keysTriggered;
}
for (Location<World> lock : locks) {
Optional<org.spongepowered.api.block.tileentity.TileEntity> optTileEnt = lock.getTileEntity();
if (!optTileEnt.isPresent()) {
return false;
}
org.spongepowered.api.block.tileentity.TileEntity tileEnt = optTileEnt.get();
Optional<List<Text>> optTexts = tileEnt.get(Keys.SIGN_LINES);
if (!optTexts.isPresent()) {
return false;
}
if (optTexts.get().get(2).toPlain().startsWith("-"))
return false;
}
return true;
}
use of org.spongepowered.api.world.World in project Skree by Skelril.
the class PatientXInstance method setUp.
public void setUp() {
Vector3i min = getRegion().getMinimumPoint();
World world = getRegion().getExtent();
destinations.add(new Location<>(world, min.getX() + 11.5, min.getY() + 25, min.getZ() + 34.5));
destinations.add(new Location<>(world, min.getX() + 10.5, min.getY() + 20, min.getZ() + 34.5));
destinations.add(new Location<>(world, min.getX() + 57.5, min.getY() + 25, min.getZ() + 34.5));
destinations.add(new Location<>(world, min.getX() + 63.5, min.getY() + 25, min.getZ() + 45.5));
destinations.add(new Location<>(world, min.getX() + 62.5, min.getY() + 18, min.getZ() + 34.5));
destinations.add(new Location<>(world, min.getX() + 34.5, min.getY() + 29, min.getZ() + 60.5));
destinations.add(new Location<>(world, min.getX() + 34.5, min.getY() + 18, min.getZ() + 34.5));
destinations.add(new Location<>(world, min.getX() + 24.5, min.getY() + 29, min.getZ() + 41.5));
destinations.add(getCenter());
ice = new ZoneBoundingBox(min.add(14, 17, 14), new Vector3i(49, 1, 45));
drops = new ZoneBoundingBox(min.add(14, 24, 14), new Vector3i(41, 1, 41));
}
Aggregations