use of com.microsoft.Malmo.Schemas.DrawBlockBasedObjectType in project malmo by Microsoft.
the class MovingTargetDecoratorImplementation method parseParameters.
@Override
public boolean parseParameters(Object params) {
if (params == null || !(params instanceof MovingTargetDecorator))
return false;
this.targetParams = (MovingTargetDecorator) params;
this.arenaBounds = this.targetParams.getArenaBounds();
DrawBlockBasedObjectType targetBlock = this.targetParams.getBlockType();
this.blockType = (targetBlock != null) ? new XMLBlockState(targetBlock.getType(), targetBlock.getColour(), targetBlock.getFace(), targetBlock.getVariant()) : null;
Pos pos = this.targetParams.getStartPos();
int xPos = pos.getX().intValue();
int yPos = pos.getY().intValue();
int zPos = pos.getZ().intValue();
// Check start pos lies within arena:
xPos = Math.min(this.arenaBounds.getMax().getX(), Math.max(this.arenaBounds.getMin().getX(), xPos));
yPos = Math.min(this.arenaBounds.getMax().getY(), Math.max(this.arenaBounds.getMin().getY(), yPos));
zPos = Math.min(this.arenaBounds.getMax().getZ(), Math.max(this.arenaBounds.getMin().getZ(), zPos));
this.startPos = new BlockPos(xPos, yPos, zPos);
if (this.targetParams.getUpdateSpeed() == null || this.targetParams.getUpdateSpeed().equals("turnbased")) {
this.mustWaitTurn = true;
} else {
this.speedInTicks = Integer.parseInt(this.targetParams.getUpdateSpeed());
}
createRNG();
return true;
}
use of com.microsoft.Malmo.Schemas.DrawBlockBasedObjectType in project malmo by Microsoft.
the class BuildBattleDecoratorImplementation method parseParameters.
/**
* Attempt to parse the given object as a set of parameters for this handler.
*
* @param params the parameter block to parse
* @return true if the object made sense for this handler; false otherwise.
*/
@Override
public boolean parseParameters(Object params) {
if (params == null || !(params instanceof BuildBattleDecorator))
return false;
this.params = (BuildBattleDecorator) params;
this.sourceBounds = this.params.getGoalStructureBounds();
this.destBounds = this.params.getPlayerStructureBounds();
this.delta = new Vec3i(destBounds.getMin().getX() - sourceBounds.getMin().getX(), destBounds.getMin().getY() - sourceBounds.getMin().getY(), destBounds.getMin().getZ() - sourceBounds.getMin().getZ());
this.structureVolume = volumeOfBounds(this.sourceBounds);
assert (this.structureVolume == volumeOfBounds(this.destBounds));
this.dest = new ArrayList<IBlockState>(Collections.nCopies(this.structureVolume, (IBlockState) null));
this.source = new ArrayList<IBlockState>(Collections.nCopies(this.structureVolume, (IBlockState) null));
DrawBlockBasedObjectType tickBlock = this.params.getBlockTypeOnCorrectPlacement();
DrawBlockBasedObjectType crossBlock = this.params.getBlockTypeOnIncorrectPlacement();
this.blockTypeOnCorrectPlacement = (tickBlock != null) ? new XMLBlockState(tickBlock.getType(), tickBlock.getColour(), tickBlock.getFace(), tickBlock.getVariant()) : null;
this.blockTypeOnIncorrectPlacement = (crossBlock != null) ? new XMLBlockState(crossBlock.getType(), crossBlock.getColour(), crossBlock.getFace(), crossBlock.getVariant()) : null;
return true;
}
Aggregations