diff options
| author | shedaniel <daniel@shedaniel.me> | 2023-06-01 16:58:17 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2023-06-01 16:58:17 +0800 |
| commit | a6e09ed07e4079cc1bfa10776b79d4a32bca941e (patch) | |
| tree | dae7d67eeebd2993a5ecdc2b8d337d41c1127fb9 /forge/src/main | |
| parent | 981d975f0e1ddff61bfedd0d45ecbe0803372d8e (diff) | |
| parent | 31d1e1935eae254ba2ff18df57dcd8ad9d9b0fa5 (diff) | |
| download | RoughlyEnoughItems-a6e09ed07e4079cc1bfa10776b79d4a32bca941e.tar.gz RoughlyEnoughItems-a6e09ed07e4079cc1bfa10776b79d4a32bca941e.tar.bz2 RoughlyEnoughItems-a6e09ed07e4079cc1bfa10776b79d4a32bca941e.zip | |
Merge remote-tracking branch 'shedaniel/9.x-1.19' into 10.x-1.19.3
Diffstat (limited to 'forge/src/main')
| -rw-r--r-- | forge/src/main/java/me/shedaniel/rei/mixin/forge/MixinInputConstantsKey.java | 57 | ||||
| -rw-r--r-- | forge/src/main/resources/rei.mixins.json | 1 |
2 files changed, 58 insertions, 0 deletions
diff --git a/forge/src/main/java/me/shedaniel/rei/mixin/forge/MixinInputConstantsKey.java b/forge/src/main/java/me/shedaniel/rei/mixin/forge/MixinInputConstantsKey.java new file mode 100644 index 000000000..df0348de1 --- /dev/null +++ b/forge/src/main/java/me/shedaniel/rei/mixin/forge/MixinInputConstantsKey.java @@ -0,0 +1,57 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023 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.forge; + +import com.mojang.blaze3d.platform.InputConstants; +import com.mojang.blaze3d.systems.RenderSystem; +import me.shedaniel.rei.api.client.config.ConfigObject; +import net.minecraft.network.chat.Component; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +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.CallbackInfoReturnable; + +@Mixin(InputConstants.Key.class) +public abstract class MixinInputConstantsKey { + @Shadow + public abstract String getName(); + + @Inject(method = "getDisplayName", at = @At("HEAD"), cancellable = true) + private void getDisplayName(CallbackInfoReturnable<Component> cir) { + if (isPatchingAsyncThreadCrash() && !RenderSystem.isOnRenderThread()) { + cir.setReturnValue(Component.translatable(getName())); + } + } + + @Unique + private static boolean isPatchingAsyncThreadCrash() { + try { + return ConfigObject.getInstance().isPatchingAsyncThreadCrash(); + } catch (Throwable throwable) { + return false; + } + } +} diff --git a/forge/src/main/resources/rei.mixins.json b/forge/src/main/resources/rei.mixins.json index 838df45f2..e95039402 100644 --- a/forge/src/main/resources/rei.mixins.json +++ b/forge/src/main/resources/rei.mixins.json @@ -7,6 +7,7 @@ "MixinEffectRenderingInventoryScreen", "MixinFontSet", "MixinInputConstants", + "MixinInputConstantsKey", "MixinRecipeToast" ], "mixins": [ |
