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;
}
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;
}
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));
}
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);
}
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;
}
}
Aggregations