use of org.spongepowered.api.block.BlockType in project Skree by Skelril.
the class PatientXInstance method freezeBlocks.
public void freezeBlocks(int percentage, boolean throwExplosives) {
ice.forAll((pt) -> {
BlockType aboveType = getRegion().getExtent().getBlockType(pt.add(0, 1, 0));
BlockType belowType = getRegion().getExtent().getBlockType(pt.add(0, -1, 0));
if (aboveType == BlockTypes.AIR && belowType == BlockTypes.WATER || belowType == BlockTypes.FLOWING_WATER) {
if (percentage >= 100) {
getRegion().getExtent().setBlockType(pt, BlockTypes.ICE, Cause.source(SkreePlugin.container()).build());
return;
}
BlockType curType = getRegion().getExtent().getBlockType(pt);
if (curType == BlockTypes.PACKED_ICE || curType == BlockTypes.ICE) {
getRegion().getExtent().setBlockType(pt, BlockTypes.WATER, Cause.source(SkreePlugin.container()).build());
if (!Probability.getChance(config.snowBallChance) || !throwExplosives) {
return;
}
Location target = new Location<>(getRegion().getExtent(), pt.add(0, 1, 0));
for (int i = Probability.getRandom(3); i > 0; i--) {
Snowball melvin = (Snowball) getRegion().getExtent().createEntity(EntityTypes.SNOWBALL, target.getPosition());
melvin.setVelocity(new Vector3d(0, Probability.getRangedRandom(.25, 1), 0));
getRegion().getExtent().spawnEntity(melvin, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
}
} else if (Probability.getChance(percentage, 100)) {
getRegion().getExtent().setBlockType(pt, BlockTypes.PACKED_ICE, Cause.source(SkreePlugin.container()).build());
}
}
});
}
use of org.spongepowered.api.block.BlockType in project Skree by Skelril.
the class PatientXInstance method freezeEntities.
private void freezeEntities() {
Zombie boss = getBoss().get();
double total = 0;
for (Living entity : getContained(Living.class)) {
if (entity.equals(boss)) {
continue;
}
BlockType curType = entity.getLocation().getBlockType();
if (curType != BlockTypes.WATER && curType != BlockTypes.FLOWING_WATER) {
continue;
}
if (entity instanceof Zombie) {
entity.offer(Keys.HEALTH, 0D);
EntityHealthUtil.heal(boss, 1);
total += .02;
} else if (!Probability.getChance(5)) {
entity.damage(Probability.getRandom(25), EntityDamageSource.builder().entity(boss).type(DamageTypes.MAGIC).build());
}
}
modifyDifficulty(-total);
}
use of org.spongepowered.api.block.BlockType in project Skree by Skelril.
the class FreakyFourInstance method prepareFrimus.
private void prepareFrimus() {
ZoneBoundingBox frimusRG = regions.get(FreakyFourBoss.FRIMUS);
frimusRG.forAll(pt -> {
BlockType originalType = getRegion().getExtent().getBlockType(pt);
if (originalType == BlockTypes.FIRE || originalType == BlockTypes.FLOWING_LAVA || originalType == BlockTypes.LAVA) {
getRegion().getExtent().setBlockType(pt, BlockTypes.AIR, Cause.source(SkreePlugin.container()).build());
}
});
}
use of org.spongepowered.api.block.BlockType 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 org.spongepowered.api.block.BlockType in project Skree by Skelril.
the class CursedMineListener method onBlockBreak.
@Listener
public void onBlockBreak(ChangeBlockEvent.Break event, @Named(NamedCause.SOURCE) Player player) {
Optional<CursedMineInstance> optInst = manager.getApplicableZone(player);
if (!optInst.isPresent()) {
return;
}
CursedMineInstance inst = optInst.get();
Optional<ItemStack> optHeldItem = player.getItemInHand(HandTypes.MAIN_HAND);
if (!optHeldItem.isPresent()) {
event.setCancelled(true);
return;
}
for (Transaction<BlockSnapshot> block : event.getTransactions()) {
BlockType originalType = block.getOriginal().getState().getType();
if (cursedOres.contains(originalType)) {
// we were having some multi-firing problems
if (inst.recordBlockBreak(player, new BlockRecord(block.getOriginal()))) {
/*if (Probability.getChance(3000)) {
ChatUtil.send(player, "You feel as though a spirit is trying to tell you something...");
player.getInventory().addItem(BookUtil.Lore.Areas.theGreatMine());
}*/
ExperienceOrb xpOrb = (ExperienceOrb) player.getWorld().createEntity(EntityTypes.EXPERIENCE_ORB, block.getOriginal().getLocation().get().getPosition());
xpOrb.offer(Keys.CONTAINED_EXPERIENCE, (70 - player.getLocation().getBlockY()) / 2);
inst.eatFood(player);
inst.poison(player, 6);
inst.ghost(player, originalType);
}
} else if (stealableFluids.contains(originalType)) {
inst.recordBlockBreak(player, new BlockRecord(block.getOriginal()));
} else {
block.setCustom(block.getOriginal());
}
}
}
Aggregations