Skip to content

Commit

Permalink
Remove Mixin and use an alternate approach to get a custom texture at…
Browse files Browse the repository at this point in the history
…las.
  • Loading branch information
shartte committed Feb 9, 2025
1 parent aa806f9 commit 4a326ce
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 63 deletions.
17 changes: 0 additions & 17 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ dependencies {
testImplementation("org.mockito:mockito-junit-jupiter:5.12.0")

testmodRuntimeOnly sourceSets.main.output

// Annotation Processors
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
}

///////////////////
Expand Down Expand Up @@ -234,12 +231,6 @@ shadowJar {

configurations = [project.configurations.shaded]
archiveClassifier = ''

manifest {
attributes([
"MixinConfigs" : "guideme.mixins.json"
])
}
}

File proguardFile = file("build/libs/${jar.archiveBaseName.get()}-proguard-${version}.jar")
Expand Down Expand Up @@ -267,14 +258,6 @@ final proguardJar = tasks.register('proguardJar', proguard.gradle.ProGuardTask)
}
assemble.dependsOn proguardJar

///////////
// Mixins
mixin {
var refmap = add sourceSets.main, "guideme.mixins.refmap.json"
shadowJar.from refmap
config "guideme.mixins.json"
}

def publicApiIncludePatterns = {
exclude "**/*Internal.*"
exclude "**/*Internal\$*.*"
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/guideme/internal/GuiSpriteAtlas.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package guideme.internal;

import java.util.Objects;
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.TextureAtlasHolder;
import net.minecraft.resources.ResourceLocation;

class GuiSpriteAtlas extends TextureAtlasHolder {
public GuiSpriteAtlas(TextureManager textureManager, ResourceLocation location,
ResourceLocation atlasInfoLocation) {
super(textureManager, location, atlasInfoLocation);
}

public TextureAtlas getTextureAtlas() {
return Objects.requireNonNull(textureAtlas, "textureAtlas");
}
}
20 changes: 20 additions & 0 deletions src/main/java/guideme/internal/GuideMEClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import guideme.render.GuiAssets;
import java.util.Objects;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.PackOutput;
Expand Down Expand Up @@ -48,6 +49,8 @@ public class GuideMEClient {

private final GuideSearch search = new GuideSearch();

private GuiSpriteAtlas guiAtlas;

public GuideMEClient(ModLoadingContext context, IEventBus modBus) {
INSTANCE = this;
GuideME.PROXY = new GuideMEClientProxy();
Expand Down Expand Up @@ -83,9 +86,22 @@ public GuideMEClient(ModLoadingContext context, IEventBus modBus) {
}
});

modBus.addListener(this::registerReloadListener);

GuideOnStartup.init(modBus);
}

private void registerReloadListener(RegisterClientReloadListenersEvent ev) {
if (guiAtlas == null) {
guiAtlas = new GuiSpriteAtlas(
Minecraft.getInstance().textureManager,
GuiAssets.GUI_SPRITE_ATLAS,
GuideME.makeId("gui"));
}

ev.registerReloadListener(guiAtlas);
}

public static LightDarkMode currentLightDarkMode() {
return LightDarkMode.LIGHT_MODE;
}
Expand Down Expand Up @@ -207,4 +223,8 @@ public ClientConfig() {
spec = builder.build();
}
}

public TextureAtlas getGuiSpriteAtlas() {
return Objects.requireNonNull(guiAtlas).getTextureAtlas();
}
}
30 changes: 0 additions & 30 deletions src/main/java/guideme/mixins/AtlasMixin.java

This file was deleted.

3 changes: 2 additions & 1 deletion src/main/java/guideme/render/GuiSprite.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package guideme.render;

import guideme.color.LightDarkMode;
import guideme.internal.GuideMEClient;
import java.io.IOException;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite;
Expand Down Expand Up @@ -44,7 +45,7 @@ private CachedState getOrCreateCachedState() {
}

synchronized (this) {
var guiSprites = Minecraft.getInstance().getModelManager().getAtlas(GuiAssets.GUI_SPRITE_ATLAS);
var guiSprites = GuideMEClient.instance().getGuiSpriteAtlas();

var sprite = guiSprites.getSprite(id);
var spriteScaling = getSpriteScaling(id);
Expand Down
15 changes: 0 additions & 15 deletions src/main/resources/guideme.mixins.json

This file was deleted.

0 comments on commit 4a326ce

Please sign in to comment.