Search in sources :

Example 1 with BlockSpecWithDescription

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

the class AgentQuitFromTouchingBlockTypeImplementation method doIWantToQuit.

@Override
public boolean doIWantToQuit(MissionInit missionInit) {
    if (this.wantToQuit)
        return true;
    EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
    List<BlockPos> touchingBlocks = PositionHelper.getTouchingBlocks(player);
    for (BlockPos pos : touchingBlocks) {
        IBlockState bs = player.worldObj.getBlockState(pos);
        // Does this block match our trigger specs?
        String blockname = bs.getBlock().getUnlocalizedName().toLowerCase();
        if (!this.blockTypeNames.contains(blockname))
            continue;
        // The type matches one of our block types, so now we need to perform additional checks.
        for (BlockSpecWithDescription blockspec : this.params.getBlock()) {
            if (findMatch(blockspec, bs)) {
                this.quitCode = blockspec.getDescription();
                // Yes, we want to quit!
                return true;
            }
        }
    }
    // Nothing matched, we can quit happily.
    return false;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockSpecWithDescription(com.microsoft.Malmo.Schemas.BlockSpecWithDescription) BlockPos(net.minecraft.util.BlockPos) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP)

Aggregations

BlockSpecWithDescription (com.microsoft.Malmo.Schemas.BlockSpecWithDescription)1 IBlockState (net.minecraft.block.state.IBlockState)1 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)1 BlockPos (net.minecraft.util.BlockPos)1