|
2 | 2 |
|
3 | 3 | import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
4 | 4 | import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
| 5 | +import com.mojang.blaze3d.platform.GlStateManager; |
| 6 | +import com.mojang.blaze3d.systems.RenderSystem; |
| 7 | +import net.irisshaders.iris.mixinterface.AbstractTextureExtended; |
5 | 8 | import net.irisshaders.iris.pbr.TextureTracker;
|
6 | 9 | import net.minecraft.client.renderer.texture.AbstractTexture;
|
| 10 | +import org.lwjgl.opengl.GL11; |
7 | 11 | import org.spongepowered.asm.mixin.Mixin;
|
8 | 12 | import org.spongepowered.asm.mixin.Shadow;
|
9 | 13 | import org.spongepowered.asm.mixin.injection.At;
|
10 | 14 |
|
11 | 15 | @Mixin(AbstractTexture.class)
|
12 |
| -public class MixinAbstractTexture { |
| 16 | +public abstract class MixinAbstractTexture implements AbstractTextureExtended { |
13 | 17 | @Shadow
|
14 | 18 | protected int id;
|
15 | 19 |
|
| 20 | + @Shadow |
| 21 | + public abstract void bind(); |
| 22 | + |
| 23 | + @Shadow |
| 24 | + private int minFilter; |
| 25 | + |
| 26 | + @Shadow |
| 27 | + private int magFilter; |
| 28 | + |
16 | 29 | @WrapOperation(method = "getId()I", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/TextureUtil;generateTextureId()I", remap = false))
|
17 | 30 | private int iris$afterGenerateId(Operation<Integer> original) {
|
18 | 31 | int id = original.call();
|
19 | 32 | TextureTracker.INSTANCE.trackTexture(id, (AbstractTexture) (Object) this);
|
20 | 33 | return id;
|
21 | 34 | }
|
| 35 | + |
| 36 | + @Override |
| 37 | + public void setNearestFilter() { |
| 38 | + RenderSystem.assertOnRenderThreadOrInit(); |
| 39 | + int min; |
| 40 | + int mag; |
| 41 | + boolean mipmap = minFilter >= 0x2700; |
| 42 | + min = mipmap ? GL11.GL_NEAREST_MIPMAP_NEAREST : GL11.GL_NEAREST; |
| 43 | + mag = GL11.GL_NEAREST; |
| 44 | + |
| 45 | + boolean bl3 = this.minFilter != min; |
| 46 | + boolean bl4 = this.magFilter != mag; |
| 47 | + if (bl4 || bl3) { |
| 48 | + this.bind(); |
| 49 | + if (bl3) { |
| 50 | + GlStateManager._texParameter(3553, 10241, min); |
| 51 | + this.minFilter = min; |
| 52 | + } |
| 53 | + |
| 54 | + if (bl4) { |
| 55 | + GlStateManager._texParameter(3553, 10240, mag); |
| 56 | + this.magFilter = mag; |
| 57 | + } |
| 58 | + } |
| 59 | + } |
22 | 60 | }
|
0 commit comments