forked from IrisShaders/Iris
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #458
- Loading branch information
Showing
4 changed files
with
134 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/main/java/net/coderbot/iris/mixin/compat/CompatMixinPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package net.coderbot.iris.mixin.compat; | ||
|
||
import net.minecraftforge.fml.loading.FMLLoader; | ||
import org.objectweb.asm.tree.ClassNode; | ||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; | ||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class CompatMixinPlugin implements IMixinConfigPlugin { | ||
@Override | ||
public void onLoad(String mixinPackage) { | ||
|
||
} | ||
|
||
@Override | ||
public String getRefMapperConfig() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { | ||
int startIndex = mixinClassName.indexOf("compat.") + "compat.".length(); | ||
int endIndex = mixinClassName.indexOf(".", startIndex); | ||
String modid = mixinClassName.substring(startIndex, endIndex); | ||
return FMLLoader.getLoadingModList().getModFileById(modid) != null; | ||
} | ||
|
||
@Override | ||
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) { | ||
|
||
} | ||
|
||
@Override | ||
public List<String> getMixins() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { | ||
|
||
} | ||
|
||
@Override | ||
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { | ||
|
||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
src/main/java/net/coderbot/iris/mixin/compat/pixelmon/MixinNormalizedFace.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package net.coderbot.iris.mixin.compat.pixelmon; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.mojang.blaze3d.vertex.VertexConsumer; | ||
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.joml.Matrix3f; | ||
import org.joml.Matrix4f; | ||
import org.joml.Vector3f; | ||
import org.joml.Vector4f; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Overwrite; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
|
||
@Mixin(value = NormalizedFace.class, remap = false) | ||
public class MixinNormalizedFace { | ||
|
||
@Shadow | ||
public DeformVertex[] vertices; | ||
|
||
@Shadow | ||
public TextureCoordinate[] textureCoordinates; | ||
|
||
@Shadow | ||
public Vertex faceNormal; | ||
|
||
@Shadow | ||
public Vertex calculateFaceNormal() { | ||
return null; | ||
} | ||
|
||
/** | ||
* @author Asek3 | ||
* @reason We should deal with this... | ||
*/ | ||
@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(); | ||
DeformVertex vertex = this.vertices[i]; | ||
Vector4f transformedPosition = pose.transform(new Vector4f(vertex.getX(partialTick), vertex.getY(partialTick), vertex.getZ(partialTick), 1.0F)); | ||
Vector3f transformedNormal = normal.transform(new Vector3f(vertex.getXN(partialTick), vertex.getYN(partialTick), vertex.getZN(partialTick))); | ||
bufferBuilder.vertex(transformedPosition.x(), transformedPosition.y(), transformedPosition.z(), r, g, b, a, this.textureCoordinates[i].u, this.textureCoordinates[i].v, packedOverlay, packedLight, transformedNormal.x(), transformedNormal.y(), transformedNormal.z()); | ||
/*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));*/ | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"required": true, | ||
"minVersion": "0.8", | ||
"package": "net.coderbot.iris.mixin.compat", | ||
"plugin": "net.coderbot.iris.mixin.compat.CompatMixinPlugin", | ||
"refmap": "oculus-refmap.json", | ||
"compatibilityLevel": "JAVA_8", | ||
"client": [ | ||
"pixelmon.MixinNormalizedFace" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
} |