Search in sources :

Example 1 with ITransmitter

use of micdoodle8.mods.galacticraft.api.transmission.tile.ITransmitter in project MorePlanets by SteveKunG.

the class BlockSealableNuclearWasteRod method getActualState.

@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
    TileEntity tileEntity = world.getTileEntity(pos);
    if (tileEntity instanceof ITransmitter) {
        TileEntity[] connectable = new TileEntity[6];
        connectable = EnergyUtil.getAdjacentPowerConnections(tileEntity);
        return state.withProperty(DOWN, Boolean.valueOf(connectable[EnumFacing.DOWN.ordinal()] != null)).withProperty(UP, Boolean.valueOf(connectable[EnumFacing.UP.ordinal()] != null)).withProperty(NORTH, Boolean.valueOf(connectable[EnumFacing.NORTH.ordinal()] != null)).withProperty(EAST, Boolean.valueOf(connectable[EnumFacing.EAST.ordinal()] != null)).withProperty(SOUTH, Boolean.valueOf(connectable[EnumFacing.SOUTH.ordinal()] != null)).withProperty(WEST, Boolean.valueOf(connectable[EnumFacing.WEST.ordinal()] != null));
    }
    return state;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ITransmitter(micdoodle8.mods.galacticraft.api.transmission.tile.ITransmitter)

Example 2 with ITransmitter

use of micdoodle8.mods.galacticraft.api.transmission.tile.ITransmitter in project Galacticraft by micdoodle8.

the class FluidNetwork method refresh.

