diff options
author | RecursivePineapple <recursive_pineapple@proton.me> | 2024-08-08 09:16:57 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-08 20:16:57 +0700 |
commit | 89156d0d8485753e0cea91637fced1b66897a6df (patch) | |
tree | c5f8fb72aa0e30822cad8f015fd8a25021915466 /src/main/java/gregtech/common/render | |
parent | 3c228c3bab6b2fd731063e59b029f98882fc25e6 (diff) | |
download | GT5-Unofficial-89156d0d8485753e0cea91637fced1b66897a6df.tar.gz GT5-Unofficial-89156d0d8485753e0cea91637fced1b66897a6df.tar.bz2 GT5-Unofficial-89156d0d8485753e0cea91637fced1b66897a6df.zip |
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 <dream-master@gmx.net>
Co-authored-by: CookieBrigade <138534411+cookiebrigade@users.noreply.github.com>
Diffstat (limited to 'src/main/java/gregtech/common/render')
-rw-r--r-- | src/main/java/gregtech/common/render/GT_WormholeRenderer.java | 79 |
1 files changed, 79 insertions, 0 deletions
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(); + } + } +} |