use of gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipe in project GregTech by GregTechCE.
the class FluidPipeRenderer method renderBlock.
@Override
public boolean renderBlock(IBlockAccess world, BlockPos pos, IBlockState state, BufferBuilder buffer) {
CCRenderState renderState = CCRenderState.instance();
renderState.reset();
renderState.bind(buffer);
renderState.setBrightness(world, pos);
BlockFluidPipe blockPipe = ((BlockFluidPipe) state.getBlock());
TileEntityFluidPipe tileEntityPipe = (TileEntityFluidPipe) blockPipe.getPipeTileEntity(world, pos);
if (tileEntityPipe == null) {
return false;
}
FluidPipeType fluidPipeType = tileEntityPipe.getPipeType();
Material pipeMaterial = tileEntityPipe.getPipeMaterial();
int paintingColor = tileEntityPipe.getInsulationColor();
if (fluidPipeType != null && pipeMaterial != null) {
BlockRenderLayer renderLayer = MinecraftForgeClient.getRenderLayer();
if (renderLayer == BlockRenderLayer.CUTOUT) {
int connectedSidesMask = blockPipe.getActualConnections(tileEntityPipe, world);
IVertexOperation[] pipeline = new IVertexOperation[] { new Translation(pos) };
renderPipeBlock(pipeMaterial, fluidPipeType, paintingColor, renderState, pipeline, connectedSidesMask);
}
ICoverable coverable = tileEntityPipe.getCoverableImplementation();
coverable.renderCovers(renderState, new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ()), renderLayer);
}
return true;
}
use of gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipe in project GregTech by GregTechCE.
the class FluidPipeRenderer method getParticleTexture.
public Pair<TextureAtlasSprite, Integer> getParticleTexture(IPipeTile<FluidPipeType, FluidPipeProperties> tileEntity) {
if (tileEntity == null) {
return Pair.of(TextureUtils.getMissingSprite(), 0xFFFFFF);
}
FluidPipeType fluidPipeType = tileEntity.getPipeType();
Material material = ((TileEntityFluidPipe) tileEntity).getPipeMaterial();
if (fluidPipeType == null || material == null) {
return Pair.of(TextureUtils.getMissingSprite(), 0xFFFFFF);
}
TextureAtlasSprite atlasSprite = pipeTextures.get(fluidPipeType).sideTexture;
int pipeColor = getPipeColor(material, tileEntity.getInsulationColor());
return Pair.of(atlasSprite, pipeColor);
}
use of gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipe 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);
}
}
use of gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipe in project GregTech by GregTechCE.
the class FluidPipeNet method destroyNetwork.
public void destroyNetwork(boolean isLeaking, boolean isBurning) {
World world = worldData.getWorld();
((WorldFluidPipeNet) (Object) worldData).removePipeNet(this);
for (BlockPos nodePos : getAllNodes().keySet()) {
TileEntity tileEntity = world.getTileEntity(nodePos);
if (tileEntity instanceof TileEntityFluidPipe) {
if (isBurning) {
world.setBlockState(nodePos, Blocks.FIRE.getDefaultState());
} else {
world.setBlockToAir(nodePos);
}
}
Random random = world.rand;
if (isBurning) {
TileEntityFluidPipe.spawnParticles(world, nodePos, EnumFacing.UP, EnumParticleTypes.FLAME, 3 + random.nextInt(2), random);
if (random.nextInt(4) == 0) {
TileEntityFluidPipe.setNeighboursToFire(world, nodePos);
}
}
if (isLeaking && world.rand.nextInt(isBurning ? 3 : 7) == 0) {
world.createExplosion(null, nodePos.getX() + 0.5, nodePos.getY() + 0.5, nodePos.getZ() + 0.5, 1.0f + world.rand.nextFloat(), false);
}
}
}
Aggregations