Search in sources :

Example 6 with BlockType

use of com.microsoft.Malmo.Schemas.BlockType in project malmo by Microsoft.

the class MovingTargetDecoratorImplementation method isValid.

private boolean isValid(World world, BlockPos pos) {
    // In bounds?
    if (!blockInBounds(pos, this.arenaBounds))
        return false;
    // Already in path?
    if (this.path.contains(pos))
        return false;
    // Does there need to be air above the target?
    if (this.targetParams.isRequiresAirAbove() && !world.isAirBlock(pos.up()))
        return false;
    // Check the current block is "permeable"...
    IBlockState block = world.getBlockState(pos);
    List<IProperty> extraProperties = new ArrayList<IProperty>();
    DrawBlock db = MinecraftTypeHelper.getDrawBlockFromBlockState(block, extraProperties);
    boolean typesMatch = this.targetParams.getPermeableBlocks().getType().isEmpty();
    for (BlockType bt : this.targetParams.getPermeableBlocks().getType()) {
        if (db.getType() == bt) {
            typesMatch = true;
            break;
        }
    }
    if (!typesMatch)
        return false;
    if (db.getColour() != null) {
        boolean coloursMatch = this.targetParams.getPermeableBlocks().getColour().isEmpty();
        for (Colour col : this.targetParams.getPermeableBlocks().getColour()) {
            if (db.getColour() == col) {
                coloursMatch = true;
                break;
            }
        }
        if (!coloursMatch)
            return false;
    }
    if (db.getVariant() != null) {
        boolean variantsMatch = this.targetParams.getPermeableBlocks().getVariant().isEmpty();
        for (Variation var : this.targetParams.getPermeableBlocks().getVariant()) {
            if (db.getVariant() == var) {
                variantsMatch = true;
                break;
            }
        }
        if (!variantsMatch)
            return false;
    }
    return true;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IProperty(net.minecraft.block.properties.IProperty) BlockType(com.microsoft.Malmo.Schemas.BlockType) ArrayList(java.util.ArrayList) DrawBlock(com.microsoft.Malmo.Schemas.DrawBlock) Variation(com.microsoft.Malmo.Schemas.Variation) Colour(com.microsoft.Malmo.Schemas.Colour)

Aggregations

BlockType (com.microsoft.Malmo.Schemas.BlockType)6 Colour (com.microsoft.Malmo.Schemas.Colour)3 DrawBlock (com.microsoft.Malmo.Schemas.DrawBlock)3 Variation (com.microsoft.Malmo.Schemas.Variation)3 Block (net.minecraft.block.Block)2 IProperty (net.minecraft.block.properties.IProperty)2 IBlockState (net.minecraft.block.state.IBlockState)2 TileEntity (net.minecraft.tileentity.TileEntity)2 BlockPos (net.minecraft.util.math.BlockPos)2 TextComponentString (net.minecraft.util.text.TextComponentString)2 AgentQuitFromTouchingBlockType (com.microsoft.Malmo.Schemas.AgentQuitFromTouchingBlockType)1 BlockSpec (com.microsoft.Malmo.Schemas.BlockSpec)1 ContainedObjectType (com.microsoft.Malmo.Schemas.ContainedObjectType)1 DrawItem (com.microsoft.Malmo.Schemas.DrawItem)1 Facing (com.microsoft.Malmo.Schemas.Facing)1 XMLBlockState (com.microsoft.Malmo.Utils.BlockDrawingHelper.XMLBlockState)1 ArrayList (java.util.ArrayList)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntityLockableLoot (net.minecraft.tileentity.TileEntityLockableLoot)1 TileEntitySign (net.minecraft.tileentity.TileEntitySign)1