use of org.spongepowered.api.block.BlockType in project Skree by Skelril.
the class RegionManager method cleanup.
public int cleanup() {
Optional<World> optWorld = Sponge.getServer().getWorld(worldName);
int total = 0;
if (optWorld.isPresent()) {
World world = optWorld.get();
for (CachedRegion region : regionList) {
List<RegionPoint> toRemove = new ArrayList<>();
for (RegionPoint point : region.getFullPoints()) {
BlockType type = world.getBlockType(point.toInt());
if (type != CustomBlockTypes.REGION_MASTER && type != CustomBlockTypes.REGION_MARKER) {
++total;
toRemove.add(point);
}
}
region.remPoint(toRemove);
}
}
return total;
}
use of org.spongepowered.api.block.BlockType in project Skree by Skelril.
the class JungleRaidEffectListener method onBlockBurn.
@Listener
public void onBlockBurn(ChangeBlockEvent event) {
if (event.getCause().root() instanceof Player) {
return;
}
for (Transaction<BlockSnapshot> transaction : event.getTransactions()) {
BlockType finalType = transaction.getFinal().getState().getType();
if (finalType != BlockTypes.FIRE) {
continue;
}
Optional<JungleRaidInstance> optInst = manager.getApplicableZone(transaction.getOriginal().getLocation().get());
if (optInst.isPresent()) {
JungleRaidInstance inst = optInst.get();
if (inst.isFlagEnabled(JungleRaidFlag.NO_FIRE_SPREAD)) {
event.setCancelled(true);
}
break;
}
}
}
use of org.spongepowered.api.block.BlockType in project Skree by Skelril.
the class GoldRushInstance method findLeversAndFloodBlocks.
private void findLeversAndFloodBlocks() {
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 = maxY; y >= minY; --y) {
BlockState state = getRegion().getExtent().getBlock(x, y, z);
if (state.getType() == BlockTypes.LEVER) {
Location<World> loc = new Location<>(getRegion().getExtent(), x, y, z);
loc.getExtent().setBlock(loc.getBlockPosition(), state.withTrait(BooleanTraits.LEVER_POWERED, false).orElse(state), Cause.source(SkreePlugin.container()).build());
leverBlocks.put(loc, !Probability.getChance(3));
for (int i = y; i < maxY; i++) {
BlockType type = getRegion().getExtent().getBlockType(x, i, z);
if (type == BlockTypes.AIR) {
floodBlocks.add(new Location<>(getRegion().getExtent(), x, i, z));
break;
}
}
// One lever a column only
break;
}
}
}
}
}
use of org.spongepowered.api.block.BlockType in project Skree by Skelril.
the class CursedMineInstance method changeWater.
private void changeWater() {
BlockType targetType = BlockTypes.AIR;
if (lastActivation == 0 || System.currentTimeMillis() - lastActivation >= timeTilPumpShutoff) {
targetType = BlockTypes.PLANKS;
}
final BlockType finalTarget = targetType;
floodGate.forAll((pt) -> {
if (replaceableTypes.contains(getRegion().getExtent().getBlockType(pt))) {
getRegion().getExtent().setBlockType(pt, finalTarget, Cause.source(SkreePlugin.container()).build());
}
});
}
use of org.spongepowered.api.block.BlockType in project Skree by Skelril.
the class CursedMineListener method onBlockPlace.
@Listener
public void onBlockPlace(ChangeBlockEvent.Place event, @Named(NamedCause.SOURCE) Player player) {
Optional<CursedMineInstance> optInst = manager.getApplicableZone(player);
if (!optInst.isPresent()) {
return;
}
for (Transaction<BlockSnapshot> transaction : event.getTransactions()) {
BlockType originalType = transaction.getFinal().getState().getType();
BlockType finalType = transaction.getFinal().getState().getType();
if (isRedstoneTransition(originalType, finalType)) {
continue;
}
event.setCancelled(true);
break;
}
}
Aggregations