Search in sources :

Example 31 with MaterialData

use of org.bukkit.material.MaterialData in project Glowstone by GlowstoneMC.

the class BlockSnow method updateBlock.

@Override
public void updateBlock(GlowBlock block) {
    if (block.getLightFromBlocks() > 11) {
        GlowBlockState state = block.getState();
        state.setType(Material.AIR);
        state.setData(new MaterialData(Material.AIR));
        BlockFadeEvent fadeEvent = new BlockFadeEvent(block, state);
        EventFactory.callEvent(fadeEvent);
        if (!fadeEvent.isCancelled()) {
            state.update(true);
        }
    }
}
Also used : BlockFadeEvent(org.bukkit.event.block.BlockFadeEvent) GlowBlockState(net.glowstone.block.GlowBlockState) MaterialData(org.bukkit.material.MaterialData)

Example 32 with MaterialData

use of org.bukkit.material.MaterialData in project Glowstone by GlowstoneMC.

the class BlockSnowBlock method updateBlock.

@Override
public void updateBlock(GlowBlock block) {
    if (block.getLightFromBlocks() > 11) {
        GlowBlockState state = block.getState();
        state.setType(Material.AIR);
        state.setData(new MaterialData(Material.AIR));
        BlockFadeEvent fadeEvent = new BlockFadeEvent(block, state);
        EventFactory.callEvent(fadeEvent);
        if (!fadeEvent.isCancelled()) {
            state.update(true);
        }
    }
}
Also used : BlockFadeEvent(org.bukkit.event.block.BlockFadeEvent) GlowBlockState(net.glowstone.block.GlowBlockState) MaterialData(org.bukkit.material.MaterialData)

Example 33 with MaterialData

use of org.bukkit.material.MaterialData in project Glowstone by GlowstoneMC.

the class BlockVine 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 Vine) {
        if (face == BlockFace.DOWN || face == BlockFace.UP) {
            return;
        } else {
            ((Vine) data).putOnFace(face.getOppositeFace());
        }
        state.setData(data);
    } else {
        warnMaterialData(Vine.class, data);
    }
}
Also used : Vine(org.bukkit.material.Vine) MaterialData(org.bukkit.material.MaterialData)

Example 34 with MaterialData

use of org.bukkit.material.MaterialData in project Glowstone by GlowstoneMC.

the class BlockTorch 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 Torch) {
        if (canAttachTo(state.getBlock(), face)) {
            ((Torch) data).setFacingDirection(face);
        } else {
            ((Torch) data).setFacingDirection(BlockFace.UP);
        }
    } else {
        warnMaterialData(Torch.class, data);
    }
}
Also used : MaterialData(org.bukkit.material.MaterialData) Torch(org.bukkit.material.Torch)

Example 35 with MaterialData

use of org.bukkit.material.MaterialData in project Glowstone by GlowstoneMC.

the class BlockTrapDoor method placeBlock.

public void placeBlock(GlowPlayer player, GlowBlockState state, BlockFace face, ItemStack holding, Vector clickedLoc) {
    MaterialData materialData = state.getData();
    if (materialData instanceof TrapDoor) {
        TrapDoor trapDoor = (TrapDoor) materialData;
        trapDoor.setFacingDirection(face);
        if (clickedLoc.getY() >= 0.5) {
            trapDoor.setInverted(true);
        } else {
            trapDoor.setInverted(false);
        }
        state.update(true);
    } else {
        parent.warnMaterialData(TrapDoor.class, materialData);
    }
}
Also used : TrapDoor(org.bukkit.material.TrapDoor) MaterialData(org.bukkit.material.MaterialData)

Aggregations

MaterialData (org.bukkit.material.MaterialData)93 GlowBlockState (net.glowstone.block.GlowBlockState)20 ItemStack (org.bukkit.inventory.ItemStack)20 Material (org.bukkit.Material)13 Block (org.bukkit.block.Block)12 BlockState (org.bukkit.block.BlockState)12 GlowBlock (net.glowstone.block.GlowBlock)10 BlockFace (org.bukkit.block.BlockFace)10 MyPetBaby (de.Keyle.MyPet.api.entity.MyPetBaby)9 TagCompound (de.keyle.knbt.TagCompound)9 ArrayList (java.util.ArrayList)6 DoublePlant (org.bukkit.material.DoublePlant)6 Bed (org.bukkit.material.Bed)5 IOException (java.io.IOException)3 GlowDispenser (net.glowstone.block.state.GlowDispenser)3 Location (org.bukkit.Location)3 Player (org.bukkit.entity.Player)3 CocoaPlant (org.bukkit.material.CocoaPlant)3 Dispenser (org.bukkit.material.Dispenser)3 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)3