From 369a787dff5ad12336f5de439573f762670cb972 Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Mon, 10 Jul 2023 19:41:05 +0600 Subject: [PATCH] Fixed 1.7 Enchant Glint --- .../client/mixin/mixins/RenderItemMixin.java | 39 +++++++++++++++++- .../client/mods/render/AnimationsMod.java | 40 ------------------- 2 files changed, 38 insertions(+), 41 deletions(-) diff --git a/src/main/java/net/silentclient/client/mixin/mixins/RenderItemMixin.java b/src/main/java/net/silentclient/client/mixin/mixins/RenderItemMixin.java index d1bd54a..b79d29d 100644 --- a/src/main/java/net/silentclient/client/mixin/mixins/RenderItemMixin.java +++ b/src/main/java/net/silentclient/client/mixin/mixins/RenderItemMixin.java @@ -1,15 +1,20 @@ package net.silentclient.client.mixin.mixins; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.resources.model.IBakedModel; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumAction; import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; import net.silentclient.client.Client; import net.silentclient.client.mods.render.AnimationsMod; import net.silentclient.client.utils.animations.AnimationHandler; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -31,10 +36,42 @@ public abstract class RenderItemMixin { @Shadow protected abstract void renderEffect(IBakedModel model); + @Shadow protected abstract void renderModel(IBakedModel model, int color); + + @Shadow @Final private static ResourceLocation RES_ITEM_GLINT; + @Redirect(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/resources/model/IBakedModel;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/RenderItem;renderEffect(Lnet/minecraft/client/resources/model/IBakedModel;)V")) public void renderItemEffect(RenderItem instance, IBakedModel model) { if(Client.getInstance().getModInstances().getModByClass(AnimationsMod.class).isEnabled() && Client.getInstance().getSettingsManager().getSettingByClass(AnimationsMod.class, "1.7 Enchant Glint").getValBoolean()) { - AnimationsMod.renderOldEnchantEffect(instance, model); + if(model != null) { + GlStateManager.depthMask(false); + GlStateManager.depthFunc(514); + GlStateManager.disableLighting(); + GlStateManager.blendFunc(768, 1); + Minecraft.getMinecraft().getTextureManager().bindTexture(RES_ITEM_GLINT); + GlStateManager.matrixMode(5890); + + GlStateManager.pushMatrix(); + GlStateManager.scale(8.0, 8.0, 8.0); + GlStateManager.translate((Minecraft.getSystemTime() % 3000L) / 3000.0F / 8.0F, 0.0F, 0.0F); + GlStateManager.rotate(-5.0F, 0.0F, 0.0F, 1.0F); + renderModel(model, -8372020); + GlStateManager.popMatrix(); + + GlStateManager.pushMatrix(); + GlStateManager.scale(8.0, 8.0, 8.0); + GlStateManager.translate((Minecraft.getSystemTime() % 4873L) / 4873.0F / 8.0F, 0.0F, 0.0F); + GlStateManager.rotate(205.0F, 0.0F, 0.0F, 1.0F); + renderModel(model, -8372020); + GlStateManager.popMatrix(); + + GlStateManager.matrixMode(5888); + GlStateManager.blendFunc(770, 771); + GlStateManager.enableLighting(); + GlStateManager.depthFunc(515); + GlStateManager.depthMask(true); + Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture); + } } else { renderEffect(model); } diff --git a/src/main/java/net/silentclient/client/mods/render/AnimationsMod.java b/src/main/java/net/silentclient/client/mods/render/AnimationsMod.java index e86a856..ce9ba33 100644 --- a/src/main/java/net/silentclient/client/mods/render/AnimationsMod.java +++ b/src/main/java/net/silentclient/client/mods/render/AnimationsMod.java @@ -1,11 +1,5 @@ package net.silentclient.client.mods.render; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.entity.RenderItem; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.client.resources.model.IBakedModel; -import net.minecraft.util.ResourceLocation; import net.silentclient.client.mods.Mod; import net.silentclient.client.mods.ModCategory; @@ -31,38 +25,4 @@ public class AnimationsMod extends Mod { this.addBooleanSetting("Smooth Sneaking", this, true); this.addBooleanSetting("No Shaking", this, true); } - - private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png"); - - public static void renderOldEnchantEffect(RenderItem instance, IBakedModel model) { - if(model != null) { - GlStateManager.depthMask(false); - GlStateManager.depthFunc(514); - GlStateManager.disableLighting(); - GlStateManager.blendFunc(768, 1); - Minecraft.getMinecraft().getTextureManager().bindTexture(RES_ITEM_GLINT); - GlStateManager.matrixMode(5890); - - GlStateManager.pushMatrix(); - GlStateManager.scale(8.0, 8.0, 8.0); - GlStateManager.translate((Minecraft.getSystemTime() % 3000L) / 3000.0F / 8.0F, 0.0F, 0.0F); - GlStateManager.rotate(-5.0F, 0.0F, 0.0F, 1.0F); -// ((RenderItemAccessor) instance).renderModel(model, -8372020); - GlStateManager.popMatrix(); - - GlStateManager.pushMatrix(); - GlStateManager.scale(8.0, 8.0, 8.0); - GlStateManager.translate((Minecraft.getSystemTime() % 4873L) / 4873.0F / 8.0F, 0.0F, 0.0F); - GlStateManager.rotate(205.0F, 0.0F, 0.0F, 1.0F); -// ((RenderItemAccessor) instance).renderModel(model, -8372020); - GlStateManager.popMatrix(); - - GlStateManager.matrixMode(5888); - GlStateManager.blendFunc(770, 771); - GlStateManager.enableLighting(); - GlStateManager.depthFunc(515); - GlStateManager.depthMask(true); - Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture); - } - } }