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 Jan 26, 2025
2 parents 375e480 + 8fac17b commit cdaa849
Show file tree
Hide file tree
Showing 40 changed files with 652 additions and 105 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 }

implementation("org.joml:joml:1.10.5")

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 @@ -249,10 +252,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 @@ -299,6 +302,7 @@ public int getHMD(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 @@ -308,6 +312,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 @@ -435,7 +440,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.network.protocol.Packet;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.ItemStack;
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 @@ -218,4 +219,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 @@ -134,6 +134,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
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
Expand Down Expand Up @@ -1584,10 +1585,9 @@ public void updateLightmap() {
Vector3f finalColor = new Vector3f();
for (int i = 0; i < 16; ++i) {
for (int j = 0; j < 16; ++j) {
float skyBrightness =
this.blockAccess.dimensionType().brightness(i) * effectiveSkyLight;
float blockBrightnessRed = this.blockAccess.dimensionType().brightness(j) *
(this.blockLightRedFlicker + 1.5f);
float skyBrightness = this.blockAccess.dimensionType().brightness(i) * effectiveSkyLight;
float blockBrightnessRed =
this.blockAccess.dimensionType().brightness(j) * (this.blockLightRedFlicker + 1.5f);
float blockBrightnessGreen =
blockBrightnessRed * ((blockBrightnessRed * 0.6f + 0.4f) * 0.6f + 0.4f);
float blockBrightnessBlue =
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 @@ -1267,26 +1267,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
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ public static void renderFireInFirstPerson() {

// code adapted from net.minecraft.client.renderer.ScreenEffectRenderer.renderFire

RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
RenderSystem.setShader(GameRenderer::getPositionColorTexShader);
RenderSystem.setShaderTexture(0, fireSprite.atlas().location());
float uMin = fireSprite.getU0();
float uMax = fireSprite.getU1();
Expand Down Expand Up @@ -863,15 +863,15 @@ public static void renderFireInFirstPerson() {
posestack.translate(0.0D, -headHeight, 0.0D);

Matrix4f matrix = posestack.last().pose();
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR);
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR_TEX);
bufferbuilder.vertex(matrix, -width, 0.0F, -width)
.uv(u1, v1).color(1.0F, 1.0F, 1.0F, 0.9F).endVertex();
.color(1.0F, 1.0F, 1.0F, 0.9F).uv(u1, v1).endVertex();
bufferbuilder.vertex(matrix, width, 0.0F, -width)
.uv(u0, v1).color(1.0F, 1.0F, 1.0F, 0.9F).endVertex();
.color(1.0F, 1.0F, 1.0F, 0.9F).uv(u0, v1).endVertex();
bufferbuilder.vertex(matrix, width, headHeight, -width)
.uv(u0, v0).color(1.0F, 1.0F, 1.0F, 0.9F).endVertex();
.color(1.0F, 1.0F, 1.0F, 0.9F).uv(u0, v0).endVertex();
bufferbuilder.vertex(matrix, -width, headHeight, -width)
.uv(u1, v0).color(1.0F, 1.0F, 1.0F, 0.9F).endVertex();
.color(1.0F, 1.0F, 1.0F, 0.9F).uv(u1, v0).endVertex();
bufferbuilder.end();
BufferUploader.end(bufferbuilder);

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 @@ -1632,6 +1636,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 @@ -15,6 +15,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 @@ -23,6 +24,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 All @@ -44,7 +47,7 @@ public static Vec3 toMcVec3(Vector3f v) {
/**
* @return {@code m} as a Minecraft Matrix4f
*/
public static com.mojang.math.Matrix4f toMcMat4(Matrix4f m) {
public static com.mojang.math.Matrix4f toMcMat4(Matrix4fc m) {
com.mojang.math.Matrix4f mcMat = new com.mojang.math.Matrix4f();
mcMat.m00 = m.m00();
mcMat.m01 = m.m10();
Expand Down
Loading

0 comments on commit cdaa849

Please sign in to comment.