Skip to content

Commit

Permalink
Mixin SimpleTexture
Browse files Browse the repository at this point in the history
  • Loading branch information
Caedis authored and mitchej123 committed Aug 23, 2023
1 parent 26cf4c7 commit bdb473a
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/main/java/com/gtnewhorizons/angelica/mixins/Mixins.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public enum Mixins {
"renderer.MixinRenderGlobal",
"renderer.MixinModelRenderer",
"renderer.MixinTextureClock",
"renderer.MixinTextureCompass")
"renderer.MixinTextureCompass",
"renderer.MixinSimpleTexture")
.setApplyIf(() -> true))

;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.gtnewhorizons.angelica.mixins.early.renderer;

import java.awt.image.BufferedImage;

import net.minecraft.client.renderer.texture.AbstractTexture;
import net.minecraft.client.renderer.texture.SimpleTexture;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.util.ResourceLocation;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import com.gtnewhorizons.angelica.client.ShadersTex;

@Mixin(value = SimpleTexture.class)
public class MixinSimpleTexture extends AbstractTexture {

private IResourceManager passedResourceManager;
@Shadow
protected ResourceLocation textureLocation;

@Inject(method = "loadTexture(Lnet/minecraft/client/resources/IResourceManager;)V", at = @At("HEAD"))
private void getResourceManager(IResourceManager p_110551_1_, CallbackInfo cbi) {
passedResourceManager = p_110551_1_;
}

@Redirect(
method = "loadTexture(Lnet/minecraft/client/resources/IResourceManager;)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/texture/TextureUtil;uploadTextureImageAllocate(ILjava/awt/image/BufferedImage;ZZ)I",
remap = false))
private int angelica$loadTexture(int textureID, BufferedImage bufferedImage, boolean flag, boolean flag1) {

ShadersTex.loadSimpleTexture(
textureID,
bufferedImage,
flag,
flag1,
passedResourceManager,
this.textureLocation,
ShadersTex.getMultiTexID(this));
return 0;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public AClassTransformer() {
put(Names.textureDownload_, new ACTTextureDownload());
put(Names.abstractTexture_, new ACTTextureAbstract());
put(Names.iTextureObject_, new ACTTextureObject());
put(Names.simpleTexture_, new ACTTextureSimple());
put(Names.layeredTexture_, new ACTTextureLayered());
put(Names.dynamicTexture_, new ACTTextureDynamic());
put(Names.textureMap_, new ACTTextureMap());
Expand Down

0 comments on commit bdb473a

Please sign in to comment.