Search in sources :

Example 1 with IDockable

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

the class TileEntityLaunchController method updateRocketOnDockSettings.

public void updateRocketOnDockSettings() {
    if (this.attachedDock instanceof TileEntityLandingPad) {
        TileEntityLandingPad pad = ((TileEntityLandingPad) this.attachedDock);
        IDockable rocket = pad.getDockedEntity();
        if (rocket instanceof EntityAutoRocket) {
            ((EntityAutoRocket) rocket).updateControllerSettings(pad);
        }
    }
}
Also used : EntityAutoRocket(micdoodle8.mods.galacticraft.api.prefab.entity.EntityAutoRocket) TileEntityLandingPad(micdoodle8.mods.galacticraft.core.tile.TileEntityLandingPad) IDockable(micdoodle8.mods.galacticraft.api.entity.IDockable)

Example 2 with IDockable

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

the class TileEntityBuggyFueler 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() - 1.5D, this.getPos().getY() - 2.0, this.getPos().getZ() - 1.5D, this.getPos().getX() + 1.5D, this.getPos().getY() + 4.0, this.getPos().getZ() + 1.5D), new Predicate<Entity>() {

            @Override
            public boolean apply(Entity input) {
                return input instanceof IFuelable;
            }
        });
        boolean changed = false;
        for (final Object o : list) {
            if (o != null && o instanceof IDockable && !this.worldObj.isRemote) {
                final IDockable fuelable = (IDockable) o;
                if (fuelable.isDockValid(this)) {
                    this.dockedEntity = fuelable;
                    this.dockedEntity.setPad(this);
                    changed = true;
                }
            }
        }
        if (!changed) {
            if (this.dockedEntity != null) {
                this.dockedEntity.setPad(null);
            }
            this.dockedEntity = null;
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) ICargoEntity(micdoodle8.mods.galacticraft.api.entity.ICargoEntity) TileEntity(net.minecraft.tileentity.TileEntity) IFuelable(micdoodle8.mods.galacticraft.api.entity.IFuelable) IDockable(micdoodle8.mods.galacticraft.api.entity.IDockable)

Example 3 with IDockable

use of micdoodle8.mods.galacticraft.api.entity.IDockable 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

IDockable (micdoodle8.mods.galacticraft.api.entity.IDockable)3 ICargoEntity (micdoodle8.mods.galacticraft.api.entity.ICargoEntity)2 Entity (net.minecraft.entity.Entity)2 TileEntity (net.minecraft.tileentity.TileEntity)2 IFuelable (micdoodle8.mods.galacticraft.api.entity.IFuelable)1 ILandable (micdoodle8.mods.galacticraft.api.entity.ILandable)1 EntityAutoRocket (micdoodle8.mods.galacticraft.api.prefab.entity.EntityAutoRocket)1 TileEntityLandingPad (micdoodle8.mods.galacticraft.core.tile.TileEntityLandingPad)1