Search in sources :

Example 1 with MobWithDescription

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

the class AgentQuitFromCatchingMobImplementation method doIWantToQuit.

@Override
public boolean doIWantToQuit(MissionInit missionInit) {
    this.quitCode = "";
    List<Entity> caughtEntities = RewardForCatchingMobImplementation.getCaughtEntities();
    for (Entity ent : caughtEntities) {
        // Do we care about this entity?
        for (MobWithDescription mob : this.qcmparams.getMob()) {
            for (EntityTypes et : mob.getType()) {
                if (et.value().equals(ent.getName())) {
                    if (!mob.isGlobal()) {
                        // If global flag is false, our player needs to be adjacent to the mob in order to claim the reward.
                        BlockPos entityPos = new BlockPos(ent.posX, ent.posY, ent.posZ);
                        EntityPlayerSP player = Minecraft.getMinecraft().player;
                        BlockPos playerPos = new BlockPos(player.posX, player.posY, player.posZ);
                        if (Math.abs(entityPos.getX() - playerPos.getX()) + Math.abs(entityPos.getZ() - playerPos.getZ()) > 1)
                            continue;
                    }
                    this.quitCode = mob.getDescription();
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : EntityTypes(com.microsoft.Malmo.Schemas.EntityTypes) Entity(net.minecraft.entity.Entity) MobWithDescription(com.microsoft.Malmo.Schemas.MobWithDescription) BlockPos(net.minecraft.util.math.BlockPos) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP)

Aggregations

EntityTypes (com.microsoft.Malmo.Schemas.EntityTypes)1 MobWithDescription (com.microsoft.Malmo.Schemas.MobWithDescription)1 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)1 Entity (net.minecraft.entity.Entity)1 BlockPos (net.minecraft.util.math.BlockPos)1