use of com.microsoft.Malmo.Schemas.BlockType in project malmo by Microsoft.
the class MazeDecoratorImplementation method getBlock.
private XMLBlockState getBlock(MazeBlock mblock, Random rand) {
BlockType blockName = chooseBlock(mblock.getType(), rand);
Colour blockCol = chooseColour(mblock.getColour(), rand);
Variation blockVar = chooseVariant(mblock.getVariant(), rand);
return new XMLBlockState(blockName, blockCol, null, blockVar);
}
use of com.microsoft.Malmo.Schemas.BlockType in project malmo by Microsoft.
the class AgentQuitFromTouchingBlockTypeImplementation method parseParameters.
@Override
public boolean parseParameters(Object params) {
if (params == null || !(params instanceof AgentQuitFromTouchingBlockType))
return false;
this.params = (AgentQuitFromTouchingBlockType) params;
// Flatten all the possible block type names for ease of matching later:
this.blockTypeNames = new ArrayList<String>();
for (BlockSpec bs : this.params.getBlock()) {
for (BlockType bt : bs.getType()) {
Block b = Block.getBlockFromName(bt.value());
this.blockTypeNames.add(b.getUnlocalizedName().toLowerCase());
}
}
return true;
}
use of com.microsoft.Malmo.Schemas.BlockType in project malmo by Microsoft.
the class MinecraftTypeHelper method getDrawBlockFromBlockState.
/**
* Extract the type, variation and facing attributes of a blockstate and return them in a new DrawBlock object.<br>
* @param state the IBlockState to be examined
* @return A DrawBlock object
*/
public static DrawBlock getDrawBlockFromBlockState(IBlockState state, List<IProperty> extraProperties) {
if (state == null)
return null;
DrawBlock block = new DrawBlock();
Object blockName = Block.REGISTRY.getNameForObject(state.getBlock());
if (blockName instanceof ResourceLocation) {
String name = ((ResourceLocation) blockName).getResourcePath();
BlockType type = BlockType.fromValue(name);
block.setType(type);
}
Colour col = null;
Variation var = null;
Facing face = null;
// Add properties:
for (IProperty prop : state.getProperties().keySet()) {
String propVal = state.getValue(prop).toString();
boolean matched = false;
// Try colour first:
if (col == null) {
col = attemptToGetAsColour(propVal);
if (col != null)
matched = true;
}
// Then variant:
if (!matched && var == null) {
var = attemptToGetAsVariant(propVal);
if (var != null)
matched = true;
}
// Then facing:
if (!matched && face == null) {
face = attemptToGetAsFacing(propVal);
if (face != null)
matched = true;
}
if (!matched) {
if (extraProperties != null)
extraProperties.add(prop);
}
}
if (col != null)
block.setColour(col);
if (var != null)
block.setVariant(var);
if (face != null)
block.setFace(face);
return block;
}
use of com.microsoft.Malmo.Schemas.BlockType 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++;
}
}
}
use of com.microsoft.Malmo.Schemas.BlockType in project malmo by Microsoft.
the class BlockDrawingHelper method DrawPrimitive.
protected void DrawPrimitive(DrawSign s, World w) throws Exception {
String sType = s.getType().value();
// Safe - SignType is a subset of BlockType
BlockType bType = BlockType.fromValue(sType);
XMLBlockState blockType = new XMLBlockState(bType, s.getColour(), s.getFace(), s.getVariant());
BlockPos pos = new BlockPos(s.getX(), s.getY(), s.getZ());
setBlockState(w, pos, blockType);
if (blockType.type == BlockType.STANDING_SIGN && s.getRotation() != null) {
IBlockState placedBlockState = w.getBlockState(pos);
if (placedBlockState != null) {
Block placedBlock = placedBlockState.getBlock();
if (placedBlock != null) {
IBlockState rotatedBlock = placedBlock.getStateFromMeta(s.getRotation());
w.setBlockState(pos, rotatedBlock);
}
}
}
TileEntity tileentity = w.getTileEntity(pos);
if (tileentity instanceof TileEntitySign) {
TileEntitySign sign = (TileEntitySign) tileentity;
if (s.getLine1() != null)
sign.signText[0] = new TextComponentString(s.getLine1());
if (s.getLine2() != null)
sign.signText[1] = new TextComponentString(s.getLine2());
if (s.getLine3() != null)
sign.signText[2] = new TextComponentString(s.getLine3());
if (s.getLine4() != null)
sign.signText[3] = new TextComponentString(s.getLine4());
}
}
Aggregations