Search in sources :

Example 11 with BlockEntity

use of net.glowstone.block.entity.BlockEntity in project Glowstone by GlowstoneMC.

the class InMemoryBlockStorage method createMockBlock.

private GlowBlock createMockBlock(Location location, Material type, byte data) {
    GlowBlock mockBlock = Mockito.mock(GlowBlock.class);
    when(mockBlock.getLocation()).thenReturn(location);
    when(mockBlock.getType()).thenReturn(type);
    when(mockBlock.getType().getId()).thenReturn(type.getId());
    when(mockBlock.getData()).thenReturn(data);
    BlockEntity entity = null;
    BlockType blockType = ItemTable.instance().getBlock(type);
    if (blockType != null) {
        GlowChunk mockChunk = Mockito.mock(GlowChunk.class);
        when(mockChunk.getBlock(anyInt(), anyInt(), anyInt())).thenReturn(mockBlock);
        entity = blockType.createBlockEntity(mockChunk, 0, 0, 0);
    }
    when(mockBlock.getBlockEntity()).thenReturn(entity);
    return mockBlock;
}
Also used : GlowBlock(net.glowstone.block.GlowBlock) BlockType(net.glowstone.block.blocktype.BlockType) BlockEntity(net.glowstone.block.entity.BlockEntity) GlowChunk(net.glowstone.chunk.GlowChunk)

Aggregations

BlockEntity (net.glowstone.block.entity.BlockEntity)11 CompoundTag (net.glowstone.util.nbt.CompoundTag)5 GlowBlock (net.glowstone.block.GlowBlock)4 BlockType (net.glowstone.block.blocktype.BlockType)4 Material (org.bukkit.Material)3 ByteBuf (io.netty.buffer.ByteBuf)2 IOException (java.io.IOException)2 ChunkSection (net.glowstone.chunk.ChunkSection)2 GlowChunk (net.glowstone.chunk.GlowChunk)2 UnknownEntityTypeException (net.glowstone.io.entity.UnknownEntityTypeException)2 ChunkDataMessage (net.glowstone.net.message.play.game.ChunkDataMessage)2 Location (org.bukkit.Location)2 DataInputStream (java.io.DataInputStream)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 ResourceBundle (java.util.ResourceBundle)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 GlowWorld (net.glowstone.GlowWorld)1 DispenserEntity (net.glowstone.block.entity.DispenserEntity)1 GlowDispenser (net.glowstone.block.entity.state.GlowDispenser)1