diff options
author | GDCloud <93287602+GDCloudstrike@users.noreply.github.com> | 2024-09-01 19:59:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-01 19:59:32 +0200 |
commit | dda0f8bb1ed2211b2df492d7bd53751e47de305f (patch) | |
tree | d22877026684353beabd58728d0cd0824ec87ea7 /src/main/java/gregtech/common/render/items/GlitchEffectRenderer.java | |
parent | e2ae14d4b5c0f3081dd9ff9fbe66beae7d724b9b (diff) | |
download | GT5-Unofficial-dda0f8bb1ed2211b2df492d7bd53751e47de305f.tar.gz GT5-Unofficial-dda0f8bb1ed2211b2df492d7bd53751e47de305f.tar.bz2 GT5-Unofficial-dda0f8bb1ed2211b2df492d7bd53751e47de305f.zip |
Godforge continuation (#2950)
* fix wrong offset
* improve item insertion window
* finish upgrade material functionality
* add tooltip to material button
* add rhugnor gear
* half serious upgrade costs (will definitely change)
* fix stocking hatch not working for fuel supply
* add information window
* add heat formula info
* add autobuild hint dot info
* add phonon related items and fluids
* first iteration of glitchy material renderer
* tweak renderer overlay opacity
* add new material
* add phononic seed crystal and six-phased copper block
* add recipes for phonon transfer medium chain
* add solenoid block replacement
* add creon
* decouple smelting module structure
* spotless weirdness
* add most casing recipes and late loading method (for the special singularities)
* add new singularity recipes
* more recipes
* add glow
* generate more dragonblood parts
* add upgrade costs
* fix upgrade tree window scrollable weirdness
* forgor glow texture
* add last upgrade text + a random comma
* re-add phonon medium abs recipe
* add six-phased copper nanite recipe
* fix button overlay being off by 1 pixel
* fix merge mishaps
* forgot to adjust debug buttons
* fix stocking bus fuel insertion and fuel int overflow
* add graviton shard ejection
* minor structure oopsie
* ejection button registration
* ejection button tooltip
* add graviton shard item
* eject the right item + save ejection status to nbt
* fix input bus amount npe
* change rendering block offset
* adapt eoh rendering to allow changing the star's size
* initial rendering changes (make the blue star render)
* change seed crystal recipes
* another small seed crystal change
* adjust item renderer
* add tooltips
* circuit oredict fix
* tooltips, upgrade names, some experimental ui changes and small fixes
* author
* make star bigger
* fix recipes
* remove unnecessary tooltips
* spotless
* recipe adjustments
* make magneto resonatic block craftable
* change magneto resonatic gem autoclave times + spotless
* add structurecheck button to modules
* more recipe adjustments
* fix extra material crash
* more recipe adjustments
* lower eternal singularity amounts
* display recipetimes <1 sec properly
* try to fix hasShiftDown crash
* adjust plasma module recipes
* swap placeholder names
* implement rings disappearing/reappearing for renderer
* utility for structure strings
* buff plasma module parallel
* fix itemlist
* Spotless apply for branch godforge for #2950 (#3013)
spotlessApply
Co-authored-by: GitHub GTNH Actions <>
---------
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Co-authored-by: boubou19 <miisterunknown@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'src/main/java/gregtech/common/render/items/GlitchEffectRenderer.java')
-rw-r--r-- | src/main/java/gregtech/common/render/items/GlitchEffectRenderer.java | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/src/main/java/gregtech/common/render/items/GlitchEffectRenderer.java b/src/main/java/gregtech/common/render/items/GlitchEffectRenderer.java new file mode 100644 index 0000000000..f7e4413c97 --- /dev/null +++ b/src/main/java/gregtech/common/render/items/GlitchEffectRenderer.java @@ -0,0 +1,124 @@ +package gregtech.common.render.items; + +import java.util.Random; + +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.fluids.FluidStack; + +import org.lwjgl.opengl.GL11; + +import codechicken.lib.render.TextureUtils; +import gregtech.api.interfaces.IGT_ItemWithMaterialRenderer; +import gregtech.api.util.GT_Utility; + +public class GlitchEffectRenderer extends GT_GeneratedMaterial_Renderer { + + public Random rand = new Random(); + int[] red = new int[] { 255, 50, 50, 192 }; + int[] cyan = new int[] { 0, 220, 220, 160 }; + int counter = 0; + double offsetRed = 0; + double offsetCyan = 0; + + private void applyGlitchEffect(ItemRenderType type, boolean shouldModulateColor, int[] color, IIcon... icons) { + double offset; + for (IIcon icon : icons) { + if (icon == null) continue; + if (counter % 2 == 0) { + offset = offsetRed; + } else { + offset = offsetCyan; + } + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + + Tessellator t = Tessellator.instance; + + if (type.equals(IItemRenderer.ItemRenderType.INVENTORY)) { + t.startDrawingQuads(); + if (shouldModulateColor) { + t.setColorRGBA_F(color[0] / 255.0F, color[1] / 255.0F, color[2] / 255.0F, color[3] / 255.0F); + } else { + t.setColorRGBA_F(1f, 1f, 1f, 0.75f); + } + t.addVertexWithUV(0 + offset, 0 + offset, 0, icon.getMinU(), icon.getMinV()); + t.addVertexWithUV(0 + offset, 16 + offset, 0, icon.getMinU(), icon.getMaxV()); + t.addVertexWithUV(16 + offset, 16 + offset, 0, icon.getMaxU(), icon.getMaxV()); + t.addVertexWithUV(16 + offset, 0 + offset, 0, icon.getMaxU(), icon.getMinV()); + t.draw(); + } + + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } + counter++; + } + + @Override + protected void renderRegularItem(ItemRenderType type, ItemStack item, IIcon icon, boolean shouldModulateColor, + int pass, Object... data) { + short metaData = (short) item.getItemDamage(); + if (!(item.getItem() instanceof IGT_ItemWithMaterialRenderer itemRenderer)) return; + + int currentFrame = (int) ((System.nanoTime() % 4_000_000_000L) / 20_000_000L); + boolean timing = currentFrame <= 20; + + if (timing && currentFrame % 5 == 0) { + offsetRed = rand.nextDouble() * 1.7 * Math.signum(rand.nextGaussian()); + offsetCyan = rand.nextDouble() * 1.7 * Math.signum(rand.nextGaussian()); + } + + IIcon itemIcon = itemRenderer.getIcon(metaData, pass); + IIcon overlay = itemRenderer.getOverlayIcon(metaData, pass); + FluidStack aFluid = GT_Utility.getFluidForFilledItem(item, true); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glEnable(GL11.GL_ALPHA_TEST); + + if (shouldModulateColor) { + short[] modulation = itemRenderer.getRGBa(item); + GL11.glColor4f( + modulation[0] / 255.0F, + modulation[1] / 255.0F, + modulation[2] / 255.0F, + modulation[3] / 255.0F); + } + + GL11.glEnable(GL11.GL_ALPHA_TEST); + + if (itemIcon != null) { + markNeedsAnimationUpdate(itemIcon); + renderRegularItem(type, item, itemIcon, aFluid == null); + } + + if (overlay != null && aFluid != null && aFluid.getFluid() != null) { + IIcon fluidIcon = aFluid.getFluid() + .getIcon(aFluid); + if (fluidIcon != null) { + markNeedsAnimationUpdate(fluidIcon); + // Adds colour to a cells fluid. Does not colour full fluid icons as shown in NEI etc. + renderContainedFluid(type, aFluid, fluidIcon); + } + } + + if (overlay != null) { + GL11.glColor3f(1.0F, 1.0F, 1.0F); + TextureUtils.bindAtlas(itemRenderer.getSpriteNumber()); + markNeedsAnimationUpdate(overlay); + renderItemOverlay(type, overlay); + } + + if (type == ItemRenderType.INVENTORY && timing) { + GL11.glDisable(GL11.GL_DEPTH_TEST); + applyGlitchEffect(type, shouldModulateColor, cyan, itemIcon, overlay); + GL11.glEnable(GL11.GL_DEPTH_TEST); + applyGlitchEffect(type, shouldModulateColor, red, itemIcon, overlay); + + } + GL11.glDisable(GL11.GL_BLEND); + } +} |