Search in sources :

Example 1 with MovingTargetDecorator

use of com.microsoft.Malmo.Schemas.MovingTargetDecorator 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;
}
Also used : Pos(com.microsoft.Malmo.Schemas.Pos) BlockPos(net.minecraft.util.math.BlockPos) DrawBlockBasedObjectType(com.microsoft.Malmo.Schemas.DrawBlockBasedObjectType) BlockPos(net.minecraft.util.math.BlockPos) MovingTargetDecorator(com.microsoft.Malmo.Schemas.MovingTargetDecorator) XMLBlockState(com.microsoft.Malmo.Utils.BlockDrawingHelper.XMLBlockState)

Aggregations

DrawBlockBasedObjectType (com.microsoft.Malmo.Schemas.DrawBlockBasedObjectType)1 MovingTargetDecorator (com.microsoft.Malmo.Schemas.MovingTargetDecorator)1 Pos (com.microsoft.Malmo.Schemas.Pos)1 XMLBlockState (com.microsoft.Malmo.Utils.BlockDrawingHelper.XMLBlockState)1 BlockPos (net.minecraft.util.math.BlockPos)1