Search in sources :

Example 6 with TileEntityPressureTube

use of me.desht.pneumaticcraft.common.tileentity.TileEntityPressureTube in project pnc-repressurized by TeamPneumatic.

the class BlockPressureTube method collisionRayTrace.

@Override
public RayTraceResult collisionRayTrace(IBlockState state, World world, BlockPos pos, Vec3d origin, Vec3d direction) {
    RayTraceResult bestRTR = null;
    AxisAlignedBB bestAABB = null;
    setBlockBounds(BASE_BOUNDS);
    RayTraceResult rtr = super.collisionRayTrace(state, world, pos, origin, direction);
    if (rtr != null) {
        rtr.hitInfo = TubeHitInfo.CENTER;
        bestRTR = rtr;
        bestAABB = getBoundingBox(state, world, pos);
    }
    TileEntityPressureTube tube = ModInteractionUtils.getInstance().getTube(getTE(world, pos));
    for (int i = 0; i < 6; i++) {
        if (tube.sidesConnected[i] || tube.sidesClosed[i]) {
            setBlockBounds(tube.sidesClosed[i] ? closedBoundingBoxes[i] : boundingBoxes[i]);
            rtr = super.collisionRayTrace(state, world, pos, origin, direction);
            if (isCloserMOP(origin, bestRTR, rtr)) {
                // tube connection arm
                rtr.hitInfo = new TubeHitInfo(EnumFacing.getFront(i), TubeHitInfo.PartType.TUBE);
                bestRTR = rtr;
                bestAABB = getBoundingBox(state, world, pos);
            }
        }
    }
    TubeModule[] modules = tube.modules;
    for (EnumFacing dir : EnumFacing.VALUES) {
        if (modules[dir.ordinal()] != null) {
            setBlockBounds(modules[dir.ordinal()].boundingBoxes[dir.ordinal()]);
            rtr = super.collisionRayTrace(state, world, pos, origin, direction);
            if (isCloserMOP(origin, bestRTR, rtr)) {
                // tube module
                rtr.hitInfo = new TubeHitInfo(dir, TubeHitInfo.PartType.MODULE);
                bestRTR = rtr;
                bestAABB = getBoundingBox(state, world, pos);
            }
        }
    }
    if (bestAABB != null)
        setBlockBounds(bestAABB);
    return bestRTR;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) RayTraceResult(net.minecraft.util.math.RayTraceResult) TubeModule(me.desht.pneumaticcraft.common.block.tubes.TubeModule) ItemTubeModule(me.desht.pneumaticcraft.common.item.ItemTubeModule) TileEntityPressureTube(me.desht.pneumaticcraft.common.tileentity.TileEntityPressureTube)

Example 7 with TileEntityPressureTube

use of me.desht.pneumaticcraft.common.tileentity.TileEntityPressureTube in project pnc-repressurized by TeamPneumatic.

the class ModuleNetworkManager method getConnectedModules.

Set<TubeModule> getConnectedModules(TubeModule module) {
    Set<TubeModule> modules = new HashSet<>();
    Set<TileEntityPressureTube> traversedTubes = new HashSet<>();
    Stack<TileEntityPressureTube> pendingTubes = new Stack<>();
    pendingTubes.push((TileEntityPressureTube) module.getTube());
    while (!pendingTubes.isEmpty()) {
        TileEntityPressureTube tube = pendingTubes.pop();
        for (TubeModule m : tube.modules) {
            if (m != null)
                modules.add(m);
        }
        TileEntityCache[] cache = ((AirHandler) tube.getAirHandler(null)).getTileCache();
        for (EnumFacing d : EnumFacing.VALUES) {
            if (tube.sidesConnected[d.ordinal()]) {
                TileEntityPressureTube newTube = ModInteractionUtils.getInstance().getTube(cache[d.ordinal()].getTileEntity());
                if (newTube != null && !traversedTubes.contains(newTube)) {
                    pendingTubes.add(newTube);
                    traversedTubes.add(newTube);
                }
            }
        }
    }
    return modules;
}
Also used : AirHandler(me.desht.pneumaticcraft.common.pressure.AirHandler) EnumFacing(net.minecraft.util.EnumFacing) TileEntityPressureTube(me.desht.pneumaticcraft.common.tileentity.TileEntityPressureTube) TileEntityCache(me.desht.pneumaticcraft.common.util.TileEntityCache) HashSet(java.util.HashSet) Stack(java.util.Stack)

