From 89156d0d8485753e0cea91637fced1b66897a6df Mon Sep 17 00:00:00 2001 From: RecursivePineapple Date: Thu, 8 Aug 2024 09:16:57 -0400 Subject: Added the miniature wormhole generator (#2800) * Added the miniature wormhole generator * Updated structure & tooltip and added hatch hask * Fixed controller promotion not working * Initial work wormhole render + spotless + git strangeness * Fix wildcard imports * Removed redundant code + added more reasonable defaults * fix * sa * Remove debug print statements --------- Co-authored-by: Martin Robertz Co-authored-by: CookieBrigade <138534411+cookiebrigade@users.noreply.github.com> --- .../common/render/GT_WormholeRenderer.java | 79 ++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 src/main/java/gregtech/common/render/GT_WormholeRenderer.java (limited to 'src/main/java/gregtech/common/render') diff --git a/src/main/java/gregtech/common/render/GT_WormholeRenderer.java b/src/main/java/gregtech/common/render/GT_WormholeRenderer.java new file mode 100644 index 0000000000..43385eb861 --- /dev/null +++ b/src/main/java/gregtech/common/render/GT_WormholeRenderer.java @@ -0,0 +1,79 @@ +package gregtech.common.render; + +import static com.github.technus.tectech.rendering.EOH.EOH_RenderingUtils.addRenderedBlockInWorld; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.registry.ClientRegistry; +import gregtech.common.tileentities.render.TileWormhole; + +public class GT_WormholeRenderer extends TileEntitySpecialRenderer { + + public GT_WormholeRenderer() { + ClientRegistry.bindTileEntitySpecialRenderer(TileWormhole.class, this); + } + + private static final double trimPercentage = .95; + private static final double corePercentage = trimPercentage / Math.sqrt(3); + + private static void render(Block coreBlock, double rotation) { + + GL11.glPushMatrix(); + GL11.glRotated(rotation, 2, 1, 0); + GL11.glScaled(-1, -1, -1); + + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setColorOpaque_F(1f, 1f, 1f); + addRenderedBlockInWorld(Blocks.quartz_block, 0, 0, 0, 0); + Tessellator.instance.draw(); + + GL11.glScaled(trimPercentage, trimPercentage, trimPercentage); + + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setColorOpaque_F(0.1f, 0.1f, 0.1f); + addRenderedBlockInWorld(Blocks.coal_block, 0, 0, 0, 0); + Tessellator.instance.draw(); + GL11.glPopMatrix(); + + if (coreBlock != null) { + GL11.glPushMatrix(); + GL11.glScaled(corePercentage, corePercentage, corePercentage); + GL11.glRotated(rotation, 0, -2, .1); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setColorOpaque_F(1f, 1f, 1f); + addRenderedBlockInWorld(coreBlock, 0, 0, 0, 0); + Tessellator.instance.draw(); + GL11.glPopMatrix(); + } + + } + + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float timeSinceLastTick) { + + if (tile instanceof TileWormhole wTile) { + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); + GL11.glScaled(wTile.targetRadius, wTile.targetRadius, wTile.targetRadius); + GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); + GL11.glDisable(GL11.GL_LIGHTING); + + double rotationTimer = wTile.getWorldObj() + .getWorldInfo() + .getWorldTotalTime() + timeSinceLastTick; + + this.bindTexture(TextureMap.locationBlocksTexture); + render(wTile.getBlock(), rotationTimer); + + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } + } +} -- cgit