Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/Multiloader-1.20.5' into…
Browse files Browse the repository at this point in the history
… Multiloader-1.21
  • Loading branch information
fayer3 committed Jul 8, 2024
2 parents b4cf2dc + f946d90 commit d89c6e4
Show file tree
Hide file tree
Showing 38 changed files with 441 additions and 205 deletions.
61 changes: 60 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.7-SNAPSHOT" apply false
id 'io.github.juuxel.loom-quiltflower' version '1.8.0' apply false
}

Expand Down Expand Up @@ -56,6 +56,65 @@ subprojects {
}
}

tasks.register('fixForge', Zip) {
if (gradle.startParameter.taskNames.contains(name)) {
if (!file('./build/libs/' + archives_base_name +
'-' + minecraft_version +
'-' + mod_version +
'-forge_nonfunctional_without_changes.jar').exists() ||
!file('./build/libs/' + archives_base_name +
'-' + minecraft_version +
'-' + mod_version +
'-neoforge.jar').exists()) {
throw new GradleException("forge and neoforge need to be built to run this task")
}
doFirst {
println('unzipping jars')
}
copy {
// extract all forge files
from zipTree('./build/libs/' + archives_base_name +
'-' + minecraft_version +
'-' + mod_version +
'-forge_nonfunctional_without_changes.jar')
into './build/tmp/forge'
// remove any refmap
exclude "**/*-refmap.json"
// remove the refmap from the mixin jsons
eachFile { fileCopyDetails ->
if (fileCopyDetails.name.endsWith('.json')) {
filter {
line -> line.contains('"refmap": "vivecraft-common-refmap.json"') ? '"dummy": ""' : line
}
}
}
}
copy {
// override the general classes with the neoforge ones, since those are mapped correctly
from zipTree('./build/libs/' + archives_base_name +
'-' + minecraft_version +
'-' + mod_version +
'-neoforge.jar')
into './build/tmp/forge'
include '/org/vivecraft/**'
exclude '**/neoforge/**', '**/Xplat*.class', '**/Xevents*.class'
}

// zip up the combined jar again
archiveFileName = archives_base_name +
'-' + minecraft_version +
'-' + mod_version +
'-forge.jar'
destinationDirectory = file('./build/libs/')
from './build/tmp/forge'

doLast {
println('removing temp files')
delete './build/tmp/forge'
}
}
}

