Search in sources :

Example 1 with TileEntityFluidPipeTickable

use of gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipeTickable in project GregTech by GregTechCE.

the class DebugPipeNetInfoProvider method addProbeInfo.

@Override
public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
    if (mode == ProbeMode.DEBUG && ConfigHolder.debug) {
        TileEntity tileEntity = world.getTileEntity(data.getPos());
        if (tileEntity instanceof MetaTileEntityHolder) {
            MetaTileEntity metaTileEntity = ((MetaTileEntityHolder) tileEntity).getMetaTileEntity();
            if (metaTileEntity != null) {
                ArrayList<String> arrayList = new ArrayList<>();
                arrayList.add("MetaTileEntity Id: " + metaTileEntity.metaTileEntityId);
                metaTileEntity.addDebugInfo(arrayList);
                arrayList.forEach(probeInfo::text);
            }
        }
        if (tileEntity instanceof TileEntityPipeBase) {
            IPipeTile<?, ?> pipeTile = (IPipeTile<?, ?>) tileEntity;
            BlockPipe<?, ?, ?> blockPipe = pipeTile.getPipeBlock();
            PipeNet<?> pipeNet = blockPipe.getWorldPipeNet(world).getNetFromPos(data.getPos());
            if (pipeNet != null) {
                probeInfo.text("Net: " + pipeNet.hashCode());
                probeInfo.text("Node Info: ");
                StringBuilder builder = new StringBuilder();
                Map<BlockPos, ? extends Node<?>> nodeMap = pipeNet.getAllNodes();
                Node<?> node = nodeMap.get(data.getPos());
                builder.append("{").append("active: ").append(node.isActive).append(", mark: ").append(node.mark).append(", blocked: ").append(node.blockedConnections).append("}");
                probeInfo.text(builder.toString());
            }
            probeInfo.text("tile blocked: " + pipeTile.getBlockedConnections());
            if (blockPipe instanceof BlockFluidPipe) {
                if (pipeTile instanceof TileEntityFluidPipeTickable) {
                    probeInfo.text("tile active: " + ((TileEntityFluidPipeTickable) pipeTile).isActive());
                }
            }
        }
    }
}
Also used : IPipeTile(gregtech.api.pipenet.tile.IPipeTile) MetaTileEntityHolder(gregtech.api.metatileentity.MetaTileEntityHolder) ArrayList(java.util.ArrayList) BlockFluidPipe(gregtech.common.pipelike.fluidpipe.BlockFluidPipe) TileEntityFluidPipeTickable(gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipeTickable) TileEntityPipeBase(gregtech.api.pipenet.tile.TileEntityPipeBase) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) BlockPos(net.minecraft.util.math.BlockPos)

Example 2 with TileEntityFluidPipeTickable

use of gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipeTickable in project GregTech by GregTechCE.

the class BlockFluidPipe method onActiveModeChange.

@Override
protected void onActiveModeChange(World world, BlockPos pos, boolean isActiveNow, boolean isInitialChange) {
    TileEntityFluidPipe oldTileEntity = (TileEntityFluidPipe) world.getTileEntity(pos);
    if (!(oldTileEntity instanceof TileEntityFluidPipeTickable) && isActiveNow) {
        TileEntityFluidPipeTickable newTileEntity = new TileEntityFluidPipeTickable();
        newTileEntity.transferDataFrom(oldTileEntity);
        newTileEntity.setActive(true);
        world.setTileEntity(pos, newTileEntity);
    } else if (oldTileEntity instanceof TileEntityFluidPipeTickable) {
        ((TileEntityFluidPipeTickable) oldTileEntity).setActive(isActiveNow);
    }
}
Also used : TileEntityFluidPipeTickable(gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipeTickable) TileEntityFluidPipe(gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipe)

Aggregations

TileEntityFluidPipeTickable (gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipeTickable)2 MetaTileEntity (gregtech.api.metatileentity.MetaTileEntity)1 MetaTileEntityHolder (gregtech.api.metatileentity.MetaTileEntityHolder)1 IPipeTile (gregtech.api.pipenet.tile.IPipeTile)1 TileEntityPipeBase (gregtech.api.pipenet.tile.TileEntityPipeBase)1 BlockFluidPipe (gregtech.common.pipelike.fluidpipe.BlockFluidPipe)1 TileEntityFluidPipe (gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipe)1 ArrayList (java.util.ArrayList)1 TileEntity (net.minecraft.tileentity.TileEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1