Search in sources :

Example 46 with GlowBlock

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

the class TNTDispenseBehavior method dispenseStack.

@Override
protected ItemStack dispenseStack(GlowBlock block, ItemStack stack) {
    GlowWorld world = block.getWorld();
    GlowBlock target = block.getRelative(BlockDispenser.getFacing(block));
    GlowTNTPrimed tnt = (GlowTNTPrimed) world.spawnEntity(target.getLocation().add(0.5, 0, 0.5), EntityType.PRIMED_TNT);
    world.playSound(tnt.getLocation(), Sound.ENTITY_TNT_PRIMED, 1, 1);
    stack.setAmount(stack.getAmount() - 1);
    return stack.getAmount() > 0 ? stack : null;
}
Also used : GlowBlock(net.glowstone.block.GlowBlock) GlowWorld(net.glowstone.GlowWorld) GlowTNTPrimed(net.glowstone.entity.GlowTNTPrimed)

Example 47 with GlowBlock

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

the class GlowDispenser method dispense.

@Override
public boolean dispense() {
    GlowBlock block = getBlock();
    int dispenseSlot = getDispenseSlot();
    if (dispenseSlot < 0) {
        block.getWorld().playEffect(block.getLocation(), Effect.CLICK1, 0);
        return false;
    }
    ItemStack origItems = getInventory().getItem(dispenseSlot);
    DispenseBehavior behavior = getDispenseBehaviorRegistry().getBehavior(origItems.getType());
    ItemStack result = behavior.dispense(block, origItems);
    getInventory().setItem(dispenseSlot, result);
    return true;
}
Also used : GlowBlock(net.glowstone.block.GlowBlock) ItemStack(org.bukkit.inventory.ItemStack)

Example 48 with GlowBlock

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

the class BlockStateDelegate method backupBlockState.

/**
     * Backups a block state.
     *
     * @param block the block which state should be backup
     */
public void backupBlockState(Block block) {
    blockStateMap.remove(block.getLocation());
    blockStateBackupMap.put(block.getLocation(), new GlowBlockState((GlowBlock) block));
}
Also used : GlowBlock(net.glowstone.block.GlowBlock) GlowBlockState(net.glowstone.block.GlowBlockState)

Example 49 with GlowBlock

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

the class Explosion method setBlockOnFire.

private void setBlockOnFire(GlowBlock block) {
    if (random.nextInt(3) != 0) {
        return;
    }
    Block below = block.getRelative(BlockFace.DOWN);
    Material belowType = below.getType();
    if (belowType == Material.AIR || belowType == Material.FIRE || !belowType.isFlammable()) {
        return;
    }
    BlockIgniteEvent event = EventFactory.callEvent(new BlockIgniteEvent(block, IgniteCause.EXPLOSION, source));
    if (event.isCancelled()) {
        return;
    }
    block.setType(Material.FIRE);
}
Also used : GlowBlock(net.glowstone.block.GlowBlock) Block(org.bukkit.block.Block) Material(org.bukkit.Material) BlockIgniteEvent(org.bukkit.event.block.BlockIgniteEvent)

Example 50 with GlowBlock

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

the class Explosion method calculateRay.

private void calculateRay(int ox, int oy, int oz, Collection<BlockVector> result) {
    double x = ox / 7.5 - 1;
    double y = oy / 7.5 - 1;
    double z = oz / 7.5 - 1;
    Vector direction = new Vector(x, y, z);
    direction.normalize();
    // 0.3 blocks away with each step
    direction.multiply(0.3f);
    Location current = location.clone();
    float currentPower = calculateStartPower();
    while (currentPower > 0) {
        GlowBlock block = world.getBlockAt(current);
        if (block.getType() != Material.AIR) {
            double blastDurability = getBlastDurability(block) / 5d;
            blastDurability += 0.3F;
            blastDurability *= 0.3F;
            currentPower -= blastDurability;
            if (currentPower > 0) {
                result.add(new BlockVector(block.getX(), block.getY(), block.getZ()));
            }
        }
        current.add(direction);
        currentPower -= 0.225f;
    }
}
Also used : GlowBlock(net.glowstone.block.GlowBlock) BlockVector(org.bukkit.util.BlockVector) BlockVector(org.bukkit.util.BlockVector) Vector(org.bukkit.util.Vector) Location(org.bukkit.Location)

Aggregations

GlowBlock (net.glowstone.block.GlowBlock)72 BlockFace (org.bukkit.block.BlockFace)23 GlowBlockState (net.glowstone.block.GlowBlockState)21 Block (org.bukkit.block.Block)16 GlowWorld (net.glowstone.GlowWorld)14 MaterialData (org.bukkit.material.MaterialData)13 ItemTable (net.glowstone.block.ItemTable)10 BlockType (net.glowstone.block.blocktype.BlockType)7 ItemType (net.glowstone.block.itemtype.ItemType)7 Material (org.bukkit.Material)7 Vector (org.bukkit.util.Vector)7 BlockEntity (net.glowstone.block.entity.BlockEntity)6 ItemStack (org.bukkit.inventory.ItemStack)6 BlockVector (org.bukkit.util.BlockVector)5 Message (com.flowpowered.network.Message)4 IOException (java.io.IOException)4 GlowPlayer (net.glowstone.entity.GlowPlayer)4 Title (com.destroystokyo.paper.Title)3 ByteBufUtils (com.flowpowered.network.util.ByteBufUtils)3 Preconditions (com.google.common.base.Preconditions)3