Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/Multiloader-1.21.4' into…
Browse files Browse the repository at this point in the history
… Multiloader-1.21.3
  • Loading branch information
fayer3 committed Jan 25, 2025
2 parents 79e5f86 + 2e32b08 commit e150b1c
Show file tree
Hide file tree
Showing 36 changed files with 576 additions and 114 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ subprojects {
// parchment mappings as backup
parchment("org.parchmentmc.data:parchment-${rootProject.minecraft_version}:${rootProject.parchment_version}@zip")
}
implementation("org.lwjgl:lwjgl-openvr:${rootProject.lwjgl_version}")
implementation("org.lwjgl:lwjgl-openvr:${rootProject.lwjgl_version}:natives-linux")
implementation("org.lwjgl:lwjgl-openvr:${rootProject.lwjgl_version}:natives-macos")
implementation("org.lwjgl:lwjgl-openvr:${rootProject.lwjgl_version}:natives-windows")
implementation("org.lwjgl:lwjgl-openvr:${rootProject.lwjgl_version}") { transitive = false }
implementation("org.lwjgl:lwjgl-openvr:${rootProject.lwjgl_version}:natives-linux") { transitive = false }
implementation("org.lwjgl:lwjgl-openvr:${rootProject.lwjgl_version}:natives-macos") { transitive = false }
implementation("org.lwjgl:lwjgl-openvr:${rootProject.lwjgl_version}:natives-windows") { transitive = false }

