Skip to content

Commit

Permalink
Merge remote-tracking branch 'vivecraft/Multiloader-1.21' into 1.21.0
Browse files Browse the repository at this point in the history
  • Loading branch information
The Judge committed Sep 30, 2024
2 parents c9c64f3 + eea1369 commit c275c92
Show file tree
Hide file tree
Showing 17 changed files with 75 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.phys.Vec3;
import org.vivecraft.client.VRPlayersClient;
import org.vivecraft.client.Xplat;
import org.vivecraft.client_vr.utils.ScaleHelper;
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> {
Expand Down Expand Up @@ -157,13 +156,11 @@ public void setupAnim(T pEntity, float pLimbSwing, float pLimbSwingAmount, float
this.leftShoulder.y += 3.2F;
}

Vec3 vec3 = rotinfo.leftArmPos;
Vec3 vec32 = rotinfo.rightArmPos;
if (Xplat.isModLoaded("pehkui")) {
// remove pehkui scale from that, since the whole entity is scaled
vec3 = vec3.scale(1.0F / PehkuiHelper.getPlayerScale(pEntity, Minecraft.getInstance().getTimer().getGameTimeDeltaPartialTick(false)));
vec32 = vec32.scale(1.0F / PehkuiHelper.getPlayerScale(pEntity, Minecraft.getInstance().getTimer().getGameTimeDeltaPartialTick(false)));
}
// remove entity scale from that
float scale = 1.0F / ScaleHelper.getEntityScale(pEntity, Minecraft.getInstance().getTimer().getGameTimeDeltaPartialTick(false));
Vec3 vec3 = rotinfo.leftArmPos.scale(scale);
Vec3 vec32 = rotinfo.rightArmPos.scale(scale);

vec3 = vec3.add(0.0D, d0, 0.0D);
vec3 = vec3.yRot((float) (-Math.PI + d1));
vec3 = vec3.scale(16.0F / rotinfo.heightScale);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
import org.vivecraft.client.VivecraftVRMod;
import org.vivecraft.client.Xplat;
import org.vivecraft.client.network.ClientNetworking;
import org.vivecraft.client_vr.utils.ScaleHelper;
import org.vivecraft.client_vr.ClientDataHolderVR;
import org.vivecraft.client_vr.ItemTags;
import org.vivecraft.client_vr.MethodHolder;
Expand All @@ -39,7 +39,6 @@
import org.vivecraft.client_vr.render.RenderPass;
import org.vivecraft.client_vr.settings.VRSettings;
import org.vivecraft.common.VRServerPerms;
import org.vivecraft.mod_compat_vr.pehkui.PehkuiHelper;

import java.util.ArrayList;
import java.util.Random;
Expand Down Expand Up @@ -147,16 +146,14 @@ public void preTick() {

this.worldScale = rawWorldScale;

if (Xplat.isModLoaded("pehkui")) {
// scale world with player size
this.worldScale *= PehkuiHelper.getPlayerScale(mc.player, mc.getTimer().getGameTimeDeltaPartialTick(false));
// limit scale
if (this.worldScale > 100F) {
this.worldScale = 100F;
} else if (this.worldScale < 0.025F) //minClip + player position indicator offset
{
this.worldScale = 0.025F;
}
// scale world with player size
this.worldScale *= ScaleHelper.getEntityScale(mc.player, mc.getTimer().getGameTimeDeltaPartialTick(false));
// limit scale
if (this.worldScale > 100F) {
this.worldScale = 100F;
} else if (this.worldScale < 0.025F) //minClip + player position indicator offset
{
this.worldScale = 0.025F;
}

// check that nobody tries to bypass the server set worldscale limit it with a runtime worldscale
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import net.minecraft.world.item.UseAnim;
import net.minecraft.world.phys.Vec3;
import org.vivecraft.client.VivecraftVRMod;
import org.vivecraft.client.Xplat;
import org.vivecraft.client.network.ClientNetworking;
import org.vivecraft.client_vr.utils.ScaleHelper;
import org.vivecraft.client_vr.ClientDataHolderVR;
import org.vivecraft.client_vr.VRData;
import org.vivecraft.client_vr.extensions.PlayerExtension;
Expand All @@ -22,7 +22,6 @@
import org.vivecraft.client_vr.settings.VRSettings;
import org.vivecraft.common.network.CommonNetworkHelper;
import org.vivecraft.common.utils.math.Vector3;
import org.vivecraft.mod_compat_vr.pehkui.PehkuiHelper;

import java.nio.ByteBuffer;

Expand Down Expand Up @@ -126,12 +125,9 @@ public void doProcess(LocalPlayer player) {
this.lastpressed = this.pressed;
this.lastDraw = this.currentDraw;
this.lastcanDraw = this.canDraw;
this.maxDraw = (double) this.mc.player.getBbHeight() * 0.22D;

if (Xplat.isModLoaded("pehkui")) {
// this is meant to be relative to the base Bb height, not the scaled one
this.maxDraw /= PehkuiHelper.getPlayerBbScale(player, mc.getTimer().getGameTimeDeltaPartialTick(false));
}
// this is meant to be relative to the base Bb height, not the scaled one
this.maxDraw = (double) this.mc.player.getBbHeight() * 0.22D / ScaleHelper.getEntityBbScale(player, mc.getTimer().getGameTimeDeltaPartialTick(false));

Vec3 vec3 = vrdata.getController(0).getPosition();
Vec3 vec31 = vrdata.getController(1).getPosition();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket;
import net.minecraft.world.entity.Pose;
import org.vivecraft.client.Xplat;
import org.vivecraft.client.network.ClientNetworking;
import org.vivecraft.client_vr.utils.ScaleHelper;
import org.vivecraft.client_vr.ClientDataHolderVR;
import org.vivecraft.common.network.CommonNetworkHelper;
import org.vivecraft.mod_compat_vr.pehkui.PehkuiHelper;

public class CrawlTracker extends Tracker {
private boolean wasCrawling;
Expand Down Expand Up @@ -44,10 +43,7 @@ public void reset(LocalPlayer player) {
}

public void doProcess(LocalPlayer player) {
double scaleMultiplier = 1.0;
if (Xplat.isModLoaded("pehkui")) {
scaleMultiplier /= PehkuiHelper.getPlayerScale(player, mc.getTimer().getGameTimeDeltaPartialTick(false));
}
float scaleMultiplier = 1.0F / ScaleHelper.getEntityScale(player, mc.getTimer().getGameTimeDeltaPartialTick(false));
this.crawling = this.dh.vr.hmdPivotHistory.averagePosition(0.2F).y * (double) this.dh.vrPlayer.worldScale * scaleMultiplier + (double) 0.1F < (double) this.dh.vrSettings.crawlThreshold;
this.updateState(player);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,12 @@ public static void applyFirstPersonItemTransforms(PoseStack pMatrixStack, Vivecr
translateY = 0.0D;
translateX = 0.0D;
} else if (rendertype == VivecraftItemTransformType.Mace) {
translateX = 0.00D;
translateY = 0.02D;
translateZ = -0.07D;
preRotation = Axis.XP.rotationDegrees((float) gunAngle);
translateX = 0.0D;
translateY = 0.0125;
translateZ = -0.06;
rotation = rotation.mul(Axis.XP.rotationDegrees((float) -gunAngle));
scale = 0.56F;
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -885,9 +885,16 @@ public static void renderFaceOverlay(float partialTicks) {
if (((GameRendererExtension) mc.gameRenderer).vivecraft$isInBlock() > 0.0F) {
renderFaceInBlock();

RenderSystem.getModelViewStack().pushMatrix().identity();
RenderHelper.applyVRModelView(dataHolder.currentPass, RenderSystem.getModelViewStack());
RenderSystem.applyModelViewMatrix();

renderGuiAndShadow(partialTicks, true, true);

VRArmHelper.renderVRHands(partialTicks, true, true, true, true);

RenderSystem.getModelViewStack().popMatrix();
RenderSystem.applyModelViewMatrix();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.vivecraft.client_vr.utils;

import net.minecraft.world.entity.LivingEntity;
import org.vivecraft.client.Xplat;
import org.vivecraft.mod_compat_vr.pehkui.PehkuiHelper;

public class ScaleHelper {

public static float getEntityScale(LivingEntity livingEntity, float tickDelta) {
float scale = livingEntity.getScale();
if (Xplat.isModLoaded("pehkui")) {
scale *= PehkuiHelper.getEntityScale(livingEntity, tickDelta);
}
return scale;
}

public static float getEntityBbScale(LivingEntity livingEntity, float tickDelta) {
float scale = livingEntity.getScale();
if (Xplat.isModLoaded("pehkui")) {
scale *= PehkuiHelper.getEntityBbScale(livingEntity, tickDelta);
}
return scale;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -542,10 +542,6 @@ public abstract class MinecraftVRMixin implements MinecraftExtension {
if (VRState.vrRunning) {

if (ClientDataHolderVR.getInstance().menuWorldRenderer.isReady()) {
// update textures in the menu
if (this.level == null) {
this.textureManager.tick();
}
ClientDataHolderVR.getInstance().menuWorldRenderer.tick();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.vivecraft.client.Xplat;
import org.vivecraft.client_vr.VRState;
import org.vivecraft.client_vr.render.helpers.RenderHelper;
import org.vivecraft.mod_compat_vr.pehkui.PehkuiHelper;

@Mixin(ItemPickupParticle.class)
public class ItemPickupParticleVRMixin {
Expand Down Expand Up @@ -45,14 +43,7 @@ public class ItemPickupParticleVRMixin {
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Mth;lerp(DDD)D", ordinal = 1), method = "render")
public double vivecraft$updateY(double d, double e, double f) {
if (VRState.vrRunning && target == vivecraft$mc.player) {
float offset = 0.5F;
if (Xplat.isModLoaded("pehkui")) {
// pehkui changes the offset, need to account for that
offset *= PehkuiHelper.getPlayerScale(target, (float) d);
}
// offset, so the particle is centered around the arm
offset += itemEntity.getBbHeight();
e = f = vivecraft$playerPos.y - offset;
e = f = vivecraft$playerPos.y - itemEntity.getBbHeight();
}

return Mth.lerp(d, e, f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class IrisHelper {
private static Method CapturedRenderingState_getGbufferProjection;

private static Method WorldRenderingSettings_setUseExtendedVertexFormat;
private static Method WorldRenderingSettings_shouldUseExtendedVertexFormat;

public static boolean isIrisLoaded() {
return Xplat.isModLoaded("iris") || Xplat.isModLoaded("oculus");
Expand Down Expand Up @@ -83,7 +84,11 @@ public static boolean hasWaterEffect() {
}

public static boolean isShaderActive() {
return IrisApi.getInstance().isShaderPackInUse();
try {
return IrisApi.getInstance().isShaderPackInUse() || (WorldRenderingSettings_shouldUseExtendedVertexFormat != null && (boolean) WorldRenderingSettings_shouldUseExtendedVertexFormat.invoke(WorldRenderingSettings.INSTANCE));
} catch (InvocationTargetException | IllegalAccessException e) {
return false;
}
}

public static boolean hasIssuesWithMenuWorld() {
Expand Down Expand Up @@ -164,6 +169,7 @@ private static boolean init() {

try {
WorldRenderingSettings_setUseExtendedVertexFormat = Class.forName("net.irisshaders.iris.shaderpack.materialmap.WorldRenderingSettings").getMethod("setUseExtendedVertexFormat", boolean.class);
WorldRenderingSettings_shouldUseExtendedVertexFormat = Class.forName("net.irisshaders.iris.shaderpack.materialmap.WorldRenderingSettings").getMethod("shouldUseExtendedVertexFormat");
} catch (ClassNotFoundException | NoSuchMethodException ignore) {}

// distant horizon compat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import virtuoel.pehkui.util.ScaleUtils;

public class PehkuiHelper {
public static float getPlayerScale(Entity player, float tickDelta) {
return ScaleUtils.getEyeHeightScale(player, tickDelta);
public static float getEntityScale(Entity entity, float tickDelta) {
return ScaleUtils.getEyeHeightScale(entity, tickDelta);
}

public static float getPlayerBbScale(Entity player, float tickDelta) {
return ScaleUtils.getBoundingBoxHeightScale(player, tickDelta);
public static float getEntityBbScale(Entity entity, float tickDelta) {
return ScaleUtils.getBoundingBoxHeightScale(entity, tickDelta);
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ minecraft_version=1.21
enabled_platforms=fabric,forge,neoforge

archives_base_name=vivecraft
mod_version=1.1.12-b3
mod_version=1.1.12-b5
maven_group=org.vivecraft

architectury_version=12.0.26
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.jellysquid.mods.sodium.client.render.immediate.model;

public interface ModelCuboid {
public class ModelCuboid {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.caffeinemc.mods.sodium.client.render.immediate.model;

public interface ModelCuboid {
public class ModelCuboid {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.irisshaders.iris.compat.sodium.impl.shader_overrides;

public interface IrisChunkProgramOverrides {
public class IrisChunkProgramOverrides {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.irisshaders.iris.compat.sodium.impl.shader_overrides;

public interface IrisChunkShaderInterface {
public class IrisChunkShaderInterface {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.irisshaders.iris.pipeline;

public interface SodiumTerrainPipeline {
public class SodiumTerrainPipeline {
}

0 comments on commit c275c92

Please sign in to comment.