use of net.glowstone.block.GlowBlock in project Glowstone by GlowstoneMC.
the class ItemFlintAndSteel method setBlockOnFire.
private boolean setBlockOnFire(GlowPlayer player, GlowBlock clicked, BlockFace face, ItemStack holding, Vector clickedLoc) {
GlowBlock fireBlock = clicked.getRelative(face);
if (fireBlock.getType() != Material.AIR) {
return true;
}
if (!clicked.isFlammable() && clicked.getRelative(BlockFace.DOWN).getType() == Material.AIR) {
return true;
}
BlockIgniteEvent event = EventFactory.callEvent(new BlockIgniteEvent(fireBlock, IgniteCause.FLINT_AND_STEEL, player, null));
if (event.isCancelled()) {
player.setItemInHand(holding);
return false;
}
// clone holding to avoid decreasing of the item's amount
ItemTable.instance().getBlock(Material.FIRE).rightClickBlock(player, clicked, face, holding.clone(), clickedLoc);
return true;
}
use of net.glowstone.block.GlowBlock in project Glowstone by GlowstoneMC.
the class BlockSapling method searchSourceBlockForHugeTree.
private GlowBlock searchSourceBlockForHugeTree(GlowBlock block) {
GlowWorld world = block.getWorld();
int sourceX = block.getX();
int sourceY = block.getY();
int sourceZ = block.getZ();
int data = block.getData();
for (int x = -1; x <= 0; x++) {
for (int z = -1; z <= 0; z++) {
GlowBlock b = world.getBlockAt(sourceX + x, sourceY, sourceZ + z);
if (b.getType() == Material.SAPLING && b.getData() == data && b.getRelative(BlockFace.SOUTH).getType() == Material.SAPLING && b.getRelative(BlockFace.SOUTH).getData() == data && b.getRelative(BlockFace.EAST).getType() == Material.SAPLING && b.getRelative(BlockFace.EAST).getData() == data && b.getRelative(BlockFace.SOUTH_EAST).getType() == Material.SAPLING && b.getRelative(BlockFace.SOUTH_EAST).getData() == data) {
return b;
}
}
}
return null;
}
use of net.glowstone.block.GlowBlock in project Glowstone by GlowstoneMC.
the class BlockRedstoneRepeater method updatePhysics.
@Override
public void updatePhysics(GlowBlock me) {
super.updatePhysics(me);
Diode diode = (Diode) me.getState().getData();
GlowBlock target = me.getRelative(diode.getFacing().getOppositeFace());
boolean powered = target.getType() == Material.REDSTONE_TORCH_ON || target.isBlockPowered() || target.getType() == Material.REDSTONE_WIRE && target.getData() > 0 && BlockRedstone.calculateConnections(target).contains(diode.getFacing()) || target.getType() == Material.DIODE_BLOCK_ON && ((Diode) target.getState().getData()).getFacing() == diode.getFacing();
if (powered != (me.getType() == Material.DIODE_BLOCK_ON)) {
me.getWorld().requestPulse(me);
}
}
use of net.glowstone.block.GlowBlock in project Glowstone by GlowstoneMC.
the class GlowFallingBlock method placeFallingBlock.
private void placeFallingBlock() {
location.getBlock().setTypeIdAndData(material.getId(), getBlockData(), true);
if (getBlockEntityCompoundTag() != null) {
if (location.getBlock() instanceof GlowBlock) {
GlowBlock block = (GlowBlock) location.getBlock();
BlockEntity blockEntity = block.getBlockEntity();
if (blockEntity != null) {
blockEntity.loadNbt(getBlockEntityCompoundTag());
}
}
}
}
use of net.glowstone.block.GlowBlock in project Glowstone by GlowstoneMC.
the class FlowingLiquidDecorator method decorate.
@Override
public void decorate(World world, Random random, Chunk source) {
int sourceX = (source.getX() << 4) + random.nextInt(16);
int sourceZ = (source.getZ() << 4) + random.nextInt(16);
int sourceY = random.nextInt(random.nextInt(type == Material.LAVA ? random.nextInt(240) + 8 : 248) + 8);
Block block = world.getBlockAt(sourceX, sourceY, sourceZ);
if ((block.getType() == Material.STONE || block.getType() == Material.AIR) && block.getRelative(BlockFace.DOWN).getType() == Material.STONE && block.getRelative(BlockFace.UP).getType() == Material.STONE) {
int stoneBlockCount = 0;
for (BlockFace face : SIDES) {
if (block.getRelative(face).getType() == Material.STONE) {
stoneBlockCount++;
}
}
if (stoneBlockCount == 3) {
int airBlockCount = 0;
for (BlockFace face : SIDES) {
if (block.getRelative(face).isEmpty()) {
airBlockCount++;
}
}
if (airBlockCount == 1) {
BlockState state = block.getState();
state.setType(type);
state.update(true);
new PulseTask((GlowBlock) state.getBlock(), true, 1, true).startPulseTask();
}
}
}
}
Aggregations