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;
}
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;
}
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);
}
}
}
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;
}
Aggregations