use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.
the class PipeRenderer method getParticleTexture.
public Pair<TextureAtlasSprite, Integer> getParticleTexture(IPipeTile<?, ?> pipeTile) {
if (pipeTile == null) {
return Pair.of(TextureUtils.getMissingSprite(), 0xFFFFFF);
}
IPipeType<?> pipeType = pipeTile.getPipeType();
Material material = pipeTile instanceof TileEntityMaterialPipeBase ? ((TileEntityMaterialPipeBase<?, ?>) pipeTile).getPipeMaterial() : null;
if (pipeType == null) {
return Pair.of(TextureUtils.getMissingSprite(), 0xFFFFFF);
}
TextureAtlasSprite atlasSprite = getParticleTexture(pipeType, material);
int pipeColor = getPipeColor(material, pipeTile.getPaintingColor());
return Pair.of(atlasSprite, pipeColor);
}
use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.
the class PipeRenderer 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);
BlockPipe<?, ?, ?> blockPipe = (BlockPipe<?, ?, ?>) state.getBlock();
IPipeTile<?, ?> pipeTile = blockPipe.getPipeTileEntity(world, pos);
if (pipeTile == null) {
return false;
}
IPipeType<?> pipeType = pipeTile.getPipeType();
Material pipeMaterial = pipeTile instanceof TileEntityMaterialPipeBase ? ((TileEntityMaterialPipeBase<?, ?>) pipeTile).getPipeMaterial() : null;
int paintingColor = pipeTile.getPaintingColor();
int connectedSidesMap = pipeTile.getVisualConnections();
int blockedConnections = pipeTile.getBlockedConnections();
if (pipeType != null) {
BlockRenderLayer renderLayer = MinecraftForgeClient.getRenderLayer();
boolean[] sideMask = new boolean[EnumFacing.VALUES.length];
for (EnumFacing side : EnumFacing.VALUES) {
sideMask[side.getIndex()] = state.shouldSideBeRendered(world, pos, side);
}
Textures.RENDER_STATE.set(new CubeRendererState(renderLayer, sideMask, world));
if (renderLayer == BlockRenderLayer.CUTOUT) {
renderState.lightMatrix.locate(world, pos);
PipeRenderContext renderContext = new PipeRenderContext(pos, renderState.lightMatrix, connectedSidesMap, blockedConnections, pipeType.getThickness());
renderContext.color = GTUtility.convertRGBtoOpaqueRGBA_CL(getPipeColor(pipeMaterial, paintingColor));
buildRenderer(renderContext, blockPipe, pipeTile, pipeType, pipeMaterial);
renderPipeBlock(renderState, renderContext);
}
ICoverable coverable = pipeTile.getCoverableImplementation();
coverable.renderCovers(renderState, new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ()), renderLayer);
Textures.RENDER_STATE.set(null);
}
return true;
}
use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.
the class PipeRenderer method renderItem.
@Override
public void renderItem(ItemStack rawItemStack, TransformType transformType) {
ItemStack stack = ModCompatibility.getRealItemStack(rawItemStack);
if (!(stack.getItem() instanceof ItemBlockPipe)) {
return;
}
CCRenderState renderState = CCRenderState.instance();
GlStateManager.enableBlend();
renderState.reset();
renderState.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
BlockPipe<?, ?, ?> blockFluidPipe = (BlockPipe<?, ?, ?>) ((ItemBlockPipe<?, ?>) stack.getItem()).getBlock();
IPipeType<?> pipeType = blockFluidPipe.getItemPipeType(stack);
Material material = blockFluidPipe instanceof BlockMaterialPipe ? ((BlockMaterialPipe<?, ?, ?>) blockFluidPipe).getItemMaterial(stack) : null;
if (pipeType != null) {
// 12 == 0b1100 is North and South connection (index 2 & 3)
PipeRenderContext renderContext = new PipeRenderContext(12, 0, pipeType.getThickness());
renderContext.color = GTUtility.convertRGBtoOpaqueRGBA_CL(getPipeColor(material, -1));
buildRenderer(renderContext, blockFluidPipe, null, pipeType, material);
renderPipeBlock(renderState, renderContext);
}
renderState.draw();
GlStateManager.disableBlend();
}
use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.
the class TurbineRotorBehavior method getRotorEfficiency.
public int getRotorEfficiency(ItemStack stack) {
Material material = getPartMaterial(stack);
ToolProperty property = material.getProperty(PropertyKey.TOOL);
return property == null ? -1 : ((int) ((60 + property.getToolSpeed() * 8)) / 5 * 5);
}
use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.
the class AbstractMaterialPartBehavior method getPartMaterial.
public Material getPartMaterial(ItemStack itemStack) {
NBTTagCompound compound = getPartStatsTag(itemStack);
Material defaultMaterial = Materials.Neutronium;
if (compound == null || !compound.hasKey("Material", NBT.TAG_STRING)) {
return defaultMaterial;
}
String materialName = compound.getString("Material");
Material material = GregTechAPI.MATERIAL_REGISTRY.getObject(materialName);
if (material == null || !material.hasProperty(PropertyKey.INGOT)) {
return defaultMaterial;
}
return material;
}
Aggregations