use of org.bukkit.block.BlockFace in project Glowstone by GlowstoneMC.
the class BlockLiquid method updatePhysicsAfterEvent.
@Override
public void updatePhysicsAfterEvent(GlowBlock me) {
super.updatePhysicsAfterEvent(me);
if (isStationary(me.getType())) {
// TODO: set flowing
// me.setType(getOpposite(me.getType()), me.getData(), false);
}
boolean isWater = isWater(me.getType());
if (me.getState().getRawData() != STRENGTH_SOURCE) {
BlockFace[] faces = { UP, NORTH, EAST, SOUTH, WEST };
boolean connected = false;
int count = 0;
for (BlockFace face : faces) {
if (me.getRelative(face).getType() == me.getType()) {
if (isWater && count < 2 && face != UP && me.getRelative(face).getState().getRawData() == STRENGTH_SOURCE) {
count++;
}
if (!connected && face == UP || me.getRelative(face).getState().getRawData() < me.getState().getRawData()) {
connected = true;
if (me.getWorld().getServer().getClassicWater()) {
me.getState().setRawData(STRENGTH_SOURCE);
}
}
if (me.getWorld().getServer().getClassicWater() && me.getRelative(face).getState().getRawData() == STRENGTH_SOURCE) {
me.getRelative(face).setType(Material.AIR);
}
}
}
if (!connected) {
me.setType(Material.AIR);
return;
}
if (count == 2) {
me.getState().setRawData(STRENGTH_SOURCE);
return;
}
}
if (!(me.getState().getRawData() == (isWater || me.getWorld().getEnvironment() == World.Environment.NETHER ? STRENGTH_MIN_WATER : STRENGTH_MIN_LAVA)) || me.getRelative(DOWN).getType() == Material.AIR) {
calculateFlow(me);
}
}
use of org.bukkit.block.BlockFace in project Glowstone by GlowstoneMC.
the class BlockNeedsAttached method updatePhysicsAfterEvent.
@Override
public void updatePhysicsAfterEvent(GlowBlock me) {
super.updatePhysicsAfterEvent(me);
BlockFace attachedTo = getAttachedFace(me);
if (attachedTo == null) {
return;
}
if (me.getRelative(attachedTo).getType() == Material.AIR || !canPlaceAt(null, me, attachedTo.getOppositeFace())) {
dropMe(me);
}
}
use of org.bukkit.block.BlockFace in project Glowstone by GlowstoneMC.
the class BlockButton method extraUpdate.
private void extraUpdate(GlowBlock block) {
Button button = (Button) block.getState().getData();
ItemTable itemTable = ItemTable.instance();
GlowBlock target = block.getRelative(button.getAttachedFace());
if (target.getType().isSolid()) {
for (BlockFace face2 : ADJACENT) {
GlowBlock target2 = target.getRelative(face2);
BlockType notifyType = itemTable.getBlock(target2.getType());
if (notifyType != null) {
if (target2.getFace(block) == null) {
notifyType.onNearBlockChanged(target2, BlockFace.SELF, block, block.getType(), block.getData(), block.getType(), block.getData());
}
notifyType.onRedstoneUpdate(target2);
}
}
}
}
use of org.bukkit.block.BlockFace in project Glowstone by GlowstoneMC.
the class BlockFence method blockInteract.
@Override
public boolean blockInteract(GlowPlayer player, GlowBlock block, BlockFace face, Vector clickedLoc) {
super.blockInteract(player, block, face, clickedLoc);
if (!player.getLeashedEntities().isEmpty()) {
LeashHitch leashHitch = GlowLeashHitch.getLeashHitchAt(block);
ImmutableList.copyOf(player.getLeashedEntities()).stream().filter(e -> !(EventFactory.getInstance().callEvent(new PlayerLeashEntityEvent(e, leashHitch, player)).isCancelled())).forEach(e -> e.setLeashHolder(leashHitch));
return true;
}
return false;
}
use of org.bukkit.block.BlockFace in project Glowstone by GlowstoneMC.
the class BlockDirectional method placeBlock.
@Override
public void placeBlock(GlowPlayer player, GlowBlockState state, BlockFace face, ItemStack holding, Vector clickedLoc) {
super.placeBlock(player, state, face, holding, clickedLoc);
// the direction of the block
BlockFace faceHead = calculateFace(player, state);
state.setRawData((byte) getRawFace(opposite ? faceHead.getOppositeFace() : faceHead));
}
Aggregations