From 1f29025a9f77bd570a45627c6a3fd47708da9043 Mon Sep 17 00:00:00 2001 From: Techjar Date: Fri, 10 Nov 2023 02:11:48 -0500 Subject: [PATCH] Add integration for Origins mod climbing power --- build.gradle | 12 ++++++++++++ common/build.gradle | 4 ++++ .../gameplay/trackers/ClimbTracker.java | 3 ++- .../mod_compat_vr/origins/OriginsHelper.java | 19 +++++++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 common/src/main/java/org/vivecraft/mod_compat_vr/origins/OriginsHelper.java diff --git a/build.gradle b/build.gradle index 7cb380fff..752c8e4b7 100644 --- a/build.gradle +++ b/build.gradle @@ -133,6 +133,18 @@ allprojects { } } + exclusiveContent { + forRepository { + maven { + name = "quiltmc" + url = "https://maven.quiltmc.org/repository/release" + } + } + filter { + includeGroup "org.quiltmc.parsers" + } + } + exclusiveContent { forRepository { ivy { diff --git a/common/build.gradle b/common/build.gradle index 72e9b7261..de954b420 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -45,6 +45,10 @@ dependencies { transitive(false) } + // for origins compat + modCompileOnly "maven.modrinth:origins:1.11.3" + modCompileOnlyApi "com.github.apace100:apoli:2.10.3" + // needed dependencies compileOnly("com.google.code.findbugs:jsr305:3.0.2") compileOnly('com.electronwill.night-config:toml:3.6.6') diff --git a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/ClimbTracker.java b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/ClimbTracker.java index 3926e0fde..ebe30cf60 100644 --- a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/ClimbTracker.java +++ b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/ClimbTracker.java @@ -24,6 +24,7 @@ import org.vivecraft.client_vr.gameplay.VRPlayer; import org.vivecraft.client_vr.provider.ControllerType; import org.vivecraft.common.network.CommonNetworkHelper; +import org.vivecraft.mod_compat_vr.origins.OriginsHelper; import java.util.*; @@ -109,7 +110,7 @@ public boolean isActive(LocalPlayer p) { } public boolean isClimbeyClimb() { - return this.isActive(this.mc.player) && this.isClimbeyClimbEquipped(); + return this.isActive(this.mc.player) && this.isClimbeyClimbEquipped() && (!OriginsHelper.isLoaded() || OriginsHelper.hasClimbingPower(this.mc.player)); } public boolean isClimbeyClimbEquipped() { diff --git a/common/src/main/java/org/vivecraft/mod_compat_vr/origins/OriginsHelper.java b/common/src/main/java/org/vivecraft/mod_compat_vr/origins/OriginsHelper.java new file mode 100644 index 000000000..e9a6adee1 --- /dev/null +++ b/common/src/main/java/org/vivecraft/mod_compat_vr/origins/OriginsHelper.java @@ -0,0 +1,19 @@ +package org.vivecraft.mod_compat_vr.origins; + +import java.util.List; + +import org.vivecraft.client.Xplat; +import io.github.apace100.apoli.component.PowerHolderComponent; +import io.github.apace100.apoli.power.ClimbingPower; +import net.minecraft.world.entity.LivingEntity; + +public class OriginsHelper { + public static boolean isLoaded() { + return Xplat.isModLoaded("origins"); + } + + public static boolean hasClimbingPower(LivingEntity entity) { + List powers = PowerHolderComponent.getPowers(entity, ClimbingPower.class); + return powers.stream().anyMatch(ClimbingPower::canHold); + } +}