use of com.flowpowered.math.vector.Vector3i in project Skree by Skelril.
the class ZonePool method getLastMarkedPoint.
public Vector2i getLastMarkedPoint() throws IllegalStateException {
if (globalBoxList.isEmpty()) {
return new Vector2i(0, 0);
}
globalBoxList.sort((a, b) -> {
Vector3i aMax = a.getMaximumPoint();
Vector3i bMax = b.getMaximumPoint();
if (aMax.getX() < bMax.getX() || aMax.getZ() < bMax.getZ()) {
return -1;
}
return 1;
});
Vector3i lastMax = globalBoxList.get(globalBoxList.size() - 1).getMaximumPoint();
return new Vector2i(lastMax.getX() + 1, lastMax.getZ() + 1);
}
use of com.flowpowered.math.vector.Vector3i in project Skree by Skelril.
the class JungleRaidEffectProcessor method distributor.
private static void distributor(JungleRaidInstance inst) {
FlagEffectData data = inst.getFlagData();
boolean isSuddenDeath = inst.isSuddenDeath();
if (isSuddenDeath) {
data.amt = 100;
}
if (inst.isFlagEnabled(JungleRaidFlag.END_OF_DAYS) || inst.isFlagEnabled(JungleRaidFlag.GRENADES) || inst.isFlagEnabled(JungleRaidFlag.POTION_PLUMMET) || isSuddenDeath) {
Vector3i bvMax = inst.getRegion().getMaximumPoint();
Vector3i bvMin = inst.getRegion().getMinimumPoint();
for (int i = 0; i < Probability.getRangedRandom(data.amt / 3, data.amt); i++) {
Location<World> testLoc = new Location<>(inst.getRegion().getExtent(), Probability.getRangedRandom(bvMin.getX(), bvMax.getX()), bvMax.getY(), Probability.getRangedRandom(bvMin.getZ(), bvMax.getZ()));
if (testLoc.getBlockType() != BlockTypes.AIR)
continue;
if (inst.isFlagEnabled(JungleRaidFlag.END_OF_DAYS) || isSuddenDeath) {
PrimedTNT explosive = (PrimedTNT) inst.getRegion().getExtent().createEntity(EntityTypes.PRIMED_TNT, testLoc.getPosition());
explosive.setVelocity(new Vector3d(random.nextDouble() * 2.0 - 1, random.nextDouble() * 2 * -1, random.nextDouble() * 2.0 - 1));
explosive.offer(Keys.FUSE_DURATION, 20 * 4);
// TODO used to have a 1/4 chance of creating fire
inst.getRegion().getExtent().spawnEntity(explosive, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
}
if (inst.isFlagEnabled(JungleRaidFlag.POTION_PLUMMET)) {
PotionEffectType type = Probability.pickOneOf(Sponge.getRegistry().getAllOf(PotionEffectType.class));
for (int ii = Probability.getRandom(5); ii > 0; --ii) {
ThrownPotion potion = (ThrownPotion) inst.getRegion().getExtent().createEntity(EntityTypes.SPLASH_POTION, testLoc.getPosition());
potion.setVelocity(new Vector3d(random.nextDouble() * 2.0 - 1, 0, random.nextDouble() * 2.0 - 1));
potion.offer(Keys.POTION_EFFECTS, Lists.newArrayList(PotionEffect.of(type, 1, type.isInstant() ? 1 : 20 * 10)));
inst.getRegion().getExtent().spawnEntity(potion, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
}
}
if (inst.isFlagEnabled(JungleRaidFlag.GRENADES)) {
new ItemDropper(testLoc).dropStacks(Lists.newArrayList(newItemStack(ItemTypes.SNOWBALL, Probability.getRandom(3))), SpawnTypes.PLUGIN);
}
}
if (data.amt < 150 && Probability.getChance(inst.isFlagEnabled(JungleRaidFlag.SUPER) ? 9 : 25))
++data.amt;
}
}
use of com.flowpowered.math.vector.Vector3i in project Skree by Skelril.
the class GoldRushInstance method setup.
private void setup() {
Vector3i offset = getRegion().getMinimumPoint();
rewardChest = new Location<>(getRegion().getExtent(), offset.getX() + 15, offset.getY() + 2, offset.getZ() + 6);
startingRoom = new ZoneBoundingBox(offset.add(2, 1, 76), new Vector3i(27, 7, 14));
keyRoom = new ZoneBoundingBox(offset.add(1, 1, 36), new Vector3i(30, 7, 39));
flashMemoryRoom = new ZoneBoundingBox(offset.add(11, 1, 17), new Vector3i(9, 7, 19));
flashMemoryDoor = new ZoneBoundingBox(offset.add(14, 1, 36), new Vector3i(3, 3, 1));
rewardRoomDoor = new ZoneBoundingBox(offset.add(14, 1, 16), new Vector3i(3, 3, 1));
// Setup room one
findChestAndKeys();
// Setup room two
findLeversAndFloodBlocks();
}
use of com.flowpowered.math.vector.Vector3i 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 com.flowpowered.math.vector.Vector3i 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();
}
}
}
Aggregations