diff options
| author | shedaniel <daniel@shedaniel.me> | 2021-08-28 16:01:34 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2021-08-28 16:01:42 +0800 |
| commit | 8a0601c75fa2462494ed949797f04243fe9cb10e (patch) | |
| tree | d68bb62284aa8f63faecb5060b9803846f33ed72 /fabric/src/main/java | |
| parent | 2318a37d8482498bdec25947e15177ba77996cb8 (diff) | |
| download | RoughlyEnoughItems-8a0601c75fa2462494ed949797f04243fe9cb10e.tar.gz RoughlyEnoughItems-8a0601c75fa2462494ed949797f04243fe9cb10e.tar.bz2 RoughlyEnoughItems-8a0601c75fa2462494ed949797f04243fe9cb10e.zip | |
Fix crash if architectury isn't installed, fix replay mod and REI fighting to show GUIs
Diffstat (limited to 'fabric/src/main/java')
| -rw-r--r-- | fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinScreen.java | 12 | ||||
| -rw-r--r-- | fabric/src/main/java/me/shedaniel/rei/mixin/fabric/REIMixinPlugin.java | 71 |
2 files changed, 81 insertions, 2 deletions
diff --git a/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinScreen.java b/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinScreen.java index a14577a7f..1f2346895 100644 --- a/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinScreen.java +++ b/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinScreen.java @@ -27,6 +27,7 @@ import me.shedaniel.rei.impl.client.fabric.ErrorDisplayerImpl; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.Screen; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -35,10 +36,17 @@ import java.util.function.Consumer; @Mixin(Screen.class) public class MixinScreen { + @Unique + private static final ThreadLocal<Boolean> REI_IN = ThreadLocal.withInitial(() -> false); + @Inject(method = "init(Lnet/minecraft/client/Minecraft;II)V", at = @At("HEAD")) private void init(Minecraft minecraft, int i, int j, CallbackInfo ci) { - for (Consumer<Screen> consumer : ErrorDisplayerImpl.consumerList) { - consumer.accept((Screen) (Object) this); + if (!REI_IN.get()) { + REI_IN.set(true); + for (Consumer<Screen> consumer : ErrorDisplayerImpl.consumerList) { + consumer.accept((Screen) (Object) this); + } + REI_IN.set(false); } } } diff --git a/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/REIMixinPlugin.java b/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/REIMixinPlugin.java new file mode 100644 index 000000000..12f87038a --- /dev/null +++ b/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/REIMixinPlugin.java @@ -0,0 +1,71 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.mixin.fabric; + +import net.fabricmc.loader.api.FabricLoader; +import org.objectweb.asm.tree.ClassNode; +import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; + +import java.util.List; +import java.util.Set; + +public class REIMixinPlugin implements IMixinConfigPlugin { + @Override + public void onLoad(String mixinPackage) { + + } + + @Override + public String getRefMapperConfig() { + return null; + } + + @Override + public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { + if (mixinClassName.endsWith("MixinClientPacketListener")) + return FabricLoader.getInstance().isModLoaded("architectury"); + return true; + } + + @Override + public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) { + + } + + @Override + public List<String> getMixins() { + return null; + } + + @Override + public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } + + @Override + public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } +} |
