aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorGTNH-Colen <54497873+GTNH-Colen@users.noreply.github.com>2023-04-02 03:15:25 +0100
committerGTNH-Colen <54497873+GTNH-Colen@users.noreply.github.com>2023-04-02 03:15:25 +0100
commit778d0b2fe42632cdbedd9e3a7b7a073a119bb143 (patch)
treed9d5cc2285c4ba9e1942b39b13ac25c49cfc5913 /src/main
parentde42ad9111bb2d3e8f9319ce2675b88b7e7d002d (diff)
downloadGT5-Unofficial-778d0b2fe42632cdbedd9e3a7b7a073a119bb143.tar.gz
GT5-Unofficial-778d0b2fe42632cdbedd9e3a7b7a073a119bb143.tar.bz2
GT5-Unofficial-778d0b2fe42632cdbedd9e3a7b7a073a119bb143.zip
Add item renderer for EOH
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/github/technus/tectech/thing/item/RenderEyeOfHarmonyItem.java97
1 files changed, 97 insertions, 0 deletions
diff --git a/src/main/java/com/github/technus/tectech/thing/item/RenderEyeOfHarmonyItem.java b/src/main/java/com/github/technus/tectech/thing/item/RenderEyeOfHarmonyItem.java
new file mode 100644
index 0000000000..35fc174310
--- /dev/null
+++ b/src/main/java/com/github/technus/tectech/thing/item/RenderEyeOfHarmonyItem.java
@@ -0,0 +1,97 @@
+package com.github.technus.tectech.thing.item;
+
+import static com.github.technus.tectech.thing.block.RenderEyeOfHarmony.*;
+import static java.lang.Math.pow;
+
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ResourceLocation;
+import net.minecraftforge.client.IItemRenderer;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.client.FMLClientHandler;
+
+public class RenderEyeOfHarmonyItem implements IItemRenderer {
+
+ @Override
+ public boolean handleRenderType(ItemStack item, ItemRenderType type) {
+ return true;
+ }
+
+ @Override
+ public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
+ return true;
+ }
+
+ @Override
+ public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
+ GL11.glPushMatrix();
+
+ if (type == ItemRenderType.INVENTORY) GL11.glRotated(180, 0, 1, 0);
+ else if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
+ GL11.glTranslated(0.5, 0.5, 0.5);
+ if (type == ItemRenderType.EQUIPPED) GL11.glRotated(90, 0, 1, 0);
+ }
+
+ // Render star stuff.
+ renderStarLayer(0, STAR_LAYER_0, 1.0f);
+ renderStarLayer(1, STAR_LAYER_1, 0.4f);
+ renderStarLayer(2, STAR_LAYER_2, 0.2f);
+
+ GL11.glPopMatrix();
+ }
+
+ private void renderStarLayer(int layer, ResourceLocation texture, float alpha) {
+
+ // Begin animation.
+ GL11.glPushMatrix();
+
+ // OpenGL settings, not sure exactly what these do.
+
+ // Disables lighting, so star is always lit (I think).
+ GL11.glDisable(GL11.GL_LIGHTING);
+ // Culls things out of line of sight?
+ GL11.glEnable(GL11.GL_CULL_FACE);
+ // Merges colours of the various layers of the star?
+ GL11.glEnable(GL11.GL_BLEND);
+ // ???
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+
+ // Bind animation to layer of star.
+ FMLClientHandler.instance().getClient().getTextureManager().bindTexture(texture);
+
+ // 0.01f magic number to shrink sphere obj down.
+ // Size obtained from the multis current recipe.
+ float scale = 0.01f;
+
+ // Put each subsequent layer further out.
+ scale *= pow(1.04f, layer);
+
+ // Scale the star up in the x, y and z directions.
+ GL11.glScalef(scale, scale, scale);
+
+ switch (layer) {
+ case 0:
+ GL11.glRotatef(130 + (System.currentTimeMillis() / 64) % 360, 0F, 1F, 1F);
+ break;
+ case 1:
+ GL11.glRotatef(-49 + (System.currentTimeMillis() / 64) % 360, 1F, 1F, 0F);
+ break;
+ case 2:
+ GL11.glRotatef(67 + (System.currentTimeMillis() / 64) % 360, 1F, 0F, 1F);
+ break;
+ }
+
+ // Set colour and alpha (transparency) of the star layer.
+ GL11.glColor4f(1, 1, 1, alpha);
+
+ starModel.renderAll();
+ GL11.glDisable(GL11.GL_BLEND);
+ GL11.glDepthMask(true);
+ GL11.glEnable(GL11.GL_LIGHTING);
+
+ // Finish animation.
+ GL11.glPopMatrix();
+ }
+
+}