use of org.bukkit.material.Button in project Glowstone by GlowstoneMC.
the class BlockButton method placeBlock.
@Override
public void placeBlock(GlowPlayer player, GlowBlockState state, BlockFace face, ItemStack holding, Vector clickedLoc) {
super.placeBlock(player, state, face, holding, clickedLoc);
MaterialData data = state.getData();
if (!(data instanceof Button)) {
warnMaterialData(Button.class, data);
return;
}
setAttachedFace(state, face.getOppositeFace());
}
use of org.bukkit.material.Button 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.getTypeId());
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.material.Button in project Glowstone by GlowstoneMC.
the class BlockButton method blockInteract.
@Override
public boolean blockInteract(GlowPlayer player, GlowBlock block, BlockFace face, Vector clickedLoc) {
GlowBlockState state = block.getState();
MaterialData data = state.getData();
if (!(data instanceof Button)) {
warnMaterialData(Button.class, data);
return false;
}
Button button = (Button) data;
if (button.isPowered()) {
return true;
}
button.setPowered(true);
state.update();
extraUpdate(block);
// todo: switch to block scheduling system when one is available
new BukkitRunnable() {
@Override
public void run() {
button.setPowered(false);
state.update();
if (block.getType() == Material.WOOD_BUTTON || block.getType() == Material.STONE_BUTTON) {
extraUpdate(block);
block.getWorld().playSound(block.getLocation(), block.getType() == Material.WOOD_BUTTON ? Sound.BLOCK_WOOD_BUTTON_CLICK_OFF : Sound.BLOCK_STONE_BUTTON_CLICK_OFF, 0.3f, 0.5f);
}
}
}.runTaskLater(null, block.getType() == Material.STONE_BUTTON ? 20 : 30);
return true;
}
Aggregations