diff options
| author | shedaniel <daniel@shedaniel.me> | 2021-05-28 20:28:48 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2021-05-28 20:28:48 +0800 |
| commit | 0bde3511d83e54b990c3840573523d643cc843e9 (patch) | |
| tree | fed3512555478e521fb69edc717f6ac791c26b72 | |
| parent | df1c72250631fb89ffde9ecca7f47c1bdc44620a (diff) | |
| download | RoughlyEnoughItems-0bde3511d83e54b990c3840573523d643cc843e9.tar.gz RoughlyEnoughItems-0bde3511d83e54b990c3840573523d643cc843e9.tar.bz2 RoughlyEnoughItems-0bde3511d83e54b990c3840573523d643cc843e9.zip | |
Fix #540
40 files changed, 241 insertions, 746 deletions
diff --git a/api/build.gradle b/api/build.gradle index 40ea8f83d..8a5f988f3 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -1,4 +1,4 @@ -archivesBaseName = rootProject.name + "-" + project.name +archivesBaseName = rootProject.name + "-" + project.name dependencies { modCompileOnly("net.fabricmc:fabric-loader:${project.fabricloader_version}") diff --git a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java index 20bfdd767..571b6022a 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java @@ -58,10 +58,6 @@ public interface ConfigObject { boolean isGrabbingItems(); - boolean isConfigScreenAnimated(); - - boolean isCreditsScreenAnimated(); - boolean isFavoritesAnimated(); boolean isToastDisplayedOnCopyIdentifier(); @@ -92,8 +88,6 @@ public interface ConfigObject { int getMaxRecipePerPage(); - boolean doesShowUtilsButtons(); - boolean doesDisableRecipeBook(); boolean doesFixTabCloseContainer(); diff --git a/api/src/main/java/me/shedaniel/rei/api/client/view/Views.java b/api/src/main/java/me/shedaniel/rei/api/client/view/Views.java index 6ddd1b416..7280c4e6a 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/view/Views.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/view/Views.java @@ -38,8 +38,7 @@ public interface Views extends Reloadable<REIClientPlugin> { /** * Returns all craftable items from materials. * - * @param inventoryItems the materials * @return the list of craftable entries */ - Collection<EntryStack<?>> findCraftableEntriesByMaterials(Iterable<? extends EntryStack<?>> inventoryItems); + Collection<EntryStack<?>> findCraftableEntriesByMaterials(); } diff --git a/api/src/main/java/me/shedaniel/rei/api/common/display/DisplaySerializerRegistry.java b/api/src/main/java/me/shedaniel/rei/api/common/display/DisplaySerializerRegistry.java index 8b2c8c0e1..e1d62beb7 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/display/DisplaySerializerRegistry.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/display/DisplaySerializerRegistry.java @@ -27,8 +27,13 @@ import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.plugins.PluginManager; import me.shedaniel.rei.api.common.plugins.REIPlugin; import me.shedaniel.rei.api.common.registry.Reloadable; +import me.shedaniel.rei.api.common.transfer.info.MenuSerializationContext; import net.minecraft.nbt.CompoundTag; +/** + * The display serializer used for display transfers. + * This is mostly a fallback system for {@link me.shedaniel.rei.api.common.transfer.info.MenuInfo#save(MenuSerializationContext, Display)}. + */ public interface DisplaySerializerRegistry extends Reloadable<REIPlugin<?>> { static DisplaySerializerRegistry getInstance() { return PluginManager.getInstance().get(DisplaySerializerRegistry.class); @@ -37,9 +42,6 @@ public interface DisplaySerializerRegistry extends Reloadable<REIPlugin<?>> { /** * Registers a {@link DisplaySerializer} for serializing a {@link Display} for syncing across server-client, and * for serializing displays to disk for favorites. - * <p> - * Since REI 6, all {@link me.shedaniel.rei.api.client.registry.display.DisplayCategory} are required to register their serializers, - * or mark themselves as unavailable for serialization. * * @param categoryId the category identifier of the display * @param serializer the serializer of the display @@ -50,20 +52,15 @@ public interface DisplaySerializerRegistry extends Reloadable<REIPlugin<?>> { /** * Marks a {@link Display} as unavailable to sync across server-client, and * for serializing displays to disk for favorites. - * <p> - * Since REI 6, all {@link me.shedaniel.rei.api.client.registry.display.DisplayCategory} are required to register their serializers, - * or mark themselves as unavailable for serialization. * * @param categoryId the category identifier of the display * @param <D> the type of the display */ <D extends Display> void registerNotSerializable(CategoryIdentifier<D> categoryId); - <D extends Display> boolean hasRegistered(CategoryIdentifier<D> categoryId); - <D extends Display> boolean hasSerializer(CategoryIdentifier<D> categoryId); - <D extends Display> CompoundTag save(CategoryIdentifier<? extends D> categoryId, D display, CompoundTag tag); + <D extends Display> CompoundTag save(D display, CompoundTag tag); <D extends Display> D read(CategoryIdentifier<? extends D> categoryId, CompoundTag tag); } diff --git a/api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPlugin.java b/api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPlugin.java index 44998c914..35394feab 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPlugin.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPlugin.java @@ -23,6 +23,7 @@ package me.shedaniel.rei.api.common.plugins; +import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.common.display.DisplaySerializerRegistry; import me.shedaniel.rei.api.common.entry.comparison.FluidComparatorRegistry; import me.shedaniel.rei.api.common.entry.comparison.ItemComparatorRegistry; @@ -33,21 +34,21 @@ import org.jetbrains.annotations.ApiStatus; import java.util.Collection; import java.util.Collections; +/** + * Base interface for a REI plugin. + * + * @see REIServerPlugin + * @see REIClientPlugin + */ @ApiStatus.OverrideOnly public interface REIPlugin<P extends REIPlugin<?>> extends Comparable<REIPlugin<P>>, REIPluginProvider<P> { /** - * @return the priority of the plugin, the smaller the number, the earlier it is called. + * @return the priority of the plugin, the smaller the priority, the earlier it is called. */ - default int getPriority() { + default double getPriority() { return 0; } - default String getPluginName() { - Class<?> self = getClass(); - String simpleName = self.getSimpleName(); - return simpleName == null ? self.getName() : simpleName; - } - @Override default int compareTo(REIPlugin o) { return Double.compare(getPriority(), o.getPriority()); diff --git a/api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPluginProvider.java b/api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPluginProvider.java index 4380fb0cb..4f0f6d815 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPluginProvider.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPluginProvider.java @@ -25,6 +25,11 @@ package me.shedaniel.rei.api.common.plugins; import java.util.Collection; +/** + * A provider for {@link REIPlugin}. + * + * @param <P> the type of plugin + */ public interface REIPluginProvider<P extends REIPlugin<?>> { default String getPluginProviderName() { Class<?> self = getClass(); @@ -32,7 +37,18 @@ public interface REIPluginProvider<P extends REIPlugin<?>> { return simpleName == null ? self.getName() : simpleName; } + /** + * Provides the collection of REI plugins, can be dynamic. + * + * @return the collection of REI plugins. + */ Collection<P> provide(); + /** + * Returns the type of plugin this provider provides, + * should be same as {@link P}. + * + * @return the type of plugin this provider provides + */ Class<P> getPluginProviderClass(); } diff --git a/api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfo.java b/api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfo.java index d65b2b6eb..ca2ff4c41 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfo.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfo.java @@ -134,7 +134,7 @@ public interface MenuInfo<T extends AbstractContainerMenu, D extends Display> ex * @return the {@link CompoundTag} serialized */ default CompoundTag save(MenuSerializationContext<T, ?, D> context, D display) { - return DisplaySerializerRegistry.getInstance().save(display.getCategoryIdentifier(), display, new CompoundTag()); + return DisplaySerializerRegistry.getInstance().save(display, new CompoundTag()); } /** diff --git a/api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfoRegistry.java b/api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfoRegistry.java index 29942fcc0..44ca628b6 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfoRegistry.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfoRegistry.java @@ -29,6 +29,7 @@ import me.shedaniel.rei.api.common.plugins.PluginManager; import me.shedaniel.rei.api.common.plugins.REIServerPlugin; import me.shedaniel.rei.api.common.registry.Reloadable; import net.minecraft.world.inventory.AbstractContainerMenu; +import org.jetbrains.annotations.Nullable; import java.util.function.Predicate; @@ -44,6 +45,7 @@ public interface MenuInfoRegistry extends Reloadable<REIServerPlugin> { <D extends Display> void registerGeneric(Predicate<CategoryIdentifier<?>> categoryPredicate, MenuInfoProvider<?, D> menuInfo); + @Nullable <C extends AbstractContainerMenu, D extends Display> MenuInfo<C, D> get(CategoryIdentifier<D> category, Class<C> menuClass); int infoSize(); diff --git a/build.gradle b/build.gradle index e6a71eb19..132727672 100755 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id("architectury-plugin") version("3.1-SNAPSHOT") + id("architectury-plugin") version("3.2-SNAPSHOT") id("dev.architectury.loom") version("0.7.2-SNAPSHOT") apply false id("org.cadixdev.licenser") version("0.5.0") id("com.matthewprenger.cursegradle") version("1.4.0") @@ -41,6 +41,10 @@ allprojects { maven { url "https://maven.shedaniel.me" } maven { url "https://maven.terraformersmc.com/releases" } } + + architectury { + transformerVersion = "3.0.46" + } license { header rootProject.file("HEADER") diff --git a/default-plugin/build.gradle b/default-plugin/build.gradle index 1f0d45a41..01a2f1bed 100644 --- a/default-plugin/build.gradle +++ b/default-plugin/build.gradle @@ -1,4 +1,4 @@ -archivesBaseName = rootProject.name + "-" + project.name +archivesBaseName = rootProject.name + "-" + project.name loom { accessWidener = gradle.rootProject.project("fabric").file("src/main/resources/roughlyenoughitems.accessWidener") diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java index b63d5de93..bf5890660 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java @@ -26,11 +26,11 @@ package me.shedaniel.rei.plugin.client; import com.google.common.collect.Iterators; import com.google.common.collect.Lists; import com.google.common.collect.Sets; +import dev.architectury.injectables.annotations.ExpectPlatform; +import dev.architectury.injectables.annotations.PlatformOnly; import it.unimi.dsi.fastutil.objects.Object2FloatMap; import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; import it.unimi.dsi.fastutil.objects.ReferenceSet; -import me.shedaniel.architectury.annotations.ExpectPlatform; -import me.shedaniel.architectury.annotations.PlatformOnly; import me.shedaniel.architectury.platform.Platform; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.favorites.FavoriteEntry; @@ -44,7 +44,6 @@ import me.shedaniel.rei.api.client.registry.screen.ExclusionZones; import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry; import me.shedaniel.rei.api.client.registry.transfer.TransferHandlerRegistry; import me.shedaniel.rei.api.common.entry.EntryIngredient; -import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; import me.shedaniel.rei.api.common.util.CollectionUtils; import me.shedaniel.rei.api.common.util.EntryIngredients; import me.shedaniel.rei.api.common.util.EntryStacks; @@ -357,7 +356,7 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin } @Override - public int getPriority() { + public double getPriority() { return -100; } diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/DefaultPlugin.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/DefaultPlugin.java index fe7aa4ca8..e07fc1b15 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/DefaultPlugin.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/DefaultPlugin.java @@ -23,8 +23,8 @@ package me.shedaniel.rei.plugin.common; -import me.shedaniel.architectury.annotations.ExpectPlatform; -import me.shedaniel.architectury.annotations.PlatformOnly; +import dev.architectury.injectables.annotations.ExpectPlatform; +import dev.architectury.injectables.annotations.PlatformOnly; import me.shedaniel.architectury.hooks.FluidStackHooks; import me.shedaniel.architectury.platform.Platform; import me.shedaniel.architectury.utils.NbtType; @@ -56,11 +56,13 @@ import net.minecraft.world.item.BucketItem; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.material.Fluid; +import org.jetbrains.annotations.ApiStatus; import java.util.List; import java.util.function.Function; import java.util.stream.Stream; +@ApiStatus.Internal public class DefaultPlugin implements BuiltinPlugin, REIServerPlugin { @Override public void registerItemComparators(ItemComparatorRegistry registry) { @@ -141,7 +143,7 @@ public class DefaultPlugin implements BuiltinPlugin, REIServerPlugin { } @Override - public int getPriority() { + public double getPriority() { return -100; } } diff --git a/runtime/build.gradle b/runtime/build.gradle index a424f888c..a697d1016 100644 --- a/runtime/build.gradle +++ b/runtime/build.gradle @@ -1,4 +1,4 @@ -archivesBaseName = rootProject.name + "-" + project.name +archivesBaseName = rootProject.name + "-" + project.name architectury { common(forgeEnabled.toBoolean()) diff --git a/runtime/src/main/java/me/shedaniel/rei/PluginDetector.java b/runtime/src/main/java/me/shedaniel/rei/PluginDetector.java index 56d7c65c7..28592bcf3 100644 --- a/runtime/src/main/java/me/shedaniel/rei/PluginDetector.java +++ b/runtime/src/main/java/me/shedaniel/rei/PluginDetector.java @@ -23,7 +23,7 @@ package me.shedaniel.rei; -import me.shedaniel.architectury.annotations.ExpectPlatform; +import dev.architectury.injectables.annotations.ExpectPlatform; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java index 1edb3c221..eec3d7514 100644 --- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java +++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java @@ -71,7 +71,7 @@ import me.shedaniel.rei.impl.client.REIHelperImpl; import me.shedaniel.rei.impl.client.config.ConfigManagerImpl; import me.shedaniel.rei.impl.client.entry.type.types.RenderingEntryDefinition; import me.shedaniel.rei.impl.client.favorites.FavoriteEntryTypeRegistryImpl; -import me.shedaniel.rei.impl.client.gui.ContainerScreenOverlay; +import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl; import me.shedaniel.rei.impl.client.gui.widget.InternalWidgets; import me.shedaniel.rei.impl.client.gui.widget.QueuedTooltip; import me.shedaniel.rei.impl.client.registry.category.CategoryRegistryImpl; @@ -574,7 +574,7 @@ public class RoughlyEnoughItemsCore { return; resetFocused(screen); REIHelper.getInstance().getOverlay().get().render(matrices, mouseX, mouseY, delta); - ((ContainerScreenOverlay) REIHelper.getInstance().getOverlay().get()).lateRender(matrices, mouseX, mouseY, delta); + ((ScreenOverlayImpl) REIHelper.getInstance().getOverlay().get()).lateRender(matrices, mouseX, mouseY, delta); resetFocused(screen); }); ClientScreenInputEvent.MOUSE_DRAGGED_PRE.register((minecraftClient, screen, mouseX1, mouseY1, button, mouseX2, mouseY2) -> { diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsInitializer.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsInitializer.java index 78f118501..0ee468267 100644 --- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsInitializer.java +++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsInitializer.java @@ -23,7 +23,7 @@ package me.shedaniel.rei; -import me.shedaniel.architectury.annotations.ExpectPlatform; +import dev.architectury.injectables.annotations.ExpectPlatform; import net.fabricmc.api.EnvType; import java.lang.reflect.InvocationTargetException; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java index 849856165..140c1edc1 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java @@ -24,6 +24,8 @@ package me.shedaniel.rei.impl.client; import io.netty.buffer.Unpooled; +import it.unimi.dsi.fastutil.longs.LongOpenHashSet; +import it.unimi.dsi.fastutil.longs.LongSet; import me.shedaniel.architectury.networking.NetworkManager; import me.shedaniel.architectury.platform.Platform; import me.shedaniel.rei.RoughlyEnoughItemsNetwork; @@ -65,7 +67,6 @@ import org.jetbrains.annotations.Nullable; import java.time.LocalDateTime; import java.util.*; import java.util.function.Supplier; -import java.util.stream.Collectors; @ApiStatus.Internal @Environment(EnvType.CLIENT) @@ -215,11 +216,12 @@ public class ClientHelperImpl implements ClientHelper { } @ApiStatus.Internal - public Set<EntryStack<?>> _getInventoryItemsTypes() { + public LongSet _getInventoryItemsTypes() { return Minecraft.getInstance().player.inventory.compartments.stream() .flatMap(Collection::stream) .map(EntryStacks::of) - .collect(Collectors.toSet()); + .mapToLong(EntryStacks::hashExact) + .collect(LongOpenHashSet::new, LongOpenHashSet::add, LongOpenHashSet::addAll); } @ApiStatus.Internal diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/ErrorDisplayer.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/ErrorDisplayer.java index b6eb5da51..12bf9da50 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/ErrorDisplayer.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/ErrorDisplayer.java @@ -23,7 +23,7 @@ package me.shedaniel.rei.impl.client; -import me.shedaniel.architectury.annotations.ExpectPlatform; +import dev.architectury.injectables.annotations.ExpectPlatform; import me.shedaniel.rei.RoughlyEnoughItemsState; import me.shedaniel.rei.impl.client.gui.screen.WarningAndErrorScreen; import net.minecraft.client.Minecraft; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/REIHelperImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/REIHelperImpl.java index 4f44c5fe4..731b2a996 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/REIHelperImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/REIHelperImpl.java @@ -30,15 +30,15 @@ import me.shedaniel.architectury.event.events.GuiEvent; import me.shedaniel.architectury.event.events.client.ClientTickEvent; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.REIHelper; -import me.shedaniel.rei.api.client.overlay.ScreenOverlay; import me.shedaniel.rei.api.client.config.ConfigManager; import me.shedaniel.rei.api.client.config.ConfigObject; import me.shedaniel.rei.api.client.gui.config.SearchFieldLocation; import me.shedaniel.rei.api.client.gui.screen.DisplayScreen; import me.shedaniel.rei.api.client.gui.widgets.TextField; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; +import me.shedaniel.rei.api.client.overlay.ScreenOverlay; import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry; -import me.shedaniel.rei.impl.client.gui.ContainerScreenOverlay; +import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl; import me.shedaniel.rei.impl.client.gui.widget.search.OverlaySearchField; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @@ -60,7 +60,7 @@ public class REIHelperImpl implements REIHelper { private static final ResourceLocation DISPLAY_TEXTURE_DARK = new |