Example 8 with TileEntityPressureTube

use of me.desht.pneumaticcraft.common.tileentity.TileEntityPressureTube in project pnc-repressurized by TeamPneumatic.

the class BlockPressureTube method randomDisplayTick.

@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState state, World par1World, BlockPos pos, Random par5Random) {
    TileEntity te = getTE(par1World, pos);
    if (te instanceof TileEntityPressureTube) {
        TileEntityPressureTube tePt = (TileEntityPressureTube) te;
        int l = 0;
        for (TubeModule module : tePt.modules) {
            if (module != null)
                l = Math.max(l, module.getRedstoneLevel());
        }
        if (l > 0) {
            double d0 = pos.getX() + 0.5D + (par5Random.nextFloat() - 0.5D) * 0.5D;
            double d1 = pos.getY() + 0.5D + (par5Random.nextFloat() - 0.5D) * 0.5D;
            double d2 = pos.getZ() + 0.5D + (par5Random.nextFloat() - 0.5D) * 0.5D;
            float f = l / 15.0F;
            float f1 = f * 0.6F + 0.4F;
            float f2 = f * f * 0.7F - 0.5F;
            float f3 = f * f * 0.6F - 0.7F;
            if (f2 < 0.0F) {
                f2 = 0.0F;
            }
            if (f3 < 0.0F) {
                f3 = 0.0F;
            }
            par1World.spawnParticle(EnumParticleTypes.REDSTONE, d0, d1, d2, f1, f2, f3);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TubeModule(me.desht.pneumaticcraft.common.block.tubes.TubeModule) ItemTubeModule(me.desht.pneumaticcraft.common.item.ItemTubeModule) TileEntityPressureTube(me.desht.pneumaticcraft.common.tileentity.TileEntityPressureTube) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 9 with TileEntityPressureTube

use of me.desht.pneumaticcraft.common.tileentity.TileEntityPressureTube in project pnc-repressurized by TeamPneumatic.

the class BlockPressureTube method getWeakPower.

@Override
public int getWeakPower(IBlockState state, IBlockAccess par1IBlockAccess, BlockPos pos, EnumFacing side) {
    TileEntity te = getTE(par1IBlockAccess, pos);
    if (te instanceof TileEntityPressureTube) {
        TileEntityPressureTube tePt = (TileEntityPressureTube) te;
        int redstoneLevel = 0;
        for (EnumFacing face : EnumFacing.VALUES) {
            if (tePt.modules[face.ordinal()] != null) {
                if (side.getOpposite() == face || face != side && tePt.modules[face.ordinal()].isInline()) {
                    // if we are on the same side, or when we have an 'in line' module that is not on the opposite side.
                    redstoneLevel = Math.max(redstoneLevel, tePt.modules[face.ordinal()].getRedstoneLevel());
                }
            }
        }
        return redstoneLevel;
    }
    return 0;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityPressureTube(me.desht.pneumaticcraft.common.tileentity.TileEntityPressureTube)

Aggregations

TileEntityPressureTube (me.desht.pneumaticcraft.common.tileentity.TileEntityPressureTube)9 TileEntity (net.minecraft.tileentity.TileEntity)5 TubeModule (me.desht.pneumaticcraft.common.block.tubes.TubeModule)4 ItemTubeModule (me.desht.pneumaticcraft.common.item.ItemTubeModule)4 RayTraceResult (net.minecraft.util.math.RayTraceResult)2 HashSet (java.util.HashSet)1 Stack (java.util.Stack)1 PacketPlaySound (me.desht.pneumaticcraft.common.network.PacketPlaySound)1 AirHandler (me.desht.pneumaticcraft.common.pressure.AirHandler)1 TileEntityCache (me.desht.pneumaticcraft.common.util.TileEntityCache)1 IBlockState (net.minecraft.block.state.IBlockState)1 EntityItem (net.minecraft.entity.item.EntityItem)1 ItemStack (net.minecraft.item.ItemStack)1 EnumFacing (net.minecraft.util.EnumFacing)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 Vec3d (net.minecraft.util.math.Vec3d)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1