use of gregtech.common.pipelike.fluidpipe.FluidPipeType 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.FluidPipeType in project GregTech by GregTechCE.
the class FluidPipeRenderer method registerIcons.
public void registerIcons(TextureMap map) {
for (FluidPipeType fluidPipeType : FluidPipeType.values()) {
ResourceLocation inLocation = new ResourceLocation(GTValues.MODID, String.format("blocks/pipe/pipe_%s_in", fluidPipeType.name));
ResourceLocation sideLocation = new ResourceLocation(GTValues.MODID, String.format("blocks/pipe/pipe_%s_side", fluidPipeType.name));
TextureAtlasSprite inTexture = map.registerSprite(inLocation);
TextureAtlasSprite sideTexture = map.registerSprite(sideLocation);
this.pipeTextures.put(fluidPipeType, new PipeTextureInfo(inTexture, sideTexture));
}
for (FluidPipeType fluidPipeType : FluidPipeType.values()) {
float thickness = fluidPipeType.getThickness();
double height = (1.0f - thickness) / 2.0f;
int angles = 5 + fluidPipeType.ordinal();
CCModel model = ShapeModelGenerator.generateModel(angles, height, thickness / 3.0f, height);
CCModel fullBlockModel = ShapeModelGenerator.generateModel(angles, 1.0f, thickness / 3.0f, height);
CCModel[] rotatedVariants = ShapeModelGenerator.generateRotatedVariants(model);
CCModel[] fullBlockVariants = ShapeModelGenerator.generateFullBlockVariants(fullBlockModel);
this.pipeModels.put(fluidPipeType, new PipeModelInfo(rotatedVariants, fullBlockVariants));
}
}
use of gregtech.common.pipelike.fluidpipe.FluidPipeType in project GregTech by GregTechCE.
the class FluidPipeRenderer method renderItem.
@Override
public void renderItem(ItemStack rawItemStack, TransformType transformType) {
ItemStack stack = ModCompatibility.getRealItemStack(rawItemStack);
if (!(stack.getItem() instanceof ItemBlockFluidPipe)) {
return;
}
CCRenderState renderState = CCRenderState.instance();
GlStateManager.enableBlend();
renderState.reset();
renderState.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
BlockFluidPipe blockFluidPipe = (BlockFluidPipe) ((ItemBlockFluidPipe) stack.getItem()).getBlock();
FluidPipeType pipeType = blockFluidPipe.getItemPipeType(stack);
Material material = blockFluidPipe.getItemMaterial(stack);
if (pipeType != null && material != null) {
renderPipeBlock(material, pipeType, IPipeTile.DEFAULT_INSULATION_COLOR, renderState, new IVertexOperation[0], 0);
}
renderState.draw();
GlStateManager.disableBlend();
}
use of gregtech.common.pipelike.fluidpipe.FluidPipeType in project GregTech by GregTechCE.
the class MetaBlocks method registerOreDict.
public static void registerOreDict() {
OreDictUnifier.registerOre(new ItemStack(LOG, 1, GTValues.W), OrePrefix.log, Materials.Wood);
OreDictUnifier.registerOre(new ItemStack(LEAVES, 1, GTValues.W), "treeLeaves");
OreDictUnifier.registerOre(new ItemStack(SAPLING, 1, GTValues.W), "treeSapling");
GameRegistry.addSmelting(LOG, new ItemStack(Items.COAL, 1, 1), 0.15F);
for (Entry<DustMaterial, BlockCompressed> entry : COMPRESSED.entrySet()) {
DustMaterial material = entry.getKey();
BlockCompressed block = entry.getValue();
ItemStack itemStack = block.getItem(material);
OreDictUnifier.registerOre(itemStack, OrePrefix.block, material);
}
for (Entry<SolidMaterial, BlockFrame> entry : FRAMES.entrySet()) {
SolidMaterial material = entry.getKey();
BlockFrame block = entry.getValue();
for (int i = 0; i < 16; i++) {
ItemStack itemStack = new ItemStack(block, 1, i);
OreDictUnifier.registerOre(itemStack, OrePrefix.frameGt, material);
}
}
for (BlockOre blockOre : ORES) {
DustMaterial material = blockOre.material;
for (StoneType stoneType : blockOre.STONE_TYPE.getAllowedValues()) {
if (stoneType == null)
continue;
ItemStack normalStack = blockOre.getItem(blockOre.getDefaultState().withProperty(blockOre.STONE_TYPE, stoneType));
OreDictUnifier.registerOre(normalStack, stoneType.processingPrefix, material);
}
}
for (Material pipeMaterial : CABLE.getEnabledMaterials()) {
for (Insulation insulation : Insulation.values()) {
ItemStack itemStack = CABLE.getItem(insulation, pipeMaterial);
OreDictUnifier.registerOre(itemStack, insulation.getOrePrefix(), pipeMaterial);
}
}
for (Material pipeMaterial : FLUID_PIPE.getEnabledMaterials()) {
for (FluidPipeType fluidPipeType : FluidPipeType.values()) {
ItemStack itemStack = FLUID_PIPE.getItem(fluidPipeType, pipeMaterial);
OreDictUnifier.registerOre(itemStack, fluidPipeType.getOrePrefix(), pipeMaterial);
}
}
}
use of gregtech.common.pipelike.fluidpipe.FluidPipeType in project GregTech by GregTechCE.
the class FluidPipeRenderer method handleRenderBlockDamage.
@Override
public void handleRenderBlockDamage(IBlockAccess world, BlockPos pos, IBlockState state, TextureAtlasSprite sprite, BufferBuilder buffer) {
CCRenderState renderState = CCRenderState.instance();
renderState.reset();
renderState.bind(buffer);
renderState.setPipeline(new Vector3(new Vec3d(pos)).translation(), new IconTransformation(sprite));
BlockFluidPipe blockFluidPipe = (BlockFluidPipe) state.getBlock();
IPipeTile<FluidPipeType, FluidPipeProperties> tileEntityPipe = blockFluidPipe.getPipeTileEntity(world, pos);
if (tileEntityPipe == null) {
return;
}
FluidPipeType fluidPipeType = tileEntityPipe.getPipeType();
if (fluidPipeType == null) {
return;
}
float thickness = fluidPipeType.getThickness();
int connectedSidesMask = blockFluidPipe.getActualConnections(tileEntityPipe, world);
Cuboid6 baseBox = BlockFluidPipe.getSideBox(null, thickness);
BlockRenderer.renderCuboid(renderState, baseBox, 0);
for (EnumFacing renderSide : EnumFacing.VALUES) {
if ((connectedSidesMask & (1 << renderSide.getIndex())) > 0) {
Cuboid6 sideBox = BlockFluidPipe.getSideBox(renderSide, thickness);
BlockRenderer.renderCuboid(renderState, sideBox, 0);
}
}
}
Aggregations