diff --git a/fabric/src/main/java/net/blay09/mods/refinedrelocation/FabricRefinedRelocation.java b/fabric/src/main/java/net/blay09/mods/refinedrelocation/FabricRefinedRelocation.java index cd5313a..872d00e 100644 --- a/fabric/src/main/java/net/blay09/mods/refinedrelocation/FabricRefinedRelocation.java +++ b/fabric/src/main/java/net/blay09/mods/refinedrelocation/FabricRefinedRelocation.java @@ -1,11 +1,37 @@ package net.blay09.mods.refinedrelocation; import net.blay09.mods.balm.api.Balm; +import net.blay09.mods.balm.api.DeferredObject; +import net.blay09.mods.balm.common.BalmBlockEntity; +import net.blay09.mods.balm.fabric.provider.FabricBalmProviders; +import net.blay09.mods.refinedrelocation.api.filter.IMultiRootFilter; +import net.blay09.mods.refinedrelocation.api.filter.IRootFilter; +import net.blay09.mods.refinedrelocation.api.grid.ISortingGridMember; +import net.blay09.mods.refinedrelocation.block.entity.ModBlockEntities; import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.lookup.v1.block.BlockApiLookup; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.block.entity.BlockEntityType; public class FabricRefinedRelocation implements ModInitializer { @Override public void onInitialize() { Balm.initialize(RefinedRelocation.MOD_ID, RefinedRelocation::initialize); + + registerProvider("sorting_grid_member", ISortingGridMember.class, ModBlockEntities.sortingChests.stream().map(DeferredObject::get).toArray(BlockEntityType[]::new)); + registerProvider("root_filter", IRootFilter.class, ModBlockEntities.sortingChests.stream().map(DeferredObject::get).toArray(BlockEntityType[]::new)); + registerProvider("multi_root_filter", IMultiRootFilter.class, ModBlockEntities.sortingChests.stream().map(DeferredObject::get).toArray(BlockEntityType[]::new)); + } + + private void registerProvider(String name, Class clazz, BlockEntityType... blockEntities) { + var providers = ((FabricBalmProviders) Balm.getProviders()); + ResourceLocation identifier = new ResourceLocation(RefinedRelocation.MOD_ID, name); + providers.registerProvider(identifier, clazz); + registerLookup(identifier, clazz, blockEntities); + } + + private void registerLookup(ResourceLocation identifier, Class clazz, BlockEntityType... blockEntities) { + var lookup = BlockApiLookup.get(identifier, clazz, Void.class); + lookup.registerForBlockEntities((blockEntity, context) -> ((BalmBlockEntity) blockEntity).getProvider(clazz), blockEntities); } } diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index d85c939..12cf8b3 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -10,9 +10,9 @@ "ZerotS" ], "contact": { - "homepage": "https://blay09.net/mods/refinedrelocation", - "sources": "https://github.com/ModdingForBlockheads/RefinedRelocation2", - "issues": "https://github.com/ModdingForBlockheads/RefinedRelocation2/issues" + "homepage": "https://mods.twelveiterations.com/mc/refined-relocation/", + "sources": "https://github.com/TwelveIterationMods/RefinedRelocation2", + "issues": "https://github.com/TwelveIterationMods/RefinedRelocation2/issues" }, "license": "All Rights Reserved", @@ -34,11 +34,10 @@ "refinedrelocation.mixins.json" ], "depends": { - "cloth-config2": ">=5.0.34", - "balm-fabric": ">=4.2.0", - "fabricloader": ">=0.14.7", + "balm-fabric": ">=7.0.0", + "fabricloader": ">=0.14.21", "fabric": "*", - "minecraft": "1.19.x", + "minecraft": ">=1.20", "java": ">=17" }, "suggests": { @@ -47,7 +46,7 @@ "custom": { "modmenu": { "links": { - "modmenu.discord": "https://discord.gg/scGAfXC" + "modmenu.discord": "https://discord.gg/VAfZ2Nau6j" } } } diff --git a/fabric/src/main/resources/refinedrelocation.mixins.json b/fabric/src/main/resources/refinedrelocation.mixins.json index 31aaa58..6fcbdb6 100644 --- a/fabric/src/main/resources/refinedrelocation.mixins.json +++ b/fabric/src/main/resources/refinedrelocation.mixins.json @@ -4,8 +4,7 @@ "package": "net.blay09.mods.refinedrelocation.mixin", "compatibilityLevel": "JAVA_17", "mixins": [ - "AbstractContainerMenuAccessor", - "CreativeModeTabAccessor" + "AbstractContainerMenuAccessor" ], "client": [ "LevelRendererAccessor", diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index a5c354d..82add24 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -1,13 +1,13 @@ modLoader="javafml" -loaderVersion="[41,)" +loaderVersion="${forge_loader_version_range}" license="All rights reserved" -issueTrackerURL="https://github.com/ModdingForBlockheads/RefinedRelocation2/issues" +issueTrackerURL="https://github.com/TwelveIterationMods/RefinedRelocation2/issues" [[mods]] modId="refinedrelocation" version="${file.jarVersion}" displayName="Refined Relocation" -displayURL="https://blay09.net/mods/refinedrelocation" +displayURL="https://mods.twelveiterations.com/mc/refined-relocation" logoFile="refinedrelocation-icon.png" credits="BlayTheNinth" authors="BlayTheNinth" @@ -18,18 +18,18 @@ Adds sorting networks, filter systems, block extenders and more. [[dependencies.refinedrelocation]] modId="forge" mandatory=true - versionRange="[41,)" + versionRange="${forge_version_range}" ordering="NONE" side="BOTH" [[dependencies.refinedrelocation]] modId="minecraft" mandatory=true - versionRange="[1.19,1.20)" + versionRange="${minecraft_version_range}" ordering="NONE" side="BOTH" [[dependencies.refinedrelocation]] modId="balm" mandatory=true - versionRange="[4.2.0,)" + versionRange="${balm_version_range}" ordering="NONE" side="BOTH" diff --git a/forge/src/main/resources/refinedrelocation.mixins.json b/forge/src/main/resources/refinedrelocation.mixins.json index 0b926e5..3f46635 100644 --- a/forge/src/main/resources/refinedrelocation.mixins.json +++ b/forge/src/main/resources/refinedrelocation.mixins.json @@ -5,8 +5,7 @@ "compatibilityLevel": "JAVA_17", "refmap": "refinedrelocation.refmap.json", "mixins": [ - "AbstractContainerMenuAccessor", - "CreativeModeTabAccessor" + "AbstractContainerMenuAccessor" ], "client": [ "LevelRendererAccessor",