use of com.flowpowered.math.vector.Vector3i in project Skree by Skelril.
the class Luminositor method onRightClick.
@Listener
public void onRightClick(InteractBlockEvent.Secondary.MainHand event, @First Player player) {
Optional<ItemStack> optHeldItem = player.getItemInHand(HandTypes.MAIN_HAND);
if (optHeldItem.isPresent()) /* && optClickedPosition.isPresent() */
{
if (this.equals(optHeldItem.get().getItem())) {
Direction dir = event.getTargetSide();
Optional<Location<World>> optTargetBlockLoc = event.getTargetBlock().getLocation();
if (!optTargetBlockLoc.isPresent()) {
return;
}
Location<World> targetBlockLoc = optTargetBlockLoc.get();
Vector3i targPos = targetBlockLoc.getBlockPosition().add(dir.toVector3d().toInt());
Location<World> trueTargBlock = new Location<>(targetBlockLoc.getExtent(), targPos);
int lightLevel = LightLevelUtil.getMaxLightLevel(trueTargBlock).get();
TextColor color;
if (lightLevel >= 12) {
color = TextColors.GREEN;
} else if (lightLevel >= 8) {
color = TextColors.RED;
} else {
color = TextColors.DARK_RED;
}
// TODO system message.color(color)
player.sendMessage(Text.of(TextColors.YELLOW, "Light level: ", color, lightLevel));
event.setUseBlockResult(Tristate.FALSE);
}
}
}
use of com.flowpowered.math.vector.Vector3i in project Skree by Skelril.
the class BarrierBlockTerrainGenerator method populate.
@Override
public void populate(World world, MutableBlockVolume buffer, ImmutableBiomeVolume biomes) {
Vector3i min = buffer.getBlockMin();
Vector3i max = buffer.getBlockMax();
for (int y = min.getY(); y <= max.getY(); ++y) {
for (int x = min.getX(); x <= max.getX(); ++x) {
for (int z = min.getZ(); z <= max.getZ(); ++z) {
buffer.setBlockType(x, y, z, BlockTypes.BARRIER, Cause.source(SkreePlugin.container()).build());
}
}
}
}
use of com.flowpowered.math.vector.Vector3i in project Skree by Skelril.
the class SolidWorldTerrainGenerator method populate.
@Override
public void populate(World world, MutableBlockVolume buffer, ImmutableBiomeVolume biomes) {
Vector3i min = buffer.getBlockMin();
Vector3i max = buffer.getBlockMax();
for (int y = min.getY(); y <= max.getY() - 5; ++y) {
for (int x = min.getX(); x <= max.getX(); ++x) {
for (int z = min.getZ(); z <= max.getZ(); ++z) {
buffer.setBlockType(x, y, z, BlockTypes.BEDROCK, Cause.source(SkreePlugin.container()).build());
}
}
}
}
use of com.flowpowered.math.vector.Vector3i in project Skree by Skelril.
the class CursedMineInstance method setUp.
private void setUp() {
Vector3i offset = getRegion().getMinimumPoint();
entryPoint = new Location<>(getRegion().getExtent(), offset.getX() + 71.5, offset.getY() + 59, offset.getZ() + 86.5);
floodGate = new ZoneBoundingBox(offset.add(66, 40, 131), new Vector3i(13, 1, 9));
}
use of com.flowpowered.math.vector.Vector3i in project Skree by Skelril.
the class CursedMineInstance method drain.
public void drain() {
for (Entity e : getContained(Carrier.class)) {
// TODO Inventory API not fully implemented
if (!(e instanceof Player)) {
continue;
}
Inventory eInventory = ((Carrier) e).getInventory();
if (e instanceof Player) {
Location<World> playerLoc = e.getLocation();
// Emerald
long diff = System.currentTimeMillis() - lastActivation;
if (playerLoc.getY() < 30 && (lastActivation == 0 || diff <= timeTilPumpShutoff * .35 || diff >= timeTilPumpShutoff * 5)) {
PositionRandomizer randomizer = new PositionRandomizer(5);
for (int i = 0; i < Probability.getRangedRandom(2, 5); i++) {
Vector3i targetPos;
do {
targetPos = randomizer.createPosition3i(playerLoc.getPosition());
} while (getRegion().getExtent().getBlockType(targetPos) != BlockTypes.AIR);
Entity entity = getRegion().getExtent().createEntity(EntityTypes.BLAZE, targetPos);
getRegion().getExtent().spawnEntity(entity, Cause.source(SpawnCause.builder().type(SpawnTypes.MOB_SPAWNER).build()).build());
}
}
}
for (int i = 0; i < (eInventory.size() / 2) - 2 || i < 1; i++) {
if (e instanceof Player) {
if (Probability.getChance(15) && checkInventory((Player) e)) {
((Player) e).sendMessage(Text.of(TextColors.YELLOW, "Divine intervention protects some of your items."));
continue;
}
}
// Iron
eInventory.query(ItemTypes.IRON_BLOCK).poll(Probability.getRandom(2));
eInventory.query(ItemTypes.IRON_ORE).poll(Probability.getRandom(4));
eInventory.query(ItemTypes.IRON_INGOT).poll(Probability.getRandom(8));
// Gold
eInventory.query(ItemTypes.GOLD_BLOCK).poll(Probability.getRandom(2));
eInventory.query(ItemTypes.GOLD_ORE).poll(Probability.getRandom(4));
eInventory.query(ItemTypes.GOLD_INGOT).poll(Probability.getRandom(10));
eInventory.query(ItemTypes.GOLD_NUGGET).poll(Probability.getRandom(80));
// Redstone
eInventory.query(ItemTypes.REDSTONE_ORE).poll(Probability.getRandom(2));
eInventory.query(ItemTypes.REDSTONE).poll(Probability.getRandom(34));
// Lap
eInventory.query(ItemTypes.LAPIS_BLOCK).poll(Probability.getRandom(2));
eInventory.query(ItemTypes.LAPIS_ORE).poll(Probability.getRandom(4));
eInventory.query(LAPIS_DYE).poll(Probability.getRandom(34));
// Diamond
eInventory.query(ItemTypes.DIAMOND_BLOCK).poll(Probability.getRandom(2));
eInventory.query(ItemTypes.DIAMOND_ORE).poll(Probability.getRandom(4));
eInventory.query(ItemTypes.DIAMOND).poll(Probability.getRandom(16));
}
}
}
Aggregations