// for OSC tracker support
implementation("com.illposed.osc:javaosc-core:0.9")
Expand Down
13 changes: 9 additions & 4 deletions common/src/main/java/org/vivecraft/client/ClientVRPlayers.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.vivecraft.client_vr.render.helpers.RenderHelper;
import org.vivecraft.client_vr.settings.AutoCalibration;
import org.vivecraft.client_vr.settings.VRSettings;
import org.vivecraft.client_xr.render_pass.RenderPassType;
import org.vivecraft.common.network.FBTMode;
import org.vivecraft.common.network.VrPlayerState;
import org.vivecraft.common.utils.MathUtils;
Expand Down Expand Up @@ -228,7 +229,9 @@ public void tick() {
Vector3f look;
if (rotInfo != null) {
look = MathUtils.FORWARD.rotateY(-rotInfo.getBodyYawRad(), new Vector3f());
if (player.isVisuallySwimming() && (player.isInWater() || rotInfo.fbtMode == FBTMode.ARMS_ONLY)) {
if (player.isVisuallySwimming() &&
(player.isInWater() || rotInfo.fbtMode == FBTMode.ARMS_ONLY))
{
yOffset = 0.3F * rotInfo.heightScale;
xzOffset = 14f * rotInfo.heightScale;

Expand All @@ -250,10 +253,10 @@ public void tick() {
if (ClientDataHolderVR.getInstance().vrSettings.playerModelType ==
VRSettings.PlayerModelType.SPLIT_ARMS_LEGS)
{
yOffset = -0.7F * Mth.cos(bend*Mth.HALF_PI) * rotInfo.heightScale;
yOffset = -0.7F * Mth.cos(bend * Mth.HALF_PI) * rotInfo.heightScale;
xzOffset = bend * 14f * rotInfo.heightScale;
} else {
yOffset = -0.7F * Mth.cos(bend*Mth.PI) * rotInfo.heightScale;
yOffset = -0.7F * Mth.cos(bend * Mth.PI) * rotInfo.heightScale;
xzOffset = 14f * rotInfo.heightScale * Mth.sin(bend * Mth.PI);
}
pos = pos.add(pivot.x, pivot.y, pivot.z);
Expand Down Expand Up @@ -296,6 +299,7 @@ public boolean hasHMD(UUID uuid) {

/**
* gets the latest clientside player data, use this when not rendering, i.e. on tick
*
* @param uuid uuid of the player to get the data for
* @return latest available player data
*/
Expand All @@ -305,6 +309,7 @@ public RotInfo getLatestRotationsForPlayer(UUID uuid) {

/**
* gets the clientside interpolated player data, this one should only be called during rendering
*
* @param uuid uuid of the player to get the data for
* @return interpolated data
*/
Expand Down Expand Up @@ -432,7 +437,7 @@ public static RotInfo getMainPlayerRotInfo(LivingEntity player, float partialTic
rotInfo.headRot = rotInfo.headQuat.transform(MathUtils.BACK, new Vector3f());

Vec3 pos;
if (player == Minecraft.getInstance().player) {
if (player == Minecraft.getInstance().player && !RenderPassType.isGuiOnly()) {
pos = ((GameRendererExtension) Minecraft.getInstance().gameRenderer).vivecraft$getRvePos(partialTick);
} else {
pos = player.getPosition(partialTick);
Expand Down
12 changes: 12 additions & 0 deletions common/src/main/java/org/vivecraft/client/Xplat.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.core.BlockPos;
import net.minecraft.network.protocol.Packet;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeSpecialEffects;
Expand Down Expand Up @@ -226,4 +227,15 @@ static int getKeyModifier(KeyMapping keyMapping) {
static int getKeyModifierKey(KeyMapping keyMapping) {
return -1;
}

/**
* checks if the given player is a fake player, instead of an actual player
*
* @param player player to check
* @return {@code true} when it is a fake player
*/
@ExpectPlatform
static boolean isFakePlayer(ServerPlayer player) {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@

import net.minecraft.client.gui.screens.Screen;
import org.vivecraft.client.gui.framework.GuiVROptionsBase;
import org.vivecraft.client.gui.framework.VROptionEntry;
import org.vivecraft.client_vr.settings.VRSettings;

public class GuiRoomscaleSettings extends GuiVROptionsBase {
private static final VRSettings.VrOptions[] ROOMSCALE_SETTINGS = new VRSettings.VrOptions[]{
VRSettings.VrOptions.WEAPON_COLLISION,
VRSettings.VrOptions.FEET_COLLISION,
VRSettings.VrOptions.REALISTIC_OPENING,
VRSettings.VrOptions.REALISTIC_JUMP,
VRSettings.VrOptions.REALISTIC_SNEAK,
VRSettings.VrOptions.REALISTIC_CLIMB,
VRSettings.VrOptions.REALISTIC_ROW,
VRSettings.VrOptions.REALISTIC_SWIM,
VRSettings.VrOptions.BOW_MODE,
VRSettings.VrOptions.BACKPACK_SWITCH,
VRSettings.VrOptions.ALLOW_CRAWLING,
VRSettings.VrOptions.REALISTIC_DISMOUNT,
VRSettings.VrOptions.REALISTIC_BLOCK_INTERACT,
VRSettings.VrOptions.REALISTIC_ENTITY_INTERACT,
VRSettings.VrOptions.SWORD_BLOCK_COLLISION
private final VROptionEntry[] roomScaleSettings = new VROptionEntry[]{
new VROptionEntry("vivecraft.options.screen.weaponcollision.button", (button, mousePos) -> {
this.minecraft.setScreen(new GuiWeaponCollisionSettings(this));
return true;
}),
new VROptionEntry(VRSettings.VrOptions.REALISTIC_JUMP),
new VROptionEntry(VRSettings.VrOptions.REALISTIC_SNEAK),
new VROptionEntry(VRSettings.VrOptions.REALISTIC_CLIMB),
new VROptionEntry(VRSettings.VrOptions.REALISTIC_ROW),
new VROptionEntry(VRSettings.VrOptions.REALISTIC_SWIM),
new VROptionEntry(VRSettings.VrOptions.BOW_MODE),
new VROptionEntry(VRSettings.VrOptions.BACKPACK_SWITCH),
new VROptionEntry(VRSettings.VrOptions.ALLOW_CRAWLING),
new VROptionEntry(VRSettings.VrOptions.REALISTIC_DISMOUNT),
new VROptionEntry(VRSettings.VrOptions.REALISTIC_BLOCK_INTERACT),
new VROptionEntry(VRSettings.VrOptions.REALISTIC_ENTITY_INTERACT)
};

public GuiRoomscaleSettings(Screen lastScreen) {
Expand All @@ -30,7 +31,7 @@ public GuiRoomscaleSettings(Screen lastScreen) {
@Override
public void init() {
this.vrTitle = "vivecraft.options.screen.roomscale";
super.init(ROOMSCALE_SETTINGS, true);
super.init(this.roomScaleSettings, true);
super.addDefaultButtons();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.vivecraft.client.gui.settings;

import net.minecraft.client.gui.screens.Screen;
import org.vivecraft.client.gui.framework.GuiVROptionsBase;
import org.vivecraft.client_vr.settings.VRSettings;

public class GuiWeaponCollisionSettings extends GuiVROptionsBase {
private static final VRSettings.VrOptions[] WEAPON_COLLISION_SETTINGS = new VRSettings.VrOptions[]{
VRSettings.VrOptions.WEAPON_COLLISION,
VRSettings.VrOptions.FEET_COLLISION,
VRSettings.VrOptions.REALISTIC_OPENING,
VRSettings.VrOptions.SWORD_BLOCK_COLLISION,
VRSettings.VrOptions.ONLY_SWORD_COLLISION,
VRSettings.VrOptions.REDUCED_PLAYER_REACH
};

public GuiWeaponCollisionSettings(Screen lastScreen) {
super(lastScreen);
}

@Override
public void init() {
this.vrTitle = "vivecraft.options.screen.weaponcollision";
super.init(WEAPON_COLLISION_SETTINGS, true);
super.addDefaultButtons();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ public void doProcess(LocalPlayer player) {
boolean isTool = false;
boolean isSword = false;

if (this.dh.vrSettings.onlySwordCollision &&
!(item instanceof SwordItem || itemstack.is(ItemTags.VIVECRAFT_SWORDS)))
{
// only swords can hit
continue;
}

if (!(item instanceof SwordItem || itemstack.is(ItemTags.VIVECRAFT_SWORDS)) &&
!(item instanceof TridentItem || itemstack.is(ItemTags.VIVECRAFT_SPEARS)))
{
Expand Down Expand Up @@ -214,12 +221,14 @@ public void doProcess(LocalPlayer player) {
AABB weaponTipBB = new AABB(handPos, weaponTip);

List<Entity> mobs = this.mc.level.getEntities(this.mc.player, weaponTipBB);
mobs.removeIf((e) -> e instanceof Player);
if (this.dh.vrSettings.reducedPlayerReach) {
// shorter range for players to try to prevent accidental hits
mobs.removeIf((e) -> e instanceof Player);

// shorter range for players to try to prevent accidental hits
List<Entity> players = this.mc.level.getEntities(this.mc.player, weaponBB);
players.removeIf((e) -> !(e instanceof Player));
mobs.addAll(players);
List<Entity> players = this.mc.level.getEntities(this.mc.player, weaponBB);
players.removeIf((e) -> !(e instanceof Player));
mobs.addAll(players);
}

for (Entity entity : mobs) {
if (entity.isPickable() && entity != this.mc.getCameraEntity().getVehicle()) {
Expand Down
24 changes: 12 additions & 12 deletions common/src/main/java/org/vivecraft/client_vr/provider/MCVR.java
Original file line number Diff line number Diff line change
Expand Up @@ -1271,26 +1271,26 @@ public void calibrateFBT(float headsetYaw) {
if (startIndex >= 0) {
this.usingUnlabeledTrackers = true;

// unassigned trackers, assign them by distance
// only check non identified trackers
List<Integer> indices = new ArrayList<>();
for (int t = startIndex + 3; t < endIndex + 3; t++) {
if (this.deviceSource[t].isValid()) {
int finalT = t;
trackers.removeIf((triple -> triple.getLeft().equals(this.deviceSource[finalT])));
} else {
indices.add(t);
}
}

// unassigned trackers, assign them by distance
for (int t : indices) {
int closestIndex = -1;
float closestDistance = Float.MAX_VALUE;

// find the closest tracker to the reference point
for (int i = 0; i < trackers.size(); i++) {
// int trackerIndex = trackers.get(i);
Triple<DeviceSource, Integer, Matrix4fc> tracker = trackers.get(i);

// if regular fbt is already detected, skip those trackers
if (hasFBT()) {
if (this.deviceSource[WAIST_TRACKER].equals(tracker.getLeft()) ||
this.deviceSource[LEFT_FOOT_TRACKER].equals(tracker.getLeft()) ||
this.deviceSource[RIGHT_FOOT_TRACKER].equals(tracker.getLeft()))
{
continue;
}
}

tracker.getRight().getTranslation(tempV)
.sub(posAvg.x, 0F, posAvg.z) // center around headset
.rotateY(headsetYaw)
Expand Down
31 changes: 28 additions & 3 deletions common/src/main/java/org/vivecraft/client_vr/render/VRShaders.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package org.vivecraft.client_vr.render;

import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.shaders.AbstractUniform;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.VertexFormat;
import net.minecraft.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.CompiledShaderProgram;
import net.minecraft.client.renderer.ShaderDefines;
import net.minecraft.client.renderer.ShaderProgram;
import net.minecraft.client.renderer.*;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.TriState;

import java.util.function.Function;

public class VRShaders {
// FSAA shader and its uniforms
Expand Down Expand Up @@ -57,6 +62,26 @@ public class VRShaders {
ResourceLocation.fromNamespaceAndPath("vivecraft", "core/rendertype_end_gateway_vr"),
DefaultVertexFormat.POSITION, ShaderDefines.EMPTY);

// menu crosshair shader
private static final RenderStateShard.TransparencyStateShard MENU_CROSSHAIR_TRANSPARENCY = new RenderStateShard.TransparencyStateShard(
"menu_crosshair_transparency", () -> {
RenderSystem.enableBlend();
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.ONE_MINUS_DST_COLOR, GlStateManager.DestFactor.ZERO,
GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE);
}, () -> {
RenderSystem.disableBlend();
RenderSystem.defaultBlendFunc();
});

public static final Function<ResourceLocation, RenderType> MENU_CROSSHAIR = Util.memoize(
(resourceLocation) -> RenderType.create("menu_crosshair", DefaultVertexFormat.POSITION_TEX_COLOR,
VertexFormat.Mode.QUADS, 786432, RenderType.CompositeState.builder()
.setTextureState(new RenderStateShard.TextureStateShard(resourceLocation, TriState.FALSE, false))
.setShaderState(RenderStateShard.POSITION_TEXTURE_COLOR_SHADER)
.setTransparencyState(MENU_CROSSHAIR_TRANSPARENCY)
.setDepthTestState(RenderStateShard.NO_DEPTH_TEST)
.createCompositeState(false)));

// fabulous vr shader
public static final ResourceLocation VR_TRANSPARENCY_SHADER_ID = ResourceLocation.fromNamespaceAndPath("vivecraft",
"post/vrtransparency");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.CoreShaders;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.ShaderProgram;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.core.Vec3i;
Expand All @@ -32,6 +31,7 @@
import org.vivecraft.client_vr.gameplay.trackers.TelescopeTracker;
import org.vivecraft.client_vr.provider.MCVR;
import org.vivecraft.client_vr.render.RenderPass;
import org.vivecraft.client_vr.render.VRShaders;
import org.vivecraft.client_vr.settings.VRSettings;
import org.vivecraft.common.utils.MathUtils;
import org.vivecraft.mixin.client.blaze3d.RenderSystemAccessor;
Expand Down Expand Up @@ -332,7 +332,7 @@ public static void drawMouseMenuQuad(GuiGraphics guiGraphics, int mouseX, int mo
float size = 15.0F * Math.max(ClientDataHolderVR.getInstance().vrSettings.menuCrosshairScale,
1.0F / (float) MC.getWindow().getGuiScale());

guiGraphics.blitSprite(RenderType::crosshair, Gui.CROSSHAIR_SPRITE, (int) (mouseX - size * 0.5F + 1),
guiGraphics.blitSprite(VRShaders.MENU_CROSSHAIR, Gui.CROSSHAIR_SPRITE, (int) (mouseX - size * 0.5F + 1),
(int) (mouseY - size * 0.5F + 1), (int) size, (int) size);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ public enum DataSource implements OptionEnum<DataSource> {
public boolean feetCollision = true; // VIVE weapon feet collides with blocks/enemies
@SettingField(VrOptions.SWORD_BLOCK_COLLISION)
public boolean swordBlockCollision = true;
@SettingField(VrOptions.ONLY_SWORD_COLLISION)
public boolean onlySwordCollision = false;
@SettingField(VrOptions.REDUCED_PLAYER_REACH)
public boolean reducedPlayerReach = true;
@SettingField(VrOptions.MOVEMENT_MULTIPLIER)
public float movementSpeedMultiplier = 1.0f; // VIVE - use full speed by default
@SettingField(VrOptions.FREEMOVE_MODE)
Expand Down Expand Up @@ -1633,6 +1637,8 @@ Object convertOption(String value) {
},
FEET_COLLISION(false, true),
SWORD_BLOCK_COLLISION(false, true), // lets swords hit blocks that can be mined or instabroken
ONLY_SWORD_COLLISION(false, true), // only let swords hit stuff
REDUCED_PLAYER_REACH(false, true), // reduces roomscale reach to hit players
// VIVE END - new options
// JRBUDDA VIVE
ALLOW_CRAWLING(false, true), // Roomscale Crawling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class MathUtils {
public static final Vector3fc RIGHT = new Vector3f(-1.0F, 0.0F, 0.0F);
public static final Vector3fc UP = new Vector3f(0.0F, 1.0F, 0.0F);
public static final Vector3fc DOWN = new Vector3f(0.0F, -1.0F, 0.0F);
public static final Vector3fc ZERO = new Vector3f();

public static final Vec3 FORWARD_D = new Vec3(0.0, 0.0, 1.0);
public static final Vec3 BACK_D = new Vec3(0.0, 0.0, -1.0);
Expand All @@ -22,6 +23,8 @@ public class MathUtils {
public static final Vec3 UP_D = new Vec3(0.0, 1.0, 0.0);
public static final Vec3 DOWN_D = new Vec3(0.0, -1.0, 0.0);

public static final Matrix4fc IDENTITY = new Matrix4f();

/**
* subtracts {@code b} from {@code a}, and returns the result as a Vector3f, should only be used to get local position differences
*
Expand Down
Loading

0 comments on commit e150b1c

Please sign in to comment.