Skip to content

Commit

Permalink
Hacky fix for Pixelmon 1.16.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Asek3 committed Sep 7, 2023
1 parent 27e9b74 commit c9e1302
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 2 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ dependencies {
//modCompileOnly "maven.modrinth:rubidium:0.2.12"
modCompileOnly "me.jellysquid.mods:Rubidium:0.2.13"
modCompileOnly "curse.maven:epic-fight-mod-405076:4029362"
modCompileOnly "curse.maven:pixelmon-389487:4718641"

implementation fileTree(include: ['*.jar'], dir: 'libs')
toJar fileTree(include: ['antlr4-runtime-4.10.1.jar', 'glsl-transformer-1.0.0-pre21.2.jar'], dir: 'libs')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package net.coderbot.iris.mixin.compat.pixelmon;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Matrix3f;
import com.mojang.math.Matrix4f;
import com.pixelmonmod.pixelmon.client.models.smd.DeformVertex;
import com.pixelmonmod.pixelmon.client.models.smd.NormalizedFace;
import com.pixelmonmod.pixelmon.client.models.smd.TextureCoordinate;
import com.pixelmonmod.pixelmon.client.models.smd.Vertex;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;

@Mixin(NormalizedFace.class)
public class MixinNormalizedFace {

@Shadow
public DeformVertex[] vertices;

@Shadow
public TextureCoordinate[] textureCoordinates;

@Shadow
public Vertex faceNormal;

@Shadow
public Vertex calculateFaceNormal() {
return null;
}

@Overwrite
public void addFaceForRender(PoseStack matrixStack, VertexConsumer bufferBuilder, int packedLight, int packedOverlay, boolean smoothShading, float partialTick, float r, float g, float b, float a) {
if (!smoothShading &&
this.faceNormal == null)
this.faceNormal = calculateFaceNormal();
for (int i = 0; i < 3; i++) {
Matrix4f pose = matrixStack.last().pose();
Matrix3f normal = matrixStack.last().normal();
bufferBuilder.vertex(pose.m00 * this.vertices[i]
.getX(partialTick) + pose.m01 * this.vertices[i].getY(partialTick) + pose.m02 * this.vertices[i].getZ(partialTick) + pose.m03, pose.m10 * this.vertices[i]
.getX(partialTick) + pose.m11 * this.vertices[i].getY(partialTick) + pose.m12 * this.vertices[i].getZ(partialTick) + pose.m13, pose.m20 * this.vertices[i]
.getX(partialTick) + pose.m21 * this.vertices[i].getY(partialTick) + pose.m22 * this.vertices[i].getZ(partialTick) + pose.m23, r, g, b, a, (this.textureCoordinates[i]).u, (this.textureCoordinates[i]).v, packedOverlay, packedLight, normal.m00 * this.vertices[i]

.getXN(partialTick) + normal.m01 * this.vertices[i].getYN(partialTick) + normal.m02 * this.vertices[i].getZN(partialTick), normal.m10 * this.vertices[i]
.getXN(partialTick) + normal.m11 * this.vertices[i].getYN(partialTick) + normal.m12 * this.vertices[i].getZN(partialTick), normal.m20 * this.vertices[i]
.getXN(partialTick) + normal.m21 * this.vertices[i].getYN(partialTick) + normal.m22 * this.vertices[i].getZN(partialTick));
}
}

}
25 changes: 24 additions & 1 deletion src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,27 @@ public com.mojang.blaze3d.platform.GlStateManager$DepthState
public net.minecraft.client.renderer.texture.Stitcher$Holder
public net.minecraft.client.renderer.WorldRenderer$LocalRenderInformationContainer
public net.minecraft.client.renderer.WorldRenderer field_228415_m_ # renderBuffers
public-f net.minecraft.client.renderer.texture.TextureAtlasSprite$Info
public-f net.minecraft.client.renderer.texture.TextureAtlasSprite$Info

public net.minecraft.util.math.vector.Matrix4f field_226575_a_ # m00
public net.minecraft.util.math.vector.Matrix4f field_226576_b_ # m01
public net.minecraft.util.math.vector.Matrix4f field_226577_c_ # m02
public net.minecraft.util.math.vector.Matrix4f field_226578_d_ # m03
public net.minecraft.util.math.vector.Matrix4f field_226579_e_ # m10
public net.minecraft.util.math.vector.Matrix4f field_226580_f_ # m11
public net.minecraft.util.math.vector.Matrix4f field_226581_g_ # m12
public net.minecraft.util.math.vector.Matrix4f field_226582_h_ # m13
public net.minecraft.util.math.vector.Matrix4f field_226583_i_ # m20
public net.minecraft.util.math.vector.Matrix4f field_226584_j_ # m21
public net.minecraft.util.math.vector.Matrix4f field_226585_k_ # m22
public net.minecraft.util.math.vector.Matrix4f field_226586_l_ # m23

public net.minecraft.util.math.vector.Matrix3f field_226097_a_ # m00
public net.minecraft.util.math.vector.Matrix3f field_226098_b_ # m01
public net.minecraft.util.math.vector.Matrix3f field_226099_c_ # m02
public net.minecraft.util.math.vector.Matrix3f field_226100_d_ # m10
public net.minecraft.util.math.vector.Matrix3f field_226101_e_ # m11
public net.minecraft.util.math.vector.Matrix3f field_226102_f_ # m12
public net.minecraft.util.math.vector.Matrix3f field_226103_g_ # m20
public net.minecraft.util.math.vector.Matrix3f field_226104_h_ # m21
public net.minecraft.util.math.vector.Matrix3f field_226105_i_ # m22
3 changes: 2 additions & 1 deletion src/main/resources/mixins.oculus.compat.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"refmap": "oculus-refmap.json",
"compatibilityLevel": "JAVA_8",
"client": [
"epicfight.MixinEpicFightRenderTypes"
"epicfight.MixinEpicFightRenderTypes",
"pixelmon.MixinNormalizedFace"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit c9e1302

Please sign in to comment.