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