Skip to content

Commit

Permalink
Add integration for Origins mod climbing power
Browse files Browse the repository at this point in the history
  • Loading branch information
Techjar committed Nov 10, 2023
1 parent d2f6698 commit 6d7ca31
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
12 changes: 12 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;

Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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) {
try {
List<ClimbingPower> powers = PowerHolderComponent.getPowers(entity, ClimbingPower.class);
return powers.stream().anyMatch(ClimbingPower::canHold);
} catch (Throwable e) {
e.printStackTrace();
}
return false;
}
}

0 comments on commit 6d7ca31

Please sign in to comment.