Search in sources :

Example 1 with ILandable

use of micdoodle8.mods.galacticraft.api.entity.ILandable in project Galacticraft by micdoodle8.

the class TileEntityLandingPad method update.

@Override
public void update() {
    if (!this.initialised) {
        if (!this.worldObj.isRemote)
            this.onCreate(this.worldObj, this.getPos());
        this.initialiseMultiTiles(this.getPos(), this.worldObj);
        this.initialised = true;
    }
    if (!this.worldObj.isRemote) {
        final List<Entity> list = this.worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.fromBounds(this.getPos().getX() - 0.5D, this.getPos().getY(), this.getPos().getZ() - 0.5D, this.getPos().getX() + 0.5D, this.getPos().getY() + 1.0D, this.getPos().getZ() + 0.5D));
        boolean docked = false;
        for (final Object o : list) {
            if (o instanceof IDockable && !((Entity) o).isDead) {
                final IDockable fuelable = (IDockable) o;
                if (!fuelable.inFlight()) {
                    docked = true;
                    if (fuelable != this.dockedEntity && fuelable.isDockValid(this)) {
                        if (fuelable instanceof ILandable) {
                            ((ILandable) fuelable).landEntity(this.getPos());
                        } else {
                            fuelable.setPad(this);
                        }
                    }
                    break;
                }
            }
        }
        if (!docked) {
            this.dockedEntity = null;
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) ICargoEntity(micdoodle8.mods.galacticraft.api.entity.ICargoEntity) TileEntity(net.minecraft.tileentity.TileEntity) ILandable(micdoodle8.mods.galacticraft.api.entity.ILandable) IDockable(micdoodle8.mods.galacticraft.api.entity.IDockable)

Aggregations

ICargoEntity (micdoodle8.mods.galacticraft.api.entity.ICargoEntity)1 IDockable (micdoodle8.mods.galacticraft.api.entity.IDockable)1 ILandable (micdoodle8.mods.galacticraft.api.entity.ILandable)1 Entity (net.minecraft.entity.Entity)1 TileEntity (net.minecraft.tileentity.TileEntity)1