allprojects {
apply plugin: "architectury-plugin"
apply plugin: "maven-publish"
Expand Down
16 changes: 14 additions & 2 deletions common/src/main/java/org/vivecraft/client/Xplat.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ public interface Xplat {
* <a href="https://plugins.jetbrains.com/plugin/16210-architectury">You should also get the IntelliJ plugin to help with @ExpectPlatform.</a>
*/

enum ModLoader{
FABRIC("fabric"),
FORGE("forge"),
NEOFORGE("neoforge");

public final String name;

ModLoader(String name) {
this.name = name;
}
}

@ExpectPlatform
static boolean isModLoaded(String name) {
return false;
Expand All @@ -43,8 +55,8 @@ static boolean isDedicatedServer() {
}

@ExpectPlatform
static String getModloader() {
return "";
static ModLoader getModloader() {
throw new AssertionError();
}

@ExpectPlatform
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ public class GuiRoomscaleSettings extends GuiVROptionsBase {
VRSettings.VrOptions.BOW_MODE,
VRSettings.VrOptions.BACKPACK_SWITCH,
VRSettings.VrOptions.ALLOW_CRAWLING,
VRSettings.VrOptions.REALISTIC_DISMOUNT
VRSettings.VrOptions.REALISTIC_DISMOUNT,
VRSettings.VrOptions.REALISTIC_BLOCK_INTERACT,
VRSettings.VrOptions.REALISTIC_ENTITY_INTERACT
};

public GuiRoomscaleSettings(Screen guiScreen) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class GuiSeatedOptions extends GuiVROptionsBase {
new VROptionEntry(VRSettings.VrOptions.WALK_UP_BLOCKS),
new VROptionEntry(VRSettings.VrOptions.WORLD_ROTATION_INCREMENT),
new VROptionEntry(VRSettings.VrOptions.VEHICLE_ROTATION),
new VROptionEntry(VRSettings.VrOptions.DUMMY),
new VROptionEntry(VRSettings.VrOptions.REVERSE_HANDS),
new VROptionEntry(VRSettings.VrOptions.SEATED_FREE_MOVE, true),
new VROptionEntry(VRSettings.VrOptions.RIGHT_CLICK_DELAY, false),
new VROptionEntry("vivecraft.options.screen.teleport.button", (button, mousePos) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public HMDLayer(RenderLayerParent<AbstractClientPlayer, PlayerModel<AbstractClie

@Override
public void render(PoseStack poseStack, MultiBufferSource multiBufferSource, int i, AbstractClientPlayer entity, float f, float g, float h, float j, float k, float l) {
if (this.getParentModel() instanceof VRPlayerModel<?> vrPlayerModel) {
if (this.getParentModel().head.visible && this.getParentModel() instanceof VRPlayerModel<?> vrPlayerModel) {
VRPlayersClient.RotInfo rotinfo = VRPlayersClient.getInstance().getRotationsForPlayer(entity.getUUID());
ResourceLocation hmd;
switch (rotinfo.hmd) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.client.player.AbstractClientPlayer;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.layers.RenderLayer;
import net.minecraft.client.renderer.entity.player.PlayerRenderer;
import net.minecraft.world.phys.Vec3;
import org.vivecraft.client.VRPlayersClient;
Expand Down Expand Up @@ -34,6 +35,10 @@ public VRPlayerRenderer(EntityRendererProvider.Context context, boolean slim, bo
this.addLayer(new HMDLayer(this));
}

public boolean hasLayerType(RenderLayer<?,?> renderLayer) {
return this.layers.stream().anyMatch(layer -> layer.getClass() == renderLayer.getClass());
}

@Override
public void render(AbstractClientPlayer entityIn, float pEntityYaw, float pPartialTicks, PoseStack matrixStackIn, MultiBufferSource pBuffer, int pPackedLight) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static boolean checkForUpdates() {
}

try {
String apiURL = "https://api.modrinth.com/v2/project/vivecraft/version?loaders=[%22" + Xplat.getModloader() + "%22]&game_versions=[%22" + SharedConstants.VERSION_STRING + "%22]";
String apiURL = "https://api.modrinth.com/v2/project/vivecraft/version?loaders=[%22" + Xplat.getModloader().name + "%22]&game_versions=[%22" + SharedConstants.VERSION_STRING + "%22]";
HttpURLConnection conn = (HttpURLConnection) new URL(apiURL).openConnection();
// 10 seconds read and connect timeout
conn.setConnectTimeout(10000);
Expand Down Expand Up @@ -76,7 +76,7 @@ public static boolean checkForUpdates() {
// sort the versions, modrinth doesn't guarantee them to be sorted.
Collections.sort(versions);

String currentVersionNumber = Xplat.getModVersion() + "-" + Xplat.getModloader();
String currentVersionNumber = Xplat.getModVersion() + "-" + Xplat.getModloader().name;
Version current = new Version(currentVersionNumber, currentVersionNumber, "");

// enforce update notifications if using a non release
Expand Down
11 changes: 10 additions & 1 deletion common/src/main/java/org/vivecraft/client_vr/VRState.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.vivecraft.mod_compat_vr.ShadersHelper;
import org.vivecraft.mod_compat_vr.optifine.OptifineHelper;

import java.io.File;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryManagerMXBean;

Expand All @@ -44,7 +45,14 @@ public static void initializeVR() {
// TODO: move this into the init, does mean all callocs need to be done later
// check that the right lwjgl version is loaded that we ship the openvr part of
if (!Version.getVersion().startsWith("3.3.3")) {
throw new RenderConfigException("VR Init Error", Component.translatable("vivecraft.messages.rendersetupfailed", I18n.get("vivecraft.messages.invalidlwjgl", Version.getVersion(), "3.3.3"), "OpenVR_LWJGL"));
String suppliedJar = "";
try {
suppliedJar = new File(Version.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getName();
} catch (Exception e) {
VRSettings.logger.error("couldn't check lwjgl source:", e);
}

throw new RenderConfigException("VR Init Error", Component.translatable("vivecraft.messages.rendersetupfailed", I18n.get("vivecraft.messages.invalidlwjgl", Version.getVersion(), "3.3.3", suppliedJar), "OpenVR_LWJGL"));
}

dh.vr = new MCOpenVR(Minecraft.getInstance(), dh);
Expand Down Expand Up @@ -113,6 +121,7 @@ public static void initializeVR() {
} catch (RenderConfigException renderConfigException) {
vrEnabled = false;
destroyVR(true);
renderConfigException.printStackTrace();
Minecraft.getInstance().setScreen(new ErrorScreen(renderConfigException.title, renderConfigException.error));
} catch (Throwable e) {
vrEnabled = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
public interface MinecraftExtension {

void vivecraft$notifyMirror(String buttonDisplayString, boolean b, int i);
void vivecraft$drawProfiler();
}
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public void doProcess(LocalPlayer player) {
}
}

if (!this.active[j]) {
if (this.dh.vrSettings.realisticEntityInteractEnabled && !this.active[j]) {
int k = Mth.floor(vec3.x);
int l = Mth.floor(vec3.y);
int i = Mth.floor(vec3.z);
Expand All @@ -200,7 +200,7 @@ public void doProcess(LocalPlayer player) {
}
}

if (!this.active[j]) {
if (this.dh.vrSettings.realisticBlockInteractEnabled && !this.active[j]) {
BlockPos blockpos = null;
blockpos = BlockPos.containing(vec3);
BlockState blockstate = this.mc.level.getBlockState(blockpos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ public void poll(long frameIndex) {

this.updateAim();

this.controllerPose[0].M[0][3] = 0.3F;
this.controllerPose[0].M[0][3] = this.dh.vrSettings.reverseHands ? -0.3F : 0.3F;
this.controllerPose[0].M[1][3] = 1.2F;
this.controllerPose[0].M[2][3] = -0.5F;

this.controllerPose[1].M[0][3] = -0.3F;
this.controllerPose[1].M[0][3] = this.dh.vrSettings.reverseHands ? 0.3F : -0.3F;
this.controllerPose[1].M[1][3] = 1.2F;
this.controllerPose[1].M[2][3] = -0.5F;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public static void applyFirstPersonItemTransforms(PoseStack pMatrixStack, Vivecr
rotation.mul(Axis.XP.rotationDegrees(-45.0F));
rotation.mul(Axis.XP.rotationDegrees((float) gunAngle));
} else if (rendertype == VivecraftItemTransformType.Shield) {
boolean reverse = dh.vrSettings.reverseHands && !dh.vrSettings.seated;
boolean reverse = dh.vrSettings.reverseHands;
if (reverse) {
k *= -1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,25 @@ public static Vec3 getControllerRenderPos(int c) {
return dataHolder.vrPlayer.vrdata_world_render.getController(c).getPosition();
} else {
Vec3 out = null;
int mainHand = InteractionHand.MAIN_HAND.ordinal();
if (dataHolder.vrSettings.reverseHands) {
c = 1 - c;
mainHand = InteractionHand.OFF_HAND.ordinal();
}

if (mc.getCameraEntity() != null && mc.level != null) {
Vec3 dir = dataHolder.vrPlayer.vrdata_world_render.hmd.getDirection();
dir = dir.yRot((float) Math.toRadians(c == 0 ? -35.0D : 35.0D));
dir = new Vec3(dir.x, 0.0D, dir.z);
dir = dir.normalize();
if (TelescopeTracker.isTelescope(mc.player.getUseItem())) {
if (c == 0 && mc.player.getUsedItemHand() == InteractionHand.MAIN_HAND) {
out = dataHolder.vrPlayer.vrdata_world_render.eye0.getPosition()
.add(dataHolder.vrPlayer.vrdata_world_render.hmd.getDirection()
.scale(0.2 * dataHolder.vrPlayer.vrdata_world_render.worldScale));
}
if (c == 1 && mc.player.getUsedItemHand() == InteractionHand.OFF_HAND) {
out = dataHolder.vrPlayer.vrdata_world_render.eye1.getPosition()
.add(dataHolder.vrPlayer.vrdata_world_render.hmd.getDirection()
.scale(0.2 * dataHolder.vrPlayer.vrdata_world_render.worldScale));
}
if (TelescopeTracker.isTelescope(mc.player.getUseItem()) && TelescopeTracker.isTelescope(c == mainHand ? mc.player.getMainHandItem() : mc.player.getOffhandItem())) {
// move the controller in front of the eye when using the spyglass
VRData.VRDevicePose eye = c == 0 ? dataHolder.vrPlayer.vrdata_world_render.eye0 :
dataHolder.vrPlayer.vrdata_world_render.eye1;

out = eye.getPosition()
.add(dataHolder.vrPlayer.vrdata_world_render.hmd.getDirection()
.scale(0.2 * dataHolder.vrPlayer.vrdata_world_render.worldScale));
}
if (out == null) {
out = dataHolder.vrPlayer.vrdata_world_render.getEye(RenderPass.CENTER).getPosition().add(
Expand All @@ -139,11 +141,11 @@ public static void setupRenderingAtController(int controller, Matrix4f matrix) {
getSmoothCameraPosition(dataHolder.currentPass, dataHolder.vrPlayer.getVRDataWorld()));
matrix.translate((float) aimSource.x, (float) aimSource.y, (float) aimSource.z);
float sc = dataHolder.vrPlayer.vrdata_world_render.worldScale;
if (mc.level != null && TelescopeTracker.isTelescope(mc.player.getUseItem())) {
if (dataHolder.vrSettings.seated && mc.level != null && TelescopeTracker.isTelescope(mc.player.getUseItem()) && TelescopeTracker.isTelescope(controller == 0 ? mc.player.getMainHandItem() : mc.player.getOffhandItem())) {
matrix.mul(dataHolder.vrPlayer.vrdata_world_render.hmd.getMatrix().inverted()
.transposed().toMCMatrix());
matrix.rotate(Axis.XP.rotationDegrees(90));
matrix.translate(controller == 0 ? 0.075F * sc : -0.075F * sc, -0.025F * sc, 0.0325F * sc);
matrix.translate(controller == (dataHolder.vrSettings.reverseHands ? 1 : 0) ? 0.075F * sc : -0.075F * sc, -0.025F * sc, 0.0325F * sc);
} else {
matrix.mul(dataHolder.vrPlayer.vrdata_world_render.getController(controller)
.getMatrix().inverted().transposed().toMCMatrix());
Expand Down Expand Up @@ -242,6 +244,12 @@ public static void drawScreen(float f, Screen screen, GuiGraphics guiGraphics) {
posestack.translate(0.0F, 0.0F, -11000.0F);
RenderSystem.applyModelViewMatrix();

Matrix4f guiProjection = (new Matrix4f()).setOrtho(
0.0F, (float) (mc.getWindow().getWidth() / mc.getWindow().getGuiScale()),
(float) (mc.getWindow().getHeight() / mc.getWindow().getGuiScale()), 0.0F,
1000.0F, 21000.0F);
RenderSystem.setProjectionMatrix(guiProjection, VertexSorting.ORTHOGRAPHIC_Z);

RenderSystem.blendFuncSeparate(
GlStateManager.SourceFactor.SRC_ALPHA,
GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA,
Expand Down
Loading

0 comments on commit d89c6e4

Please sign in to comment.