Search in sources :

Example 1 with ItemTable

use of net.glowstone.block.ItemTable in project Glowstone by GlowstoneMC.

the class PulseTask method run.

@Override
public void run() {
    Block block = location.getBlock();
    if (block == null) {
        cancel();
        return;
    }
    if (!location.getChunk().isLoaded()) {
        return;
    }
    if (block.getType() != originalMaterial) {
        cancel();
        return;
    }
    ItemTable table = ItemTable.instance();
    BlockType type = table.getBlock(originalMaterial);
    if (type != null) {
        type.receivePulse((GlowBlock) block);
    }
}
Also used : ItemTable(net.glowstone.block.ItemTable) BlockType(net.glowstone.block.blocktype.BlockType) GlowBlock(net.glowstone.block.GlowBlock) Block(org.bukkit.block.Block)

Example 2 with ItemTable

use of net.glowstone.block.ItemTable in project Glowstone by GlowstoneMC.

the class BlockRedstoneRepeater method extraUpdate.

private void extraUpdate(GlowBlock block) {
    Diode diode = (Diode) block.getState().getData();
    ItemTable itemTable = ItemTable.instance();
    GlowBlock target = block.getRelative(diode.getFacing());
    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);
            }
        }
    }
}
Also used : GlowBlock(net.glowstone.block.GlowBlock) Diode(org.bukkit.material.Diode) ItemTable(net.glowstone.block.ItemTable) BlockFace(org.bukkit.block.BlockFace)

Example 3 with ItemTable

use of net.glowstone.block.ItemTable in project Glowstone by GlowstoneMC.

the class BlockRedstoneTorch method extraUpdate.

private void extraUpdate(GlowBlock block) {
    ItemTable itemTable = ItemTable.instance();
    GlowBlock target = block.getRelative(BlockFace.UP);
    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);
            }
        }
    }
}
Also used : GlowBlock(net.glowstone.block.GlowBlock) ItemTable(net.glowstone.block.ItemTable) BlockFace(org.bukkit.block.BlockFace)

Example 4 with ItemTable

use of net.glowstone.block.ItemTable in project Glowstone by GlowstoneMC.

the class GlowWorld method pulseTickMap.

private void pulseTickMap() {
    ItemTable itemTable = ItemTable.instance();
    for (Location location : tickMap) {
        GlowChunk chunk = (GlowChunk) location.getChunk();
        if (!chunk.isLoaded()) {
            continue;
        }
        int typeId = chunk.getType(location.getBlockX() & 0xF, location.getBlockZ() & 0xF, location.getBlockY());
        BlockType type = itemTable.getBlock(typeId);
        if (type == null) {
            cancelPulse(location);
            continue;
        }
        GlowBlock block = new GlowBlock(chunk, location.getBlockX(), location.getBlockY(), location.getBlockZ());
        int speed = type.getPulseTickSpeed(block);
        boolean once = type.isPulseOnce(block);
        if (speed == 0) {
            continue;
        }
        if (fullTime % speed == 0) {
            type.receivePulse(block);
            if (once) {
                cancelPulse(location);
            }
        }
    }
}
Also used : GlowBlock(net.glowstone.block.GlowBlock) ItemTable(net.glowstone.block.ItemTable) BlockType(net.glowstone.block.blocktype.BlockType) Location(org.bukkit.Location) GlowChunk(net.glowstone.chunk.GlowChunk)

Example 5 with ItemTable

use of net.glowstone.block.ItemTable in project Glowstone by GlowstoneMC.

the class BlockLever method extraUpdate.

private void extraUpdate(GlowBlock block) {
    Lever lever = (Lever) block.getState().getData();
    ItemTable itemTable = ItemTable.instance();
    GlowBlock target = block.getRelative(lever.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);
            }
        }
    }
}
Also used : GlowBlock(net.glowstone.block.GlowBlock) Lever(org.bukkit.material.Lever) ItemTable(net.glowstone.block.ItemTable) BlockFace(org.bukkit.block.BlockFace)

Aggregations

GlowBlock (net.glowstone.block.GlowBlock)8 ItemTable (net.glowstone.block.ItemTable)8 BlockFace (org.bukkit.block.BlockFace)6 BlockType (net.glowstone.block.blocktype.BlockType)2 GlowChunk (net.glowstone.chunk.GlowChunk)1 Location (org.bukkit.Location)1 Block (org.bukkit.block.Block)1 Button (org.bukkit.material.Button)1 Diode (org.bukkit.material.Diode)1 Lever (org.bukkit.material.Lever)1