Search in sources :

Example 1 with DrawBlockBasedObjectType

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;
}
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)

Example 2 with DrawBlockBasedObjectType

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;
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) IBlockState(net.minecraft.block.state.IBlockState) DrawBlockBasedObjectType(com.microsoft.Malmo.Schemas.DrawBlockBasedObjectType) BuildBattleDecorator(com.microsoft.Malmo.Schemas.BuildBattleDecorator) XMLBlockState(com.microsoft.Malmo.Utils.BlockDrawingHelper.XMLBlockState)

Aggregations

DrawBlockBasedObjectType (com.microsoft.Malmo.Schemas.DrawBlockBasedObjectType)2 XMLBlockState (com.microsoft.Malmo.Utils.BlockDrawingHelper.XMLBlockState)2 BuildBattleDecorator (com.microsoft.Malmo.Schemas.BuildBattleDecorator)1 MovingTargetDecorator (com.microsoft.Malmo.Schemas.MovingTargetDecorator)1 Pos (com.microsoft.Malmo.Schemas.Pos)1 IBlockState (net.minecraft.block.state.IBlockState)1 BlockPos (net.minecraft.util.math.BlockPos)1 Vec3i (net.minecraft.util.math.Vec3i)1