Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/Multiloader-1.19' into M…
Browse files Browse the repository at this point in the history
…ultiloader-1.18
  • Loading branch information
fayer3 committed Oct 7, 2023
2 parents 2fdea0a + afc5ea5 commit a3f581b
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 10 deletions.
1 change: 1 addition & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies {
modCompileOnly "maven.modrinth:sodium:mc1.19.3-0.4.9"
modCompileOnly "883067831485366304:1076634925077364786:sodium-fabric-mc1.19.3-0.4.10rev.c131708-dirty:jar"
modCompileOnly "maven.modrinth:rubidium:0.5.6"
compileOnly 'org.joml:joml:1.10.4' //temp sodium


// for iris compat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.vivecraft.client.Xplat;
import org.vivecraft.mod_compat_vr.optifine.OptifineHelper;
import org.vivecraft.mod_compat_vr.pehkui.PehkuiHelper;
import org.vivecraft.mod_compat_vr.sodium.SodiumHelper;

public class VRPlayerModel_WithArms<T extends LivingEntity> extends VRPlayerModel<T> {
private final boolean slim;
Expand Down Expand Up @@ -47,21 +48,37 @@ public VRPlayerModel_WithArms(ModelPart modelPart, boolean isSlim) {
//finger hax
// some mods remove the base parts
if (!leftShoulder.cubes.isEmpty()) {
copyUV(leftShoulder.cubes.get(0).polygons[1], leftHand.cubes.get(0).polygons[1]);
copyUV(leftShoulder.cubes.get(0).polygons[1], leftHand.cubes.get(0).polygons[0]);
copyUV(leftShoulder.cubes.get(0).polygons[3], leftHand.cubes.get(0).polygons[3]);
copyUV(leftShoulder.cubes.get(0).polygons[3], leftHand.cubes.get(0).polygons[2]);
if (SodiumHelper.isLoaded()) {
SodiumHelper.copyModelCuboidUV(leftShoulder, leftHand, 3, 3);
SodiumHelper.copyModelCuboidUV(leftShoulder, leftHand, 3, 2);
}
}
if (!rightShoulder.cubes.isEmpty()) {
copyUV(rightShoulder.cubes.get(0).polygons[1], this.rightHand.cubes.get(0).polygons[1]);
copyUV(rightShoulder.cubes.get(0).polygons[1], this.rightHand.cubes.get(0).polygons[0]);
copyUV(rightShoulder.cubes.get(0).polygons[3], this.rightHand.cubes.get(0).polygons[3]);
copyUV(rightShoulder.cubes.get(0).polygons[3], this.rightHand.cubes.get(0).polygons[2]);
if (SodiumHelper.isLoaded()) {
SodiumHelper.copyModelCuboidUV(rightShoulder, rightHand, 3, 3);
SodiumHelper.copyModelCuboidUV(rightShoulder, rightHand, 3, 2);
}
}

if (!rightSleeve.cubes.isEmpty()) {
copyUV(rightShoulder_sleeve.cubes.get(0).polygons[1], this.rightSleeve.cubes.get(0).polygons[1]);
copyUV(rightShoulder_sleeve.cubes.get(0).polygons[1], this.rightSleeve.cubes.get(0).polygons[0]);
copyUV(rightShoulder_sleeve.cubes.get(0).polygons[3], this.rightSleeve.cubes.get(0).polygons[3]);
copyUV(rightShoulder_sleeve.cubes.get(0).polygons[3], this.rightSleeve.cubes.get(0).polygons[2]);
if (SodiumHelper.isLoaded()) {
SodiumHelper.copyModelCuboidUV(rightShoulder_sleeve, rightSleeve, 3, 3);
SodiumHelper.copyModelCuboidUV(rightShoulder_sleeve, rightSleeve, 3, 2);
}
}
if (!leftSleeve.cubes.isEmpty()) {
copyUV(leftShoulder_sleeve.cubes.get(0).polygons[1], leftSleeve.cubes.get(0).polygons[1]);
copyUV(leftShoulder_sleeve.cubes.get(0).polygons[1], leftSleeve.cubes.get(0).polygons[0]);
copyUV(leftShoulder_sleeve.cubes.get(0).polygons[3], leftSleeve.cubes.get(0).polygons[3]);
copyUV(leftShoulder_sleeve.cubes.get(0).polygons[3], leftSleeve.cubes.get(0).polygons[2]);
if (SodiumHelper.isLoaded()) {
SodiumHelper.copyModelCuboidUV(leftShoulder_sleeve, leftSleeve, 3, 3);
SodiumHelper.copyModelCuboidUV(leftShoulder_sleeve, leftSleeve, 3, 2);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public void setup(BlockGetter pLevel, Entity pRenderViewEntity, boolean pThirdPe
ClientDataHolderVR dataholder = ClientDataHolderVR.getInstance();
RenderPass renderpass = dataholder.currentPass;

VRData.VRDevicePose eye = dataholder.vrPlayer.vrdata_world_render.getEye(renderpass);
VRData.VRDevicePose eye = dataholder.vrPlayer.getVRDataWorld().getEye(renderpass);
if (renderpass == RenderPass.CENTER && dataholder.vrSettings.displayMirrorCenterSmooth > 0.0F) {
this.setPosition(RenderHelper.getSmoothCameraPosition(renderpass, dataholder.vrPlayer.vrdata_world_render));
this.setPosition(RenderHelper.getSmoothCameraPosition(renderpass, dataholder.vrPlayer.getVRDataWorld()));
} else {
this.setPosition(eye.getPosition());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package org.vivecraft.mod_compat_vr.sodium;

import me.jellysquid.mods.sodium.client.render.immediate.model.ModelCuboid;
import me.jellysquid.mods.sodium.client.render.texture.SpriteUtil;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import org.vivecraft.client.Xplat;
import org.vivecraft.client_vr.settings.VRSettings;

import java.lang.reflect.Field;

public class SodiumHelper {

Expand All @@ -27,4 +32,40 @@ public static void markTextureAsActive(TextureAtlasSprite sprite) {
// public static void vignette(boolean b) {
// SodiumClientMod.options().quality.enableVignette = b;
// }


private static boolean hasModelCuboid;
private static boolean checkedForModelCuboid;
private static Field sodium$cuboids;

public static void copyModelCuboidUV(ModelPart source, ModelPart dest, int sourcePoly, int destPoly) {
if (!checkedForModelCuboid) {
checkedForModelCuboid = true;
try {
Class.forName("me.jellysquid.mods.sodium.client.render.immediate.model.ModelCuboid");
sodium$cuboids = ModelPart.class.getDeclaredField("sodium$cuboids");
sodium$cuboids.setAccessible(true);
hasModelCuboid = true;
} catch (ClassNotFoundException ignored) {
return;
} catch (NoSuchFieldException e) {
VRSettings.logger.error("sodium version has ModelCuboids, but field was not found. VR hands will probably look wrong");
return;
}
}
if (hasModelCuboid) {
try {
ModelCuboid.Quad sourceQuad = ((ModelCuboid[]) sodium$cuboids.get(source))[0].quads[sourcePoly];
ModelCuboid.Quad destQuad = ((ModelCuboid[]) sodium$cuboids.get(dest))[0].quads[destPoly];

for (int i = 0; i < sourceQuad.textures.length; i++) {
destQuad.textures[i].x = sourceQuad.textures[i].x;
destQuad.textures[i].y = sourceQuad.textures[i].y;
}
} catch (IllegalAccessException | ClassCastException ignored) {
VRSettings.logger.error("sodium version has ModelCuboids, but field has wrong type. VR hands will probably look wrong");
hasModelCuboid = false;
}
}
}
}

0 comments on commit a3f581b

Please sign in to comment.