Search in sources :

Example 36 with BlockVec3

use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.

the class TileEntityArclamp method revertAir.

private void revertAir() {
    if (this.airToRestore.isEmpty())
        return;
    if (this.usingLightList == null) {
        this.usingLightList = this.worldObj.isRemote ? usingLightListClient : usingLightListServer;
    }
    int index = 0;
    for (BlockVec3 vec : this.airToRestore) {
        this.setDarkerAir(vec);
    }
    if (!this.usingLightList.getAndSet(true)) {
        for (BlockVec3 vec : this.airToRestore) {
            index = this.checkLightPartA(EnumSkyBlock.BLOCK, vec.toBlockPos(), index);
        }
        this.checkLightPartB(EnumSkyBlock.BLOCK, index);
        this.usingLightList.set(false);
    }
    this.airToRestore.clear();
    this.checkLightFor(EnumSkyBlock.BLOCK, this.pos);
}
Also used : BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 37 with BlockVec3

use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.

the class TileEntityOxygen method produceOxygen.

public boolean produceOxygen(EnumFacing outputDirection) {
    int provide = this.getOxygenProvide(outputDirection);
    if (provide > 0) {
        TileEntity outputTile = new BlockVec3(this).getTileEntityOnSide(this.worldObj, outputDirection);
        FluidNetwork outputNetwork = NetworkHelper.getFluidNetworkFromTile(outputTile, outputDirection);
        if (outputNetwork != null) {
            int gasRequested = outputNetwork.getRequest();
            if (gasRequested > 0) {
                int usedGas = outputNetwork.emitToBuffer(new FluidStack(GCFluids.fluidOxygenGas, Math.min(gasRequested, provide)), true);
                this.drawOxygen(usedGas, true);
                return true;
            }
        } else if (outputTile instanceof IOxygenReceiver) {
            float requestedOxygen = ((IOxygenReceiver) outputTile).getOxygenRequest(outputDirection.getOpposite());
            if (requestedOxygen > 0) {
                int acceptedOxygen = ((IOxygenReceiver) outputTile).receiveOxygen(outputDirection.getOpposite(), provide, true);
                this.drawOxygen(acceptedOxygen, true);
                return true;
            }
        }
    // else if (EnergyConfigHandler.isMekanismLoaded())
    // {
    // //TODO Oxygen item handling - internal tank (IGasItem)
    // //int acceptedOxygen = GasTransmission.addGas(itemStack, type, amount);
    // //this.drawOxygen(acceptedOxygen, true);
    // 
    // if (outputTile instanceof IGasHandler && ((IGasHandler) outputTile).canReceiveGas(outputDirection.getOpposite(), (Gas) EnergyConfigHandler.gasOxygen))
    // {
    // GasStack toSend = new GasStack((Gas) EnergyConfigHandler.gasOxygen, (int) Math.floor(provide));
    // int acceptedOxygen = 0;
    // try {
    // acceptedOxygen = ((IGasHandler) outputTile).receiveGas(outputDirection.getOpposite(), toSend);
    // } catch (Exception e) { }
    // this.drawOxygen(acceptedOxygen, true);
    // return true;
    // }
    // }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FluidNetwork(micdoodle8.mods.galacticraft.core.fluid.FluidNetwork) FluidStack(net.minecraftforge.fluids.FluidStack) IOxygenReceiver(micdoodle8.mods.galacticraft.api.transmission.tile.IOxygenReceiver) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 38 with BlockVec3

use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.

the class TileEntityFluidPipe method canConnect.

@Override
public boolean canConnect(EnumFacing direction, NetworkType type) {
    TileEntity adjacentTile = new BlockVec3(this).getTileEntityOnSide(this.worldObj, direction);
    if (type == NetworkType.FLUID) {
        if (adjacentTile instanceof IColorable) {
            IBlockState state = this.worldObj.getBlockState(this.getPos());
            IBlockState adjacentTileState = adjacentTile.getWorld().getBlockState(adjacentTile.getPos());
            byte thisCol = this.getColor(state);
            byte otherCol = ((IColorable) adjacentTile).getColor(adjacentTileState);
            return thisCol == otherCol || thisCol == EnumDyeColor.WHITE.getDyeDamage() || otherCol == EnumDyeColor.WHITE.getDyeDamage();
        }
        return true;
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3) IColorable(micdoodle8.mods.galacticraft.api.tile.IColorable)

Example 39 with BlockVec3

use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.

the class TileEntityFuelLoader method update.

@Override
public void update() {
    super.update();
    if (!this.worldObj.isRemote) {
        this.loadedFuelLastTick = false;
        final FluidStack liquidContained = FluidUtil.getFluidContained(this.containingItems[1]);
        if (FluidUtil.isFuel(liquidContained)) {
            FluidUtil.loadFromContainer(this.fuelTank, GCFluids.fluidFuel, this.containingItems, 1, liquidContained.amount);
        }
        if (this.ticks % 100 == 0) {
            this.attachedFuelable = null;
            BlockVec3 thisVec = new BlockVec3(this);
            for (final EnumFacing dir : EnumFacing.VALUES) {
                final TileEntity pad = thisVec.getTileEntityOnSide(this.worldObj, dir);
                if (pad instanceof TileEntityMulti) {
                    final TileEntity mainTile = ((TileEntityMulti) pad).getMainBlockTile();
                    if (mainTile instanceof IFuelable) {
                        this.attachedFuelable = (IFuelable) mainTile;
                        break;
                    }
                } else if (pad instanceof IFuelable) {
                    this.attachedFuelable = (IFuelable) pad;
                    break;
                }
            }
        }
        if (this.fuelTank != null && this.fuelTank.getFluid() != null && this.fuelTank.getFluid().amount > 0) {
            final FluidStack liquid = new FluidStack(GCFluids.fluidFuel, 2);
            if (this.attachedFuelable != null && this.hasEnoughEnergyToRun && !this.disabled) {
                int filled = this.attachedFuelable.addFuel(liquid, true);
                this.loadedFuelLastTick = filled > 0;
                this.fuelTank.drain(filled, true);
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnumFacing(net.minecraft.util.EnumFacing) IFuelable(micdoodle8.mods.galacticraft.api.entity.IFuelable) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 40 with BlockVec3

use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.

the class EntityTieredRocket method onUpdate.

@Override
public void onUpdate() {
    if (this.getWaitForPlayer()) {
        if (this.riddenByEntity != null) {
            if (this.ticks >= 40) {
                if (!this.worldObj.isRemote) {
                    Entity e = this.riddenByEntity;
                    e.mountEntity(null);
                    e.mountEntity(this);
                    GCLog.debug("Remounting player in rocket.");
                }
                this.setWaitForPlayer(false);
                this.motionY = -0.5D;
            } else {
                this.motionX = this.motionY = this.motionZ = 0.0D;
                this.riddenByEntity.motionX = this.riddenByEntity.motionY = this.riddenByEntity.motionZ = 0;
            }
        } else {
            this.motionX = this.motionY = this.motionZ = 0.0D;
        }
    }
    super.onUpdate();
    if (!this.worldObj.isRemote) {
        if (this.launchCooldown > 0) {
            this.launchCooldown--;
        }
        if (this.preGenIterator != null) {
            if (this.preGenIterator.hasNext()) {
                MinecraftServer mcserver;
                if (this.worldObj instanceof WorldServer) {
                    mcserver = ((WorldServer) this.worldObj).getMinecraftServer();
                    BlockVec3 coords = this.preGenIterator.next();
                    World w = mcserver.worldServerForDimension(coords.y);
                    if (w != null) {
                        w.getChunkFromChunkCoords(coords.x, coords.z);
                        // Pregen a second chunk if still on launchpad (low strain on server)
                        if (this.launchPhase < EnumLaunchPhase.LAUNCHED.ordinal() && this.preGenIterator.hasNext()) {
                            coords = this.preGenIterator.next();
                            w = mcserver.worldServerForDimension(coords.y);
                            w.getChunkFromChunkCoords(coords.x, coords.z);
                        }
                    }
                }
            } else {
                this.preGenIterator = null;
                EntityTieredRocket.preGenInProgress = false;
            }
        }
    }
    if (this.rumble > 0) {
        this.rumble--;
    } else if (this.rumble < 0) {
        this.rumble++;
    }
    if (this.riddenByEntity != null) {
        final double rumbleAmount = this.rumble / (double) (37 - 5 * Math.max(this.getRocketTier(), 5));
        this.riddenByEntity.posX += rumbleAmount;
        this.riddenByEntity.posZ += rumbleAmount;
    }
    if (this.launchPhase >= EnumLaunchPhase.IGNITED.ordinal()) {
        this.performHurtAnimation();
        this.rumble = (float) this.rand.nextInt(3) - 3;
    }
    if (!this.worldObj.isRemote) {
        this.lastLastMotionY = this.lastMotionY;
        this.lastMotionY = this.motionY;
    }
}
Also used : ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) Entity(net.minecraft.entity.Entity) WorldServer(net.minecraft.world.WorldServer) World(net.minecraft.world.World) MinecraftServer(net.minecraft.server.MinecraftServer) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Aggregations

BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)104 TileEntity (net.minecraft.tileentity.TileEntity)44 EnumFacing (net.minecraft.util.EnumFacing)20 IBlockState (net.minecraft.block.state.IBlockState)14 BlockPos (net.minecraft.util.BlockPos)13 World (net.minecraft.world.World)10 IPartialSealableBlock (micdoodle8.mods.galacticraft.api.block.IPartialSealableBlock)9 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)9 Block (net.minecraft.block.Block)9 ArrayList (java.util.ArrayList)7 FluidNetwork (micdoodle8.mods.galacticraft.core.fluid.FluidNetwork)7 Footprint (micdoodle8.mods.galacticraft.core.wrappers.Footprint)7 NBTTagList (net.minecraft.nbt.NBTTagList)7 IConductor (micdoodle8.mods.galacticraft.api.transmission.tile.IConductor)6 TileEntityOxygenSealer (micdoodle8.mods.galacticraft.core.tile.TileEntityOxygenSealer)6 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)6 Entity (net.minecraft.entity.Entity)5 LinkedList (java.util.LinkedList)4 INetworkProvider (micdoodle8.mods.galacticraft.api.transmission.tile.INetworkProvider)4 PacketSimple (micdoodle8.mods.galacticraft.core.network.PacketSimple)4