Skip to content

Commit 12207da

Browse files
committed
feat: Add BalmModSupport.vr().isInVR() with Vivecraft support
1 parent 6abe159 commit 12207da

13 files changed

Lines changed: 104 additions & 0 deletions

File tree

common/dependencies.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ dependencies {
77
compileOnly libs.clothConfigNeoForge
88
compileOnly libs.configuredNeoForge
99
compileOnly libs.ftbUltimineCommon
10+
compileOnly libs.vivecraftCommon
1011
}

common/src/main/java/net/blay09/mods/balm/platform/compatibility/BalmModSupport.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import net.blay09.mods.balm.platform.compatibility.multiminers.BalmModSupportMultiMiners;
66
import net.blay09.mods.balm.platform.compatibility.recipeviewer.BalmModSupportRecipeViewer;
77
import net.blay09.mods.balm.platform.compatibility.trinkets.BalmModSupportTrinkets;
8+
import net.blay09.mods.balm.platform.compatibility.vr.BalmModSupportVR;
89

910
public interface BalmModSupport {
1011

@@ -17,4 +18,7 @@ public interface BalmModSupport {
1718
BalmModSupportHudInfo hudInfo();
1819

1920
BalmModSupportRecipeViewer recipeViewers();
21+
22+
BalmModSupportVR vr();
23+
2024
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package net.blay09.mods.balm.platform.compatibility.vr;
2+
3+
import net.minecraft.world.entity.player.Player;
4+
import net.minecraft.world.item.ItemStack;
5+
6+
import java.util.List;
7+
import java.util.function.Predicate;
8+
9+
public interface BalmModSupportVR {
10+
boolean isInVR(Player player);
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package net.blay09.mods.balm.platform.compatibility.vr.internal;
2+
3+
import net.blay09.mods.balm.platform.compatibility.vr.BalmModSupportVR;
4+
import net.minecraft.world.entity.player.Player;
5+
6+
public class NoopVR implements BalmModSupportVR {
7+
@Override
8+
public boolean isInVR(Player player) {
9+
return false;
10+
}
11+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package net.blay09.mods.balm.platform.compatibility.vr.internal;
2+
3+
import net.blay09.mods.balm.platform.compatibility.vr.BalmModSupportVR;
4+
import net.minecraft.world.entity.player.Player;
5+
6+
import java.util.List;
7+
8+
public class VRMultiplexer implements BalmModSupportVR {
9+
private final List<BalmModSupportVR> providers;
10+
11+
public VRMultiplexer(List<BalmModSupportVR> providers) {
12+
this.providers = providers;
13+
}
14+
15+
@Override
16+
public boolean isInVR(Player player) {
17+
return providers.stream().anyMatch(provider -> provider.isInVR(player));
18+
}
19+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package net.blay09.mods.balm.platform.compatibility.vr.internal;
2+
3+
import net.blay09.mods.balm.platform.compatibility.vr.BalmModSupportVR;
4+
import net.minecraft.world.entity.player.Player;
5+
import org.vivecraft.api.VRAPI;
6+
7+
public class VivecraftIntegration implements BalmModSupportVR {
8+
@Override
9+
public boolean isInVR(Player player) {
10+
return VRAPI.instance().isVRPlayer(player);
11+
}
12+
}

fabric/dependencies.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ dependencies {
1111
compileOnly libs.clothConfigFabric
1212
compileOnly libs.configuredFabric
1313
compileOnly libs.ftbUltimineFabric
14+
compileOnly libs.vivecraftCommon
1415
}

fabric/src/main/java/net/blay09/mods/balm/fabric/platform/compatibility/internal/FabricBalmModSupport.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import net.blay09.mods.balm.platform.compatibility.recipeviewer.BalmModSupportRecipeViewer;
44
import net.blay09.mods.balm.platform.compatibility.recipeviewer.internal.CommonBalmModSupportRecipeViewer;
5+
import net.blay09.mods.balm.platform.compatibility.vr.BalmModSupportVR;
6+
import net.blay09.mods.balm.platform.compatibility.vr.internal.NoopVR;
7+
import net.blay09.mods.balm.platform.compatibility.vr.internal.VRMultiplexer;
58
import net.blay09.mods.balm.platform.runtime.internal.BalmRuntime;
69
import net.blay09.mods.balm.platform.compatibility.BalmModSupport;
710
import net.blay09.mods.balm.platform.compatibility.hudinfo.BalmModSupportHudInfo;
@@ -20,6 +23,7 @@
2023
public class FabricBalmModSupport implements BalmModSupport {
2124
private final Supplier<BalmModSupportMultiMiners> multiminers;
2225
private final Supplier<BalmModSupportTrinkets> trinkets;
26+
private final Supplier<BalmModSupportVR> vr;
2327
private final CommonBalmModSupportHudInfo hudInfo = new CommonBalmModSupportHudInfo();
2428
private final CommonBalmModSupportRecipeViewer recipeViewers = new CommonBalmModSupportRecipeViewer();
2529
private final BalmModSupportMilkFluid milkFluid = new FabricModSupportMilkFluid();
@@ -35,6 +39,11 @@ public FabricBalmModSupport(BalmRuntime<?> runtime) {
3539
.withMultiplexer(TrinketsMultiplexer::new)
3640
.withFallback(new NoopTrinkets())
3741
.buildLazily();
42+
vr = runtime.<BalmModSupportVR>modProxy()
43+
.with("vivecraft", "net.blay09.mods.balm.platform.compatibility.vr.internal.VivecraftIntegration")
44+
.withMultiplexer(VRMultiplexer::new)
45+
.withFallback(new NoopVR())
46+
.buildLazily();
3847
}
3948

4049
@Override
@@ -61,4 +70,9 @@ public BalmModSupportHudInfo hudInfo() {
6170
public BalmModSupportRecipeViewer recipeViewers() {
6271
return recipeViewers;
6372
}
73+
74+
@Override
75+
public BalmModSupportVR vr() {
76+
return vr.get();
77+
}
6478
}

forge/dependencies.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ dependencies {
99
compileOnly libs.clothConfigNeoForge
1010
compileOnly libs.jadeNeoForge
1111
compileOnly libs.ftbUltimineCommon
12+
compileOnly libs.vivecraftCommon
1213
}

forge/src/main/java/net/blay09/mods/balm/forge/platform/compatibility/ForgeBalmModSupport.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@
1313
import net.blay09.mods.balm.platform.compatibility.trinkets.BalmModSupportTrinkets;
1414
import net.blay09.mods.balm.platform.compatibility.trinkets.internal.NoopTrinkets;
1515
import net.blay09.mods.balm.platform.compatibility.trinkets.internal.TrinketsMultiplexer;
16+
import net.blay09.mods.balm.platform.compatibility.vr.BalmModSupportVR;
17+
import net.blay09.mods.balm.platform.compatibility.vr.internal.NoopVR;
18+
import net.blay09.mods.balm.platform.compatibility.vr.internal.VRMultiplexer;
1619
import net.blay09.mods.balm.platform.runtime.internal.BalmRuntime;
1720

1821
import java.util.function.Supplier;
1922

2023
public class ForgeBalmModSupport implements BalmModSupport {
2124
private final Supplier<BalmModSupportMultiMiners> multiminers;
2225
private final Supplier<BalmModSupportTrinkets> trinkets;
26+
private final Supplier<BalmModSupportVR> vr;
2327
private final CommonBalmModSupportHudInfo hudInfo = new CommonBalmModSupportHudInfo();
2428
private final CommonBalmModSupportRecipeViewer recipeViewers = new CommonBalmModSupportRecipeViewer();
2529
private final BalmModSupportMilkFluid milkFluid = new ForgeBalmModSupportMilkFluid();
@@ -33,6 +37,11 @@ public ForgeBalmModSupport(BalmRuntime<?> runtime) {
3337
.withMultiplexer(TrinketsMultiplexer::new)
3438
.withFallback(new NoopTrinkets())
3539
.buildLazily();
40+
vr = runtime.<BalmModSupportVR>modProxy()
41+
.with("vivecraft", "net.blay09.mods.balm.platform.compatibility.vr.internal.VivecraftIntegration")
42+
.withMultiplexer(VRMultiplexer::new)
43+
.withFallback(new NoopVR())
44+
.buildLazily();
3645
}
3746

3847
@Override
@@ -59,4 +68,9 @@ public BalmModSupportMilkFluid milkFluid() {
5968
public BalmModSupportRecipeViewer recipeViewers() {
6069
return recipeViewers;
6170
}
71+
72+
@Override
73+
public BalmModSupportVR vr() {
74+
return vr.get();
75+
}
6276
}

0 commit comments

Comments
 (0)