Search in sources :

Example 1 with ContainedObjectType

use of com.microsoft.Malmo.Schemas.ContainedObjectType in project malmo by Microsoft.

the class BlockDrawingHelper method DrawPrimitive.

protected void DrawPrimitive(DrawContainer c, World w) throws Exception {
    // First, draw the container block:
    String cType = c.getType().value();
    // Safe - ContainerType is a subset of BlockType
    BlockType bType = BlockType.fromValue(cType);
    XMLBlockState blockType = new XMLBlockState(bType, c.getColour(), c.getFace(), c.getVariant());
    if (!blockType.isValid())
        throw new Exception("Unrecogised item type: " + c.getType().value());
    BlockPos pos = new BlockPos(c.getX(), c.getY(), c.getZ());
    setBlockState(w, pos, blockType);
    // Now fill the container:
    TileEntity tileentity = w.getTileEntity(pos);
    if (tileentity instanceof TileEntityLockableLoot) {
        // First clear out any leftovers:
        ((TileEntityLockableLoot) tileentity).clear();
        int index = 0;
        for (ContainedObjectType cot : c.getObject()) {
            DrawItem di = new DrawItem();
            di.setColour(cot.getColour());
            di.setType(cot.getType());
            di.setVariant(cot.getVariant());
            ItemStack stack = MinecraftTypeHelper.getItemStackFromDrawItem(di);
            stack.setCount(cot.getQuantity());
            ((TileEntityLockableLoot) tileentity).setInventorySlotContents(index, stack);
            index++;
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityLockableLoot(net.minecraft.tileentity.TileEntityLockableLoot) BlockType(com.microsoft.Malmo.Schemas.BlockType) ContainedObjectType(com.microsoft.Malmo.Schemas.ContainedObjectType) BlockPos(net.minecraft.util.math.BlockPos) TextComponentString(net.minecraft.util.text.TextComponentString) DrawItem(com.microsoft.Malmo.Schemas.DrawItem) ItemStack(net.minecraft.item.ItemStack)

Aggregations

BlockType (com.microsoft.Malmo.Schemas.BlockType)1 ContainedObjectType (com.microsoft.Malmo.Schemas.ContainedObjectType)1 DrawItem (com.microsoft.Malmo.Schemas.DrawItem)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1 TileEntityLockableLoot (net.minecraft.tileentity.TileEntityLockableLoot)1 BlockPos (net.minecraft.util.math.BlockPos)1 TextComponentString (net.minecraft.util.text.TextComponentString)1