Skip to content

Commit 7ec107e

Browse files
committed
fix: compat with passive gauge
1 parent 09777b3 commit 7ec107e

File tree

4 files changed

+23
-17
lines changed

4 files changed

+23
-17
lines changed

forge/build.gradle

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@ dependencies {
2020
implementation(project(path: ":create_factory_abstractions-${minecraft_version}", configuration: 'namedElements')) { transitive false }
2121
include project(":create_factory_abstractions-${minecraft_version}")
2222

23+
modCompileOnly "net.liukrast:extra_gauges-${minecraft_version}:${extra_gauges_version}", {
24+
transitive = false
25+
}
26+
27+
// modLocalRuntime "net.liukrast:extra_gauges-${minecraft_version}:${extra_gauges_version}", {
28+
// transitive = false
29+
// }
30+
2331
modLocalRuntime "curse.maven:create-vibrant-vaults-1251719:6463890"
2432
// modLocalRuntime "curse.maven:create-enchantment-industry-688768:6549319"
25-
modLocalRuntime "curse.maven:create-extra-gauges-1263228:6916170"
2633
// modLocalRuntime "curse.maven:create-dragon-minus-1216624:6552025"
27-
// modLocalRuntime "net.liukrast:extra_gauges-${minecraft_version}:1.1.1", {
28-
// transitive = false
29-
// }
3034
}
3135

3236
// This block of code expands all declared replace properties in the specified resource targets.
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
package ru.zznty.create_factory_logistics.compat.extra_gauges;
22

33
import com.simibubi.create.content.logistics.factoryBoard.FactoryPanelBehaviour;
4+
import net.liukrast.eg.api.logistics.board.AbstractPanelBehaviour;
45
import net.neoforged.fml.ModList;
5-
import org.jetbrains.annotations.Nullable;
66

77
public final class AbstractPanelBehaviourStub {
8-
@Nullable
9-
private static Class<?> clazz;
8+
private static final boolean isInstalled = ModList.get().isLoaded("extra_gauges");
109

11-
static {
12-
try {
13-
clazz = ModList.get().isLoaded("extra_gauges") ?
14-
Class.forName("net.liukrast.eg.api.logistics.board.AbstractPanelBehaviour") : null;
15-
} catch (ClassNotFoundException e) {
16-
// ignore
17-
}
10+
public static boolean shouldTick(FactoryPanelBehaviour instance) {
11+
if (!isInstalled) return false;
12+
13+
return shouldTickInstalled(instance);
1814
}
1915

20-
public static boolean is(FactoryPanelBehaviour instance) {
21-
return clazz != null && clazz.isInstance(instance);
16+
private static boolean shouldTickInstalled(FactoryPanelBehaviour instance) {
17+
if (instance instanceof AbstractPanelBehaviour behaviour) {
18+
return behaviour.skipOriginalTick();
19+
}
20+
return false;
2221
}
2322
}

forge/src/main/java/ru/zznty/create_factory_logistics/mixin/logistics/panel/FactoryPanelRequestMixin.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import net.minecraft.world.MenuProvider;
2222
import net.minecraft.world.item.ItemStack;
2323
import org.joml.Math;
24+
import org.spongepowered.asm.mixin.Debug;
2425
import org.spongepowered.asm.mixin.Mixin;
2526
import org.spongepowered.asm.mixin.Shadow;
2627
import org.spongepowered.asm.mixin.Unique;
@@ -35,6 +36,7 @@
3536
import java.util.*;
3637
import java.util.stream.Collectors;
3738

39+
@Debug(export = true)
3840
@Mixin(FactoryPanelBehaviour.class)
3941
public abstract class FactoryPanelRequestMixin extends FilteringBehaviour implements MenuProvider {
4042
@Shadow
@@ -199,7 +201,7 @@ private int getConfigRequestIntervalInTicks() {
199201
private void tickRequests(Operation<Void> original) {
200202
FactoryPanelBehaviour source = (FactoryPanelBehaviour) (Object) this;
201203

202-
if (AbstractPanelBehaviourStub.is(source)) {
204+
if (AbstractPanelBehaviourStub.shouldTick(source)) {
203205
// we don't want to override mixins from extra gauges so skip to the original
204206
original.call();
205207
return;

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ ponder_version = 1.0.56
5252
flywheel_version = 1.0.4
5353
registrate_version = MC1.21-1.3.0+62
5454
jei_version = 19.21.0.247
55+
extra_gauges_version = 2.0.5

0 commit comments

Comments
 (0)