@Override
public void refresh() {
    if (this.acceptors != null) {
        this.acceptors.clear();
    }
    try {
        Iterator<IBufferTransmitter<FluidStack>> it = this.pipes.iterator();
        while (it.hasNext()) {
            ITransmitter transmitter = it.next();
            TileEntity tileTransmitter = (TileEntity) transmitter;
            if (transmitter == null) {
                it.remove();
                continue;
            }
            transmitter.onNetworkChanged();
            if (tileTransmitter.isInvalid() || tileTransmitter.getWorld() == null) {
                it.remove();
                continue;
            } else {
                if (this.worldObj == null) {
                    this.worldObj = tileTransmitter.getWorld();
                }
                transmitter.setNetwork(this);
            }
        }
        updateCapacity();
        clamp();
    } catch (Exception e) {
        FMLLog.severe("Failed to refresh liquid pipe network.");
        e.printStackTrace();
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBufferTransmitter(micdoodle8.mods.galacticraft.api.transmission.tile.IBufferTransmitter) ITransmitter(micdoodle8.mods.galacticraft.api.transmission.tile.ITransmitter)

Example 3 with ITransmitter

use of micdoodle8.mods.galacticraft.api.transmission.tile.ITransmitter in project MorePlanets by SteveKunG.

the class BlockSealableNuclearWasteRod method getActualState.

@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
    TileEntity tileEntity = world.getTileEntity(pos);
    if (tileEntity instanceof ITransmitter) {
        TileEntity[] connectable = new TileEntity[6];
        connectable = EnergyUtil.getAdjacentPowerConnections(tileEntity);
        return state.withProperty(DOWN, connectable[EnumFacing.DOWN.ordinal()] != null).withProperty(UP, connectable[EnumFacing.UP.ordinal()] != null).withProperty(NORTH, connectable[EnumFacing.NORTH.ordinal()] != null).withProperty(EAST, connectable[EnumFacing.EAST.ordinal()] != null).withProperty(SOUTH, connectable[EnumFacing.SOUTH.ordinal()] != null).withProperty(WEST, connectable[EnumFacing.WEST.ordinal()] != null);
    }
    return state;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ITransmitter(micdoodle8.mods.galacticraft.api.transmission.tile.ITransmitter)

Example 4 with ITransmitter

use of micdoodle8.mods.galacticraft.api.transmission.tile.ITransmitter in project Galacticraft by micdoodle8.

the class BlockTransmitter method addCollisionBoxesToList.

@Override
public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity) {
    Vector3 minVector = this.getMinVector(state);
    Vector3 maxVector = this.getMaxVector(state);
    this.setBlockBounds((float) minVector.x, (float) minVector.y, (float) minVector.z, (float) maxVector.x, (float) maxVector.y, (float) maxVector.z);
    super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
    TileEntity tileEntity = worldIn.getTileEntity(pos);
    if (tileEntity instanceof ITransmitter) {
        TileEntity[] connectable;
        switch(this.getNetworkType(state)) {
            case FLUID:
                connectable = OxygenUtil.getAdjacentFluidConnections(tileEntity);
                break;
            case POWER:
                connectable = EnergyUtil.getAdjacentPowerConnections(tileEntity);
                break;
            default:
                connectable = new TileEntity[6];
        }
        if (connectable[4] != null) {
            this.setBlockBounds(0, (float) minVector.y, (float) minVector.z, (float) maxVector.x, (float) maxVector.y, (float) maxVector.z);
            super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
        }
        if (connectable[5] != null) {
            this.setBlockBounds((float) minVector.x, (float) minVector.y, (float) minVector.z, 1, (float) maxVector.y, (float) maxVector.z);
            super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
        }
        if (connectable[0] != null) {
            this.setBlockBounds((float) minVector.x, 0, (float) minVector.z, (float) maxVector.x, (float) maxVector.y, (float) maxVector.z);
            super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
        }
        if (connectable[1] != null) {
            this.setBlockBounds((float) minVector.x, (float) minVector.y, (float) minVector.z, (float) maxVector.x, 1, (float) maxVector.z);
            super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
        }
        if (connectable[2] != null) {
            this.setBlockBounds((float) minVector.x, (float) minVector.y, 0, (float) maxVector.x, (float) maxVector.y, (float) maxVector.z);
            super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
        }
        if (connectable[3] != null) {
            this.setBlockBounds((float) minVector.x, (float) minVector.y, (float) minVector.z, (float) maxVector.x, (float) maxVector.y, 1);
            super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
        }
    }
    this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ITransmitter(micdoodle8.mods.galacticraft.api.transmission.tile.ITransmitter) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3)

Example 5 with ITransmitter

use of micdoodle8.mods.galacticraft.api.transmission.tile.ITransmitter in project Galacticraft by micdoodle8.

the class BlockTransmitter method setBlockBoundsBasedOnState.

/**
 * Returns the bounding box of the wired rectangular prism to render.
 */
@Override
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos) {
    TileEntity tileEntity = worldIn.getTileEntity(pos);
    IBlockState bs = worldIn.getBlockState(pos);
    if (tileEntity instanceof ITransmitter && bs.getBlock() instanceof BlockTransmitter) {
        Vector3 minVector = this.getMinVector(bs);
        Vector3 maxVector = this.getMaxVector(bs);
        TileEntity[] connectable = new TileEntity[6];
        switch(this.getNetworkType(bs)) {
            case FLUID:
                connectable = OxygenUtil.getAdjacentFluidConnections(tileEntity);
                break;
            case POWER:
                connectable = EnergyUtil.getAdjacentPowerConnections(tileEntity);
                break;
            default:
                break;
        }
        float minX = (float) minVector.x;
        float minY = (float) minVector.y;
        float minZ = (float) minVector.z;
        float maxX = (float) maxVector.x;
        float maxY = (float) maxVector.y;
        float maxZ = (float) maxVector.z;
        if (connectable[0] != null) {
            minY = 0.0F;
        }
        if (connectable[1] != null) {
            maxY = 1.0F;
        }
        if (connectable[2] != null) {
            minZ = 0.0F;
        }
        if (connectable[3] != null) {
            maxZ = 1.0F;
        }
        if (connectable[4] != null) {
            minX = 0.0F;
        }
        if (connectable[5] != null) {
            maxX = 1.0F;
        }
        this.setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) ITransmitter(micdoodle8.mods.galacticraft.api.transmission.tile.ITransmitter) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3)

Aggregations

ITransmitter (micdoodle8.mods.galacticraft.api.transmission.tile.ITransmitter)6 TileEntity (net.minecraft.tileentity.TileEntity)6 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)2 IGridNetwork (micdoodle8.mods.galacticraft.api.transmission.grid.IGridNetwork)1 IBufferTransmitter (micdoodle8.mods.galacticraft.api.transmission.tile.IBufferTransmitter)1 INetworkProvider (micdoodle8.mods.galacticraft.api.transmission.tile.INetworkProvider)1 BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)1 FluidNetwork (micdoodle8.mods.galacticraft.core.fluid.FluidNetwork)1 IBlockState (net.minecraft.block.state.IBlockState)1 EnumFacing (net.minecraft.util.EnumFacing)1