use of com.flowpowered.math.vector.Vector3i in project Skree by Skelril.
the class ZoneRelativePositionListener method onBlockInteract.
@Listener
public void onBlockInteract(InteractBlockEvent.Secondary event, @First Player player) {
Optional<Location<World>> optLocation = event.getTargetBlock().getLocation();
if (!optLocation.isPresent()) {
return;
}
Location<World> location = optLocation.get();
Optional<T> optInst = getApplicable(location);
if (!optInst.isPresent()) {
return;
}
T inst = optInst.get();
Vector3i minPoint = inst.getRegion().getMinimumPoint();
Vector3i clickedPoint = location.getBlockPosition();
Vector3i offset = clickedPoint.sub(minPoint);
player.sendMessage(Text.of("Offset: ", offset));
}
use of com.flowpowered.math.vector.Vector3i in project Skree by Skelril.
the class FreakyFourInstance method dabombDetonate.
public void dabombDetonate(double percentEffectiveness) {
ZoneBoundingBox dabomb_RG = getRegion(FreakyFourBoss.DA_BOMB);
Vector3i min = dabomb_RG.getMinimumPoint();
Vector3i max = dabomb_RG.getMaximumPoint();
int minX = min.getX();
int minY = min.getY();
int minZ = min.getZ();
int maxX = max.getX();
int maxZ = max.getZ();
int dmgFact = (int) Math.max(3, percentEffectiveness * config.daBombTNTStrength);
for (int x = minX; x < maxX; ++x) {
for (int z = minZ; z < maxZ; ++z) {
if (Probability.getChance(config.daBombTNT)) {
getRegion().getExtent().triggerExplosion(Explosion.builder().location(new Location<>(getRegion().getExtent(), new Vector3d(x, minY, z))).radius(dmgFact).canCauseFire(false).shouldDamageEntities(true).build(), Cause.source(SkreePlugin.container()).build());
}
}
}
}
use of com.flowpowered.math.vector.Vector3i in project Skree by Skelril.
the class FreakyFourInstance method createWall.
private void createWall(ZoneBoundingBox region, Predicate<BlockType> oldExpr, Predicate<BlockType> newExpr, BlockType oldType, BlockType newType, int density, int floodFloor) {
final Vector3i min = region.getMinimumPoint();
final Vector3i max = region.getMaximumPoint();
int minX = min.getX();
int minY = min.getY();
int minZ = min.getZ();
int maxX = max.getX();
int maxY = max.getY();
int maxZ = max.getZ();
int initialTimes = maxZ - minZ + 1;
IntegratedRunnable integratedRunnable = new IntegratedRunnable() {
@Override
public boolean run(int times) {
int startZ = minZ + (initialTimes - times) - 1;
for (int x = minX; x <= maxX; ++x) {
for (int z = startZ; z < Math.min(maxZ, startZ + 4); ++z) {
boolean flood = Probability.getChance(density);
for (int y = minY; y <= maxY; ++y) {
BlockType block = getRegion().getExtent().getBlockType(x, y, z);
if (z == startZ && newExpr.test(block)) {
getRegion().getExtent().setBlockType(x, y, z, oldType, Cause.source(SkreePlugin.container()).build());
} else if (flood && oldExpr.test(block)) {
getRegion().getExtent().setBlockType(x, y, z, newType, Cause.source(SkreePlugin.container()).build());
}
}
}
}
return true;
}
@Override
public void end() {
if (floodFloor != -1) {
for (int x = minX; x <= maxX; ++x) {
for (int z = minZ; z <= maxZ; ++z) {
if (!Probability.getChance(floodFloor))
continue;
BlockType block = getRegion().getExtent().getBlockType(x, minY, z);
if (oldExpr.test(block)) {
getRegion().getExtent().setBlockType(x, minY, z, newType, Cause.source(SkreePlugin.container()).build());
}
}
}
}
}
};
TimedRunnable<IntegratedRunnable> timedRunnable = new TimedRunnable<>(integratedRunnable, initialTimes);
Task task = Task.builder().execute(timedRunnable).interval(500, MILLISECONDS).submit(SkreePlugin.inst());
timedRunnable.setTask(task);
}
use of com.flowpowered.math.vector.Vector3i in project Skree by Skelril.
the class TheForgeInstance method getRandomEntryPoint.
private Location<World> getRandomEntryPoint() {
Vector3i minimumPoint = getRegion().getMinimumPoint();
Vector3i maximumPoint = getRegion().getMaximumPoint();
Location<World> targetPoint;
do {
double targetX = Probability.getRangedRandom(minimumPoint.getX(), maximumPoint.getX()) + .5;
double targetY = minimumPoint.getY() + 7;
double targetZ = Probability.getRangedRandom(minimumPoint.getZ(), maximumPoint.getZ()) + .5;
targetPoint = new Location<>(getRegion().getExtent(), targetX, targetY, targetZ);
} while (!isValidTeleportDestination(targetPoint));
return targetPoint;
}
use of com.flowpowered.math.vector.Vector3i in project Skree by Skelril.
the class FreakyFourInstance method setUp.
private void setUp() {
Vector3i offset = region.getMinimumPoint();
regions.put(FreakyFourBoss.CHARLOTTE, new ZoneBoundingBox(offset.add(72, 7, 1), new Vector3i(22, 5, 41)));
regions.put(FreakyFourBoss.FRIMUS, new ZoneBoundingBox(offset.add(48, 7, 1), new Vector3i(22, 5, 41)));
regions.put(FreakyFourBoss.DA_BOMB, new ZoneBoundingBox(offset.add(24, 7, 1), new Vector3i(22, 5, 41)));
regions.put(FreakyFourBoss.SNIPEE, new ZoneBoundingBox(offset.add(1, 7, 1), new Vector3i(21, 5, 41)));
}
Aggregations