Skip to content

Commit

Permalink
Overhaul part 2 (still not complete)! 👀
Browse files Browse the repository at this point in the history
  • Loading branch information
Mixces committed May 20, 2024
1 parent f3aa1c2 commit f195945
Show file tree
Hide file tree
Showing 7 changed files with 371 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(value = ForgeHooksClient.class, remap = false)
@Mixin(
value = ForgeHooksClient.class,
remap = false
)
public class ForgeHooksClientMixin {

@Inject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
import org.spongepowered.asm.mixin.injection.ModifyArgs;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;

@Mixin(value = LayerArmorBase.class, priority = Integer.MIN_VALUE)
@Mixin(
value = LayerArmorBase.class,
priority = Integer.MIN_VALUE
)
public class LayerArmorBaseMixin {

@ModifyArgs(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.polyfrost.glintcolorizer.mixin;

import net.minecraft.client.Minecraft;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import org.polyfrost.glintcolorizer.config.GlintConfig;
Expand Down Expand Up @@ -32,7 +31,7 @@ public class RenderItemMixin_GlintCustomizer {
private void glintColorizer$push(IBakedModel model, CallbackInfo ci) {
if (!RenderItemHook.INSTANCE.isPotionGlintEnabled()) { return; }
if (GlintConfig.INSTANCE.getPotionGlintSize() && RenderItemHook.INSTANCE.isRenderingInGUI() &&
RenderItemHook.INSTANCE.isPotionItem() && GlintConfig.INSTANCE.getPotionGlintBackground()) {
RenderItemHook.INSTANCE.isPotionItem() && (GlintConfig.INSTANCE.getPotionGlintForeground() || GlintConfig.INSTANCE.getPotionGlintBackground())) {
GlStateManager.pushMatrix();
}
}
Expand All @@ -46,7 +45,7 @@ public class RenderItemMixin_GlintCustomizer {
private void glintColorizer$pop(IBakedModel model, CallbackInfo ci) {
if (!RenderItemHook.INSTANCE.isPotionGlintEnabled()) { return; }
if (GlintConfig.INSTANCE.getPotionGlintSize() && RenderItemHook.INSTANCE.isRenderingInGUI() &&
RenderItemHook.INSTANCE.isPotionItem() && GlintConfig.INSTANCE.getPotionGlintBackground()) {
RenderItemHook.INSTANCE.isPotionItem() && (GlintConfig.INSTANCE.getPotionGlintForeground() || GlintConfig.INSTANCE.getPotionGlintBackground())) {
GlStateManager.popMatrix();
}
}
Expand All @@ -63,23 +62,25 @@ public class RenderItemMixin_GlintCustomizer {
private int glintColorizer$modifyColor1(int color) {
if (!GlintConfig.INSTANCE.enabled) { return color; }
if (RenderItemHook.INSTANCE.isRenderingHeld()) {
return GlintConfig.INSTANCE.getHeldColor().getRGB();
return GlintConfig.INSTANCE.getHeldIndividualStrokes() ? GlintConfig.INSTANCE.getHeldStrokeOne().getRGB() : GlintConfig.INSTANCE.getHeldColor().getRGB();
}
if (RenderItemHook.INSTANCE.isRenderingInGUI()) {
if (GlintConfig.INSTANCE.getPotionBasedColor() && RenderItemHook.INSTANCE.isPotionItem()) {
return glintColorizer$getPotionColor(Objects.requireNonNull(RenderItemHook.INSTANCE.getItemStack()));
}
return GlintConfig.INSTANCE.getGUIcolor().getRGB();
if (GlintConfig.INSTANCE.getPotionGlintBackground() && RenderItemHook.INSTANCE.isPotionItem()) {
return GlintConfig.INSTANCE.getShinyIndividualStrokes() ? GlintConfig.INSTANCE.getShinyStrokeOne().getRGB() : GlintConfig.INSTANCE.getShinyColor().getRGB();
} else {
return GlintConfig.INSTANCE.getGuiIndividualStrokes() ? GlintConfig.INSTANCE.getGuiStrokeOne().getRGB() : GlintConfig.INSTANCE.getGuiColor().getRGB();
}
}
if (RenderItemHook.INSTANCE.isRenderingDropped()) {
return GlintConfig.INSTANCE.getDroppedColor().getRGB();
return GlintConfig.INSTANCE.getDroppedIndividualStrokes() ? GlintConfig.INSTANCE.getDroppedStrokeOne().getRGB() : GlintConfig.INSTANCE.getDroppedColor().getRGB();
}
if (RenderItemHook.INSTANCE.isRenderingFramed()) {
return GlintConfig.INSTANCE.getFramedColor().getRGB();
return GlintConfig.INSTANCE.getFramedIndividualStrokes() ? GlintConfig.INSTANCE.getFramedStrokeOne().getRGB() : GlintConfig.INSTANCE.getFramedColor().getRGB();
}
return color;

// return GlintConfig.individualStrokes ? GlintConfig.strokeOne.getRGB() : GlintConfig.color.getRGB();
}

@ModifyArg(
Expand All @@ -94,22 +95,25 @@ public class RenderItemMixin_GlintCustomizer {
private int glintColorizer$modifyColor2(int color) {
if (!GlintConfig.INSTANCE.enabled) { return color; }
if (RenderItemHook.INSTANCE.isRenderingHeld()) {
return GlintConfig.INSTANCE.getHeldColor().getRGB();
return GlintConfig.INSTANCE.getHeldIndividualStrokes() ? GlintConfig.INSTANCE.getHeldStrokeTwo().getRGB() : GlintConfig.INSTANCE.getHeldColor().getRGB();
}
if (RenderItemHook.INSTANCE.isRenderingInGUI()) {
if (GlintConfig.INSTANCE.getPotionBasedColor() && RenderItemHook.INSTANCE.isPotionItem()) {
return glintColorizer$getPotionColor(Objects.requireNonNull(RenderItemHook.INSTANCE.getItemStack()));
}
return GlintConfig.INSTANCE.getGUIcolor().getRGB();
if (GlintConfig.INSTANCE.getPotionGlintBackground() && RenderItemHook.INSTANCE.isPotionItem()) {
return GlintConfig.INSTANCE.getShinyIndividualStrokes() ? GlintConfig.INSTANCE.getShinyStrokeTwo().getRGB() : GlintConfig.INSTANCE.getShinyColor().getRGB();
} else {
return GlintConfig.INSTANCE.getGuiIndividualStrokes() ? GlintConfig.INSTANCE.getGuiStrokeTwo().getRGB() : GlintConfig.INSTANCE.getGuiColor().getRGB();
}
}
if (RenderItemHook.INSTANCE.isRenderingDropped()) {
return GlintConfig.INSTANCE.getDroppedColor().getRGB();
return GlintConfig.INSTANCE.getDroppedIndividualStrokes() ? GlintConfig.INSTANCE.getDroppedStrokeTwo().getRGB() : GlintConfig.INSTANCE.getDroppedColor().getRGB();
}
if (RenderItemHook.INSTANCE.isRenderingFramed()) {
return GlintConfig.INSTANCE.getFramedColor().getRGB();
return GlintConfig.INSTANCE.getFramedIndividualStrokes() ? GlintConfig.INSTANCE.getFramedStrokeTwo().getRGB() : GlintConfig.INSTANCE.getFramedColor().getRGB();
}
return color;
// return GlintConfig.INSTANCE.getIndividualStrokes() ? GlintConfig.INSTANCE.getStrokeTwo().getRGB() : GlintConfig.INSTANCE.getColor().getRGB();
}

/**
Expand All @@ -128,9 +132,4 @@ public class RenderItemMixin_GlintCustomizer {
}
}

// @Unique
// private void glintColorizer$configColors() {
//
// }

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package org.polyfrost.glintcolorizer.mixin;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.util.ResourceLocation;
import org.polyfrost.glintcolorizer.config.GlintConfig;
import org.polyfrost.glintcolorizer.handler.SecondGlintHandler;
import org.polyfrost.glintcolorizer.hook.RenderItemHook;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.RenderItem;
Expand All @@ -22,13 +21,9 @@
public abstract class RenderItemMixin_ShinyEffect {

@Shadow protected abstract void renderEffect(IBakedModel model);

@Shadow @Final private static ResourceLocation RES_ITEM_GLINT;

@Shadow @Final private TextureManager textureManager;

@Shadow protected abstract void renderModel(IBakedModel model, int color);

@Inject(
method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/resources/model/IBakedModel;)V",
at = @At(
Expand Down Expand Up @@ -61,7 +56,7 @@ public abstract class RenderItemMixin_ShinyEffect {
)
private void glintColorizer$onRenderModel(ItemStack stack, IBakedModel model, CallbackInfo ci) {
if (!RenderItemHook.INSTANCE.isPotionGlintEnabled()) { return; }
if (GlintConfig.INSTANCE.getPotionGlintBackground() && RenderItemHook.INSTANCE.isRenderingInGUI() && RenderItemHook.INSTANCE.isPotionItem() && stack.hasEffect()) {
if ((GlintConfig.INSTANCE.getPotionGlintForeground() || GlintConfig.INSTANCE.getPotionGlintBackground()) && RenderItemHook.INSTANCE.isRenderingInGUI() && RenderItemHook.INSTANCE.isPotionItem() && stack.hasEffect()) {
renderEffect(model);
}
}
Expand All @@ -76,35 +71,9 @@ public abstract class RenderItemMixin_ShinyEffect {
)
private void glintColorizer$onRenderModel2(ItemStack stack, IBakedModel model, CallbackInfo ci) {
if (!RenderItemHook.INSTANCE.isPotionGlintEnabled()) { return; }
if (GlintConfig.INSTANCE.getPotionGlintBackground() && RenderItemHook.INSTANCE.isRenderingInGUI() && RenderItemHook.INSTANCE.isPotionItem() && stack.hasEffect()) {
GlStateManager.pushMatrix();
GlStateManager.depthMask(false);
GlStateManager.depthFunc(514);
GlStateManager.disableLighting();
GlStateManager.blendFunc(768, 1);
this.textureManager.bindTexture(RES_ITEM_GLINT);
GlStateManager.matrixMode(5890);
GlStateManager.pushMatrix();
GlStateManager.scale(8.0f, 8.0f, 8.0f);
float f = (float)(Minecraft.getSystemTime() % 3000L) / 3000.0f / 8.0f;
GlStateManager.translate(f, 0.0f, 0.0f);
GlStateManager.rotate(-50.0f, 0.0f, 0.0f, 1.0f);
this.renderModel(model, GlintConfig.INSTANCE.getGUIcolor().getRGB());
GlStateManager.popMatrix();
GlStateManager.pushMatrix();
GlStateManager.scale(8.0f, 8.0f, 8.0f);
float f1 = (float)(Minecraft.getSystemTime() % 4873L) / 4873.0f / 8.0f;
GlStateManager.translate(-f1, 0.0f, 0.0f);
GlStateManager.rotate(10.0f, 0.0f, 0.0f, 1.0f);
this.renderModel(model, GlintConfig.INSTANCE.getGUIcolor().getRGB());
GlStateManager.popMatrix();
GlStateManager.matrixMode(5888);
GlStateManager.blendFunc(770, 771);
GlStateManager.enableLighting();
GlStateManager.depthFunc(515);
GlStateManager.depthMask(true);
this.textureManager.bindTexture(TextureMap.locationBlocksTexture);
GlStateManager.popMatrix();
if (GlintConfig.INSTANCE.getPotionGlintBackground() && !GlintConfig.INSTANCE.getPotionGlintForeground() && RenderItemHook.INSTANCE.isRenderingInGUI() && RenderItemHook.INSTANCE.isPotionItem() && stack.hasEffect()) {
RenderItem instance = (RenderItem) (Object) this;
SecondGlintHandler.renderEffect(instance, model, textureManager, RES_ITEM_GLINT);
}
}

Expand All @@ -117,6 +86,9 @@ public abstract class RenderItemMixin_ShinyEffect {
)
private boolean glintColorizer$disableRenderEffect(ItemStack instance) {
if (RenderItemHook.INSTANCE.isPotionGlintEnabled() && RenderItemHook.INSTANCE.isRenderingInGUI() && RenderItemHook.INSTANCE.isPotionItem()) {
if (GlintConfig.INSTANCE.getPotionGlintForeground()) {
return false;
}
return !GlintConfig.INSTANCE.getPotionGlintBackground();
}
return instance.hasEffect();
Expand Down
Loading

0 comments on commit f195945

Please sign in to comment.