Search in sources :

Example 1 with BuildBattleDecorator

use of com.microsoft.Malmo.Schemas.BuildBattleDecorator 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.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

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