oldcheese Posted December 7, 2017 Posted December 7, 2017 (edited) Heya. I'm working on a TileEntity and since it's something that's rarely used I wanted to add a moving part to it that always turned towards you regardless of where you were. For this I used the Tesselator and TESR using GlStatemanager to make sure it always rotates towards the player. code here: public class TESRHenge extends TileEntitySpecialRenderer<TileEntityHenge> { @Override public void render(TileEntityHenge te, double x, double y, double z, float partialTicks, int destroyStage, float alpha){ GlStateManager.enableRescaleNormal(); GlStateManager.pushMatrix(); GlStateManager.enableBlend(); GlStateManager.translate(x+0.5, y+0.5 , z+0.5); GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F); GlStateManager.rotate((float)(Minecraft.getMinecraft().getRenderManager().playerViewX == 2 ? -1 : 1) * Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F); GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F); GlStateManager.scale(0.6, 0.6, 0.6); Tessellator tess = Tessellator.getInstance(); BufferBuilder buff = tess.getBuffer(); Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation(Main.MODID + ":" + "textures/modeltex/sphere.png")); buff.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); buff.pos(-0.5, -0.5, 0.0D).tex(1, 1).color(1.0F, 1.0F, 1.0F, 1F).endVertex(); buff.pos(0.5, -0.5, 0.0D).tex(0, 1).color(1.0F, 1.0F, 1.0F, 1F).endVertex(); buff.pos(0.5,0.5, 0.0).tex(0, 0).color(1.0F, 1.0F, 1.0F, 1F).endVertex(); buff.pos(-0.5,0.5, 0.0).tex(1, 0).color(1.0F, 1.0F, 1.0F, 1F).endVertex(); tess.draw(); GlStateManager.popMatrix(); GlStateManager.disableRescaleNormal(); GlStateManager.disableBlend(); } As a disclaimer: I have never used the Tessellator before. It took me about an hour of experimenting before I realized I needed to draw the four corners. I'm also still reading into GlStateManager The thing is, I want this spawned 'particle' to completely ignore lighting and always be at maximum brightness. I've tried using GlStateManager.disableLighting and Enablelighting. I'm just not quite sure what each one does. Anyhow. Seems the easiest way would be to simply make my block be a light source. But I'd rather not do that. I feel like there should be a way here. Am I supposed to use GlStateManager for this or should I somehow implement a lightmap into my Tessellator? How would I start doing this? If anyone could point me in the right direction that'd be great. Edit: I'm not very smart. There's a function for this in the TESR class itself. Edited December 7, 2017 by oldcheese solved Quote
Silly511 Posted December 7, 2017 Posted December 7, 2017 TileEntitySpecialRenderer has a method called setLightmapDisabled that allows you to disable and enable lighting. The lighting in GlStateManager causes your polygons to be shaded slightly darker on the sides and bottom. 1 Quote
oldcheese Posted December 7, 2017 Author Posted December 7, 2017 Welp. I was so entranced in trying to figure out how to properly rotate, transform and add vertexes that I forgot to look at the actual TESR class. That definitely did the trick. Thanks. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.