aboutsummaryrefslogtreecommitdiff
path: root/fabric
diff options
context:
space:
mode:
Diffstat (limited to 'fabric')
-rw-r--r--fabric/build.gradle4
-rw-r--r--fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java3
-rw-r--r--fabric/src/main/java/me/shedaniel/rei/impl/client/gui/credits/fabric/CreditsScreenImpl.java69
-rw-r--r--fabric/src/main/java/me/shedaniel/rei/impl/client/gui/fabric/ScreenOverlayImplFabric.java1
-rw-r--r--fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagBuilder.java12
-rw-r--r--fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagLoader.java100
-rw-r--r--fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagManager.java10
-rw-r--r--fabric/src/main/resources/rei.mixins.json8
8 files changed, 68 insertions, 139 deletions
diff --git a/fabric/build.gradle b/fabric/build.gradle
index fcbea68b6..6f693ef10 100644
--- a/fabric/build.gradle
+++ b/fabric/build.gradle
@@ -35,7 +35,7 @@ dependencies {
}
//modRuntime("com.terraformersmc:modmenu:${modmenu_version}") { transitive false }
modApi("me.shedaniel:architectury-fabric:${architectury_version}")
- modApi("me.shedaniel:error-notifier-fabric:1.0.9")
+ modCompileOnly("me.shedaniel:error-notifier-fabric:1.0.9")
include("me.shedaniel:error-notifier-fabric:1.0.9")
depProjects.forEach {
@@ -135,7 +135,7 @@ unifiedPublishing {
}
}
- if (false && (project.hasProperty("modrinth_key") || System.getenv("modrinth_key") != null) {
+ if (false && (project.hasProperty("modrinth_key") || System.getenv("modrinth_key") != null)) {
modrinth {
token = project.hasProperty("modrinth_key") ? project.property("modrinth_key") : System.getenv("modrinth_key")
id = "nfn13YXA"
diff --git a/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java b/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java
index 695a0abdf..4c985658f 100644
--- a/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java
+++ b/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java
@@ -28,6 +28,8 @@ import me.shedaniel.architectury.utils.Env;
import me.shedaniel.rei.RoughlyEnoughItemsState;
import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
import me.shedaniel.rei.api.common.plugins.*;
+import me.shedaniel.rei.impl.init.PluginDetector;
+import me.shedaniel.rei.impl.init.PrimitivePlatformAdapter;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.loader.api.FabricLoader;
@@ -36,6 +38,7 @@ import org.apache.commons.lang3.tuple.Pair;
import java.util.*;
import java.util.function.Consumer;
+import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
diff --git a/fabric/src/main/java/me/shedaniel/rei/impl/client/gui/credits/fabric/CreditsScreenImpl.java b/fabric/src/main/java/me/shedaniel/rei/impl/client/gui/credits/fabric/CreditsScreenImpl.java
deleted file mode 100644
index 86c1f5248..000000000
--- a/fabric/src/main/java/me/shedaniel/rei/impl/client/gui/credits/fabric/CreditsScreenImpl.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.impl.client.gui.credits.fabric;
-
-import com.google.common.collect.Lists;
-import me.shedaniel.rei.impl.client.gui.credits.CreditsScreen;
-import net.fabricmc.loader.api.FabricLoader;
-import net.fabricmc.loader.api.metadata.CustomValue;
-import net.minecraft.util.Tuple;
-
-import java.util.Comparator;
-import java.util.List;
-import java.util.stream.Collectors;
-
-public class CreditsScreenImpl {
- public static void fillTranslators(Exception[] exception, List<Tuple<String, List<CreditsScreen.TranslatorEntry>>> translators) {
- FabricLoader.getInstance().getModContainer("roughlyenoughitems").ifPresent(rei -> {
- try {
- if (rei.getMetadata().containsCustomValue("rei:translators")) {
- CustomValue.CvObject jsonObject = rei.getMetadata().getCustomValue("rei:translators").getAsObject();
- jsonObject.forEach(entry -> {
- CustomValue value = entry.getValue();
- List<CreditsScreen.TranslatorEntry> behind = value.getType() == CustomValue.CvType.ARRAY ? Lists.newArrayList(value.getAsArray().iterator()).stream()
- .map(customValue -> {
- if (customValue.getType() == CustomValue.CvType.OBJECT) {
- CustomValue.CvObject object = customValue.getAsObject();
- // name and proofreader
- String name = object.get("name").getAsString();
- boolean proofreader = object.containsKey("proofreader") && object.get("proofreader").getAsBoolean();
- return new CreditsScreen.TranslatorEntry(name, proofreader);
- } else {
- return new CreditsScreen.TranslatorEntry(customValue.getAsString(), false);
- }
- })
- .sorted(Comparator.comparing(CreditsScreen.TranslatorEntry::getName, String::compareToIgnoreCase))
- .collect(Collectors.toList())
- : Lists.newArrayList(new CreditsScreen.TranslatorEntry(value.getAsString()));
- translators.add(new Tuple<>(entry.getKey(), behind));
- });
- }
- translators.sort(Comparator.comparing(Tuple::getA, String::compareToIgnoreCase));
- } catch (Exception e) {
- exception[0] = e;
- e.printStackTrace();
- }
- });
- }
-}
diff --git a/fabric/src/main/java/me/shedaniel/rei/impl/client/gui/fabric/ScreenOverlayImplFabric.java b/fabric/src/main/java/me/shedaniel/rei/impl/client/gui/fabric/ScreenOverlayImplFabric.java
index 29559389c..3bc074c94 100644
--- a/fabric/src/main/java/me/shedaniel/rei/impl/client/gui/fabric/ScreenOverlayImplFabric.java
+++ b/fabric/src/main/java/me/shedaniel/rei/impl/client/gui/fabric/ScreenOverlayImplFabric.java
@@ -25,6 +25,7 @@ package me.shedaniel.rei.impl.client.gui.fabric;
import com.mojang.blaze3d.vertex.PoseStack;
import me.shedaniel.rei.api.client.gui.widgets.Tooltip;
+import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.locale.Language;
diff --git a/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagBuilder.java b/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagBuilder.java
index c56f2a8c4..9a9db18f2 100644
--- a/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagBuilder.java
+++ b/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagBuilder.java
@@ -61,22 +61,26 @@ public class MixinTagBuilder<T> {
List<ResourceLocation> otherTags = new ArrayList<>();
for (Tag.BuilderEntry builderEntry : this.entries) {
- if (builderEntry.entry() instanceof Tag.OptionalTagEntry tagEntry) {
+ if (builderEntry.getEntry() instanceof Tag.OptionalTagEntry) {
+ Tag.OptionalTagEntry tagEntry = (Tag.OptionalTagEntry) builderEntry.getEntry();
Tag<T> apply = tagResolver.apply(tagEntry.id);
if (apply != null) {
otherTags.add(tagEntry.id);
}
- } else if (builderEntry.entry() instanceof Tag.TagEntry tagEntry) {
+ } else if (builderEntry.getEntry() instanceof Tag.TagEntry) {
+ Tag.TagEntry tagEntry = (Tag.TagEntry) builderEntry.getEntry();
Tag<T> apply = tagResolver.apply(tagEntry.id);
if (apply != null) {
otherTags.add(tagEntry.id);
}
- } else if (builderEntry.entry() instanceof Tag.OptionalElementEntry tagEntry) {
+ } else if (builderEntry.getEntry() instanceof Tag.OptionalElementEntry) {
+ Tag.OptionalElementEntry tagEntry = (Tag.OptionalElementEntry) builderEntry.getEntry();
T apply = valueResolver.apply(tagEntry.id);
if (apply != null) {
otherElements.add(tagEntry.id);
}
- } else if (builderEntry.entry() instanceof Tag.ElementEntry tagEntry) {
+ } else if (builderEntry.getEntry() instanceof Tag.ElementEntry) {
+ Tag.ElementEntry tagEntry = (Tag.ElementEntry) builderEntry.getEntry();
T apply = valueResolver.apply(tagEntry.id);
if (apply != null) {
otherElements.add(tagEntry.id);
diff --git a/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagLoader.java b/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagLoader.java
index 8fdbd1086..b29774fdb 100644
--- a/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagLoader.java
+++ b/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagLoader.java
@@ -28,7 +28,6 @@ import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
-import it.unimi.dsi.fastutil.objects.Reference2ObjectMaps;
import me.shedaniel.rei.api.common.util.CollectionUtils;
import me.shedaniel.rei.impl.common.InternalLogger;
import me.shedaniel.rei.plugin.common.displays.tag.TagNodes;
@@ -36,7 +35,6 @@ import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.Tag;
-import net.minecraft.tags.TagKey;
import net.minecraft.tags.TagLoader;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@@ -51,53 +49,53 @@ import java.util.*;
public class MixinTagLoader<T> {
@Shadow @Final private String directory;
- @Inject(method = "build", at = @At("HEAD"))
- private void load(Map<ResourceLocation, Tag.Builder> map, CallbackInfoReturnable<Map<ResourceLocation, Tag<T>>> cir) {
- TagNodes.RAW_TAG_DATA_MAP.put(directory, new HashMap<>());
- TagNodes.CURRENT_TAG_DIR.set(directory);
- }
-
- @Inject(method = "build", at = @At("RETURN"))
- private void loadPost(Map<ResourceLocation, Tag.Builder> map, CallbackInfoReturnable<Map<ResourceLocation, Tag<T>>> cir) {
- Map<Tag<T>, ResourceLocation> inverseMap = new HashMap<>(cir.getReturnValue().size());
- for (Map.Entry<ResourceLocation, Tag<T>> entry : cir.getReturnValue().entrySet()) {
- inverseMap.put(entry.getValue(), entry.getKey());
- }
- ResourceKey<? extends Registry<?>> resourceKey = TagNodes.TAG_DIR_MAP.get(directory);
- if (resourceKey == null) return;
- TagNodes.TAG_DATA_MAP.put(resourceKey, new HashMap<>());
- Map<ResourceLocation, TagNodes.TagData> tagDataMap = TagNodes.TAG_DATA_MAP.get(resourceKey);
- if (tagDataMap == null) return;
- Registry<T> registry = ((Registry<Registry<T>>) Registry.REGISTRY).get((ResourceKey<Registry<T>>) resourceKey);
- Stopwatch stopwatch = Stopwatch.createStarted();
-
- Iterator<Map.Entry<Tag<?>, TagNodes.RawTagData>> entryIterator = TagNodes.RAW_TAG_DATA_MAP.getOrDefault(directory, Collections.emptyMap())
- .entrySet().iterator();
-
- if (!entryIterator.hasNext()) return;
-
- while (entryIterator.hasNext()) {
- Map.Entry<Tag<?>, TagNodes.RawTagData> entry = entryIterator.next();
- Tag<?> tag = entry.getKey();
- entryIterator.remove();
-
- if (registry != null) {
- ResourceLocation tagLoc = inverseMap.get(tag);
-
- if (tagLoc != null) {
- TagNodes.RawTagData rawTagData = entry.getValue();
- IntList elements = new IntArrayList();
- for (ResourceLocation element : rawTagData.otherElements()) {
- T t = registry.get(element);
- if (t != null) {
- elements.add(registry.getId(t));
- }
- }
- tagDataMap.put(tagLoc, new TagNodes.TagData(elements, rawTagData.otherTags()));
- }
- }
- }
-
- InternalLogger.getInstance().debug("Processed %d tags in %s for %s", tagDataMap.size(), stopwatch.stop(), resourceKey.location());
- }
+// @Inject(method = "build", at = @At("HEAD"))
+// private void load(Map<ResourceLocation, Tag.Builder> map, CallbackInfoReturnable<Map<ResourceLocation, Tag<T>>> cir) {
+// TagNodes.RAW_TAG_DATA_MAP.put(directory, new HashMap<>());
+// TagNodes.CURRENT_TAG_DIR.set(directory);
+// }
+//
+// @Inject(method = "build", at = @At("RETURN"))
+// private void loadPost(Map<ResourceLocation, Tag.Builder> map, CallbackInfoReturnable<Map<ResourceLocation, Tag<T>>> cir) {
+// Map<Tag<T>, ResourceLocation> inverseMap = new HashMap<>(cir.getReturnValue().size());
+// for (Map.Entry<ResourceLocation, Tag<T>> entry : cir.getReturnValue().entrySet()) {
+// inverseMap.put(entry.getValue(), entry.getKey());
+// }
+// ResourceKey<? extends Registry<?>> resourceKey = TagNodes.TAG_DIR_MAP.get(directory);
+// if (resourceKey == null) return;
+// TagNodes.TAG_DATA_MAP.put(resourceKey, new HashMap<>());
+// Map<ResourceLocation, TagNodes.TagData> tagDataMap = TagNodes.TAG_DATA_MAP.get(resourceKey);
+// if (tagDataMap == null) return;
+// Registry<T> registry = ((Registry<Registry<T>>) Registry.REGISTRY).get((ResourceKey<Registry<T>>) resourceKey);
+// Stopwatch stopwatch = Stopwatch.createStarted();
+//
+// Iterator<Map.Entry<Tag<?>, TagNodes.RawTagData>> entryIterator = TagNodes.RAW_TAG_DATA_MAP.getOrDefault(directory, Collections.emptyMap())
+// .entrySet().iterator();
+//
+// if (!entryIterator.hasNext()) return;
+//
+// while (entryIterator.hasNext()) {
+// Map.Entry<Tag<?>, TagNodes.RawTagData> entry = entryIterator.next();
+// Tag<?> tag = entry.getKey();
+// entryIterator.remove();
+//
+// if (registry != null) {
+// ResourceLocation tagLoc = inverseMap.get(tag);
+//
+// if (tagLoc != null) {
+// TagNodes.RawTagData rawTagData = entry.getValue();
+// IntList elements = new IntArrayList();
+// for (ResourceLocation element : rawTagData.otherElements()) {
+// T t = registry.get(element);
+// if (t != null) {
+// elements.add(registry.getId(t));
+// }
+// }
+// tagDataMap.put(tagLoc, new TagNodes.TagData(elements, rawTagData.otherTags()));
+// }
+// }
+// }
+//
+// InternalLogger.getInstance().debug("Processed %d tags in %s for %s", tagDataMap.size(), stopwatch.stop(), resourceKey.location());
+// }
}
diff --git a/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagManager.java b/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagManager.java
index c872f4395..f34271a98 100644
--- a/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagManager.java
+++ b/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinTagManager.java
@@ -39,9 +39,9 @@ import java.util.concurrent.Executor;
@Mixin(TagManager.class)
public abstract class MixinTagManager<T> {
- @Inject(method = "createLoader", at = @At("HEAD"))
- private void load(ResourceManager resourceManager, Executor executor, RegistryAccess.RegistryEntry<T> registryEntry, CallbackInfoReturnable<CompletableFuture<TagManager.LoadResult<T>>> cir) {
- ResourceKey<? extends Registry<T>> resourceKey = registryEntry.key();
- TagNodes.TAG_DIR_MAP.put(TagManager.getTagDir(resourceKey), resourceKey);
- }
+// @Inject(method = "createLoader", at = @At("HEAD"))
+// private void load(ResourceManager resourceManager, Executor executor, RegistryAccess.RegistryEntry<T> registryEntry, CallbackInfoReturnable<CompletableFuture<TagManager.LoadResult<T>>> cir) {
+// ResourceKey<? extends Registry<T>> resourceKey = registryEntry.key();
+// TagNodes.TAG_DIR_MAP.put(TagManager.getTagDir(resourceKey), resourceKey);
+// }
}
diff --git a/fabric/src/main/resources/rei.mixins.json b/fabric/src/main/resources/rei.mixins.json
index 7a7630703..7ea4f0b35 100644
--- a/fabric/src/main/resources/rei.mixins.json
+++ b/fabric/src/main/resources/rei.mixins.json
@@ -3,16 +3,8 @@
"package": "me.shedaniel.rei.mixin.fabric",
"compatibilityLevel": "JAVA_8",
"client": [
- "MixinClientPacketListener",
- "MixinInputConstants",
- "MixinRecipeToast",
- "MixinScreen"
],
"mixins": [
- "MixinPacketEncoder",
- "MixinTagBuilder",
- "MixinTagLoader",
- "MixinTagManager"
],
"injectors": {
"maxShiftBy": 5,