use of codechicken.lib.vec.Matrix4 in project GregTech by GregTechCE.
the class MetaTileEntityRenderer method renderBlock.
@Override
public boolean renderBlock(IBlockAccess world, BlockPos pos, IBlockState state, BufferBuilder buffer) {
MetaTileEntity metaTileEntity = BlockMachine.getMetaTileEntity(world, pos);
if (metaTileEntity == null) {
return false;
}
CCRenderState renderState = CCRenderState.instance();
renderState.reset();
renderState.bind(buffer);
Matrix4 translation = new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ());
BlockRenderLayer renderLayer = MinecraftForgeClient.getRenderLayer();
if (metaTileEntity.canRenderInLayer(renderLayer)) {
renderState.lightMatrix.locate(world, pos);
IVertexOperation[] pipeline = new IVertexOperation[] { renderState.lightMatrix };
metaTileEntity.renderMetaTileEntity(renderState, translation.copy(), pipeline);
}
Matrix4 coverTranslation = new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ());
metaTileEntity.renderCovers(renderState, coverTranslation, renderLayer);
if (metaTileEntity.isFragile() && renderLayer == BlockRenderLayer.CUTOUT) {
TextureMap textureMap = Minecraft.getMinecraft().getTextureMapBlocks();
Random posRand = new Random(MathHelper.getPositionRandom(pos));
int destroyStage = posRand.nextInt(10);
TextureAtlasSprite atlasSprite = textureMap.getAtlasSprite("minecraft:blocks/destroy_stage_" + destroyStage);
for (EnumFacing face : EnumFacing.VALUES) {
Textures.renderFace(renderState, translation, new IVertexOperation[0], face, Cuboid6.full, atlasSprite);
}
}
return true;
}
use of codechicken.lib.vec.Matrix4 in project GregTech by GregTechCE.
the class MetaTileEntityTESR method renderCoverFast.
/**
* Used Specifically to render covers that are IFastRenderMetaTileEntity
* Adapted from renderTileEntityFastPart
* *
*/
private void renderCoverFast(MetaTileEntityHolder te, double x, double y, double z, float partialTicks, int destroyStage, float alpha, List<Tuple<IFastRenderMetaTileEntity, EnumFacing>> coverList) {
Matrix4 translation = (new Matrix4()).translate(x, y, z);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
RenderHelper.disableStandardItemLighting();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.enableBlend();
if (Minecraft.isAmbientOcclusionEnabled()) {
GlStateManager.shadeModel(GL11.GL_SMOOTH);
} else {
GlStateManager.shadeModel(GL11.GL_FLAT);
}
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
for (Tuple<IFastRenderMetaTileEntity, EnumFacing> tuple : coverList) {
CCRenderState renderState = CCRenderState.instance();
renderState.reset();
renderState.bind(buffer);
renderState.setBrightness(te.getWorld(), te.getPos().offset(tuple.getSecond()));
tuple.getFirst().renderMetaTileEntityFast(renderState, translation, partialTicks);
}
buffer.setTranslation(0, 0, 0);
tessellator.draw();
RenderHelper.enableStandardItemLighting();
}
use of codechicken.lib.vec.Matrix4 in project GregTech by GregTechCE.
the class MetaTileEntityTESR method renderTileEntityFast.
@Override
public void renderTileEntityFast(MetaTileEntityHolder te, double x, double y, double z, float partialTicks, int destroyStage, float partial, BufferBuilder buffer) {
MetaTileEntity metaTileEntity = te.getMetaTileEntity();
if (metaTileEntity instanceof IFastRenderMetaTileEntity) {
CCRenderState renderState = CCRenderState.instance();
renderState.reset();
renderState.bind(buffer);
renderState.setBrightness(te.getWorld(), te.getPos());
Matrix4 translation = new Matrix4().translate(x, y, z);
((IFastRenderMetaTileEntity) metaTileEntity).renderMetaTileEntityFast(renderState, translation, partialTicks);
}
}
use of codechicken.lib.vec.Matrix4 in project GregTech by GregTechCE.
the class LargeTurbineRenderer method renderSided.
@SideOnly(Side.CLIENT)
public void renderSided(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline, EnumFacing side, boolean hasBase, boolean hasRotor, boolean isActive, int rotorRGB) {
Matrix4 cornerOffset = null;
switch(side.getAxis()) {
case X:
cornerOffset = translation.copy().translate(0.01 * side.getXOffset(), -1.0, -1.0);
cornerOffset.scale(1.0, 3.0, 3.0);
break;
case Z:
cornerOffset = translation.copy().translate(-1.0, -1.0, 0.01 * side.getZOffset());
cornerOffset.scale(3.0, 3.0, 1.0);
break;
case Y:
cornerOffset = translation.copy().translate(-1.0, 0.01 * side.getYOffset(), -1.0);
cornerOffset.scale(3.0, 1.0, 3.0);
break;
}
if (hasBase) {
Textures.renderFace(renderState, cornerOffset, pipeline, side, Cuboid6.full, baseRingSprite);
renderState.brightness = 0xF000F0;
renderState.colour = 0xFFFFFFFF;
Textures.renderFace(renderState, cornerOffset, new IVertexOperation[0], side, Cuboid6.full, baseBackgroundSprite);
}
if (hasRotor) {
TextureAtlasSprite sprite = isActive ? activeBladeSprite : idleBladeSprite;
IVertexOperation[] color = ArrayUtils.add(pipeline, new ColourMultiplier(GTUtility.convertRGBtoOpaqueRGBA_CL(rotorRGB)));
Textures.renderFace(renderState, cornerOffset, color, side, Cuboid6.full, sprite);
}
}
use of codechicken.lib.vec.Matrix4 in project GregTech by GregTechCE.
the class CableRenderer 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);
IVertexOperation[] pipeline = { new Translation(pos) };
BlockCable blockCable = (BlockCable) state.getBlock();
TileEntityCable tileEntityCable = (TileEntityCable) blockCable.getPipeTileEntity(world, pos);
if (tileEntityCable == null)
return false;
int paintingColor = tileEntityCable.getInsulationColor();
int connectedSidesMask = blockCable.getActualConnections(tileEntityCable, world);
Insulation insulation = tileEntityCable.getPipeType();
Material material = tileEntityCable.getPipeMaterial();
if (insulation != null && material != null) {
BlockRenderLayer renderLayer = MinecraftForgeClient.getRenderLayer();
if (renderLayer == BlockRenderLayer.CUTOUT) {
renderCableBlock(material, insulation, paintingColor, renderState, pipeline, connectedSidesMask);
}
ICoverable coverable = tileEntityCable.getCoverableImplementation();
coverable.renderCovers(renderState, new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ()), renderLayer);
}
return true;
}
Aggregations