From ede58f42456ebcd39d1c0a81e6b651203dcd6191 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Sat, 7 Dec 2024 16:04:01 +0100 Subject: [PATCH] feat: introduce client api --- .../common/api/RefinedStorageApi.java | 22 ---- .../common/api/RefinedStorageApiProxy.java | 41 ------- .../common/api/RefinedStorageClientApi.java | 49 ++++++++ .../api/RefinedStorageClientApiProxy.java | 90 +++++++++++++++ .../storage/StorageContainerItemHelper.java | 10 -- .../common/AbstractClientModInitializer.java | 45 ++++---- .../common/RefinedStorageApiImpl.java | 58 ---------- .../common/RefinedStorageClientApiImpl.java | 107 ++++++++++++++++++ ...CraftingPatternClientTooltipComponent.java | 4 +- ...ocessingPatternClientTooltipComponent.java | 6 +- ...ingTablePatternClientTooltipComponent.java | 6 +- ...necutterPatternClientTooltipComponent.java | 6 +- .../AutocrafterManagerContainerMenu.java | 3 +- .../monitor/AutocraftingMonitorScreen.java | 6 +- .../monitor/AutocraftingTaskButton.java | 6 +- ...singMatrixInputClientTooltipComponent.java | 6 +- .../preview/AutocraftingPreviewScreen.java | 6 +- .../preview/AutocraftingRequestButton.java | 6 +- .../common/content/BlockEntities.java | 20 ++-- .../grid/screen/AbstractGridScreen.java | 6 +- .../screen/hint/FluidGridInsertionHint.java | 7 +- .../common/grid/view/FluidGridResource.java | 4 +- .../StorageContainerItemHelperImpl.java | 26 ----- .../FluidStorageBlockBlockItem.java | 3 +- .../FluidStorageBlockProvider.java | 8 +- .../ItemStorageBlockProvider.java | 6 - .../storage/storageblock/StorageBlock.java | 1 + .../storagedisk/FluidStorageDiskItem.java | 3 +- .../StorageMonitorBlockEntityRenderer.java | 4 +- .../common/support/AbstractBaseScreen.java | 3 +- .../common/support/ResourceSlotRendering.java | 4 +- .../resource/FluidResourceRendering.java | 12 +- .../resource/ItemResourceRendering.java | 7 +- .../tooltip/MouseClientTooltipComponent.java | 4 +- .../ResourceClientTooltipComponent.java | 6 +- .../fabric/ClientModInitializerImpl.java | 24 ++-- .../diskdrive/DiskDriveUnbakedModel.java | 9 +- .../DiskInterfaceUnbakedModel.java | 8 +- .../PortableGridUnbakedModel.java | 6 +- .../neoforge/ModInitializer.java | 2 + .../diskdrive/DiskDriveUnbakedGeometry.java | 4 +- .../DiskInterfaceUnbakedGeometry.java | 4 +- .../PortableGridUnbakedGeometry.java | 4 +- .../support/render/DiskModelBaker.java | 5 +- 44 files changed, 383 insertions(+), 284 deletions(-) create mode 100644 refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/RefinedStorageClientApi.java create mode 100644 refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/RefinedStorageClientApiProxy.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/RefinedStorageClientApiImpl.java diff --git a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/RefinedStorageApi.java b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/RefinedStorageApi.java index b73c87c1f..9c470730f 100644 --- a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/RefinedStorageApi.java +++ b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/RefinedStorageApi.java @@ -7,14 +7,10 @@ import com.refinedmods.refinedstorage.api.network.energy.EnergyStorage; import com.refinedmods.refinedstorage.api.network.node.NetworkNode; import com.refinedmods.refinedstorage.api.network.security.SecurityPolicy; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; -import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.common.api.constructordestructor.ConstructorStrategyFactory; import com.refinedmods.refinedstorage.common.api.constructordestructor.DestructorStrategyFactory; import com.refinedmods.refinedstorage.common.api.exporter.ExporterTransferStrategyFactory; import com.refinedmods.refinedstorage.common.api.grid.Grid; -import com.refinedmods.refinedstorage.common.api.grid.GridInsertionHint; -import com.refinedmods.refinedstorage.common.api.grid.GridInsertionHints; import com.refinedmods.refinedstorage.common.api.grid.GridSynchronizer; import com.refinedmods.refinedstorage.common.api.grid.strategy.GridExtractionStrategy; import com.refinedmods.refinedstorage.common.api.grid.strategy.GridExtractionStrategyFactory; @@ -41,7 +37,6 @@ import com.refinedmods.refinedstorage.common.api.support.resource.RecipeModIngredientConverter; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceContainerInsertStrategy; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceFactory; -import com.refinedmods.refinedstorage.common.api.support.resource.ResourceRendering; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceType; import com.refinedmods.refinedstorage.common.api.support.slotreference.SlotReference; import com.refinedmods.refinedstorage.common.api.support.slotreference.SlotReferenceFactory; @@ -50,7 +45,6 @@ import com.refinedmods.refinedstorage.common.api.wirelesstransmitter.WirelessTransmitterRangeModifier; import java.util.Collection; -import java.util.List; import java.util.Optional; import java.util.Set; import javax.annotation.Nullable; @@ -62,7 +56,6 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; -import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.MenuType; @@ -141,10 +134,6 @@ GridInsertionStrategy createGridInsertionStrategy(AbstractContainerMenu containe Collection getResourceContainerInsertStrategies(); - void addAlternativeGridInsertionHint(GridInsertionHint hint); - - GridInsertionHints getGridInsertionHints(); - GridExtractionStrategy createGridExtractionStrategy(AbstractContainerMenu containerMenu, ServerPlayer player, Grid grid); @@ -169,10 +158,6 @@ GridScrollingStrategy createGridScrollingStrategy(AbstractContainerMenu containe Set getAlternativeResourceFactories(); - void registerResourceRendering(Class resourceClass, ResourceRendering rendering); - - ResourceRendering getResourceRendering(Class resourceClass); - void addIngredientConverter(RecipeModIngredientConverter converter); RecipeModIngredientConverter getIngredientConverter(); @@ -215,8 +200,6 @@ EnergyStorage asBlockItemEnergyStorage( Optional getPattern(ItemStack stack, Level level); - void openAutocraftingPreview(List requests, @Nullable Object parentScreen); - ResourceLocation getCreativeModeTabId(); AbstractNetworkNodeContainerBlockEntity createStorageBlockEntity(BlockPos pos, @@ -232,9 +215,4 @@ AbstractContainerMenu createStorageBlockContainerMenu(int syncId, MenuType menuType); StreamCodec getStorageBlockDataStreamCodec(); - - Object createStorageBlockScreen(AbstractContainerMenu menu, - Inventory inventory, - Component title, - Class resourceClass); } diff --git a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/RefinedStorageApiProxy.java b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/RefinedStorageApiProxy.java index e7890d06e..f917a941a 100644 --- a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/RefinedStorageApiProxy.java +++ b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/RefinedStorageApiProxy.java @@ -7,14 +7,10 @@ import com.refinedmods.refinedstorage.api.network.energy.EnergyStorage; import com.refinedmods.refinedstorage.api.network.node.NetworkNode; import com.refinedmods.refinedstorage.api.network.security.SecurityPolicy; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; -import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.common.api.constructordestructor.ConstructorStrategyFactory; import com.refinedmods.refinedstorage.common.api.constructordestructor.DestructorStrategyFactory; import com.refinedmods.refinedstorage.common.api.exporter.ExporterTransferStrategyFactory; import com.refinedmods.refinedstorage.common.api.grid.Grid; -import com.refinedmods.refinedstorage.common.api.grid.GridInsertionHint; -import com.refinedmods.refinedstorage.common.api.grid.GridInsertionHints; import com.refinedmods.refinedstorage.common.api.grid.GridSynchronizer; import com.refinedmods.refinedstorage.common.api.grid.strategy.GridExtractionStrategy; import com.refinedmods.refinedstorage.common.api.grid.strategy.GridExtractionStrategyFactory; @@ -41,7 +37,6 @@ import com.refinedmods.refinedstorage.common.api.support.resource.RecipeModIngredientConverter; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceContainerInsertStrategy; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceFactory; -import com.refinedmods.refinedstorage.common.api.support.resource.ResourceRendering; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceType; import com.refinedmods.refinedstorage.common.api.support.slotreference.SlotReference; import com.refinedmods.refinedstorage.common.api.support.slotreference.SlotReferenceFactory; @@ -50,7 +45,6 @@ import com.refinedmods.refinedstorage.common.api.wirelesstransmitter.WirelessTransmitterRangeModifier; import java.util.Collection; -import java.util.List; import java.util.Optional; import java.util.Set; import javax.annotation.Nullable; @@ -62,7 +56,6 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; -import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.MenuType; @@ -237,16 +230,6 @@ public Collection getResourceContainerInsertStr return ensureLoaded().getResourceContainerInsertStrategies(); } - @Override - public void addAlternativeGridInsertionHint(final GridInsertionHint hint) { - ensureLoaded().addAlternativeGridInsertionHint(hint); - } - - @Override - public GridInsertionHints getGridInsertionHints() { - return ensureLoaded().getGridInsertionHints(); - } - @Override public GridExtractionStrategy createGridExtractionStrategy(final AbstractContainerMenu containerMenu, final ServerPlayer player, @@ -301,17 +284,6 @@ public Set getAlternativeResourceFactories() { return ensureLoaded().getAlternativeResourceFactories(); } - @Override - public void registerResourceRendering(final Class resourceClass, - final ResourceRendering rendering) { - ensureLoaded().registerResourceRendering(resourceClass, rendering); - } - - @Override - public ResourceRendering getResourceRendering(final Class resourceClass) { - return ensureLoaded().getResourceRendering(resourceClass); - } - @Override public void addIngredientConverter(final RecipeModIngredientConverter converter) { ensureLoaded().addIngredientConverter(converter); @@ -412,11 +384,6 @@ public Optional getPattern(final ItemStack stack, final Level level) { return ensureLoaded().getPattern(stack, level); } - @Override - public void openAutocraftingPreview(final List requests, @Nullable final Object parentScreen) { - ensureLoaded().openAutocraftingPreview(requests, parentScreen); - } - @Override public ResourceLocation getCreativeModeTabId() { return ensureLoaded().getCreativeModeTabId(); @@ -448,14 +415,6 @@ public StreamCodec getStorageBlockDat return ensureLoaded().getStorageBlockDataStreamCodec(); } - @Override - public Object createStorageBlockScreen(final AbstractContainerMenu menu, - final Inventory inventory, - final Component title, - final Class resourceClass) { - return ensureLoaded().createStorageBlockScreen(menu, inventory, title, resourceClass); - } - private RefinedStorageApi ensureLoaded() { if (delegate == null) { throw new IllegalStateException("API not loaded yet"); diff --git a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/RefinedStorageClientApi.java b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/RefinedStorageClientApi.java new file mode 100644 index 000000000..eb6cd7151 --- /dev/null +++ b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/RefinedStorageClientApi.java @@ -0,0 +1,49 @@ +package com.refinedmods.refinedstorage.common.api; + +import com.refinedmods.refinedstorage.api.resource.ResourceAmount; +import com.refinedmods.refinedstorage.api.resource.ResourceKey; +import com.refinedmods.refinedstorage.common.api.grid.GridInsertionHint; +import com.refinedmods.refinedstorage.common.api.grid.GridInsertionHints; +import com.refinedmods.refinedstorage.common.api.support.resource.ResourceRendering; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import javax.annotation.Nullable; + +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.item.Item; +import org.apiguardian.api.API; + +@API(status = API.Status.STABLE, since = "2.0.0-milestone.4.11") +public interface RefinedStorageClientApi { + RefinedStorageClientApi INSTANCE = new RefinedStorageClientApiProxy(); + + AbstractContainerScreen createStorageBlockScreen( + AbstractContainerMenu menu, + Inventory inventory, + Component title, + Class resourceClass + ); + + void openAutocraftingPreview(List requests, @Nullable Screen parentScreen); + + void registerResourceRendering(Class resourceClass, ResourceRendering rendering); + + ResourceRendering getResourceRendering(Class resourceClass); + + void addAlternativeGridInsertionHint(GridInsertionHint hint); + + GridInsertionHints getGridInsertionHints(); + + void registerDiskModel(Item item, ResourceLocation model); + + Set getDiskModels(); + + Map getDiskModelsByItem(); +} diff --git a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/RefinedStorageClientApiProxy.java b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/RefinedStorageClientApiProxy.java new file mode 100644 index 000000000..6adafab42 --- /dev/null +++ b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/RefinedStorageClientApiProxy.java @@ -0,0 +1,90 @@ +package com.refinedmods.refinedstorage.common.api; + +import com.refinedmods.refinedstorage.api.resource.ResourceAmount; +import com.refinedmods.refinedstorage.api.resource.ResourceKey; +import com.refinedmods.refinedstorage.common.api.grid.GridInsertionHint; +import com.refinedmods.refinedstorage.common.api.grid.GridInsertionHints; +import com.refinedmods.refinedstorage.common.api.support.resource.ResourceRendering; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import javax.annotation.Nullable; + +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.item.Item; + +public class RefinedStorageClientApiProxy implements RefinedStorageClientApi { + @Nullable + private RefinedStorageClientApi delegate; + + public void setDelegate(final RefinedStorageClientApi delegate) { + if (this.delegate != null) { + throw new IllegalStateException("Client API already injected"); + } + this.delegate = delegate; + } + + @Override + public AbstractContainerScreen createStorageBlockScreen( + final AbstractContainerMenu menu, + final Inventory inventory, + final Component title, + final Class resourceClass + ) { + return ensureLoaded().createStorageBlockScreen(menu, inventory, title, resourceClass); + } + + @Override + public void openAutocraftingPreview(final List requests, @Nullable final Screen parentScreen) { + ensureLoaded().openAutocraftingPreview(requests, parentScreen); + } + + @Override + public void registerResourceRendering(final Class resourceClass, + final ResourceRendering rendering) { + ensureLoaded().registerResourceRendering(resourceClass, rendering); + } + + @Override + public ResourceRendering getResourceRendering(final Class resourceClass) { + return ensureLoaded().getResourceRendering(resourceClass); + } + + @Override + public void addAlternativeGridInsertionHint(final GridInsertionHint hint) { + ensureLoaded().addAlternativeGridInsertionHint(hint); + } + + @Override + public GridInsertionHints getGridInsertionHints() { + return ensureLoaded().getGridInsertionHints(); + } + + @Override + public void registerDiskModel(final Item item, final ResourceLocation model) { + ensureLoaded().registerDiskModel(item, model); + } + + @Override + public Set getDiskModels() { + return ensureLoaded().getDiskModels(); + } + + @Override + public Map getDiskModelsByItem() { + return ensureLoaded().getDiskModelsByItem(); + } + + private RefinedStorageClientApi ensureLoaded() { + if (delegate == null) { + throw new IllegalStateException("API not loaded yet"); + } + return delegate; + } +} diff --git a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/storage/StorageContainerItemHelper.java b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/storage/StorageContainerItemHelper.java index ff50d513d..63c7f7385 100644 --- a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/storage/StorageContainerItemHelper.java +++ b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/storage/StorageContainerItemHelper.java @@ -1,19 +1,15 @@ package com.refinedmods.refinedstorage.common.api.storage; import java.util.List; -import java.util.Map; import java.util.Optional; -import java.util.Set; import java.util.function.Function; import java.util.function.LongFunction; import javax.annotation.Nullable; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.level.Level; @@ -52,11 +48,5 @@ void appendToTooltip(ItemStack stack, void transferFromBlockEntity(ItemStack stack, StorageBlockEntity blockEntity); - void registerDiskModel(Item item, ResourceLocation model); - - Set getDiskModels(); - - Map getDiskModelsByItem(); - void markAsToTransfer(ItemStack from, ItemStack to); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/AbstractClientModInitializer.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/AbstractClientModInitializer.java index 019fdfe5b..9c1d5a454 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/AbstractClientModInitializer.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/AbstractClientModInitializer.java @@ -2,6 +2,8 @@ import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApiProxy; import com.refinedmods.refinedstorage.common.api.upgrade.UpgradeMapping; import com.refinedmods.refinedstorage.common.autocrafting.autocrafter.AutocrafterScreen; import com.refinedmods.refinedstorage.common.autocrafting.autocraftermanager.AutocrafterManagerScreen; @@ -64,11 +66,17 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.Item; import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; public abstract class AbstractClientModInitializer { - @SuppressWarnings({"unchecked", "rawtypes"}) + public static void initializeClientPlatformApi() { + ((RefinedStorageClientApiProxy) RefinedStorageClientApi.INSTANCE).setDelegate( + new RefinedStorageClientApiImpl() + ); + } + protected static void registerScreens(final ScreenRegistration registration) { registration.register(Menus.INSTANCE.getDiskDrive(), DiskDriveScreen::new); registration.register(Menus.INSTANCE.getGrid(), GridScreen::new); @@ -82,12 +90,8 @@ protected static void registerScreens(final ScreenRegistration registration) { public AbstractContainerScreen create(final AbstractContainerMenu menu, final Inventory inventory, final Component title) { - return (AbstractContainerScreen) RefinedStorageApi.INSTANCE.createStorageBlockScreen( - menu, - inventory, - title, - ItemResource.class - ); + return RefinedStorageClientApi.INSTANCE.createStorageBlockScreen(menu, inventory, title, + ItemResource.class); } }); registration.register(Menus.INSTANCE.getFluidStorage(), @@ -96,12 +100,8 @@ public AbstractContainerScreen create(final AbstractConta public AbstractContainerScreen create(final AbstractContainerMenu menu, final Inventory inventory, final Component title) { - return (AbstractContainerScreen) RefinedStorageApi.INSTANCE.createStorageBlockScreen( - menu, - inventory, - title, - FluidResource.class - ); + return RefinedStorageClientApi.INSTANCE.createStorageBlockScreen(menu, inventory, title, + FluidResource.class); } }); registration.register(Menus.INSTANCE.getImporter(), ImporterScreen::new); @@ -138,12 +138,12 @@ public AutocraftingPreviewScreen create(final AutocraftingPreviewContainerMenu m } protected static void registerAlternativeGridHints() { - RefinedStorageApi.INSTANCE.addAlternativeGridInsertionHint(new FluidGridInsertionHint()); + RefinedStorageClientApi.INSTANCE.addAlternativeGridInsertionHint(new FluidGridInsertionHint()); } protected static void registerResourceRendering() { - RefinedStorageApi.INSTANCE.registerResourceRendering(ItemResource.class, new ItemResourceRendering()); - RefinedStorageApi.INSTANCE.registerResourceRendering(FluidResource.class, new FluidResourceRendering( + RefinedStorageClientApi.INSTANCE.registerResourceRendering(ItemResource.class, ItemResourceRendering.INSTANCE); + RefinedStorageClientApi.INSTANCE.registerResourceRendering(FluidResource.class, new FluidResourceRendering( Platform.INSTANCE.getBucketAmount() )); } @@ -182,18 +182,13 @@ protected static void handleInputEvents() { protected static void registerDiskModels() { final ResourceLocation diskModel = createIdentifier("block/disk/disk"); for (final ItemStorageVariant variant : ItemStorageVariant.values()) { - RefinedStorageApi.INSTANCE.getStorageContainerItemHelper().registerDiskModel( - Items.INSTANCE.getItemStorageDisk(variant), - diskModel - ); + final Item item = Items.INSTANCE.getItemStorageDisk(variant); + RefinedStorageClientApi.INSTANCE.registerDiskModel(item, diskModel); } - final ResourceLocation fluidDiskModel = createIdentifier("block/disk/fluid_disk"); for (final FluidStorageVariant variant : FluidStorageVariant.values()) { - RefinedStorageApi.INSTANCE.getStorageContainerItemHelper().registerDiskModel( - Items.INSTANCE.getFluidStorageDisk(variant), - fluidDiskModel - ); + final Item item = Items.INSTANCE.getFluidStorageDisk(variant); + RefinedStorageClientApi.INSTANCE.registerDiskModel(item, fluidDiskModel); } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/RefinedStorageApiImpl.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/RefinedStorageApiImpl.java index 821145a59..e732baff6 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/RefinedStorageApiImpl.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/RefinedStorageApiImpl.java @@ -10,16 +10,12 @@ import com.refinedmods.refinedstorage.api.network.impl.NetworkFactory; import com.refinedmods.refinedstorage.api.network.node.NetworkNode; import com.refinedmods.refinedstorage.api.network.security.SecurityPolicy; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; -import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; import com.refinedmods.refinedstorage.common.api.autocrafting.PatternProviderItem; import com.refinedmods.refinedstorage.common.api.constructordestructor.ConstructorStrategyFactory; import com.refinedmods.refinedstorage.common.api.constructordestructor.DestructorStrategyFactory; import com.refinedmods.refinedstorage.common.api.exporter.ExporterTransferStrategyFactory; import com.refinedmods.refinedstorage.common.api.grid.Grid; -import com.refinedmods.refinedstorage.common.api.grid.GridInsertionHint; -import com.refinedmods.refinedstorage.common.api.grid.GridInsertionHints; import com.refinedmods.refinedstorage.common.api.grid.GridSynchronizer; import com.refinedmods.refinedstorage.common.api.grid.strategy.GridExtractionStrategy; import com.refinedmods.refinedstorage.common.api.grid.strategy.GridExtractionStrategyFactory; @@ -46,7 +42,6 @@ import com.refinedmods.refinedstorage.common.api.support.resource.RecipeModIngredientConverter; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceContainerInsertStrategy; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceFactory; -import com.refinedmods.refinedstorage.common.api.support.resource.ResourceRendering; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceType; import com.refinedmods.refinedstorage.common.api.support.slotreference.SlotReference; import com.refinedmods.refinedstorage.common.api.support.slotreference.SlotReferenceFactory; @@ -55,9 +50,6 @@ import com.refinedmods.refinedstorage.common.api.wirelesstransmitter.WirelessTransmitterRangeModifier; import com.refinedmods.refinedstorage.common.content.ContentIds; import com.refinedmods.refinedstorage.common.grid.NoopGridSynchronizer; -import com.refinedmods.refinedstorage.common.grid.screen.hint.GridInsertionHintsImpl; -import com.refinedmods.refinedstorage.common.grid.screen.hint.ItemGridInsertionHint; -import com.refinedmods.refinedstorage.common.grid.screen.hint.SingleItemGridInsertionHint; import com.refinedmods.refinedstorage.common.grid.strategy.CompositeGridExtractionStrategy; import com.refinedmods.refinedstorage.common.grid.strategy.CompositeGridInsertionStrategy; import com.refinedmods.refinedstorage.common.grid.strategy.CompositeGridScrollingStrategy; @@ -70,7 +62,6 @@ import com.refinedmods.refinedstorage.common.storage.storageblock.StorageBlockBlockEntity; import com.refinedmods.refinedstorage.common.storage.storageblock.StorageBlockCodecs; import com.refinedmods.refinedstorage.common.storage.storageblock.StorageBlockContainerMenu; -import com.refinedmods.refinedstorage.common.storage.storageblock.StorageBlockScreen; import com.refinedmods.refinedstorage.common.storagemonitor.CompositeStorageMonitorExtractionStrategy; import com.refinedmods.refinedstorage.common.storagemonitor.CompositeStorageMonitorInsertionStrategy; import com.refinedmods.refinedstorage.common.support.energy.EnergyItemHelperImpl; @@ -89,7 +80,6 @@ import com.refinedmods.refinedstorage.common.support.slotreference.CompositeSlotReferenceProvider; import com.refinedmods.refinedstorage.common.support.slotreference.InventorySlotReference; import com.refinedmods.refinedstorage.common.upgrade.UpgradeRegistryImpl; -import com.refinedmods.refinedstorage.common.util.ClientPlatformUtil; import com.refinedmods.refinedstorage.common.util.IdentifierUtil; import com.refinedmods.refinedstorage.common.util.ServerEventQueue; @@ -119,7 +109,6 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; -import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.MenuType; @@ -168,16 +157,11 @@ public class RefinedStorageApiImpl implements RefinedStorageApi { new CompositeRecipeModIngredientConverter(); private final StorageContainerItemHelper storageContainerItemHelper = new StorageContainerItemHelperImpl(); private final List gridInsertionStrategyFactories = new ArrayList<>(); - private final GridInsertionHintsImpl gridInsertionHints = new GridInsertionHintsImpl( - new ItemGridInsertionHint(), - new SingleItemGridInsertionHint() - ); private final List gridExtractionStrategyFactories = new ArrayList<>(); private final List gridScrollingStrategyFactories = new ArrayList<>(); private final ResourceFactory itemResourceFactory = new ItemResourceFactory(); private final ResourceFactory fluidResourceFactory = new FluidResourceFactory(); private final Set resourceFactories = new HashSet<>(); - private final Map, ResourceRendering> resourceRenderingMap = new HashMap<>(); private final CompositeWirelessTransmitterRangeModifier wirelessTransmitterRangeModifier = new CompositeWirelessTransmitterRangeModifier(); private final EnergyItemHelper energyItemHelper = new EnergyItemHelperImpl(); @@ -394,16 +378,6 @@ public Collection getResourceContainerInsertStr return Collections.unmodifiableList(resourceExtractStrategies); } - @Override - public void addAlternativeGridInsertionHint(final GridInsertionHint hint) { - gridInsertionHints.addAlternativeHint(hint); - } - - @Override - public GridInsertionHints getGridInsertionHints() { - return gridInsertionHints; - } - @Override public GridExtractionStrategy createGridExtractionStrategy(final AbstractContainerMenu containerMenu, final ServerPlayer player, @@ -466,17 +440,6 @@ public Set getAlternativeResourceFactories() { return resourceFactories; } - @Override - public void registerResourceRendering(final Class resourceClass, - final ResourceRendering rendering) { - resourceRenderingMap.put(resourceClass, rendering); - } - - @Override - public ResourceRendering getResourceRendering(final Class resourceClass) { - return resourceRenderingMap.get(resourceClass); - } - @Override public void addIngredientConverter(final RecipeModIngredientConverter converter) { ingredientConverter.addConverter(converter); @@ -613,14 +576,6 @@ public Optional getPattern(final ItemStack stack, final Level level) { )); } - @Override - public void openAutocraftingPreview(final List requests, @Nullable final Object parentScreen) { - if (requests.isEmpty()) { - return; - } - ClientPlatformUtil.openCraftingPreview(requests, parentScreen); - } - @Override public ResourceLocation getCreativeModeTabId() { return ContentIds.CREATIVE_MODE_TAB; @@ -657,17 +612,4 @@ public AbstractContainerMenu createStorageBlockContainerMenu(final int syncId, public StreamCodec getStorageBlockDataStreamCodec() { return StorageBlockCodecs.STREAM_CODEC; } - - @Override - public Object createStorageBlockScreen(final AbstractContainerMenu menu, - final Inventory inventory, - final Component title, - final Class resourceClass) { - return new StorageBlockScreen( - (StorageBlockContainerMenu) menu, - inventory, - title, - getResourceRendering(resourceClass) - ); - } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/RefinedStorageClientApiImpl.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/RefinedStorageClientApiImpl.java new file mode 100644 index 000000000..fc9fa7afb --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/RefinedStorageClientApiImpl.java @@ -0,0 +1,107 @@ +package com.refinedmods.refinedstorage.common; + +import com.refinedmods.refinedstorage.api.resource.ResourceAmount; +import com.refinedmods.refinedstorage.api.resource.ResourceKey; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; +import com.refinedmods.refinedstorage.common.api.grid.GridInsertionHint; +import com.refinedmods.refinedstorage.common.api.grid.GridInsertionHints; +import com.refinedmods.refinedstorage.common.api.support.resource.ResourceRendering; +import com.refinedmods.refinedstorage.common.grid.screen.hint.GridInsertionHintsImpl; +import com.refinedmods.refinedstorage.common.grid.screen.hint.ItemGridInsertionHint; +import com.refinedmods.refinedstorage.common.grid.screen.hint.SingleItemGridInsertionHint; +import com.refinedmods.refinedstorage.common.storage.storageblock.StorageBlockContainerMenu; +import com.refinedmods.refinedstorage.common.storage.storageblock.StorageBlockScreen; +import com.refinedmods.refinedstorage.common.support.resource.ItemResource; +import com.refinedmods.refinedstorage.common.support.resource.ItemResourceRendering; +import com.refinedmods.refinedstorage.common.util.ClientPlatformUtil; + +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import javax.annotation.Nullable; + +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.item.Item; + +public class RefinedStorageClientApiImpl implements RefinedStorageClientApi { + private final Map, ResourceRendering> resourceRenderingMap = new HashMap<>(); + private final Map diskModelsByItem = new HashMap<>(); + private final Set diskModels = new HashSet<>(); + private final GridInsertionHintsImpl gridInsertionHints = new GridInsertionHintsImpl( + new ItemGridInsertionHint(), + new SingleItemGridInsertionHint() + ); + + @Override + @SuppressWarnings({"unchecked", "rawtypes"}) + public AbstractContainerScreen createStorageBlockScreen( + final AbstractContainerMenu menu, + final Inventory inventory, + final Component title, + final Class resourceClass + ) { + return (AbstractContainerScreen) new StorageBlockScreen( + (StorageBlockContainerMenu) menu, + inventory, + title, + getResourceRendering(resourceClass) + ); + } + + @Override + public void openAutocraftingPreview(final List requests, @Nullable final Screen parentScreen) { + if (requests.isEmpty()) { + return; + } + ClientPlatformUtil.openCraftingPreview(requests, parentScreen); + } + + @Override + public void addAlternativeGridInsertionHint(final GridInsertionHint hint) { + gridInsertionHints.addAlternativeHint(hint); + } + + @Override + public GridInsertionHints getGridInsertionHints() { + return gridInsertionHints; + } + + @Override + public void registerDiskModel(final Item item, final ResourceLocation model) { + diskModelsByItem.put(item, model); + diskModels.add(model); + } + + @Override + public Set getDiskModels() { + return diskModels; + } + + @Override + public Map getDiskModelsByItem() { + return Collections.unmodifiableMap(diskModelsByItem); + } + + @Override + public void registerResourceRendering(final Class resourceClass, + final ResourceRendering rendering) { + resourceRenderingMap.put(resourceClass, rendering); + } + + @Override + public ResourceRendering getResourceRendering(final Class resourceClass) { + // fast path for items + if (resourceClass == ItemResource.class) { + return ItemResourceRendering.INSTANCE; + } + return resourceRenderingMap.get(resourceClass); + } +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/CraftingPatternClientTooltipComponent.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/CraftingPatternClientTooltipComponent.java index b431f29ce..56be06912 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/CraftingPatternClientTooltipComponent.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/CraftingPatternClientTooltipComponent.java @@ -1,6 +1,6 @@ package com.refinedmods.refinedstorage.common.autocrafting; -import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; import com.refinedmods.refinedstorage.common.api.support.resource.PlatformResourceKey; import com.refinedmods.refinedstorage.common.support.resource.ItemResource; @@ -99,7 +99,7 @@ private void renderInputSlot(final int x, final int y, final GuiGraphics graphic if (!inputs.isEmpty()) { final int idx = currentCycle % inputs.size(); final PlatformResourceKey resource = inputs.get(idx); - RefinedStorageApi.INSTANCE.getResourceRendering(resource.getClass()).render( + RefinedStorageClientApi.INSTANCE.getResourceRendering(resource.getClass()).render( resource, graphics, x + sx * 18 + 1, diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/ProcessingPatternClientTooltipComponent.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/ProcessingPatternClientTooltipComponent.java index 06afaf280..7b76bfdb8 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/ProcessingPatternClientTooltipComponent.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/ProcessingPatternClientTooltipComponent.java @@ -1,7 +1,7 @@ package com.refinedmods.refinedstorage.common.autocrafting; import com.refinedmods.refinedstorage.api.resource.ResourceAmount; -import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; import com.refinedmods.refinedstorage.common.api.support.resource.PlatformResourceKey; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceRendering; import com.refinedmods.refinedstorage.common.support.ResourceSlotRendering; @@ -75,7 +75,7 @@ private static List getOutputText(final ProcessingPatternState state) } private static Component getOutputText(final ResourceAmount resourceAmount) { - final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering( + final ResourceRendering rendering = RefinedStorageClientApi.INSTANCE.getResourceRendering( resourceAmount.resource().getClass() ); final String displayAmount = rendering.formatAmount(resourceAmount.amount()); @@ -147,7 +147,7 @@ private void renderMatrixSlot( return; } final ResourceAmount resourceAmount = possibilities.get(currentCycle % possibilities.size()); - final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering( + final ResourceRendering rendering = RefinedStorageClientApi.INSTANCE.getResourceRendering( resourceAmount.resource().getClass() ); rendering.render(resourceAmount.resource(), graphics, slotX + 1, slotY + 1); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/SmithingTablePatternClientTooltipComponent.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/SmithingTablePatternClientTooltipComponent.java index 71ad06504..3383aedcc 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/SmithingTablePatternClientTooltipComponent.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/SmithingTablePatternClientTooltipComponent.java @@ -1,6 +1,6 @@ package com.refinedmods.refinedstorage.common.autocrafting; -import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceRendering; import com.refinedmods.refinedstorage.common.support.Sprites; import com.refinedmods.refinedstorage.common.support.resource.ItemResource; @@ -31,7 +31,7 @@ public void renderImage(final Font font, final int x, final int y, final GuiGrap graphics.drawString(font, outputText, x, y, 0xAAAAAA); final int slotsY = y + 9 + 2; graphics.blitSprite(Sprites.SLOT, x, slotsY, 18, 18); - final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering(ItemResource.class); + final ResourceRendering rendering = RefinedStorageClientApi.INSTANCE.getResourceRendering(ItemResource.class); rendering.render(pattern.getTemplate(), graphics, x + 1, slotsY + 1); graphics.blitSprite(Sprites.SLOT, x + 18, slotsY, 18, 18); rendering.render(pattern.getBase(), graphics, x + 18 + 1, slotsY + 1); @@ -63,7 +63,7 @@ public int getWidth(final Font font) { } private static Component getOutputText(final ItemResource output) { - final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering(ItemResource.class); + final ResourceRendering rendering = RefinedStorageClientApi.INSTANCE.getResourceRendering(ItemResource.class); return Component.literal("1x ") .append(rendering.getDisplayName(output)) .withStyle(ChatFormatting.GRAY); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/StonecutterPatternClientTooltipComponent.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/StonecutterPatternClientTooltipComponent.java index 5e32c883c..5a1c32daf 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/StonecutterPatternClientTooltipComponent.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/StonecutterPatternClientTooltipComponent.java @@ -1,6 +1,6 @@ package com.refinedmods.refinedstorage.common.autocrafting; -import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; import com.refinedmods.refinedstorage.common.api.support.resource.PlatformResourceKey; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceRendering; import com.refinedmods.refinedstorage.common.support.resource.ItemResource; @@ -33,7 +33,7 @@ class StonecutterPatternClientTooltipComponent implements ClientTooltipComponent public void renderImage(final Font font, final int x, final int y, final GuiGraphics graphics) { graphics.drawString(font, outputText, x, y, 0xAAAAAA); graphics.blitSprite(SLOT, x, y + 9 + 2, 18, 18); - final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering(ItemResource.class); + final ResourceRendering rendering = RefinedStorageClientApi.INSTANCE.getResourceRendering(ItemResource.class); rendering.render(input, graphics, x + 1, y + 9 + 2 + 1); graphics.blitSprite( LIGHT_ARROW, @@ -58,7 +58,7 @@ public void renderImage(final Font font, final int x, final int y, final GuiGrap } private static Component getOutputText(final ItemResource output) { - final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering(ItemResource.class); + final ResourceRendering rendering = RefinedStorageClientApi.INSTANCE.getResourceRendering(ItemResource.class); return Component.literal("1x ") .append(rendering.getDisplayName(output)) .withStyle(ChatFormatting.GRAY); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/autocraftermanager/AutocrafterManagerContainerMenu.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/autocraftermanager/AutocrafterManagerContainerMenu.java index 869eb7e2d..9ce99fd5c 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/autocraftermanager/AutocrafterManagerContainerMenu.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/autocraftermanager/AutocrafterManagerContainerMenu.java @@ -3,6 +3,7 @@ import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.common.Platform; import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; import com.refinedmods.refinedstorage.common.autocrafting.PatternInventory; import com.refinedmods.refinedstorage.common.content.Menus; import com.refinedmods.refinedstorage.common.support.AbstractBaseContainerMenu; @@ -274,7 +275,7 @@ boolean hasPatternOutput(final Level level, final String normalizedQuery, final private static boolean hasResource(final Set resources, final String normalizedQuery) { return resources.stream().anyMatch(key -> - RefinedStorageApi.INSTANCE.getResourceRendering(key.getClass()) + RefinedStorageClientApi.INSTANCE.getResourceRendering(key.getClass()) .getDisplayName(key) .getString() .toLowerCase(Locale.ROOT) diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/AutocraftingMonitorScreen.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/AutocraftingMonitorScreen.java index 9ac2e2d80..0a0e1fe51 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/AutocraftingMonitorScreen.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/AutocraftingMonitorScreen.java @@ -2,7 +2,7 @@ import com.refinedmods.refinedstorage.api.autocrafting.TaskId; import com.refinedmods.refinedstorage.api.autocrafting.status.TaskStatus; -import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceRendering; import com.refinedmods.refinedstorage.common.support.AbstractBaseScreen; import com.refinedmods.refinedstorage.common.support.containermenu.PropertyTypes; @@ -276,7 +276,9 @@ private void renderItem(final GuiGraphics graphics, renderItemErrorIcon(graphics, x, y); } int xx = x + 2; - final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering(item.resource().getClass()); + final ResourceRendering rendering = RefinedStorageClientApi.INSTANCE.getResourceRendering( + item.resource().getClass() + ); int yy = y + 7; rendering.render(item.resource(), graphics, xx, yy); if (isHovering(x - leftPos, y - topPos, 73, 29, mouseX, mouseY) diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/AutocraftingTaskButton.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/AutocraftingTaskButton.java index cf6036ada..8e2bee898 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/AutocraftingTaskButton.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/AutocraftingTaskButton.java @@ -3,7 +3,7 @@ import com.refinedmods.refinedstorage.api.autocrafting.TaskId; import com.refinedmods.refinedstorage.api.autocrafting.status.TaskStatus; import com.refinedmods.refinedstorage.api.resource.ResourceKey; -import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceRendering; import com.refinedmods.refinedstorage.common.support.ResourceSlotRendering; import com.refinedmods.refinedstorage.common.support.tooltip.SmallText; @@ -36,7 +36,7 @@ class AutocraftingTaskButton extends AbstractButton { super(x, y, TASK_BUTTON_WIDTH, TASK_BUTTON_HEIGHT, Component.empty()); this.task = task; final ResourceKey resource = task.resource(); - final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering(resource.getClass()); + final ResourceRendering rendering = RefinedStorageClientApi.INSTANCE.getResourceRendering(resource.getClass()); this.text = new TextMarquee( rendering.getDisplayName(resource), TASK_BUTTON_WIDTH - 16 - 4 - 4 - 4, @@ -72,7 +72,7 @@ protected void renderWidget(final GuiGraphics graphics, private void renderResourceIcon(final GuiGraphics graphics) { final ResourceKey resource = task.resource(); - final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering(resource.getClass()); + final ResourceRendering rendering = RefinedStorageClientApi.INSTANCE.getResourceRendering(resource.getClass()); final int resourceX = getX() + 3; final int resourceY = getY() + 4; rendering.render(resource, graphics, resourceX, resourceY); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/patterngrid/ProcessingMatrixInputClientTooltipComponent.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/patterngrid/ProcessingMatrixInputClientTooltipComponent.java index 00a3cd0ff..c02f40ff0 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/patterngrid/ProcessingMatrixInputClientTooltipComponent.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/patterngrid/ProcessingMatrixInputClientTooltipComponent.java @@ -1,6 +1,6 @@ package com.refinedmods.refinedstorage.common.autocrafting.patterngrid; -import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; import com.refinedmods.refinedstorage.common.api.support.resource.PlatformResourceKey; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceRendering; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceTag; @@ -69,7 +69,9 @@ public void renderImage(final Font font, final int x, final int y, final GuiGrap final PlatformResourceKey resource = alternative.resources().get( currentCycle % alternative.resources().size() ); - final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering(resource.getClass()); + final ResourceRendering rendering = RefinedStorageClientApi.INSTANCE.getResourceRendering( + resource.getClass() + ); rendering.render(resource, graphics, x, y + 9 + PADDING + i * 18); graphics.drawString( font, diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/preview/AutocraftingPreviewScreen.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/preview/AutocraftingPreviewScreen.java index 80e1b91db..9e83b6bad 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/preview/AutocraftingPreviewScreen.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/preview/AutocraftingPreviewScreen.java @@ -3,7 +3,7 @@ import com.refinedmods.refinedstorage.api.autocrafting.preview.Preview; import com.refinedmods.refinedstorage.api.autocrafting.preview.PreviewItem; import com.refinedmods.refinedstorage.api.autocrafting.preview.PreviewType; -import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceRendering; import com.refinedmods.refinedstorage.common.support.amount.AbstractAmountScreen; import com.refinedmods.refinedstorage.common.support.amount.AmountScreenConfiguration; @@ -294,7 +294,9 @@ private void renderCell(final GuiGraphics graphics, graphics.fill(x, y, x + 73, y + 29, 0xFFF2DEDE); } int xx = x + 2; - final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering(item.resource().getClass()); + final ResourceRendering rendering = RefinedStorageClientApi.INSTANCE.getResourceRendering( + item.resource().getClass() + ); int yy = y + 7; rendering.render(item.resource(), graphics, xx, yy); if (isHovering(xx - leftPos, yy - topPos, 16, 16, mouseX, mouseY) diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/preview/AutocraftingRequestButton.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/preview/AutocraftingRequestButton.java index dadb6d171..2ca23d851 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/preview/AutocraftingRequestButton.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/preview/AutocraftingRequestButton.java @@ -1,7 +1,7 @@ package com.refinedmods.refinedstorage.common.autocrafting.preview; import com.refinedmods.refinedstorage.api.resource.ResourceKey; -import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; import com.refinedmods.refinedstorage.common.api.support.resource.PlatformResourceKey; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceRendering; import com.refinedmods.refinedstorage.common.support.ResourceSlotRendering; @@ -31,7 +31,7 @@ class AutocraftingRequestButton extends AbstractButton { super(x, y, REQUEST_BUTTON_WIDTH, REQUEST_BUTTON_HEIGHT, Component.empty()); this.request = request; final ResourceKey resource = request.getResource(); - final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering(resource.getClass()); + final ResourceRendering rendering = RefinedStorageClientApi.INSTANCE.getResourceRendering(resource.getClass()); this.text = new TextMarquee( rendering.getDisplayName(resource), REQUEST_BUTTON_WIDTH - 16 - 4 - 4 - 4, @@ -59,7 +59,7 @@ protected void renderWidget(final GuiGraphics graphics, private void renderResourceIcon(final GuiGraphics graphics) { final ResourceKey resource = request.getResource(); - final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering(resource.getClass()); + final ResourceRendering rendering = RefinedStorageClientApi.INSTANCE.getResourceRendering(resource.getClass()); final int resourceX = getX() + 3; final int resourceY = getY() + 4; rendering.render(resource, graphics, resourceX, resourceY); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/BlockEntities.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/BlockEntities.java index 4366e6585..38d2e7fbb 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/BlockEntities.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/BlockEntities.java @@ -33,7 +33,6 @@ import java.util.function.Supplier; import javax.annotation.Nullable; -import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; import static java.util.Objects.requireNonNull; @@ -157,21 +156,28 @@ public void setCreativeController(final Supplier>> supplier) { + public void setItemStorageBlock( + final ItemStorageVariant variant, + final Supplier>> supplier + ) { itemStorageBlocks.put(variant, supplier); } - public BlockEntityType> getItemStorageBlock(final ItemStorageVariant variant) { + public BlockEntityType> getItemStorageBlock( + final ItemStorageVariant variant + ) { return itemStorageBlocks.get(variant).get(); } - public void setFluidStorageBlock(final FluidStorageVariant variant, - final Supplier>> supplier) { + public void setFluidStorageBlock( + final FluidStorageVariant variant, + final Supplier>> supplier + ) { fluidStorageBlocks.put(variant, supplier); } - public BlockEntityType> getFluidStorageBlock(final FluidStorageVariant variant) { + public BlockEntityType> getFluidStorageBlock( + final FluidStorageVariant variant) { return fluidStorageBlocks.get(variant).get(); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/AbstractGridScreen.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/AbstractGridScreen.java index e9d570941..3523a5716 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/AbstractGridScreen.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/AbstractGridScreen.java @@ -9,6 +9,7 @@ import com.refinedmods.refinedstorage.api.storage.tracked.TrackedResource; import com.refinedmods.refinedstorage.common.Platform; import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; import com.refinedmods.refinedstorage.common.api.grid.GridScrollMode; import com.refinedmods.refinedstorage.common.api.grid.view.PlatformGridResource; import com.refinedmods.refinedstorage.common.grid.AbstractGridContainerMenu; @@ -420,7 +421,8 @@ private void renderOverStorageAreaTooltip(final GuiGraphics graphics, final int if (carried.isEmpty()) { return; } - final List hints = RefinedStorageApi.INSTANCE.getGridInsertionHints().getHints(carried); + final List hints = RefinedStorageClientApi.INSTANCE.getGridInsertionHints() + .getHints(carried); Platform.INSTANCE.renderTooltip(graphics, hints, x, y); } @@ -541,7 +543,7 @@ private boolean tryStartAutocrafting(final PlatformGridResource resource) { if (request == null) { return false; } - RefinedStorageApi.INSTANCE.openAutocraftingPreview(List.of(request), this); + RefinedStorageClientApi.INSTANCE.openAutocraftingPreview(List.of(request), this); return true; } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/hint/FluidGridInsertionHint.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/hint/FluidGridInsertionHint.java index e0f04b3e7..b44bf7229 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/hint/FluidGridInsertionHint.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/hint/FluidGridInsertionHint.java @@ -1,7 +1,7 @@ package com.refinedmods.refinedstorage.common.grid.screen.hint; import com.refinedmods.refinedstorage.common.Platform; -import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; import com.refinedmods.refinedstorage.common.api.grid.GridInsertionHint; import com.refinedmods.refinedstorage.common.api.support.resource.FluidOperationResult; import com.refinedmods.refinedstorage.common.support.resource.FluidResource; @@ -22,9 +22,8 @@ private ClientTooltipComponent createComponent(final FluidOperationResult result return MouseClientTooltipComponent.fluid( MouseClientTooltipComponent.Type.RIGHT, (FluidResource) result.fluid(), - result.amount() == Platform.INSTANCE.getBucketAmount() - ? null - : RefinedStorageApi.INSTANCE.getResourceRendering(FluidResource.class).formatAmount(result.amount()) + result.amount() == Platform.INSTANCE.getBucketAmount() ? null : RefinedStorageClientApi.INSTANCE + .getResourceRendering(FluidResource.class).formatAmount(result.amount()) ); } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/view/FluidGridResource.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/view/FluidGridResource.java index b197dd9c6..c88f4ee23 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/view/FluidGridResource.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/view/FluidGridResource.java @@ -5,7 +5,7 @@ import com.refinedmods.refinedstorage.api.grid.view.GridView; import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.common.Platform; -import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; import com.refinedmods.refinedstorage.common.api.grid.GridScrollMode; import com.refinedmods.refinedstorage.common.api.grid.strategy.GridExtractionStrategy; import com.refinedmods.refinedstorage.common.api.grid.strategy.GridScrollingStrategy; @@ -43,7 +43,7 @@ public FluidGridResource(final FluidResource resource, final boolean autocraftable) { super(resource, name, attributes, autocraftable); this.id = BuiltInRegistries.FLUID.getId(resource.fluid()); - this.rendering = RefinedStorageApi.INSTANCE.getResourceRendering(FluidResource.class); + this.rendering = RefinedStorageClientApi.INSTANCE.getResourceRendering(FluidResource.class); } @Override diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/StorageContainerItemHelperImpl.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/StorageContainerItemHelperImpl.java index 85d8f9fc3..a5fb6d244 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/StorageContainerItemHelperImpl.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/StorageContainerItemHelperImpl.java @@ -10,13 +10,8 @@ import com.refinedmods.refinedstorage.common.api.storage.StorageRepository; import com.refinedmods.refinedstorage.common.content.DataComponents; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Optional; -import java.util.Set; import java.util.UUID; import java.util.function.Function; import java.util.function.LongFunction; @@ -25,13 +20,11 @@ import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; -import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.level.Level; @@ -41,9 +34,6 @@ public class StorageContainerItemHelperImpl implements StorageContainerItemHelper { private static final Logger LOGGER = LoggerFactory.getLogger(StorageContainerItemHelperImpl.class); - private final Map diskModelsByItem = new HashMap<>(); - private final Set diskModels = new HashSet<>(); - @Override public Optional resolveStorage(final StorageRepository storageRepository, final ItemStack stack) { @@ -200,22 +190,6 @@ public void transferFromBlockEntity(final ItemStack stack, final StorageBlockEnt } } - @Override - public void registerDiskModel(final Item item, final ResourceLocation model) { - diskModelsByItem.put(item, model); - diskModels.add(model); - } - - @Override - public Set getDiskModels() { - return diskModels; - } - - @Override - public Map getDiskModelsByItem() { - return Collections.unmodifiableMap(diskModelsByItem); - } - @Override public void markAsToTransfer(final ItemStack from, final ItemStack to) { getId(from).ifPresent(id -> to.set(DataComponents.INSTANCE.getStorageReferenceToBeTransferred(), id)); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storageblock/FluidStorageBlockBlockItem.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storageblock/FluidStorageBlockBlockItem.java index 253ede466..af786590b 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storageblock/FluidStorageBlockBlockItem.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storageblock/FluidStorageBlockBlockItem.java @@ -1,6 +1,7 @@ package com.refinedmods.refinedstorage.common.storage.storageblock; import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; import com.refinedmods.refinedstorage.common.api.storage.AbstractStorageContainerBlockItem; import com.refinedmods.refinedstorage.common.api.storage.SerializableStorage; import com.refinedmods.refinedstorage.common.api.storage.StorageRepository; @@ -60,7 +61,7 @@ protected Long getCapacity() { @Override protected String formatAmount(final long amount) { - return RefinedStorageApi.INSTANCE.getResourceRendering(FluidResource.class).formatAmount(amount); + return RefinedStorageClientApi.INSTANCE.getResourceRendering(FluidResource.class).formatAmount(amount); } @Override diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storageblock/FluidStorageBlockProvider.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storageblock/FluidStorageBlockProvider.java index cbfee9d26..2b45f1e7c 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storageblock/FluidStorageBlockProvider.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storageblock/FluidStorageBlockProvider.java @@ -22,12 +22,10 @@ public class FluidStorageBlockProvider implements StorageBlockProvider { private final FluidStorageVariant variant; private final Component displayName; - private final long energyUsage; public FluidStorageBlockProvider(final FluidStorageVariant variant) { this.variant = variant; this.displayName = createTranslation("block", String.format("%s_fluid_storage_block", variant.getName())); - this.energyUsage = getEnergyUsage(variant); } @Override @@ -37,7 +35,7 @@ public BlockEntity createBlockEntity(final BlockPos pos, final BlockState state) @Override public SerializableStorage createStorage(final Runnable listener) { - return StorageTypes.ITEM.create(variant.getCapacity(), listener); + return StorageTypes.FLUID.create(variant.getCapacity(), listener); } @Override @@ -47,10 +45,6 @@ public Component getDisplayName() { @Override public long getEnergyUsage() { - return energyUsage; - } - - private static long getEnergyUsage(final FluidStorageVariant variant) { return switch (variant) { case SIXTY_FOUR_B -> Platform.INSTANCE.getConfig().getFluidStorageBlock().get64bEnergyUsage(); case TWO_HUNDRED_FIFTY_SIX_B -> Platform.INSTANCE.getConfig().getFluidStorageBlock().get256bEnergyUsage(); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storageblock/ItemStorageBlockProvider.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storageblock/ItemStorageBlockProvider.java index edba0701a..72b13446d 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storageblock/ItemStorageBlockProvider.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storageblock/ItemStorageBlockProvider.java @@ -22,12 +22,10 @@ public class ItemStorageBlockProvider implements StorageBlockProvider { private final ItemStorageVariant variant; private final Component displayName; - private final long energyUsage; public ItemStorageBlockProvider(final ItemStorageVariant variant) { this.variant = variant; this.displayName = createTranslation("block", String.format("%s_storage_block", variant.getName())); - this.energyUsage = getEnergyUsage(variant); } @Override @@ -47,10 +45,6 @@ public Component getDisplayName() { @Override public long getEnergyUsage() { - return energyUsage; - } - - private static long getEnergyUsage(final ItemStorageVariant variant) { return switch (variant) { case ONE_K -> Platform.INSTANCE.getConfig().getStorageBlock().get1kEnergyUsage(); case FOUR_K -> Platform.INSTANCE.getConfig().getStorageBlock().get4kEnergyUsage(); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storageblock/StorageBlock.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storageblock/StorageBlock.java index 33546c932..968ccdf86 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storageblock/StorageBlock.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storageblock/StorageBlock.java @@ -29,6 +29,7 @@ public void tick(final Level level, final BlockState blockState, final BlockEntity blockEntity) { if (blockEntity instanceof AbstractBaseNetworkNodeContainerBlockEntity networkNode) { + networkNode.updateActiveness(blockState, null); networkNode.doWork(); } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storagedisk/FluidStorageDiskItem.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storagedisk/FluidStorageDiskItem.java index c26266938..769648d4c 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storagedisk/FluidStorageDiskItem.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storagedisk/FluidStorageDiskItem.java @@ -1,6 +1,7 @@ package com.refinedmods.refinedstorage.common.storage.storagedisk; import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; import com.refinedmods.refinedstorage.common.api.storage.AbstractStorageContainerItem; import com.refinedmods.refinedstorage.common.api.storage.SerializableStorage; import com.refinedmods.refinedstorage.common.api.storage.StorageRepository; @@ -53,7 +54,7 @@ protected Long getCapacity() { @Override protected String formatAmount(final long amount) { - return RefinedStorageApi.INSTANCE.getResourceRendering(FluidResource.class).formatAmount(amount); + return RefinedStorageClientApi.INSTANCE.getResourceRendering(FluidResource.class).formatAmount(amount); } @Override diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storagemonitor/StorageMonitorBlockEntityRenderer.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storagemonitor/StorageMonitorBlockEntityRenderer.java index 582990291..0c38b518e 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storagemonitor/StorageMonitorBlockEntityRenderer.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storagemonitor/StorageMonitorBlockEntityRenderer.java @@ -1,7 +1,7 @@ package com.refinedmods.refinedstorage.common.storagemonitor; import com.refinedmods.refinedstorage.api.resource.ResourceKey; -import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceRendering; import com.refinedmods.refinedstorage.common.support.direction.BiDirection; import com.refinedmods.refinedstorage.common.support.direction.BiDirectionType; @@ -61,7 +61,7 @@ private void doRender(final Level level, final BiDirection direction, final ResourceKey resource, final long amount) { - final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering(resource.getClass()); + final ResourceRendering rendering = RefinedStorageClientApi.INSTANCE.getResourceRendering(resource.getClass()); doRender( poseStack, vertexConsumers, diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/AbstractBaseScreen.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/AbstractBaseScreen.java index 72e200b35..63c90187a 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/AbstractBaseScreen.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/AbstractBaseScreen.java @@ -3,6 +3,7 @@ import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.common.Platform; import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; import com.refinedmods.refinedstorage.common.api.support.resource.PlatformResourceKey; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceFactory; import com.refinedmods.refinedstorage.common.api.upgrade.UpgradeMapping; @@ -208,7 +209,7 @@ public final List getResourceSlotTooltip(final ItemStack } protected List getResourceSlotTooltip(final ResourceKey resource, final ResourceSlot slot) { - final List tooltip = RefinedStorageApi.INSTANCE + final List tooltip = RefinedStorageClientApi.INSTANCE .getResourceRendering(resource.getClass()) .getTooltip(resource) .stream() diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/ResourceSlotRendering.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/ResourceSlotRendering.java index 4c4d8d604..8be478e1e 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/ResourceSlotRendering.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/ResourceSlotRendering.java @@ -1,7 +1,7 @@ package com.refinedmods.refinedstorage.common.support; import com.refinedmods.refinedstorage.api.resource.ResourceKey; -import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceRendering; import com.refinedmods.refinedstorage.common.support.containermenu.ResourceSlot; @@ -38,7 +38,7 @@ private static void render(final GuiGraphics graphics, final ResourceKey resource, final long amount, final boolean renderAmount) { - final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering(resource.getClass()); + final ResourceRendering rendering = RefinedStorageClientApi.INSTANCE.getResourceRendering(resource.getClass()); rendering.render(resource, graphics, x, y); if (renderAmount) { renderAmount(graphics, x, y, amount, rendering); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/FluidResourceRendering.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/FluidResourceRendering.java index 57506c10b..f4ed420e6 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/FluidResourceRendering.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/FluidResourceRendering.java @@ -18,10 +18,14 @@ import net.minecraft.world.level.Level; public class FluidResourceRendering implements ResourceRendering { - private static final DecimalFormat LESS_THAN_1_BUCKET_FORMATTER = - new DecimalFormat("0.#", DecimalFormatSymbols.getInstance(Locale.US)); - private static final DecimalFormat FORMATTER = - new DecimalFormat("#,###.#", DecimalFormatSymbols.getInstance(Locale.US)); + private static final DecimalFormat LESS_THAN_1_BUCKET_FORMATTER = new DecimalFormat( + "0.#", + DecimalFormatSymbols.getInstance(Locale.US) + ); + private static final DecimalFormat FORMATTER = new DecimalFormat( + "#,###.#", + DecimalFormatSymbols.getInstance(Locale.US) + ); private final long bucketAmount; diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ItemResourceRendering.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ItemResourceRendering.java index d4b107f7c..da2c6a27b 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ItemResourceRendering.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ItemResourceRendering.java @@ -25,8 +25,11 @@ import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.format; import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.formatWithUnits; -public class ItemResourceRendering implements ResourceRendering { - public static final Matrix4f IN_WORLD_SCALE = new Matrix4f().scale(0.3F, 0.3F, 0.001f); +public enum ItemResourceRendering implements ResourceRendering { + INSTANCE; + + public static final Matrix4f IN_WORLD_SCALE = new Matrix4f().scale(0.3F, 0.3F, 0.001F); + private final Map stackCache = new HashMap<>(); private ItemStack getStack(final ItemResource itemResource) { diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/tooltip/MouseClientTooltipComponent.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/tooltip/MouseClientTooltipComponent.java index 8ddf14d05..1c0bdf4a5 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/tooltip/MouseClientTooltipComponent.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/tooltip/MouseClientTooltipComponent.java @@ -2,7 +2,7 @@ import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.common.Platform; -import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; import com.refinedmods.refinedstorage.common.support.resource.FluidResource; import javax.annotation.Nullable; @@ -102,7 +102,7 @@ public static ClientTooltipComponent resource(final Type type, @Nullable final String amount) { return new MouseClientTooltipComponent( type, - (graphics, x, y) -> RefinedStorageApi.INSTANCE.getResourceRendering(resource.getClass()) + (graphics, x, y) -> RefinedStorageClientApi.INSTANCE.getResourceRendering(resource.getClass()) .render(resource, graphics, x, y), amount ); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/tooltip/ResourceClientTooltipComponent.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/tooltip/ResourceClientTooltipComponent.java index 526fa8153..151fa2601 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/tooltip/ResourceClientTooltipComponent.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/tooltip/ResourceClientTooltipComponent.java @@ -1,7 +1,7 @@ package com.refinedmods.refinedstorage.common.support.tooltip; import com.refinedmods.refinedstorage.api.resource.ResourceAmount; -import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceRendering; import net.minecraft.client.gui.Font; @@ -30,7 +30,7 @@ public int getWidth(final Font font) { @Override public void renderImage(final Font font, final int x, final int y, final GuiGraphics graphics) { - RefinedStorageApi.INSTANCE.getResourceRendering(resourceAmount.resource().getClass()).render( + RefinedStorageClientApi.INSTANCE.getResourceRendering(resourceAmount.resource().getClass()).render( resourceAmount.resource(), graphics, x, @@ -46,7 +46,7 @@ public void renderImage(final Font font, final int x, final int y, final GuiGrap } private static Component getNameWithAmount(final ResourceAmount resourceAmount) { - final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering( + final ResourceRendering rendering = RefinedStorageClientApi.INSTANCE.getResourceRendering( resourceAmount.resource().getClass() ); final String amount = rendering.formatAmount(resourceAmount.amount()); diff --git a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/ClientModInitializerImpl.java b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/ClientModInitializerImpl.java index 17796cf06..27d301f9a 100644 --- a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/ClientModInitializerImpl.java +++ b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/ClientModInitializerImpl.java @@ -72,6 +72,7 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; import net.minecraft.client.renderer.item.ItemProperties; +import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.inventory.AbstractContainerMenu; @@ -88,6 +89,7 @@ public class ClientModInitializerImpl extends AbstractClientModInitializer imple @Override public void onInitializeClient() { + initializeClientPlatformApi(); setRenderLayers(); registerEmissiveModels(); registerPacketHandlers(); @@ -460,27 +462,27 @@ private void registerCustomPatternModel(final ModelLoadingPlugin.Context pluginC } private void registerCustomTooltips() { - TooltipComponentCallback.EVENT.register(data -> { - if (data instanceof AbstractUpgradeItem.UpgradeDestinationTooltipComponent component) { + TooltipComponentCallback.EVENT.register(d -> { + if (d instanceof AbstractUpgradeItem.UpgradeDestinationTooltipComponent(var destinations, var helpText)) { return new CompositeClientTooltipComponent(List.of( - new UpgradeDestinationClientTooltipComponent(component.destinations()), - HelpClientTooltipComponent.create(component.helpText()) + new UpgradeDestinationClientTooltipComponent(destinations), + HelpClientTooltipComponent.create(helpText) )); } return null; }); TooltipComponentCallback.EVENT.register(data -> { - if (data instanceof HelpTooltipComponent component) { - return HelpClientTooltipComponent.create(component.text()); + if (data instanceof HelpTooltipComponent(Component text)) { + return HelpClientTooltipComponent.create(text); } return null; }); - TooltipComponentCallback.EVENT.register(data -> { - if (data instanceof RegulatorUpgradeItem.RegulatorTooltipComponent component) { + TooltipComponentCallback.EVENT.register(d -> { + if (d instanceof RegulatorUpgradeItem.RegulatorTooltipComponent(var destinations, var helpText, var r)) { return createRegulatorUpgradeClientTooltipComponent( - component.destinations(), - component.configuredResource(), - component.helpText() + destinations, + r, + helpText ); } return null; diff --git a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/storage/diskdrive/DiskDriveUnbakedModel.java b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/storage/diskdrive/DiskDriveUnbakedModel.java index a6e02f845..a72c0206a 100644 --- a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/storage/diskdrive/DiskDriveUnbakedModel.java +++ b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/storage/diskdrive/DiskDriveUnbakedModel.java @@ -1,6 +1,6 @@ package com.refinedmods.refinedstorage.fabric.storage.diskdrive; -import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; import com.refinedmods.refinedstorage.fabric.support.render.QuadRotators; import java.util.Collection; @@ -38,14 +38,14 @@ public Collection getDependencies() { final Set dependencies = new HashSet<>(); dependencies.add(BASE_MODEL); dependencies.add(LED_INACTIVE_MODEL); - dependencies.addAll(RefinedStorageApi.INSTANCE.getStorageContainerItemHelper().getDiskModels()); + dependencies.addAll(RefinedStorageClientApi.INSTANCE.getDiskModels()); return dependencies; } @Override public void resolveParents(final Function modelGetter) { modelGetter.apply(BASE_MODEL).resolveParents(modelGetter); - RefinedStorageApi.INSTANCE.getStorageContainerItemHelper().getDiskModels().forEach( + RefinedStorageClientApi.INSTANCE.getDiskModels().forEach( diskModel -> modelGetter.apply(diskModel).resolveParents(modelGetter) ); modelGetter.apply(LED_INACTIVE_MODEL).resolveParents(modelGetter); @@ -56,8 +56,7 @@ public void resolveParents(final Function modelG public BakedModel bake(final ModelBaker baker, final Function spriteGetter, final ModelState state) { - final Map diskModels = RefinedStorageApi.INSTANCE.getStorageContainerItemHelper() - .getDiskModelsByItem() + final Map diskModels = RefinedStorageClientApi.INSTANCE.getDiskModelsByItem() .entrySet() .stream() .collect(Collectors.toMap( diff --git a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/storage/diskinterface/DiskInterfaceUnbakedModel.java b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/storage/diskinterface/DiskInterfaceUnbakedModel.java index ef4d4b1f3..f964fe61b 100644 --- a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/storage/diskinterface/DiskInterfaceUnbakedModel.java +++ b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/storage/diskinterface/DiskInterfaceUnbakedModel.java @@ -1,6 +1,6 @@ package com.refinedmods.refinedstorage.fabric.storage.diskinterface; -import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; import com.refinedmods.refinedstorage.fabric.support.render.QuadRotators; import java.util.Collection; @@ -44,7 +44,7 @@ public Collection getDependencies() { dependencies.add(baseModel); dependencies.add(INACTIVE_MODEL); dependencies.add(LED_INACTIVE_MODEL); - dependencies.addAll(RefinedStorageApi.INSTANCE.getStorageContainerItemHelper().getDiskModels()); + dependencies.addAll(RefinedStorageClientApi.INSTANCE.getDiskModels()); return dependencies; } @@ -52,7 +52,7 @@ public Collection getDependencies() { public void resolveParents(final Function modelGetter) { modelGetter.apply(baseModel).resolveParents(modelGetter); modelGetter.apply(INACTIVE_MODEL).resolveParents(modelGetter); - RefinedStorageApi.INSTANCE.getStorageContainerItemHelper().getDiskModels().forEach( + RefinedStorageClientApi.INSTANCE.getDiskModels().forEach( diskModel -> modelGetter.apply(diskModel).resolveParents(modelGetter) ); modelGetter.apply(LED_INACTIVE_MODEL).resolveParents(modelGetter); @@ -63,7 +63,7 @@ public void resolveParents(final Function modelG public BakedModel bake(final ModelBaker baker, final Function spriteGetter, final ModelState state) { - final Map diskModels = RefinedStorageApi.INSTANCE.getStorageContainerItemHelper() + final Map diskModels = RefinedStorageClientApi.INSTANCE .getDiskModelsByItem() .entrySet() .stream() diff --git a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/storage/portablegrid/PortableGridUnbakedModel.java b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/storage/portablegrid/PortableGridUnbakedModel.java index 1cafd0d1a..a94087748 100644 --- a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/storage/portablegrid/PortableGridUnbakedModel.java +++ b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/storage/portablegrid/PortableGridUnbakedModel.java @@ -1,6 +1,6 @@ package com.refinedmods.refinedstorage.fabric.storage.portablegrid; -import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; import com.refinedmods.refinedstorage.fabric.support.render.QuadRotators; import java.util.Collection; @@ -48,7 +48,7 @@ public void resolveParents(final Function modelG modelGetter.apply(NORMAL_LED_MODEL).resolveParents(modelGetter); modelGetter.apply(NEAR_CAPACITY_LED_MODEL).resolveParents(modelGetter); modelGetter.apply(FULL_LED_MODEL).resolveParents(modelGetter); - RefinedStorageApi.INSTANCE.getStorageContainerItemHelper().getDiskModels().forEach( + RefinedStorageClientApi.INSTANCE.getDiskModels().forEach( diskModel -> modelGetter.apply(diskModel).resolveParents(modelGetter) ); } @@ -57,7 +57,7 @@ public void resolveParents(final Function modelG public BakedModel bake(final ModelBaker baker, final Function spriteGetter, final ModelState state) { - final Map diskModels = RefinedStorageApi.INSTANCE.getStorageContainerItemHelper() + final Map diskModels = RefinedStorageClientApi.INSTANCE .getDiskModelsByItem() .entrySet() .stream() diff --git a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/ModInitializer.java b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/ModInitializer.java index de22470b2..8a823eed4 100644 --- a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/ModInitializer.java +++ b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/ModInitializer.java @@ -1,5 +1,6 @@ package com.refinedmods.refinedstorage.neoforge; +import com.refinedmods.refinedstorage.common.AbstractClientModInitializer; import com.refinedmods.refinedstorage.common.AbstractModInitializer; import com.refinedmods.refinedstorage.common.Platform; import com.refinedmods.refinedstorage.common.PlatformProxy; @@ -215,6 +216,7 @@ public ModInitializer(final IEventBus eventBus, final ModContainer modContainer) registerTickHandler(); if (FMLEnvironment.dist == Dist.CLIENT) { + AbstractClientModInitializer.initializeClientPlatformApi(); eventBus.addListener(ClientModInitializer::onClientSetup); eventBus.addListener(ClientModInitializer::onRegisterCustomModels); eventBus.addListener(ClientModInitializer::onRegisterMenuScreens); diff --git a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/storage/diskdrive/DiskDriveUnbakedGeometry.java b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/storage/diskdrive/DiskDriveUnbakedGeometry.java index f50a5a1fb..af9a85aca 100644 --- a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/storage/diskdrive/DiskDriveUnbakedGeometry.java +++ b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/storage/diskdrive/DiskDriveUnbakedGeometry.java @@ -1,6 +1,6 @@ package com.refinedmods.refinedstorage.neoforge.storage.diskdrive; -import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; import com.refinedmods.refinedstorage.neoforge.support.render.DiskModelBaker; import com.refinedmods.refinedstorage.neoforge.support.render.RotationTranslationModelBaker; @@ -31,7 +31,7 @@ public class DiskDriveUnbakedGeometry implements IUnbakedGeometry modelGetter, final IGeometryBakingContext context) { modelGetter.apply(BASE_MODEL).resolveParents(modelGetter); - RefinedStorageApi.INSTANCE.getStorageContainerItemHelper().getDiskModels().forEach( + RefinedStorageClientApi.INSTANCE.getDiskModels().forEach( diskModel -> modelGetter.apply(diskModel).resolveParents(modelGetter) ); modelGetter.apply(LED_INACTIVE_MODEL).resolveParents(modelGetter); diff --git a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/storage/diskinterface/DiskInterfaceUnbakedGeometry.java b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/storage/diskinterface/DiskInterfaceUnbakedGeometry.java index af3d01e45..0216822af 100644 --- a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/storage/diskinterface/DiskInterfaceUnbakedGeometry.java +++ b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/storage/diskinterface/DiskInterfaceUnbakedGeometry.java @@ -1,6 +1,6 @@ package com.refinedmods.refinedstorage.neoforge.storage.diskinterface; -import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; import com.refinedmods.refinedstorage.neoforge.support.render.DiskModelBaker; import com.refinedmods.refinedstorage.neoforge.support.render.RotationTranslationModelBaker; @@ -36,7 +36,7 @@ public void resolveParents(final Function modelG final IGeometryBakingContext context) { modelGetter.apply(baseModel).resolveParents(modelGetter); modelGetter.apply(INACTIVE_MODEL).resolveParents(modelGetter); - RefinedStorageApi.INSTANCE.getStorageContainerItemHelper().getDiskModels().forEach( + RefinedStorageClientApi.INSTANCE.getDiskModels().forEach( diskModel -> modelGetter.apply(diskModel).resolveParents(modelGetter) ); modelGetter.apply(LED_INACTIVE_MODEL).resolveParents(modelGetter); diff --git a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/storage/portablegrid/PortableGridUnbakedGeometry.java b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/storage/portablegrid/PortableGridUnbakedGeometry.java index 38531d03e..c1e78dced 100644 --- a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/storage/portablegrid/PortableGridUnbakedGeometry.java +++ b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/storage/portablegrid/PortableGridUnbakedGeometry.java @@ -1,6 +1,6 @@ package com.refinedmods.refinedstorage.neoforge.storage.portablegrid; -import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; import com.refinedmods.refinedstorage.neoforge.support.render.DiskModelBaker; import com.refinedmods.refinedstorage.neoforge.support.render.RotationTranslationModelBaker; @@ -40,7 +40,7 @@ public void resolveParents(final Function modelG modelGetter.apply(NORMAL_LED_MODEL).resolveParents(modelGetter); modelGetter.apply(NEAR_CAPACITY_LED_MODEL).resolveParents(modelGetter); modelGetter.apply(FULL_LED_MODEL).resolveParents(modelGetter); - RefinedStorageApi.INSTANCE.getStorageContainerItemHelper().getDiskModels().forEach( + RefinedStorageClientApi.INSTANCE.getDiskModels().forEach( diskModel -> modelGetter.apply(diskModel).resolveParents(modelGetter) ); } diff --git a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/support/render/DiskModelBaker.java b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/support/render/DiskModelBaker.java index 6f7a5afad..abf563af9 100644 --- a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/support/render/DiskModelBaker.java +++ b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/support/render/DiskModelBaker.java @@ -1,6 +1,6 @@ package com.refinedmods.refinedstorage.neoforge.support.render; -import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.RefinedStorageClientApi; import java.util.Map; import java.util.function.Function; @@ -19,8 +19,7 @@ public class DiskModelBaker { public DiskModelBaker(final ModelState state, final ModelBaker baker, final Function spriteGetter) { - this.bakers = RefinedStorageApi.INSTANCE.getStorageContainerItemHelper() - .getDiskModelsByItem() + this.bakers = RefinedStorageClientApi.INSTANCE.getDiskModelsByItem() .entrySet() .stream() .collect(Collectors.toMap(