Skip to content

Commit 3cffcf5

Browse files
authored
Merge pull request #4 from RappyLabyAddons/development
Release v1.0.1
2 parents 15fe4b0 + 1e7211b commit 3cffcf5

80 files changed

Lines changed: 4875 additions & 42 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.rappytv.glintcolorizer.api;
2+
3+
public enum ItemEffect {
4+
NONE,
5+
DEFAULT,
6+
GLOW
7+
}

build.gradle.kts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
val versions = providers.gradleProperty("net.labymod.minecraft-versions").get().split(";")
77

88
group = "org.example"
9-
version = providers.environmentVariable("VERSION").getOrElse("1.0.0")
9+
version = providers.environmentVariable("VERSION").getOrElse("1.0.1")
1010

1111
labyMod {
1212
defaultPackageName = "com.rappytv.glintcolorizer"
@@ -16,12 +16,15 @@ labyMod {
1616
displayName = "GlintColorizer"
1717
author = "RappyTV"
1818
description = "Lets you adjust the color of enchanted items and armor."
19-
minecraftVersion = "1.8.9,1.12.2"
19+
minecraftVersion = "1.8.9<1.21.4"
2020
version = rootProject.version.toString()
2121
}
2222

2323
minecraft {
2424
registerVersion(versions.toTypedArray()) {
25+
26+
accessWidener.set(file("./game-runner/src/${this.sourceSetName}/resources/glintcolorizer-${versionId}.accesswidener"))
27+
2528
runs {
2629
getByName("client") {
2730
devLogin = true

core/src/main/java/com/rappytv/glintcolorizer/GlintColorizerAddon.java renamed to core/src/main/java/com/rappytv/glintcolorizer/core/GlintColorizerAddon.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
package com.rappytv.glintcolorizer;
1+
package com.rappytv.glintcolorizer.core;
22

3-
import com.rappytv.glintcolorizer.GlintColorizerConfig.ItemEffect;
3+
import com.rappytv.glintcolorizer.api.ItemEffect;
44
import net.labymod.api.addon.LabyAddon;
55
import net.labymod.api.models.addon.annotation.AddonMain;
66
import net.labymod.api.util.Color;
@@ -9,11 +9,11 @@
99
@AddonMain
1010
public class GlintColorizerAddon extends LabyAddon<GlintColorizerConfig> {
1111

12-
private static GlintColorizerAddon instance;
12+
private static GlintColorizerAddon INSTANCE;
1313

1414
@Override
1515
protected void enable() {
16-
instance = this;
16+
INSTANCE = this;
1717

1818
this.registerSettingCategory();
1919
}
@@ -24,26 +24,26 @@ protected Class<? extends GlintColorizerConfig> configurationClass() {
2424
}
2525

2626
public static ItemEffect getItemEffect() {
27-
return instance.configuration().enabled().get()
28-
? instance.configuration().itemEffect().get()
27+
return INSTANCE.configuration().enabled().get()
28+
? INSTANCE.configuration().itemEffect().get()
2929
: ItemEffect.DEFAULT;
3030
}
3131

3232
@Nullable
3333
public static Color getItemGlintColor() {
34-
if(!instance.configuration().enabled().get()
35-
|| !instance.configuration().enableCustomItemGlintColor().get()) {
34+
if (!INSTANCE.configuration().enabled().get()
35+
|| !INSTANCE.configuration().enableCustomItemGlintColor().get()) {
3636
return null;
3737
}
38-
return instance.configuration().customItemGlintColor().get();
38+
return INSTANCE.configuration().customItemGlintColor().get();
3939
}
4040

4141
@Nullable
4242
public static Color getArmorGlintColor() {
43-
if(!instance.configuration().enabled().get()
44-
|| !instance.configuration().enableCustomArmorGlintColor().get()) {
43+
if (!INSTANCE.configuration().enabled().get()
44+
|| !INSTANCE.configuration().enableCustomArmorGlintColor().get()) {
4545
return null;
4646
}
47-
return instance.configuration().customArmorGlintColor().get();
47+
return INSTANCE.configuration().customArmorGlintColor().get();
4848
}
4949
}

core/src/main/java/com/rappytv/glintcolorizer/GlintColorizerConfig.java renamed to core/src/main/java/com/rappytv/glintcolorizer/core/GlintColorizerConfig.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
package com.rappytv.glintcolorizer;
1+
package com.rappytv.glintcolorizer.core;
22

3+
import com.rappytv.glintcolorizer.api.ItemEffect;
34
import net.labymod.api.addon.AddonConfig;
45
import net.labymod.api.client.component.format.NamedTextColor;
56
import net.labymod.api.client.gui.screen.widget.widgets.input.SwitchWidget.SwitchSetting;
67
import net.labymod.api.client.gui.screen.widget.widgets.input.color.ColorPickerWidget.ColorPickerSetting;
78
import net.labymod.api.client.gui.screen.widget.widgets.input.dropdown.DropdownWidget.DropdownSetting;
89
import net.labymod.api.configuration.loader.annotation.SpriteSlot;
910
import net.labymod.api.configuration.loader.annotation.SpriteTexture;
11+
import net.labymod.api.configuration.loader.annotation.VersionCompatibility;
1012
import net.labymod.api.configuration.loader.property.ConfigProperty;
1113
import net.labymod.api.configuration.settings.annotation.SettingRequires;
1214
import net.labymod.api.configuration.settings.annotation.SettingSection;
1315
import net.labymod.api.util.Color;
1416

15-
@SpriteTexture("settings.png")
17+
@SpriteTexture("settings")
1618
public class GlintColorizerConfig extends AddonConfig {
1719

1820
@SpriteSlot
@@ -23,19 +25,24 @@ public class GlintColorizerConfig extends AddonConfig {
2325
@SpriteSlot(x = 1)
2426
@DropdownSetting
2527
private final ConfigProperty<ItemEffect> itemEffect = new ConfigProperty<>(ItemEffect.DEFAULT);
28+
2629
@SpriteSlot(size = 32, x = 2)
2730
@SwitchSetting
2831
private final ConfigProperty<Boolean> enableCustomItemGlintColor = new ConfigProperty<>(true);
32+
2933
@SettingRequires("enableCustomItemGlintColor")
3034
@SpriteSlot(size = 32, x = 3)
3135
@ColorPickerSetting(chroma = true)
3236
private final ConfigProperty<Color> customItemGlintColor = new ConfigProperty<>(Color.WHITE);
3337

3438
@SettingSection("armor")
39+
@VersionCompatibility("1.8<1.20.6")
3540
@SpriteSlot(x = 2)
3641
@SwitchSetting
3742
private final ConfigProperty<Boolean> enableCustomArmorGlintColor = new ConfigProperty<>(true);
43+
3844
@SettingRequires("enableCustomArmorGlintColor")
45+
@VersionCompatibility("1.8<1.20.6")
3946
@SpriteSlot(size = 32, x = 3)
4047
@ColorPickerSetting(chroma = true)
4148
private final ConfigProperty<Color> customArmorGlintColor = new ConfigProperty<>(NamedTextColor.AQUA.color());
@@ -48,23 +55,20 @@ public ConfigProperty<Boolean> enabled() {
4855
public ConfigProperty<ItemEffect> itemEffect() {
4956
return this.itemEffect;
5057
}
58+
5159
public ConfigProperty<Boolean> enableCustomItemGlintColor() {
5260
return this.enableCustomItemGlintColor;
5361
}
62+
5463
public ConfigProperty<Color> customItemGlintColor() {
5564
return this.customItemGlintColor;
5665
}
5766

5867
public ConfigProperty<Boolean> enableCustomArmorGlintColor() {
5968
return this.enableCustomArmorGlintColor;
6069
}
70+
6171
public ConfigProperty<Color> customArmorGlintColor() {
6272
return this.customArmorGlintColor;
6373
}
64-
65-
public enum ItemEffect {
66-
NONE,
67-
DEFAULT,
68-
GLOW
69-
}
7074
}

game-runner/src/v1_12_2/java/com/rappytv/glintcolorizer/v1_12_2/mixins/MixinLayerArmorBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.rappytv.glintcolorizer.v1_12_2.mixins;
22

3-
import com.rappytv.glintcolorizer.GlintColorizerAddon;
3+
import com.rappytv.glintcolorizer.core.GlintColorizerAddon;
44
import net.labymod.api.util.Color;
55
import net.minecraft.client.renderer.entity.layers.LayerArmorBase;
66
import org.spongepowered.asm.mixin.Mixin;

game-runner/src/v1_12_2/java/com/rappytv/glintcolorizer/v1_12_2/mixins/MixinRenderItem.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.rappytv.glintcolorizer.v1_12_2.mixins;
22

3-
import com.rappytv.glintcolorizer.GlintColorizerAddon;
4-
import com.rappytv.glintcolorizer.GlintColorizerConfig.ItemEffect;
3+
import com.rappytv.glintcolorizer.api.ItemEffect;
4+
import com.rappytv.glintcolorizer.core.GlintColorizerAddon;
55
import net.labymod.api.util.Color;
66
import net.minecraft.client.renderer.GlStateManager;
77
import net.minecraft.client.renderer.RenderItem;
@@ -20,25 +20,25 @@
2020
public class MixinRenderItem {
2121

2222
@Unique
23-
private boolean sandbox$firstDepthCall = true;
23+
private boolean glintcolorizer$firstDepthCall = true;
2424

2525
@Inject(method = "renderEffect", at = @At("HEAD"), cancellable = true)
26-
private void renderEffect(IBakedModel model, CallbackInfo ci) {
26+
private void cancelGlintRendering(IBakedModel model, CallbackInfo ci) {
2727
if(GlintColorizerAddon.getItemEffect() == ItemEffect.NONE) {
2828
ci.cancel();
2929
}
3030
}
3131

3232
@Redirect(method = "renderEffect", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;depthFunc(I)V"))
3333
private void modifyDepthFunc(int i) {
34-
if(this.sandbox$firstDepthCall) {
34+
if(this.glintcolorizer$firstDepthCall) {
3535
if(GlintColorizerAddon.getItemEffect() != ItemEffect.GLOW) {
3636
GlStateManager.depthFunc(GL11.GL_EQUAL);
3737
}
3838
} else {
3939
GlStateManager.depthFunc(i);
4040
}
41-
this.sandbox$firstDepthCall = !this.sandbox$firstDepthCall;
41+
this.glintcolorizer$firstDepthCall = !this.glintcolorizer$firstDepthCall;
4242
}
4343

4444
@ModifyConstant(method = "renderEffect", constant = @Constant(intValue = -8372020))
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.rappytv.glintcolorizer.v1_16_5;
2+
3+
import com.mojang.blaze3d.vertex.VertexConsumer;
4+
import net.labymod.api.util.Color;
5+
6+
public class ColoredVertexConsumer implements VertexConsumer {
7+
8+
private final VertexConsumer delegate;
9+
private final float red;
10+
private final float green;
11+
private final float blue;
12+
13+
public ColoredVertexConsumer(VertexConsumer delegate, Color color) {
14+
this.delegate = delegate;
15+
this.red = color.getRed() / 255f;
16+
this.green = color.getGreen() / 255f;
17+
this.blue = color.getBlue() / 255f;
18+
}
19+
20+
@Override
21+
public VertexConsumer vertex(double x, double y, double z) {
22+
return this.delegate.vertex(x, y, z);
23+
}
24+
25+
@Override
26+
public VertexConsumer color(int red, int green, int blue, int alpha) {
27+
return this.delegate.color(
28+
(int) (red * this.red),
29+
(int) (green * this.green),
30+
(int) (blue * this.blue),
31+
alpha
32+
);
33+
}
34+
35+
@Override
36+
public VertexConsumer uv(float u, float v) {
37+
return this.delegate.uv(u, v);
38+
}
39+
40+
@Override
41+
public VertexConsumer overlayCoords(int u, int v) {
42+
return this.delegate.overlayCoords(u, v);
43+
}
44+
45+
@Override
46+
public VertexConsumer uv2(int u, int v) {
47+
return this.delegate.uv2(u, v);
48+
}
49+
50+
@Override
51+
public VertexConsumer normal(float x, float y, float z) {
52+
return this.delegate.normal(x, y, z);
53+
}
54+
55+
@Override
56+
public void endVertex() {
57+
this.delegate.endVertex();
58+
}
59+
}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
package com.rappytv.glintcolorizer.v1_16_5;
2+
3+
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
4+
import com.mojang.blaze3d.vertex.VertexFormat;
5+
import net.minecraft.client.renderer.RenderStateShard;
6+
import net.minecraft.client.renderer.RenderType;
7+
import net.minecraft.client.renderer.entity.ItemRenderer;
8+
9+
public class CustomRenderTypes extends RenderType {
10+
11+
private static final RenderType GLOW_GLINT = create(
12+
"glint_glow",
13+
DefaultVertexFormat.POSITION_TEX,
14+
7,
15+
256,
16+
RenderType.CompositeState.builder()
17+
.setTextureState(new RenderStateShard.TextureStateShard(
18+
ItemRenderer.ENCHANT_GLINT_LOCATION,
19+
true,
20+
false
21+
))
22+
.setWriteMaskState(COLOR_WRITE)
23+
.setCullState(NO_CULL)
24+
.setDepthTestState(NO_DEPTH_TEST)
25+
.setTransparencyState(GLINT_TRANSPARENCY)
26+
.setTexturingState(GLINT_TEXTURING)
27+
.createCompositeState(false)
28+
);
29+
30+
private static final RenderType GLOW_ENTITY_GLINT = create(
31+
"entity_glint_glow",
32+
DefaultVertexFormat.POSITION_TEX,
33+
7,
34+
256,
35+
RenderType.CompositeState.builder()
36+
.setTextureState(new RenderStateShard.TextureStateShard(
37+
ItemRenderer.ENCHANT_GLINT_LOCATION,
38+
true,
39+
false
40+
))
41+
.setWriteMaskState(COLOR_WRITE)
42+
.setCullState(NO_CULL)
43+
.setDepthTestState(NO_DEPTH_TEST)
44+
.setTransparencyState(GLINT_TRANSPARENCY)
45+
.setTexturingState(ENTITY_GLINT_TEXTURING)
46+
.createCompositeState(false)
47+
);
48+
49+
private static final RenderType GLOW_GLINT_DIRECT = create(
50+
"glint_direct_glow",
51+
DefaultVertexFormat.POSITION_TEX,
52+
7,
53+
256,
54+
RenderType.CompositeState.builder()
55+
.setTextureState(new RenderStateShard.TextureStateShard(
56+
ItemRenderer.ENCHANT_GLINT_LOCATION,
57+
true,
58+
false
59+
))
60+
.setWriteMaskState(COLOR_WRITE)
61+
.setCullState(NO_CULL)
62+
.setDepthTestState(NO_DEPTH_TEST)
63+
.setTransparencyState(GLINT_TRANSPARENCY)
64+
.setTexturingState(GLINT_TEXTURING)
65+
.createCompositeState(false)
66+
);
67+
68+
private static final RenderType GLOW_ENTITY_GLINT_DIRECT = create(
69+
"entity_glint_direct_glow",
70+
DefaultVertexFormat.POSITION_TEX,
71+
7,
72+
256,
73+
RenderType.CompositeState.builder()
74+
.setTextureState(new RenderStateShard.TextureStateShard(
75+
ItemRenderer.ENCHANT_GLINT_LOCATION,
76+
true,
77+
false
78+
))
79+
.setWriteMaskState(COLOR_WRITE)
80+
.setCullState(NO_CULL)
81+
.setDepthTestState(NO_DEPTH_TEST)
82+
.setTransparencyState(GLINT_TRANSPARENCY)
83+
.setTexturingState(ENTITY_GLINT_TEXTURING)
84+
.createCompositeState(false)
85+
);
86+
87+
private CustomRenderTypes(
88+
String name,
89+
VertexFormat format,
90+
int mode,
91+
int bufferSize,
92+
boolean affectsCrumbling,
93+
boolean sortOnUpload,
94+
Runnable setupState,
95+
Runnable clearState
96+
) {
97+
super(name, format, mode, bufferSize, affectsCrumbling, sortOnUpload, setupState, clearState);
98+
}
99+
100+
public static RenderType getGlowGlint() {
101+
return GLOW_GLINT;
102+
}
103+
104+
public static RenderType getGlowEntityGlint() {
105+
return GLOW_ENTITY_GLINT;
106+
}
107+
108+
public static RenderType getGlowGlintDirect() {
109+
return GLOW_GLINT_DIRECT;
110+
}
111+
112+
public static RenderType getGlowEntityGlintDirect() {
113+
return GLOW_ENTITY_GLINT_DIRECT;
114+
}
115+
}

0 commit comments

Comments
 (0)