diff --git a/CHANGELOG.md b/CHANGELOG.md index b5835a3dc..0972b19ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,12 +10,15 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Changed - Updated to Minecraft 1.21.1. +- The Network Transmitter and Wireless Transmitter GUI now has an inactive and active GUI animation. +- The Wireless Transmitter now shows whether it's inactive in GUI instead of always showing the range. ### Fixed - Use new slimeballs convention tag for Processor Binding. - Portable Grid search bar texture being positioned in the wrong way. - External Storage screen unnecessarily showing upgrade slots. +- Grid setting changes not persisting after restarting Minecraft. ## [2.0.0-milestone.4.6] - 2024-08-08 diff --git a/refinedstorage-common-api/build.gradle.kts b/refinedstorage-common-api/build.gradle.kts index 14141ebd5..a0ab6c7e1 100644 --- a/refinedstorage-common-api/build.gradle.kts +++ b/refinedstorage-common-api/build.gradle.kts @@ -4,7 +4,6 @@ plugins { refinedarchitect { common() - testing() javadoc() publishing { maven = true @@ -22,9 +21,4 @@ dependencies { api(project(":refinedstorage-resource-api")) api(project(":refinedstorage-network-api")) api(project(":refinedstorage-grid-api")) - testImplementation(libs.junit.api) - testImplementation(libs.junit.params) - testImplementation(libs.assertj) - testImplementation(libs.equalsverifier) - testRuntimeOnly(libs.junit.engine) } 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 7d2ac7548..1894a2642 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 @@ -160,7 +160,7 @@ GridScrollingStrategy createGridScrollingStrategy(AbstractContainerMenu containe void registerResourceRendering(Class resourceClass, ResourceRendering rendering); - ResourceRendering getResourceRendering(ResourceKey resource); + ResourceRendering getResourceRendering(Class resourceClass); void addIngredientConverter(RecipeModIngredientConverter converter); 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 d30707043..0d8e2e3d5 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 @@ -297,8 +297,8 @@ public void registerResourceRendering(final Class res } @Override - public ResourceRendering getResourceRendering(final ResourceKey resource) { - return ensureLoaded().getResourceRendering(resource); + public ResourceRendering getResourceRendering(final Class resourceClass) { + return ensureLoaded().getResourceRendering(resourceClass); } @Override diff --git a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/AmountFormatting.java b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/AmountFormatting.java deleted file mode 100644 index 6997df638..000000000 --- a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/AmountFormatting.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.refinedmods.refinedstorage.common.api.support; - -import java.math.RoundingMode; -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; -import java.util.Locale; - -import org.apiguardian.api.API; - -@API(status = API.Status.STABLE, since = "2.0.0-milestone.1.0") -public final class AmountFormatting { - private static final DecimalFormat FORMATTER_WITH_UNITS = new DecimalFormat( - "####0.#", - DecimalFormatSymbols.getInstance(Locale.US) - ); - private static final DecimalFormat FORMATTER = new DecimalFormat( - "#,###", - DecimalFormatSymbols.getInstance(Locale.US) - ); - - static { - FORMATTER_WITH_UNITS.setRoundingMode(RoundingMode.FLOOR); - } - - private AmountFormatting() { - } - - public static String formatWithUnits(final long qty) { - if (qty >= 1_000_000_000) { - return formatBillion(qty); - } else if (qty >= 1_000_000) { - return formatMillion(qty); - } else if (qty >= 1000) { - return formatThousand(qty); - } - return String.valueOf(qty); - } - - private static String formatBillion(final long qty) { - return FORMATTER_WITH_UNITS.format(qty / 1_000_000_000D) + "B"; - } - - private static String formatMillion(final long qty) { - if (qty >= 100_000_000) { - return FORMATTER_WITH_UNITS.format(Math.floor(qty / 1_000_000D)) + "M"; - } - return FORMATTER_WITH_UNITS.format(qty / 1_000_000D) + "M"; - } - - private static String formatThousand(final long qty) { - if (qty >= 100_000) { - return FORMATTER_WITH_UNITS.format(Math.floor(qty / 1000D)) + "K"; - } - return FORMATTER_WITH_UNITS.format(qty / 1000D) + "K"; - } - - public static String format(final long qty) { - return FORMATTER.format(qty); - } -} diff --git a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/ResourceRendering.java b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/ResourceRendering.java index 1c50428d7..63722f40b 100644 --- a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/ResourceRendering.java +++ b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/ResourceRendering.java @@ -13,7 +13,11 @@ @API(status = API.Status.STABLE, since = "2.0.0-milestone.2.13") public interface ResourceRendering { - String getDisplayedAmount(long amount, boolean withUnits); + default String formatAmount(long amount) { + return formatAmount(amount, false); + } + + String formatAmount(long amount, boolean withUnits); Component getDisplayName(ResourceKey resource); diff --git a/refinedstorage-common-api/src/test/java/com/refinedmods/refinedstorage/common/api/support/AmountFormattingTest.java b/refinedstorage-common-api/src/test/java/com/refinedmods/refinedstorage/common/api/support/AmountFormattingTest.java deleted file mode 100644 index faefd7d76..000000000 --- a/refinedstorage-common-api/src/test/java/com/refinedmods/refinedstorage/common/api/support/AmountFormattingTest.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.refinedmods.refinedstorage.common.api.support; - -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -class AmountFormattingTest { - @Test - void shouldFormatWithUnitsForSmallNumber() { - // Act & assert - assertThat(AmountFormatting.formatWithUnits(0)).isEqualTo("0"); - assertThat(AmountFormatting.formatWithUnits(1)).isEqualTo("1"); - assertThat(AmountFormatting.formatWithUnits(10)).isEqualTo("10"); - assertThat(AmountFormatting.formatWithUnits(105)).isEqualTo("105"); - } - - @Test - void shouldFormatWithUnitsForThousands() { - // Act & assert - assertThat(AmountFormatting.formatWithUnits(1000)).isEqualTo("1K"); - assertThat(AmountFormatting.formatWithUnits(1510)).isEqualTo("1.5K"); - - assertThat(AmountFormatting.formatWithUnits(10_000)).isEqualTo("10K"); - assertThat(AmountFormatting.formatWithUnits(10_510)).isEqualTo("10.5K"); - assertThat(AmountFormatting.formatWithUnits(99_999)).isEqualTo("99.9K"); - - assertThat(AmountFormatting.formatWithUnits(100_000)).isEqualTo("100K"); - assertThat(AmountFormatting.formatWithUnits(100_500)).isEqualTo("100K"); - assertThat(AmountFormatting.formatWithUnits(100_999)).isEqualTo("100K"); - - assertThat(AmountFormatting.formatWithUnits(101_000)).isEqualTo("101K"); - assertThat(AmountFormatting.formatWithUnits(101_500)).isEqualTo("101K"); - assertThat(AmountFormatting.formatWithUnits(101_999)).isEqualTo("101K"); - } - - @Test - void shouldFormatWithUnitsForMillions() { - // Act & assert - assertThat(AmountFormatting.formatWithUnits(1_000_000)).isEqualTo("1M"); - assertThat(AmountFormatting.formatWithUnits(1_510_000)).isEqualTo("1.5M"); - - assertThat(AmountFormatting.formatWithUnits(10_000_000)).isEqualTo("10M"); - assertThat(AmountFormatting.formatWithUnits(10_510_000)).isEqualTo("10.5M"); - assertThat(AmountFormatting.formatWithUnits(99_999_999)).isEqualTo("99.9M"); - - assertThat(AmountFormatting.formatWithUnits(100_000_000)).isEqualTo("100M"); - assertThat(AmountFormatting.formatWithUnits(100_510_000)).isEqualTo("100M"); - assertThat(AmountFormatting.formatWithUnits(100_999_000)).isEqualTo("100M"); - - assertThat(AmountFormatting.formatWithUnits(101_000_000)).isEqualTo("101M"); - assertThat(AmountFormatting.formatWithUnits(101_510_000)).isEqualTo("101M"); - assertThat(AmountFormatting.formatWithUnits(101_999_000)).isEqualTo("101M"); - } - - @Test - void shouldFormatWithUnitsForBillions() { - // Act & assert - assertThat(AmountFormatting.formatWithUnits(1_000_000_000)).isEqualTo("1B"); - assertThat(AmountFormatting.formatWithUnits(1_010_000_000)).isEqualTo("1B"); - assertThat(AmountFormatting.formatWithUnits(1_100_000_000)).isEqualTo("1.1B"); - assertThat(AmountFormatting.formatWithUnits(1_100_001_000)).isEqualTo("1.1B"); - assertThat(AmountFormatting.formatWithUnits(1_920_001_000)).isEqualTo("1.9B"); - } - - @Test - void shouldFormatWithoutUnits() { - // Act & assert - assertThat(AmountFormatting.format(0)).isEqualTo("0"); - assertThat(AmountFormatting.format(1)).isEqualTo("1"); - assertThat(AmountFormatting.format(10)).isEqualTo("10"); - assertThat(AmountFormatting.format(105)).isEqualTo("105"); - assertThat(AmountFormatting.format(1050)).isEqualTo("1,050"); - assertThat(AmountFormatting.format(10500)).isEqualTo("10,500"); - assertThat(AmountFormatting.format(100500)).isEqualTo("100,500"); - assertThat(AmountFormatting.format(1000500)).isEqualTo("1,000,500"); - } -} 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 b9d9c997b..d673c87fd 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 @@ -19,6 +19,7 @@ import com.refinedmods.refinedstorage.common.importer.ImporterScreen; import com.refinedmods.refinedstorage.common.networking.NetworkTransmitterScreen; import com.refinedmods.refinedstorage.common.networking.RelayScreen; +import com.refinedmods.refinedstorage.common.networking.WirelessTransmitterScreen; import com.refinedmods.refinedstorage.common.security.FallbackSecurityCardScreen; import com.refinedmods.refinedstorage.common.security.SecurityCardScreen; import com.refinedmods.refinedstorage.common.security.SecurityManagerScreen; @@ -36,7 +37,6 @@ import com.refinedmods.refinedstorage.common.support.resource.ItemResource; import com.refinedmods.refinedstorage.common.support.resource.ItemResourceRendering; import com.refinedmods.refinedstorage.common.upgrade.RegulatorUpgradeScreen; -import com.refinedmods.refinedstorage.common.wirelesstransmitter.WirelessTransmitterScreen; import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; @@ -87,7 +87,9 @@ protected static void registerAlternativeGridHints() { protected static void registerResourceRendering() { RefinedStorageApi.INSTANCE.registerResourceRendering(ItemResource.class, new ItemResourceRendering()); - RefinedStorageApi.INSTANCE.registerResourceRendering(FluidResource.class, new FluidResourceRendering()); + RefinedStorageApi.INSTANCE.registerResourceRendering(FluidResource.class, new FluidResourceRendering( + Platform.INSTANCE.getBucketAmount() + )); } protected static void handleInputEvents() { diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/AbstractModInitializer.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/AbstractModInitializer.java index 771447fdd..2e4819340 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/AbstractModInitializer.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/AbstractModInitializer.java @@ -70,13 +70,19 @@ import com.refinedmods.refinedstorage.common.importer.ImporterContainerMenu; import com.refinedmods.refinedstorage.common.misc.ProcessorItem; import com.refinedmods.refinedstorage.common.misc.WrenchItem; +import com.refinedmods.refinedstorage.common.networking.BaseWirelessTransmitterRangeModifier; +import com.refinedmods.refinedstorage.common.networking.CreativeRangeUpgradeWirelessTransmitterRangeModifier; import com.refinedmods.refinedstorage.common.networking.NetworkCardItem; import com.refinedmods.refinedstorage.common.networking.NetworkReceiverBlockEntity; import com.refinedmods.refinedstorage.common.networking.NetworkTransmitterBlockEntity; import com.refinedmods.refinedstorage.common.networking.NetworkTransmitterContainerMenu; import com.refinedmods.refinedstorage.common.networking.NetworkTransmitterData; +import com.refinedmods.refinedstorage.common.networking.RangeUpgradeWirelessTransmitterRangeModifier; import com.refinedmods.refinedstorage.common.networking.RelayBlockEntity; import com.refinedmods.refinedstorage.common.networking.RelayContainerMenu; +import com.refinedmods.refinedstorage.common.networking.WirelessTransmitterBlockEntity; +import com.refinedmods.refinedstorage.common.networking.WirelessTransmitterContainerMenu; +import com.refinedmods.refinedstorage.common.networking.WirelessTransmitterData; import com.refinedmods.refinedstorage.common.security.BuiltinPermission; import com.refinedmods.refinedstorage.common.security.FallbackSecurityCardContainerMenu; import com.refinedmods.refinedstorage.common.security.PlatformSecurityNetworkComponentImpl; @@ -141,12 +147,6 @@ import com.refinedmods.refinedstorage.common.upgrade.SimpleUpgradeItem; import com.refinedmods.refinedstorage.common.upgrade.UpgradeDestinations; import com.refinedmods.refinedstorage.common.upgrade.UpgradeWithEnchantedBookRecipeSerializer; -import com.refinedmods.refinedstorage.common.wirelesstransmitter.BaseWirelessTransmitterRangeModifier; -import com.refinedmods.refinedstorage.common.wirelesstransmitter.CreativeRangeUpgradeWirelessTransmitterRangeModifier; -import com.refinedmods.refinedstorage.common.wirelesstransmitter.RangeUpgradeWirelessTransmitterRangeModifier; -import com.refinedmods.refinedstorage.common.wirelesstransmitter.WirelessTransmitterBlockEntity; -import com.refinedmods.refinedstorage.common.wirelesstransmitter.WirelessTransmitterContainerMenu; -import com.refinedmods.refinedstorage.common.wirelesstransmitter.WirelessTransmitterData; import java.util.Optional; import java.util.UUID; 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 6e0c4ebc5..6b75e9080 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 @@ -56,6 +56,7 @@ import com.refinedmods.refinedstorage.common.grid.strategy.CompositeGridExtractionStrategy; import com.refinedmods.refinedstorage.common.grid.strategy.CompositeGridInsertionStrategy; import com.refinedmods.refinedstorage.common.grid.strategy.CompositeGridScrollingStrategy; +import com.refinedmods.refinedstorage.common.networking.CompositeWirelessTransmitterRangeModifier; import com.refinedmods.refinedstorage.common.storage.ClientStorageRepository; import com.refinedmods.refinedstorage.common.storage.StorageContainerItemHelperImpl; import com.refinedmods.refinedstorage.common.storage.StorageRepositoryImpl; @@ -80,7 +81,6 @@ import com.refinedmods.refinedstorage.common.upgrade.UpgradeRegistryImpl; import com.refinedmods.refinedstorage.common.util.IdentifierUtil; import com.refinedmods.refinedstorage.common.util.ServerEventQueue; -import com.refinedmods.refinedstorage.common.wirelesstransmitter.CompositeWirelessTransmitterRangeModifier; import java.util.ArrayList; import java.util.Arrays; @@ -456,8 +456,8 @@ public void registerResourceRendering(final Class res } @Override - public ResourceRendering getResourceRendering(final ResourceKey resource) { - return resourceRenderingMap.get(resource.getClass()); + public ResourceRendering getResourceRendering(final Class resourceClass) { + return resourceRenderingMap.get(resourceClass); } @Override 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 9b32a4425..934acb854 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 @@ -100,7 +100,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).render( + RefinedStorageApi.INSTANCE.getResourceRendering(resource.getClass()).render( resource, graphics, x + sx * 18 + 1, diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternItem.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternItem.java index 522a54053..dbb5295d8 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternItem.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternItem.java @@ -10,7 +10,7 @@ import com.refinedmods.refinedstorage.common.content.Items; import com.refinedmods.refinedstorage.common.support.RecipeMatrixContainer; import com.refinedmods.refinedstorage.common.support.resource.ItemResource; -import com.refinedmods.refinedstorage.common.util.PlatformUtil; +import com.refinedmods.refinedstorage.common.util.ClientPlatformUtil; import java.util.ArrayList; import java.util.Arrays; @@ -86,7 +86,7 @@ public Optional getTooltipImage(final ItemStack stack) { if (state == null) { return Optional.of(new HelpTooltipComponent(HELP)); } - final Level level = PlatformUtil.getClientLevel(); + final Level level = ClientPlatformUtil.getClientLevel(); return switch (state.type()) { case CRAFTING -> { final CraftingPatternState craftingState = stack.get(DataComponents.INSTANCE.getCraftingPatternState()); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternRendering.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternRendering.java index 3c8108885..8f4ccc83e 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternRendering.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternRendering.java @@ -3,7 +3,7 @@ import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; import com.refinedmods.refinedstorage.common.api.autocrafting.PatternProviderItem; import com.refinedmods.refinedstorage.common.support.resource.ItemResource; -import com.refinedmods.refinedstorage.common.util.PlatformUtil; +import com.refinedmods.refinedstorage.common.util.ClientPlatformUtil; import java.util.Optional; @@ -32,7 +32,7 @@ public static boolean canDisplayOutput(final ItemStack stack) { } public static Optional getOutput(final ItemStack stack) { - final Level level = PlatformUtil.getClientLevel(); + final Level level = ClientPlatformUtil.getClientLevel(); if (level == null) { return Optional.empty(); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternTooltipCache.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternTooltipCache.java index ca8602462..969a65217 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternTooltipCache.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternTooltipCache.java @@ -35,8 +35,7 @@ public static ClientTooltipComponent getComponent(final PatternItem.StonecutterP CACHE.clear(); } return CACHE.computeIfAbsent(key.id(), id -> new StonecutterPatternClientTooltipComponent( - key.stonecutterPattern().input(), - key.stonecutterPattern().output() + key.stonecutterPattern() )); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/ProcessingMatrixInputClientTooltipComponent.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/ProcessingMatrixInputClientTooltipComponent.java index da3289b08..982a56aba 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/ProcessingMatrixInputClientTooltipComponent.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/ProcessingMatrixInputClientTooltipComponent.java @@ -69,7 +69,7 @@ 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); + final ResourceRendering rendering = RefinedStorageApi.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/ProcessingPatternClientTooltipComponent.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/ProcessingPatternClientTooltipComponent.java index 32850c518..742cefdf6 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 @@ -77,12 +77,9 @@ private static List getOutputText(final ProcessingPatternState state) private static Component getOutputText(final ResourceAmount resourceAmount) { final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering( - resourceAmount.resource() - ); - final String displayAmount = rendering.getDisplayedAmount( - resourceAmount.amount(), - false + resourceAmount.resource().getClass() ); + final String displayAmount = rendering.formatAmount(resourceAmount.amount()); return Component.literal(String.format("%sx ", displayAmount)) .append(rendering.getDisplayName(resourceAmount.resource())) .withStyle(ChatFormatting.GRAY); @@ -152,10 +149,10 @@ private void renderMatrixSlot( } final ResourceAmount resourceAmount = possibilities.get(currentCycle % possibilities.size()); final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering( - resourceAmount.resource() + resourceAmount.resource().getClass() ); rendering.render(resourceAmount.resource(), graphics, slotX + 1, slotY + 1); - ResourceSlotRendering.render(graphics, slotX + 1, slotY + 1, resourceAmount.amount(), rendering); + ResourceSlotRendering.renderAmount(graphics, slotX + 1, slotY + 1, resourceAmount.amount(), rendering); } private void renderOutputText(final Font font, final int x, final int y, final GuiGraphics graphics) { diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/SmithingTablePattern.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/SmithingTablePattern.java index 48b5de368..97a1c4520 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/SmithingTablePattern.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/SmithingTablePattern.java @@ -1,10 +1,8 @@ package com.refinedmods.refinedstorage.common.autocrafting; import com.refinedmods.refinedstorage.common.api.autocrafting.Pattern; -import com.refinedmods.refinedstorage.common.api.support.resource.PlatformResourceKey; +import com.refinedmods.refinedstorage.common.support.resource.ItemResource; -record SmithingTablePattern(PlatformResourceKey template, - PlatformResourceKey base, - PlatformResourceKey addition, - PlatformResourceKey output) implements Pattern { +record SmithingTablePattern(ItemResource template, ItemResource base, ItemResource addition, ItemResource output) + implements Pattern { } 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 2c248bd9b..312cc58e2 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,9 +1,9 @@ package com.refinedmods.refinedstorage.common.autocrafting; import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; -import com.refinedmods.refinedstorage.common.api.support.resource.PlatformResourceKey; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceRendering; import com.refinedmods.refinedstorage.common.support.Sprites; +import com.refinedmods.refinedstorage.common.support.resource.ItemResource; import net.minecraft.ChatFormatting; import net.minecraft.client.gui.Font; @@ -32,14 +32,12 @@ public void renderImage(final Font font, final int x, final int y, final GuiGrap graphics.drawString(font, outputText, x, y, requireNonNullElse(ChatFormatting.GRAY.getColor(), 15)); final int slotsY = y + 9 + 2; graphics.blitSprite(Sprites.SLOT, x, slotsY, 18, 18); - RefinedStorageApi.INSTANCE.getResourceRendering(pattern.template()) - .render(pattern.template(), graphics, x + 1, slotsY + 1); + final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering(ItemResource.class); + rendering.render(pattern.template(), graphics, x + 1, slotsY + 1); graphics.blitSprite(Sprites.SLOT, x + 18, slotsY, 18, 18); - RefinedStorageApi.INSTANCE.getResourceRendering(pattern.base()) - .render(pattern.base(), graphics, x + 18 + 1, slotsY + 1); + rendering.render(pattern.base(), graphics, x + 18 + 1, slotsY + 1); graphics.blitSprite(Sprites.SLOT, x + 18 + 18, slotsY, 18, 18); - RefinedStorageApi.INSTANCE.getResourceRendering(pattern.addition()) - .render(pattern.addition(), graphics, x + 18 + 18 + 1, slotsY + 1); + rendering.render(pattern.addition(), graphics, x + 18 + 18 + 1, slotsY + 1); graphics.blitSprite( LIGHT_ARROW, x + (18 * 3) + ARROW_SPACING, @@ -49,8 +47,7 @@ public void renderImage(final Font font, final int x, final int y, final GuiGrap ); final int lastSlotX = x + (18 * 3) + ARROW_SPACING + LIGHT_ARROW_WIDTH + ARROW_SPACING; graphics.blitSprite(Sprites.SLOT, lastSlotX, slotsY, 18, 18); - RefinedStorageApi.INSTANCE.getResourceRendering(pattern.output()) - .render(pattern.output(), graphics, lastSlotX + 1, slotsY + 1); + rendering.render(pattern.output(), graphics, lastSlotX + 1, slotsY + 1); } @Override @@ -66,10 +63,10 @@ public int getWidth(final Font font) { ); } - private static Component getOutputText(final PlatformResourceKey resource) { - final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering(resource); + private static Component getOutputText(final ItemResource output) { + final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering(ItemResource.class); return Component.literal("1x ") - .append(rendering.getDisplayName(resource)) + .append(rendering.getDisplayName(output)) .withStyle(ChatFormatting.GRAY); } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/SmithingTablePatternGridRenderer.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/SmithingTablePatternGridRenderer.java index 9628d7568..9008c9790 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/SmithingTablePatternGridRenderer.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/SmithingTablePatternGridRenderer.java @@ -1,6 +1,6 @@ package com.refinedmods.refinedstorage.common.autocrafting; -import com.refinedmods.refinedstorage.common.util.PlatformUtil; +import com.refinedmods.refinedstorage.common.util.ClientPlatformUtil; import java.util.List; import java.util.Optional; @@ -62,7 +62,7 @@ class SmithingTablePatternGridRenderer implements PatternGridRenderer { @Override public void addWidgets(final Consumer widgets, final Consumer renderables) { - final Level level = PlatformUtil.getClientLevel(); + final Level level = ClientPlatformUtil.getClientLevel(); if (level == null) { return; } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/StonecutterPattern.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/StonecutterPattern.java index 3b39fb08f..e325ac647 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/StonecutterPattern.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/StonecutterPattern.java @@ -1,7 +1,7 @@ package com.refinedmods.refinedstorage.common.autocrafting; import com.refinedmods.refinedstorage.common.api.autocrafting.Pattern; -import com.refinedmods.refinedstorage.common.api.support.resource.PlatformResourceKey; +import com.refinedmods.refinedstorage.common.support.resource.ItemResource; -record StonecutterPattern(PlatformResourceKey input, PlatformResourceKey output) implements Pattern { +record StonecutterPattern(ItemResource input, ItemResource output) implements Pattern { } 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 90756883f..eeff7d187 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 @@ -3,6 +3,7 @@ import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; 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; import net.minecraft.ChatFormatting; import net.minecraft.client.gui.Font; @@ -23,17 +24,18 @@ class StonecutterPatternClientTooltipComponent implements ClientTooltipComponent private final PlatformResourceKey input; private final PlatformResourceKey output; - StonecutterPatternClientTooltipComponent(final PlatformResourceKey input, final PlatformResourceKey output) { - this.outputText = getOutputText(output); - this.input = input; - this.output = output; + StonecutterPatternClientTooltipComponent(final StonecutterPattern pattern) { + this.outputText = getOutputText(pattern.output()); + this.input = pattern.input(); + this.output = pattern.output(); } @Override public void renderImage(final Font font, final int x, final int y, final GuiGraphics graphics) { graphics.drawString(font, outputText, x, y, requireNonNullElse(ChatFormatting.GRAY.getColor(), 15)); graphics.blitSprite(SLOT, x, y + 9 + 2, 18, 18); - RefinedStorageApi.INSTANCE.getResourceRendering(input).render(input, graphics, x + 1, y + 9 + 2 + 1); + final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering(ItemResource.class); + rendering.render(input, graphics, x + 1, y + 9 + 2 + 1); graphics.blitSprite( LIGHT_ARROW, x + 18 + ARROW_SPACING, @@ -48,7 +50,7 @@ public void renderImage(final Font font, final int x, final int y, final GuiGrap 16, 18 ); - RefinedStorageApi.INSTANCE.getResourceRendering(output).render( + rendering.render( output, graphics, x + 18 + ARROW_SPACING + LIGHT_ARROW_WIDTH + ARROW_SPACING, @@ -56,10 +58,10 @@ public void renderImage(final Font font, final int x, final int y, final GuiGrap ); } - private static Component getOutputText(final PlatformResourceKey resource) { - final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering(resource); + private static Component getOutputText(final ItemResource output) { + final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering(ItemResource.class); return Component.literal("1x ") - .append(rendering.getDisplayName(resource)) + .append(rendering.getDisplayName(output)) .withStyle(ChatFormatting.GRAY); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/StonecutterPatternGridRenderer.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/StonecutterPatternGridRenderer.java index cb7551b3c..b7b5beb04 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/StonecutterPatternGridRenderer.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/StonecutterPatternGridRenderer.java @@ -1,7 +1,7 @@ package com.refinedmods.refinedstorage.common.autocrafting; import com.refinedmods.refinedstorage.common.support.widget.ScrollbarWidget; -import com.refinedmods.refinedstorage.common.util.PlatformUtil; +import com.refinedmods.refinedstorage.common.util.ClientPlatformUtil; import java.util.function.Consumer; import javax.annotation.Nullable; @@ -125,7 +125,7 @@ public void renderBackground(final GuiGraphics graphics, } graphics.blitSprite(buttonSprite, xx, yy, 16, 18); graphics.renderItem( - recipe.value().getResultItem(requireNonNull(PlatformUtil.getClientLevel()).registryAccess()), + recipe.value().getResultItem(requireNonNull(ClientPlatformUtil.getClientLevel()).registryAccess()), xx, yy + 1 ); @@ -145,7 +145,7 @@ public void renderTooltip(final Font font, for (int i = 0; i < menu.getStonecutterRecipes().size(); ++i) { final RecipeHolder recipe = menu.getStonecutterRecipes().get(i); final ItemStack result = recipe.value().getResultItem( - requireNonNull(PlatformUtil.getClientLevel()).registryAccess() + requireNonNull(ClientPlatformUtil.getClientLevel()).registryAccess() ); final int xx = getRecipeX(x, i); final int row = i / VanillaConstants.STONECUTTER_RECIPES_PER_ROW; 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 52cbb5070..edf871ffa 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 @@ -14,6 +14,7 @@ import com.refinedmods.refinedstorage.common.networking.NetworkReceiverBlockEntity; import com.refinedmods.refinedstorage.common.networking.NetworkTransmitterBlockEntity; import com.refinedmods.refinedstorage.common.networking.RelayBlockEntity; +import com.refinedmods.refinedstorage.common.networking.WirelessTransmitterBlockEntity; import com.refinedmods.refinedstorage.common.security.SecurityManagerBlockEntity; import com.refinedmods.refinedstorage.common.storage.FluidStorageVariant; import com.refinedmods.refinedstorage.common.storage.ItemStorageVariant; @@ -25,7 +26,6 @@ import com.refinedmods.refinedstorage.common.storage.storageblock.ItemStorageBlockBlockEntity; import com.refinedmods.refinedstorage.common.storagemonitor.StorageMonitorBlockEntity; import com.refinedmods.refinedstorage.common.support.network.BaseNetworkNodeContainerBlockEntity; -import com.refinedmods.refinedstorage.common.wirelesstransmitter.WirelessTransmitterBlockEntity; import java.util.EnumMap; import java.util.Map; diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/Blocks.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/Blocks.java index 2f9eaf37f..ee4512331 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/Blocks.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/Blocks.java @@ -19,6 +19,7 @@ import com.refinedmods.refinedstorage.common.networking.NetworkReceiverBlock; import com.refinedmods.refinedstorage.common.networking.NetworkTransmitterBlock; import com.refinedmods.refinedstorage.common.networking.RelayBlock; +import com.refinedmods.refinedstorage.common.networking.WirelessTransmitterBlock; import com.refinedmods.refinedstorage.common.security.SecurityManagerBlock; import com.refinedmods.refinedstorage.common.storage.FluidStorageVariant; import com.refinedmods.refinedstorage.common.storage.ItemStorageVariant; @@ -32,7 +33,6 @@ import com.refinedmods.refinedstorage.common.storagemonitor.StorageMonitorBlock; import com.refinedmods.refinedstorage.common.support.BaseBlockItem; import com.refinedmods.refinedstorage.common.support.SimpleBlock; -import com.refinedmods.refinedstorage.common.wirelesstransmitter.WirelessTransmitterBlock; import java.util.EnumMap; import java.util.Map; diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/Menus.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/Menus.java index b4c7642a2..328a7615c 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/Menus.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/Menus.java @@ -13,6 +13,7 @@ import com.refinedmods.refinedstorage.common.importer.ImporterContainerMenu; import com.refinedmods.refinedstorage.common.networking.NetworkTransmitterContainerMenu; import com.refinedmods.refinedstorage.common.networking.RelayContainerMenu; +import com.refinedmods.refinedstorage.common.networking.WirelessTransmitterContainerMenu; import com.refinedmods.refinedstorage.common.security.FallbackSecurityCardContainerMenu; import com.refinedmods.refinedstorage.common.security.SecurityCardContainerMenu; import com.refinedmods.refinedstorage.common.security.SecurityManagerContainerMenu; @@ -25,7 +26,6 @@ import com.refinedmods.refinedstorage.common.storage.storageblock.ItemStorageBlockContainerMenu; import com.refinedmods.refinedstorage.common.storagemonitor.StorageMonitorContainerMenu; import com.refinedmods.refinedstorage.common.upgrade.RegulatorUpgradeContainerMenu; -import com.refinedmods.refinedstorage.common.wirelesstransmitter.WirelessTransmitterContainerMenu; import java.util.function.Supplier; import javax.annotation.Nullable; 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 8eaa8d5de..e0f04b3e7 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,10 +1,10 @@ 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.grid.GridInsertionHint; import com.refinedmods.refinedstorage.common.api.support.resource.FluidOperationResult; import com.refinedmods.refinedstorage.common.support.resource.FluidResource; -import com.refinedmods.refinedstorage.common.support.resource.FluidResourceRendering; import com.refinedmods.refinedstorage.common.support.tooltip.MouseClientTooltipComponent; import java.util.Optional; @@ -24,7 +24,7 @@ private ClientTooltipComponent createComponent(final FluidOperationResult result (FluidResource) result.fluid(), result.amount() == Platform.INSTANCE.getBucketAmount() ? null - : FluidResourceRendering.format(result.amount()) + : RefinedStorageApi.INSTANCE.getResourceRendering(FluidResource.class).formatAmount(result.amount()) ); } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/hint/ItemGridInsertionHint.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/hint/ItemGridInsertionHint.java index 819e6f36a..d405ff1b2 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/hint/ItemGridInsertionHint.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/hint/ItemGridInsertionHint.java @@ -1,7 +1,6 @@ package com.refinedmods.refinedstorage.common.grid.screen.hint; import com.refinedmods.refinedstorage.common.api.grid.GridInsertionHint; -import com.refinedmods.refinedstorage.common.api.support.AmountFormatting; import com.refinedmods.refinedstorage.common.support.tooltip.MouseClientTooltipComponent; import java.util.Optional; @@ -9,13 +8,15 @@ import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; import net.minecraft.world.item.ItemStack; +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.format; + public class ItemGridInsertionHint implements GridInsertionHint { @Override public Optional getHint(final ItemStack carried) { return Optional.of(MouseClientTooltipComponent.item( MouseClientTooltipComponent.Type.LEFT, carried, - carried.getCount() == 1 ? null : AmountFormatting.format(carried.getCount()) + carried.getCount() == 1 ? null : format(carried.getCount()) )); } } 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 9571ec6dc..5f8b956ba 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 @@ -3,14 +3,15 @@ import com.refinedmods.refinedstorage.api.grid.operations.GridExtractMode; import com.refinedmods.refinedstorage.api.grid.view.GridView; import com.refinedmods.refinedstorage.common.Platform; +import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; import com.refinedmods.refinedstorage.common.api.grid.GridResourceAttributeKeys; 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; import com.refinedmods.refinedstorage.common.api.grid.view.AbstractPlatformGridResource; +import com.refinedmods.refinedstorage.common.api.support.resource.ResourceRendering; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceType; import com.refinedmods.refinedstorage.common.support.resource.FluidResource; -import com.refinedmods.refinedstorage.common.support.resource.FluidResourceRendering; import com.refinedmods.refinedstorage.common.support.resource.ResourceTypes; import com.refinedmods.refinedstorage.common.support.tooltip.MouseClientTooltipComponent; @@ -27,6 +28,7 @@ public class FluidGridResource extends AbstractPlatformGridResource { private final int id; + private final ResourceRendering rendering; public FluidGridResource(final FluidResource resource, final String name, @@ -41,6 +43,7 @@ public FluidGridResource(final FluidResource resource, GridResourceAttributeKeys.TOOLTIP, Set.of(tooltip) )); this.id = BuiltInRegistries.FLUID.getId(resource.fluid()); + this.rendering = RefinedStorageApi.INSTANCE.getResourceRendering(FluidResource.class); } @Override @@ -76,12 +79,12 @@ public void render(final GuiGraphics graphics, final int x, final int y) { @Override public String getDisplayedAmount(final GridView view) { - return FluidResourceRendering.formatWithUnits(getAmount(view)); + return rendering.formatAmount(getAmount(view), true); } @Override public String getAmountInTooltip(final GridView view) { - return FluidResourceRendering.format(getAmount(view)); + return rendering.formatAmount(getAmount(view)); } @Override diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/view/ItemGridResource.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/view/ItemGridResource.java index 25912cab7..dbf43035e 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/view/ItemGridResource.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/view/ItemGridResource.java @@ -7,7 +7,6 @@ import com.refinedmods.refinedstorage.common.api.grid.strategy.GridExtractionStrategy; import com.refinedmods.refinedstorage.common.api.grid.strategy.GridScrollingStrategy; import com.refinedmods.refinedstorage.common.api.grid.view.AbstractPlatformGridResource; -import com.refinedmods.refinedstorage.common.api.support.AmountFormatting; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceType; import com.refinedmods.refinedstorage.common.support.resource.ItemResource; import com.refinedmods.refinedstorage.common.support.resource.ResourceTypes; @@ -28,6 +27,9 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.format; +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.formatWithUnits; + public class ItemGridResource extends AbstractPlatformGridResource { private final int id; private final ItemStack itemStack; @@ -73,12 +75,12 @@ public List getExtractionHints(final GridView view) { MouseClientTooltipComponent.itemWithDecorations( MouseClientTooltipComponent.Type.LEFT, itemStack, - extractableAmount == 1 ? null : AmountFormatting.format(extractableAmount) + extractableAmount == 1 ? null : format(extractableAmount) ), MouseClientTooltipComponent.itemWithDecorations( MouseClientTooltipComponent.Type.RIGHT, itemStack, - halfExtractionAmount == 1 ? null : AmountFormatting.format(halfExtractionAmount) + halfExtractionAmount == 1 ? null : format(halfExtractionAmount) ) ); } @@ -104,12 +106,12 @@ public void render(final GuiGraphics graphics, final int x, final int y) { @Override public String getDisplayedAmount(final GridView view) { - return AmountFormatting.formatWithUnits(getAmount(view)); + return formatWithUnits(getAmount(view)); } @Override public String getAmountInTooltip(final GridView view) { - return AmountFormatting.format(getAmount(view)); + return format(getAmount(view)); } @Override diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/BaseWirelessTransmitterRangeModifier.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/BaseWirelessTransmitterRangeModifier.java similarity index 88% rename from refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/BaseWirelessTransmitterRangeModifier.java rename to refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/BaseWirelessTransmitterRangeModifier.java index 76b6cc3a4..e85aced1f 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/BaseWirelessTransmitterRangeModifier.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/BaseWirelessTransmitterRangeModifier.java @@ -1,4 +1,4 @@ -package com.refinedmods.refinedstorage.common.wirelesstransmitter; +package com.refinedmods.refinedstorage.common.networking; import com.refinedmods.refinedstorage.common.Platform; import com.refinedmods.refinedstorage.common.api.upgrade.UpgradeState; diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/CompositeWirelessTransmitterRangeModifier.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/CompositeWirelessTransmitterRangeModifier.java similarity index 93% rename from refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/CompositeWirelessTransmitterRangeModifier.java rename to refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/CompositeWirelessTransmitterRangeModifier.java index 1ac68976c..e2a89ea04 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/CompositeWirelessTransmitterRangeModifier.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/CompositeWirelessTransmitterRangeModifier.java @@ -1,4 +1,4 @@ -package com.refinedmods.refinedstorage.common.wirelesstransmitter; +package com.refinedmods.refinedstorage.common.networking; import com.refinedmods.refinedstorage.common.api.upgrade.UpgradeState; import com.refinedmods.refinedstorage.common.api.wirelesstransmitter.WirelessTransmitterRangeModifier; diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/CreativeRangeUpgradeWirelessTransmitterRangeModifier.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/CreativeRangeUpgradeWirelessTransmitterRangeModifier.java similarity index 91% rename from refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/CreativeRangeUpgradeWirelessTransmitterRangeModifier.java rename to refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/CreativeRangeUpgradeWirelessTransmitterRangeModifier.java index 5c1e8e8b7..8e8764fa4 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/CreativeRangeUpgradeWirelessTransmitterRangeModifier.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/CreativeRangeUpgradeWirelessTransmitterRangeModifier.java @@ -1,4 +1,4 @@ -package com.refinedmods.refinedstorage.common.wirelesstransmitter; +package com.refinedmods.refinedstorage.common.networking; import com.refinedmods.refinedstorage.common.api.upgrade.UpgradeState; import com.refinedmods.refinedstorage.common.api.wirelesstransmitter.WirelessTransmitterRangeModifier; diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/NetworkTransmitterBlockEntity.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/NetworkTransmitterBlockEntity.java index 5f32d3502..2235d07e4 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/NetworkTransmitterBlockEntity.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/NetworkTransmitterBlockEntity.java @@ -44,6 +44,7 @@ public class NetworkTransmitterBlockEntity private static final Logger LOGGER = LoggerFactory.getLogger(NetworkTransmitterBlockEntity.class); private static final NetworkTransmitterData INACTIVE = NetworkTransmitterData.message( + false, createTranslation("gui", "network_transmitter.status.inactive") ); private static final NetworkTransmitterData MISSING_NETWORK_CARD = NetworkTransmitterData.error( @@ -138,7 +139,7 @@ NetworkTransmitterData getStatus() { "gui", "network_transmitter.status.transmitting", receiverKey.getDistance(worldPosition)) : receiverKey.getDimensionName(); - return NetworkTransmitterData.message(message); + return NetworkTransmitterData.message(true, message); } @Override diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/NetworkTransmitterContainerMenu.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/NetworkTransmitterContainerMenu.java index 33538c0eb..b14de4e46 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/NetworkTransmitterContainerMenu.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/NetworkTransmitterContainerMenu.java @@ -60,7 +60,7 @@ public void broadcastChanges() { return; } final NetworkTransmitterData newStatus = blockEntity.getStatus(); - if (newStatus.message().equals(status.message())) { + if (newStatus.equals(status)) { return; } updateStatus(serverPlayer, newStatus); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/NetworkTransmitterData.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/NetworkTransmitterData.java index 3211a3423..79039c5af 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/NetworkTransmitterData.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/NetworkTransmitterData.java @@ -6,19 +6,20 @@ import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; -public record NetworkTransmitterData(boolean error, Component message) { +public record NetworkTransmitterData(boolean error, boolean transmitting, Component message) { public static final StreamCodec STREAM_CODEC = StreamCodec.composite( ByteBufCodecs.BOOL, NetworkTransmitterData::error, + ByteBufCodecs.BOOL, NetworkTransmitterData::transmitting, ComponentSerialization.STREAM_CODEC, NetworkTransmitterData::message, NetworkTransmitterData::new ); static NetworkTransmitterData error(final Component message) { - return new NetworkTransmitterData(true, message); + return new NetworkTransmitterData(true, false, message); } - static NetworkTransmitterData message(final Component message) { - return new NetworkTransmitterData(false, message); + static NetworkTransmitterData message(final boolean transmitting, final Component message) { + return new NetworkTransmitterData(false, transmitting, message); } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/NetworkTransmitterScreen.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/NetworkTransmitterScreen.java index 0d18b7603..84bd79eab 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/NetworkTransmitterScreen.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/NetworkTransmitterScreen.java @@ -16,6 +16,8 @@ public class NetworkTransmitterScreen extends AbstractBaseScreen { private static final ResourceLocation TEXTURE = createIdentifier("textures/gui/network_transmitter.png"); + private final TransmittingIcon icon; + public NetworkTransmitterScreen(final NetworkTransmitterContainerMenu menu, final Inventory playerInventory, final Component text) { @@ -23,6 +25,7 @@ public NetworkTransmitterScreen(final NetworkTransmitterContainerMenu menu, this.inventoryLabelY = 42; this.imageWidth = 176; this.imageHeight = 137; + this.icon = new TransmittingIcon(isIconActive()); } @Override @@ -31,15 +34,31 @@ protected void init() { addSideButton(new RedstoneModeSideButtonWidget(getMenu().getProperty(PropertyTypes.REDSTONE_MODE))); } + @Override + protected void containerTick() { + super.containerTick(); + icon.tick(isIconActive()); + } + + private boolean isIconActive() { + return !getMenu().getStatus().error() && getMenu().getStatus().transmitting(); + } + + @Override + protected void renderBg(final GuiGraphics graphics, final float delta, final int mouseX, final int mouseY) { + super.renderBg(graphics, delta, mouseX, mouseY); + icon.render(graphics, leftPos + 29, topPos + 22); + } + @Override protected void renderLabels(final GuiGraphics graphics, final int mouseX, final int mouseY) { super.renderLabels(graphics, mouseX, mouseY); final NetworkTransmitterData status = getMenu().getStatus(); - final int displayTextX = 51; + final int x = 25 + 4 + icon.getWidth() + 4; if (status.error()) { - graphics.blitSprite(WARNING, displayTextX, 23, WARNING_SIZE, WARNING_SIZE); + graphics.blitSprite(WARNING, x, 23, WARNING_SIZE, WARNING_SIZE); } - graphics.drawString(font, status.message(), displayTextX + (status.error() ? (10 + 4) : 0), 25, 4210752, false); + graphics.drawString(font, status.message(), x + (status.error() ? (10 + 4) : 0), 25, 4210752, false); } @Override diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/RangeUpgradeWirelessTransmitterRangeModifier.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/RangeUpgradeWirelessTransmitterRangeModifier.java similarity index 91% rename from refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/RangeUpgradeWirelessTransmitterRangeModifier.java rename to refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/RangeUpgradeWirelessTransmitterRangeModifier.java index cf18efaaa..1686e6300 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/RangeUpgradeWirelessTransmitterRangeModifier.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/RangeUpgradeWirelessTransmitterRangeModifier.java @@ -1,4 +1,4 @@ -package com.refinedmods.refinedstorage.common.wirelesstransmitter; +package com.refinedmods.refinedstorage.common.networking; import com.refinedmods.refinedstorage.common.Platform; import com.refinedmods.refinedstorage.common.api.upgrade.UpgradeState; diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/TransmittingIcon.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/TransmittingIcon.java new file mode 100644 index 000000000..db062c2b2 --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/TransmittingIcon.java @@ -0,0 +1,65 @@ +package com.refinedmods.refinedstorage.common.networking; + +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.resources.ResourceLocation; + +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; + +class TransmittingIcon { + private static final int WIDTH_0 = 11; + private static final int WIDTH_3 = 20; + private static final int TRANSMITTING_FRAMES = 20; + private static final ResourceLocation NOT_TRANSMITTING = createIdentifier("transmitting/0"); + private static final ResourceLocation TRANSMITTING_1 = createIdentifier("transmitting/1"); + private static final ResourceLocation TRANSMITTING_2 = createIdentifier("transmitting/2"); + private static final ResourceLocation TRANSMITTING_3 = createIdentifier("transmitting/3"); + + private int frames; + private int cycle; + private boolean active; + + TransmittingIcon(final boolean active) { + this.active = active; + } + + void tick(final boolean newActive) { + this.active = newActive; + doTick(); + } + + private void doTick() { + if (!active) { + frames = 0; + cycle = 0; + return; + } + ++frames; + if (frames == TRANSMITTING_FRAMES) { + frames = 0; + cycle++; + } + } + + void render(final GuiGraphics graphics, final int x3, final int y3) { + if (!active) { + graphics.blitSprite(NOT_TRANSMITTING, x3, y3 + 4, WIDTH_0, 4); + return; + } + final int frame = cycle % 3; + switch (frame) { + case 0: + graphics.blitSprite(TRANSMITTING_1, x3, y3 + 3, 14, 6); + break; + case 1: + graphics.blitSprite(TRANSMITTING_2, x3, y3 + 1, 17, 10); + break; + case 2: + graphics.blitSprite(TRANSMITTING_3, x3, y3, WIDTH_3, 12); + break; + } + } + + int getWidth() { + return active ? WIDTH_3 : WIDTH_0; + } +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/WirelessTransmitterBlock.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/WirelessTransmitterBlock.java similarity index 98% rename from refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/WirelessTransmitterBlock.java rename to refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/WirelessTransmitterBlock.java index 30603c483..9d3de8b2c 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/WirelessTransmitterBlock.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/WirelessTransmitterBlock.java @@ -1,4 +1,4 @@ -package com.refinedmods.refinedstorage.common.wirelesstransmitter; +package com.refinedmods.refinedstorage.common.networking; import com.refinedmods.refinedstorage.common.content.BlockColorMap; import com.refinedmods.refinedstorage.common.content.BlockConstants; diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/WirelessTransmitterBlockEntity.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/WirelessTransmitterBlockEntity.java similarity index 96% rename from refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/WirelessTransmitterBlockEntity.java rename to refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/WirelessTransmitterBlockEntity.java index bdd78012a..fc9803aa0 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/WirelessTransmitterBlockEntity.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/WirelessTransmitterBlockEntity.java @@ -1,4 +1,4 @@ -package com.refinedmods.refinedstorage.common.wirelesstransmitter; +package com.refinedmods.refinedstorage.common.networking; import com.refinedmods.refinedstorage.api.network.impl.node.SimpleNetworkNode; import com.refinedmods.refinedstorage.common.Platform; @@ -95,7 +95,7 @@ public AbstractContainerMenu createMenu(final int syncId, final Inventory invent @Override public WirelessTransmitterData getMenuData() { - return new WirelessTransmitterData(getRange()); + return new WirelessTransmitterData(getRange(), isActive()); } @Override @@ -127,4 +127,8 @@ protected boolean doesBlockStateChangeWarrantNetworkNodeUpdate(final BlockState final BlockState newBlockState) { return AbstractDirectionalBlock.doesBlockStateChangeWarrantNetworkNodeUpdate(oldBlockState, newBlockState); } + + boolean isActive() { + return mainNetworkNode.isActive(); + } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/WirelessTransmitterConnectionStrategy.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/WirelessTransmitterConnectionStrategy.java similarity index 95% rename from refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/WirelessTransmitterConnectionStrategy.java rename to refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/WirelessTransmitterConnectionStrategy.java index fbdc388d8..edceb9d8c 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/WirelessTransmitterConnectionStrategy.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/WirelessTransmitterConnectionStrategy.java @@ -1,4 +1,4 @@ -package com.refinedmods.refinedstorage.common.wirelesstransmitter; +package com.refinedmods.refinedstorage.common.networking; import com.refinedmods.refinedstorage.common.api.support.network.ConnectionSink; import com.refinedmods.refinedstorage.common.support.network.ColoredConnectionStrategy; diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/WirelessTransmitterContainerMenu.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/WirelessTransmitterContainerMenu.java similarity index 86% rename from refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/WirelessTransmitterContainerMenu.java rename to refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/WirelessTransmitterContainerMenu.java index 5bf934a6f..b853d3487 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/WirelessTransmitterContainerMenu.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/WirelessTransmitterContainerMenu.java @@ -1,4 +1,4 @@ -package com.refinedmods.refinedstorage.common.wirelesstransmitter; +package com.refinedmods.refinedstorage.common.networking; import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; import com.refinedmods.refinedstorage.common.content.Menus; @@ -22,11 +22,13 @@ public class WirelessTransmitterContainerMenu extends AbstractBaseContainerMenu { private final RateLimiter rangeRateLimiter = RateLimiter.create(4); - private int range; @Nullable private final WirelessTransmitterBlockEntity wirelessTransmitter; private final Player player; + private int range; + private boolean active; + public WirelessTransmitterContainerMenu(final int syncId, final Inventory playerInventory, final WirelessTransmitterData data) { @@ -37,6 +39,7 @@ public WirelessTransmitterContainerMenu(final int syncId, )); registerProperty(new ClientProperty<>(PropertyTypes.REDSTONE_MODE, RedstoneMode.IGNORE)); this.range = data.range(); + this.active = data.active(); this.wirelessTransmitter = null; this.player = playerInventory.player; } @@ -53,6 +56,7 @@ public WirelessTransmitterContainerMenu(final int syncId, wirelessTransmitter::setRedstoneMode )); this.range = wirelessTransmitter.getRange(); + this.active = wirelessTransmitter.isActive(); this.wirelessTransmitter = wirelessTransmitter; this.player = playerInventory.player; } @@ -72,10 +76,12 @@ public void broadcastChanges() { return; } final int newRange = wirelessTransmitter.getRange(); - final boolean changed = range != newRange; + final boolean newActive = wirelessTransmitter.isActive(); + final boolean changed = range != newRange || active != newActive; if (changed && rangeRateLimiter.tryAcquire()) { this.range = newRange; - S2CPackets.sendWirelessTransmitterRange((ServerPlayer) player, range); + this.active = newActive; + S2CPackets.sendWirelessTransmitterData((ServerPlayer) player, range, active); } } @@ -83,7 +89,15 @@ int getRange() { return range; } + boolean isActive() { + return active; + } + public void setRange(final int range) { this.range = range; } + + public void setActive(final boolean active) { + this.active = active; + } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/WirelessTransmitterData.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/WirelessTransmitterData.java similarity index 67% rename from refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/WirelessTransmitterData.java rename to refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/WirelessTransmitterData.java index a0e60942b..374d274a5 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/WirelessTransmitterData.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/WirelessTransmitterData.java @@ -1,13 +1,14 @@ -package com.refinedmods.refinedstorage.common.wirelesstransmitter; +package com.refinedmods.refinedstorage.common.networking; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; -public record WirelessTransmitterData(int range) { +public record WirelessTransmitterData(int range, boolean active) { public static final StreamCodec STREAM_CODEC = StreamCodec.composite( ByteBufCodecs.INT, WirelessTransmitterData::range, + ByteBufCodecs.BOOL, WirelessTransmitterData::active, WirelessTransmitterData::new ); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/WirelessTransmitterNetworkNodeContainer.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/WirelessTransmitterNetworkNodeContainer.java similarity index 96% rename from refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/WirelessTransmitterNetworkNodeContainer.java rename to refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/WirelessTransmitterNetworkNodeContainer.java index 4e211ab69..5d2ab78d7 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/WirelessTransmitterNetworkNodeContainer.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/WirelessTransmitterNetworkNodeContainer.java @@ -1,4 +1,4 @@ -package com.refinedmods.refinedstorage.common.wirelesstransmitter; +package com.refinedmods.refinedstorage.common.networking; import com.refinedmods.refinedstorage.api.network.impl.node.AbstractNetworkNode; import com.refinedmods.refinedstorage.common.api.support.network.item.NetworkItemPlayerValidator; diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/WirelessTransmitterScreen.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/WirelessTransmitterScreen.java similarity index 67% rename from refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/WirelessTransmitterScreen.java rename to refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/WirelessTransmitterScreen.java index 85ba735f4..a65823bfd 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/WirelessTransmitterScreen.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/networking/WirelessTransmitterScreen.java @@ -1,4 +1,4 @@ -package com.refinedmods.refinedstorage.common.wirelesstransmitter; +package com.refinedmods.refinedstorage.common.networking; import com.refinedmods.refinedstorage.common.support.AbstractBaseScreen; import com.refinedmods.refinedstorage.common.support.containermenu.PropertyTypes; @@ -6,6 +6,7 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; @@ -13,8 +14,11 @@ import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createTranslation; public class WirelessTransmitterScreen extends AbstractBaseScreen { + private static final MutableComponent INACTIVE = createTranslation("gui", "wireless_transmitter.inactive"); private static final ResourceLocation TEXTURE = createIdentifier("textures/gui/wireless_transmitter.png"); + private final TransmittingIcon icon; + public WirelessTransmitterScreen(final WirelessTransmitterContainerMenu containerMenu, final Inventory inventory, final Component title) { @@ -22,6 +26,7 @@ public WirelessTransmitterScreen(final WirelessTransmitterContainerMenu containe this.inventoryLabelY = 43; this.imageWidth = 211; this.imageHeight = 137; + this.icon = new TransmittingIcon(getMenu().isActive()); } @Override @@ -30,18 +35,35 @@ protected void init() { addSideButton(new RedstoneModeSideButtonWidget(getMenu().getProperty(PropertyTypes.REDSTONE_MODE))); } + @Override + protected void containerTick() { + super.containerTick(); + icon.tick(getMenu().isActive()); + } + @Override protected ResourceLocation getTexture() { return TEXTURE; } + @Override + protected void renderBg(final GuiGraphics graphics, final float delta, final int mouseX, final int mouseY) { + super.renderBg(graphics, delta, mouseX, mouseY); + + icon.render(graphics, leftPos + 7, topPos + 22); + } + @Override protected void renderLabels(final GuiGraphics graphics, final int mouseX, final int mouseY) { super.renderLabels(graphics, mouseX, mouseY); + if (!getMenu().isActive()) { + graphics.drawString(font, INACTIVE, 7 + icon.getWidth() + 4, 25, 4210752, false); + return; + } graphics.drawString( font, createTranslation("gui", "wireless_transmitter.distance", getMenu().getRange()), - 28, + 7 + icon.getWidth() + 4, 25, 4210752, false diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/AbstractProgressStorageScreen.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/AbstractProgressStorageScreen.java index ab13cec1c..8019428f9 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/AbstractProgressStorageScreen.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/AbstractProgressStorageScreen.java @@ -39,10 +39,10 @@ private List createProgressTooltip() { tooltip, menu.getStored(), menu.getCapacity(), - this::formatQuantity + this::formatAmount ); } else { - StorageTooltipHelper.addAmountStoredWithoutCapacity(tooltip, menu.getStored(), this::formatQuantity); + StorageTooltipHelper.addAmountStoredWithoutCapacity(tooltip, menu.getStored(), this::formatAmount); } return tooltip; } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/AbstractStorageScreen.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/AbstractStorageScreen.java index 3ea7a7ea6..6b5fa984d 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/AbstractStorageScreen.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/AbstractStorageScreen.java @@ -1,6 +1,5 @@ package com.refinedmods.refinedstorage.common.storage; -import com.refinedmods.refinedstorage.common.api.support.AmountFormatting; import com.refinedmods.refinedstorage.common.support.AbstractBaseScreen; import com.refinedmods.refinedstorage.common.support.containermenu.PropertyTypes; import com.refinedmods.refinedstorage.common.support.widget.FuzzyModeSideButtonWidget; @@ -12,6 +11,7 @@ import net.minecraft.world.entity.player.Inventory; import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createTranslation; +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.format; public abstract class AbstractStorageScreen extends AbstractBaseScreen { private static final Component ALLOW_FILTER_MODE_HELP = createTranslation("gui", "storage.filter_mode.allow.help"); @@ -69,7 +69,7 @@ protected void containerTick() { } } - protected String formatQuantity(final long qty) { - return AmountFormatting.format(qty); + protected String formatAmount(final long qty) { + return format(qty); } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/SameTypeStorageType.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/SameTypeStorageType.java index f571efe2a..37e3083fe 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/SameTypeStorageType.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/SameTypeStorageType.java @@ -1,7 +1,7 @@ package com.refinedmods.refinedstorage.common.storage; import com.refinedmods.refinedstorage.api.resource.ResourceKey; -import com.refinedmods.refinedstorage.api.storage.InMemoryStorageImpl; +import com.refinedmods.refinedstorage.api.storage.StorageImpl; import com.refinedmods.refinedstorage.api.storage.limited.LimitedStorageImpl; import com.refinedmods.refinedstorage.api.storage.tracked.InMemoryTrackedStorageRepository; import com.refinedmods.refinedstorage.api.storage.tracked.TrackedStorageImpl; @@ -64,7 +64,7 @@ public long getDiskInterfaceTransferQuota(final boolean stackUpgrade) { private SerializableStorage createStorage(final StorageCodecs.StorageData data, final Runnable listener) { final TrackedStorageRepository trackingRepository = new InMemoryTrackedStorageRepository(); final TrackedStorageImpl tracked = new TrackedStorageImpl( - new InMemoryStorageImpl(), + new StorageImpl(), trackingRepository, System::currentTimeMillis ); 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 7c334447c..f46eb4e6b 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 @@ -2,12 +2,11 @@ import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; import com.refinedmods.refinedstorage.common.api.storage.AbstractStorageContainerBlockItem; -import com.refinedmods.refinedstorage.common.api.support.AmountFormatting; import com.refinedmods.refinedstorage.common.api.support.HelpTooltipComponent; import com.refinedmods.refinedstorage.common.content.Blocks; import com.refinedmods.refinedstorage.common.content.Items; import com.refinedmods.refinedstorage.common.storage.FluidStorageVariant; -import com.refinedmods.refinedstorage.common.support.resource.FluidResourceRendering; +import com.refinedmods.refinedstorage.common.support.resource.FluidResource; import java.util.Optional; import javax.annotation.Nullable; @@ -22,6 +21,7 @@ import net.minecraft.world.level.block.state.BlockState; import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createTranslation; +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.format; public class FluidStorageBlockBlockItem extends AbstractStorageContainerBlockItem { private static final Component CREATIVE_HELP = createTranslation("item", "creative_fluid_storage_block.help"); @@ -43,11 +43,7 @@ private static Component getHelpText(final FluidStorageVariant variant) { if (variant.getCapacityInBuckets() == null) { return CREATIVE_HELP; } - return createTranslation( - "item", - "fluid_storage_block.help", - AmountFormatting.format(variant.getCapacityInBuckets()) - ); + return createTranslation("item", "fluid_storage_block.help", format(variant.getCapacityInBuckets())); } @Override @@ -57,7 +53,7 @@ protected boolean hasCapacity() { @Override protected String formatAmount(final long amount) { - return FluidResourceRendering.format(amount); + return RefinedStorageApi.INSTANCE.getResourceRendering(FluidResource.class).formatAmount(amount); } @Override diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storageblock/FluidStorageBlockScreen.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storageblock/FluidStorageBlockScreen.java index e9e9e344d..75493ff6c 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storageblock/FluidStorageBlockScreen.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storageblock/FluidStorageBlockScreen.java @@ -1,6 +1,7 @@ package com.refinedmods.refinedstorage.common.storage.storageblock; -import com.refinedmods.refinedstorage.common.support.resource.FluidResourceRendering; +import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.support.resource.FluidResource; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.player.Inventory; @@ -13,7 +14,7 @@ public FluidStorageBlockScreen(final AbstractStorageBlockContainerMenu menu, } @Override - protected String formatQuantity(final long qty) { - return FluidResourceRendering.format(qty); + protected String formatAmount(final long amount) { + return RefinedStorageApi.INSTANCE.getResourceRendering(FluidResource.class).formatAmount(amount); } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storageblock/ItemStorageBlockBlockItem.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storageblock/ItemStorageBlockBlockItem.java index 99cdb125a..c19cab55a 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storageblock/ItemStorageBlockBlockItem.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storageblock/ItemStorageBlockBlockItem.java @@ -2,7 +2,6 @@ import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; import com.refinedmods.refinedstorage.common.api.storage.AbstractStorageContainerBlockItem; -import com.refinedmods.refinedstorage.common.api.support.AmountFormatting; import com.refinedmods.refinedstorage.common.api.support.HelpTooltipComponent; import com.refinedmods.refinedstorage.common.content.Blocks; import com.refinedmods.refinedstorage.common.content.Items; @@ -21,6 +20,7 @@ import net.minecraft.world.level.block.state.BlockState; import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createTranslation; +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.format; public class ItemStorageBlockBlockItem extends AbstractStorageContainerBlockItem { private static final Component CREATIVE_HELP = createTranslation("item", "creative_storage_block.help"); @@ -35,9 +35,13 @@ public ItemStorageBlockBlockItem(final Block block, final ItemStorageVariant var RefinedStorageApi.INSTANCE.getStorageContainerItemHelper() ); this.variant = variant; - this.helpText = variant.getCapacity() == null + this.helpText = getHelpText(variant); + } + + private static Component getHelpText(final ItemStorageVariant variant) { + return variant.getCapacity() == null ? CREATIVE_HELP - : createTranslation("item", "storage_block.help", AmountFormatting.format(variant.getCapacity())); + : createTranslation("item", "storage_block.help", format(variant.getCapacity())); } @Override @@ -47,7 +51,7 @@ protected boolean hasCapacity() { @Override protected String formatAmount(final long amount) { - return AmountFormatting.format(amount); + return format(amount); } @Override 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 7a76aa02a..eb5f9b939 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 @@ -4,12 +4,11 @@ import com.refinedmods.refinedstorage.common.api.storage.AbstractStorageContainerItem; import com.refinedmods.refinedstorage.common.api.storage.SerializableStorage; import com.refinedmods.refinedstorage.common.api.storage.StorageRepository; -import com.refinedmods.refinedstorage.common.api.support.AmountFormatting; import com.refinedmods.refinedstorage.common.api.support.HelpTooltipComponent; import com.refinedmods.refinedstorage.common.content.Items; import com.refinedmods.refinedstorage.common.storage.FluidStorageVariant; import com.refinedmods.refinedstorage.common.storage.StorageTypes; -import com.refinedmods.refinedstorage.common.support.resource.FluidResourceRendering; +import com.refinedmods.refinedstorage.common.support.resource.FluidResource; import java.util.Optional; import javax.annotation.Nullable; @@ -20,6 +19,7 @@ import net.minecraft.world.item.ItemStack; import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createTranslation; +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.format; public class FluidStorageDiskItem extends AbstractStorageContainerItem { private static final Component CREATIVE_HELP = createTranslation("item", "creative_fluid_storage_disk.help"); @@ -40,11 +40,7 @@ private static Component getHelpText(final FluidStorageVariant variant) { if (variant.getCapacityInBuckets() == null) { return CREATIVE_HELP; } - return createTranslation( - "item", - "fluid_storage_disk.help", - AmountFormatting.format(variant.getCapacityInBuckets()) - ); + return createTranslation("item", "fluid_storage_disk.help", format(variant.getCapacityInBuckets())); } @Override @@ -54,7 +50,7 @@ protected boolean hasCapacity() { @Override protected String formatAmount(final long amount) { - return FluidResourceRendering.format(amount); + return RefinedStorageApi.INSTANCE.getResourceRendering(FluidResource.class).formatAmount(amount); } @Override diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storagedisk/ItemStorageDiskItem.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storagedisk/ItemStorageDiskItem.java index 8b72454ee..7ba29e021 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storagedisk/ItemStorageDiskItem.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/storagedisk/ItemStorageDiskItem.java @@ -4,7 +4,6 @@ import com.refinedmods.refinedstorage.common.api.storage.AbstractStorageContainerItem; import com.refinedmods.refinedstorage.common.api.storage.SerializableStorage; import com.refinedmods.refinedstorage.common.api.storage.StorageRepository; -import com.refinedmods.refinedstorage.common.api.support.AmountFormatting; import com.refinedmods.refinedstorage.common.api.support.HelpTooltipComponent; import com.refinedmods.refinedstorage.common.content.Items; import com.refinedmods.refinedstorage.common.storage.ItemStorageVariant; @@ -19,6 +18,7 @@ import net.minecraft.world.item.ItemStack; import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createTranslation; +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.format; public class ItemStorageDiskItem extends AbstractStorageContainerItem { private static final Component CREATIVE_HELP = createTranslation("item", "creative_storage_disk.help"); @@ -32,9 +32,13 @@ public ItemStorageDiskItem(final ItemStorageVariant variant) { RefinedStorageApi.INSTANCE.getStorageContainerItemHelper() ); this.variant = variant; - this.helpText = variant.getCapacity() == null + this.helpText = getHelpText(variant); + } + + private static Component getHelpText(final ItemStorageVariant variant) { + return variant.getCapacity() == null ? CREATIVE_HELP - : createTranslation("item", "storage_disk.help", AmountFormatting.format(variant.getCapacity())); + : createTranslation("item", "storage_disk.help", format(variant.getCapacity())); } @Override @@ -44,7 +48,7 @@ protected boolean hasCapacity() { @Override protected String formatAmount(final long amount) { - return AmountFormatting.format(amount); + return format(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 519001ddf..582990291 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 @@ -61,14 +61,14 @@ private void doRender(final Level level, final BiDirection direction, final ResourceKey resource, final long amount) { - final ResourceRendering resourceRendering = RefinedStorageApi.INSTANCE.getResourceRendering(resource); + final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering(resource.getClass()); doRender( poseStack, vertexConsumers, direction.getQuaternion(), - resourceRendering.getDisplayedAmount(amount, false), + rendering.formatAmount(amount), level, - resourceRendering, + rendering, resource ); } 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 5cf47b3a0..b9379a411 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 @@ -209,7 +209,7 @@ private List getResourceSlotHelpTooltip(final ItemStack private List getTooltipForResource(final ResourceKey resource, final ResourceSlot resourceSlot) { final List tooltip = RefinedStorageApi.INSTANCE - .getResourceRendering(resource) + .getResourceRendering(resource.getClass()) .getTooltip(resource) .stream() .map(Component::getVisualOrderText) 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 f351c64c3..96a3c1420 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 @@ -41,23 +41,23 @@ private static void render(final GuiGraphics graphics, final ResourceKey resource, final long amount, final boolean renderAmount) { - final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering(resource); + final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering(resource.getClass()); rendering.render(resource, graphics, x, y); if (renderAmount) { - render(graphics, x, y, amount, rendering); + renderAmount(graphics, x, y, amount, rendering); } } - public static void render(final GuiGraphics graphics, - final int x, - final int y, - final long amount, - final ResourceRendering rendering) { + public static void renderAmount(final GuiGraphics graphics, + final int x, + final int y, + final long amount, + final ResourceRendering rendering) { renderAmount( graphics, x, y, - rendering.getDisplayedAmount(amount, true), + rendering.formatAmount(amount, true), requireNonNullElse(ChatFormatting.WHITE.getColor(), 15), true ); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/packet/s2c/NetworkTransmitterStatusPacket.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/packet/s2c/NetworkTransmitterStatusPacket.java index e38accfb6..7a6a65925 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/packet/s2c/NetworkTransmitterStatusPacket.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/packet/s2c/NetworkTransmitterStatusPacket.java @@ -14,13 +14,15 @@ import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; -public record NetworkTransmitterStatusPacket(boolean error, Component message) implements CustomPacketPayload { +public record NetworkTransmitterStatusPacket(boolean error, boolean transmitting, Component message) + implements CustomPacketPayload { public static final Type PACKET_TYPE = new Type<>( createIdentifier("network_transmitter_status") ); public static final StreamCodec STREAM_CODEC = StreamCodec.composite( ByteBufCodecs.BOOL, NetworkTransmitterStatusPacket::error, + ByteBufCodecs.BOOL, NetworkTransmitterStatusPacket::transmitting, ComponentSerialization.STREAM_CODEC, NetworkTransmitterStatusPacket::message, NetworkTransmitterStatusPacket::new ); @@ -28,7 +30,7 @@ public record NetworkTransmitterStatusPacket(boolean error, Component message) i public static void handle(final NetworkTransmitterStatusPacket packet, final PacketContext ctx) { final AbstractContainerMenu menu = ctx.getPlayer().containerMenu; if (menu instanceof NetworkTransmitterContainerMenu containerMenu) { - containerMenu.setStatus(new NetworkTransmitterData(packet.error, packet.message)); + containerMenu.setStatus(new NetworkTransmitterData(packet.error, packet.transmitting, packet.message)); } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/packet/s2c/NoPermissionPacket.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/packet/s2c/NoPermissionPacket.java index 0e2908da0..3c63a0f49 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/packet/s2c/NoPermissionPacket.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/packet/s2c/NoPermissionPacket.java @@ -1,6 +1,6 @@ package com.refinedmods.refinedstorage.common.support.packet.s2c; -import com.refinedmods.refinedstorage.common.util.SecurityToastUtil; +import com.refinedmods.refinedstorage.common.util.ClientPlatformUtil; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.chat.Component; @@ -18,7 +18,7 @@ public record NoPermissionPacket(Component component) implements CustomPacketPay ); public static void handle(final NoPermissionPacket packet) { - SecurityToastUtil.addNoPermissionToast(packet.component); + ClientPlatformUtil.addNoPermissionToast(packet.component); } @Override diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/packet/s2c/S2CPackets.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/packet/s2c/S2CPackets.java index c293ca956..1059b66c2 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/packet/s2c/S2CPackets.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/packet/s2c/S2CPackets.java @@ -24,8 +24,8 @@ public static void sendEnergyInfo(final ServerPlayer player, final long stored, Platform.INSTANCE.sendPacketToClient(player, new EnergyInfoPacket(stored, capacity)); } - public static void sendWirelessTransmitterRange(final ServerPlayer player, final int range) { - Platform.INSTANCE.sendPacketToClient(player, new WirelessTransmitterRangePacket(range)); + public static void sendWirelessTransmitterData(final ServerPlayer player, final int range, final boolean active) { + Platform.INSTANCE.sendPacketToClient(player, new WirelessTransmitterDataPacket(range, active)); } public static void sendGridActiveness(final ServerPlayer player, final boolean active) { @@ -68,7 +68,7 @@ public static void sendStorageInfoResponse(final ServerPlayer player, public static void sendNetworkTransmitterStatus(final ServerPlayer player, final NetworkTransmitterData status) { Platform.INSTANCE.sendPacketToClient( player, - new NetworkTransmitterStatusPacket(status.error(), status.message()) + new NetworkTransmitterStatusPacket(status.error(), status.transmitting(), status.message()) ); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/packet/s2c/WirelessTransmitterRangePacket.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/packet/s2c/WirelessTransmitterDataPacket.java similarity index 54% rename from refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/packet/s2c/WirelessTransmitterRangePacket.java rename to refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/packet/s2c/WirelessTransmitterDataPacket.java index 993a67aa9..a02cd501d 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/packet/s2c/WirelessTransmitterRangePacket.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/packet/s2c/WirelessTransmitterDataPacket.java @@ -1,7 +1,7 @@ package com.refinedmods.refinedstorage.common.support.packet.s2c; +import com.refinedmods.refinedstorage.common.networking.WirelessTransmitterContainerMenu; import com.refinedmods.refinedstorage.common.support.packet.PacketContext; -import com.refinedmods.refinedstorage.common.wirelesstransmitter.WirelessTransmitterContainerMenu; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.ByteBufCodecs; @@ -10,20 +10,22 @@ import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; -public record WirelessTransmitterRangePacket(int range) implements CustomPacketPayload { - public static final Type PACKET_TYPE = new Type<>( - createIdentifier("wireless_transmitter_range") +public record WirelessTransmitterDataPacket(int range, boolean active) implements CustomPacketPayload { + public static final Type PACKET_TYPE = new Type<>( + createIdentifier("wireless_transmitter_data") ); - public static final StreamCodec STREAM_CODEC = + public static final StreamCodec STREAM_CODEC = StreamCodec.composite( - ByteBufCodecs.INT, WirelessTransmitterRangePacket::range, - WirelessTransmitterRangePacket::new + ByteBufCodecs.INT, WirelessTransmitterDataPacket::range, + ByteBufCodecs.BOOL, WirelessTransmitterDataPacket::active, + WirelessTransmitterDataPacket::new ); - public static void handle(final WirelessTransmitterRangePacket packet, final PacketContext ctx) { + public static void handle(final WirelessTransmitterDataPacket packet, final PacketContext ctx) { if (ctx.getPlayer().containerMenu instanceof WirelessTransmitterContainerMenu containerMenu) { containerMenu.setRange(packet.range); + containerMenu.setActive(packet.active); } } 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 7086a8d1f..57506c10b 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 @@ -2,8 +2,8 @@ import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.common.Platform; -import com.refinedmods.refinedstorage.common.api.support.AmountFormatting; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceRendering; +import com.refinedmods.refinedstorage.common.util.IdentifierUtil; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; @@ -23,12 +23,18 @@ public class FluidResourceRendering implements ResourceRendering { private static final DecimalFormat FORMATTER = new DecimalFormat("#,###.#", DecimalFormatSymbols.getInstance(Locale.US)); + private final long bucketAmount; + + public FluidResourceRendering(final long bucketAmount) { + this.bucketAmount = bucketAmount; + } + @Override - public String getDisplayedAmount(final long amount, final boolean withUnits) { + public String formatAmount(final long amount, final boolean withUnits) { if (!withUnits) { - return format(amount); + return format(amount, bucketAmount); } - return formatWithUnits(amount); + return formatWithUnits(amount, bucketAmount); } @Override @@ -67,21 +73,21 @@ public void render(final ResourceKey resource, Platform.INSTANCE.getFluidRenderer().render(poseStack, renderTypeBuffer, light, fluidResource); } - public static String formatWithUnits(final long droplets) { - final double buckets = convertToBuckets(droplets); + private static String formatWithUnits(final long droplets, final long bucketAmount) { + final double buckets = convertToBuckets(droplets, bucketAmount); if (buckets >= 1) { - return AmountFormatting.formatWithUnits((long) Math.floor(buckets)); + return IdentifierUtil.formatWithUnits((long) Math.floor(buckets)); } else { return LESS_THAN_1_BUCKET_FORMATTER.format(buckets); } } - public static String format(final long droplets) { - final double buckets = convertToBuckets(droplets); + private static String format(final long droplets, final long bucketAmount) { + final double buckets = convertToBuckets(droplets, bucketAmount); return FORMATTER.format(buckets); } - private static double convertToBuckets(final long droplets) { - return droplets / (double) Platform.INSTANCE.getBucketAmount(); + private static double convertToBuckets(final long droplets, final long bucketAmount) { + return droplets / (double) 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 7ea0b9e85..d4b107f7c 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 @@ -1,7 +1,6 @@ package com.refinedmods.refinedstorage.common.support.resource; import com.refinedmods.refinedstorage.api.resource.ResourceKey; -import com.refinedmods.refinedstorage.common.api.support.AmountFormatting; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceRendering; import java.util.Collections; @@ -23,6 +22,9 @@ import net.minecraft.world.level.Level; import org.joml.Matrix4f; +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); private final Map stackCache = new HashMap<>(); @@ -32,14 +34,11 @@ private ItemStack getStack(final ItemResource itemResource) { } @Override - public String getDisplayedAmount(final long amount, final boolean withUnits) { + public String formatAmount(final long amount, final boolean withUnits) { if (!withUnits) { - return AmountFormatting.format(amount); - } - if (amount == 1) { - return ""; + return format(amount); } - return AmountFormatting.formatWithUnits(amount); + return formatWithUnits(amount); } @Override 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 bdcd74adb..8ddf14d05 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 @@ -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) + (graphics, x, y) -> RefinedStorageApi.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 4a43b83f1..ecff0219d 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 @@ -33,7 +33,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()).render( + RefinedStorageApi.INSTANCE.getResourceRendering(resourceAmount.resource().getClass()).render( resourceAmount.resource(), graphics, x, @@ -50,13 +50,10 @@ 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( - resourceAmount.resource() + resourceAmount.resource().getClass() ); - final String amount = rendering.getDisplayedAmount(resourceAmount.amount(), true); + final String amount = rendering.formatAmount(resourceAmount.amount()); final Component displayName = rendering.getDisplayName(resourceAmount.resource()); - if (amount.isEmpty()) { - return displayName; - } return displayName.copy().append(" (").append(amount).append(")"); } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/util/SecurityToastUtil.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/util/ClientPlatformUtil.java similarity index 57% rename from refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/util/SecurityToastUtil.java rename to refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/util/ClientPlatformUtil.java index a92ef1557..72bf0d0dd 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/util/SecurityToastUtil.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/util/ClientPlatformUtil.java @@ -1,22 +1,32 @@ package com.refinedmods.refinedstorage.common.util; +import javax.annotation.Nullable; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.components.toasts.SystemToast; import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.world.level.Level; import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createTranslation; -public final class SecurityToastUtil { +public final class ClientPlatformUtil { private static final SystemToast.SystemToastId NO_PERMISSION_TOAST_ID = new SystemToast.SystemToastId(); + private static final MutableComponent NO_PERMISSION = createTranslation("misc", "no_permission"); + + private ClientPlatformUtil() { + } - private SecurityToastUtil() { + @Nullable + public static Level getClientLevel() { // avoids classloading issues + return Minecraft.getInstance().level; } public static void addNoPermissionToast(final Component message) { SystemToast.add( Minecraft.getInstance().getToasts(), NO_PERMISSION_TOAST_ID, - createTranslation("misc", "no_permission"), + NO_PERMISSION, message ); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/util/IdentifierUtil.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/util/IdentifierUtil.java index f9fcd40ae..2c074cd29 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/util/IdentifierUtil.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/util/IdentifierUtil.java @@ -1,6 +1,9 @@ package com.refinedmods.refinedstorage.common.util; -import com.refinedmods.refinedstorage.common.api.support.AmountFormatting; +import java.math.RoundingMode; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.util.Locale; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; @@ -14,6 +17,19 @@ public final class IdentifierUtil { public static final MutableComponent YES = Component.translatable("gui.yes"); public static final MutableComponent NO = Component.translatable("gui.no"); + private static final DecimalFormat FORMATTER_WITH_UNITS = new DecimalFormat( + "####0.#", + DecimalFormatSymbols.getInstance(Locale.US) + ); + private static final DecimalFormat FORMATTER = new DecimalFormat( + "#,###", + DecimalFormatSymbols.getInstance(Locale.US) + ); + + static { + FORMATTER_WITH_UNITS.setRoundingMode(RoundingMode.FLOOR); + } + private IdentifierUtil() { } @@ -41,10 +57,8 @@ public static MutableComponent createStoredWithCapacityTranslation( return createTranslation( "misc", "stored_with_capacity", - Component.literal(stored == Long.MAX_VALUE ? "∞" : AmountFormatting.format(stored)) - .withStyle(ChatFormatting.WHITE), - Component.literal(capacity == Long.MAX_VALUE ? "∞" : AmountFormatting.format(capacity)) - .withStyle(ChatFormatting.WHITE), + Component.literal(stored == Long.MAX_VALUE ? "∞" : format(stored)).withStyle(ChatFormatting.WHITE), + Component.literal(capacity == Long.MAX_VALUE ? "∞" : format(capacity)).withStyle(ChatFormatting.WHITE), Component.literal(String.valueOf((int) (pct * 100D))) ).withStyle(ChatFormatting.GRAY); } @@ -73,4 +87,37 @@ private static String getTagTranslationKey(final String prefix, final ResourceLo final String fixedPath = id.getPath().replace('/', '.'); return prefix + id.getNamespace() + "." + fixedPath; } + + public static String formatWithUnits(final long qty) { + if (qty >= 1_000_000_000) { + return formatBillion(qty); + } else if (qty >= 1_000_000) { + return formatMillion(qty); + } else if (qty >= 1000) { + return formatThousand(qty); + } + return String.valueOf(qty); + } + + private static String formatBillion(final long qty) { + return FORMATTER_WITH_UNITS.format(qty / 1_000_000_000D) + "B"; + } + + private static String formatMillion(final long qty) { + if (qty >= 100_000_000) { + return FORMATTER_WITH_UNITS.format(Math.floor(qty / 1_000_000D)) + "M"; + } + return FORMATTER_WITH_UNITS.format(qty / 1_000_000D) + "M"; + } + + private static String formatThousand(final long qty) { + if (qty >= 100_000) { + return FORMATTER_WITH_UNITS.format(Math.floor(qty / 1000D)) + "K"; + } + return FORMATTER_WITH_UNITS.format(qty / 1000D) + "K"; + } + + public static String format(final long qty) { + return FORMATTER.format(qty); + } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/util/PlatformUtil.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/util/PlatformUtil.java deleted file mode 100644 index 24072c78e..000000000 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/util/PlatformUtil.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.refinedmods.refinedstorage.common.util; - -import javax.annotation.Nullable; - -import net.minecraft.client.Minecraft; -import net.minecraft.world.level.Level; - -public final class PlatformUtil { - private PlatformUtil() { - } - - @Nullable - public static Level getClientLevel() { // avoids classloading issues - return Minecraft.getInstance().level; - } -} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/package-info.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/package-info.java deleted file mode 100644 index dff267fde..000000000 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/wirelesstransmitter/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -@ParametersAreNonnullByDefault -@FieldsAndMethodsAreNonnullByDefault -package com.refinedmods.refinedstorage.common.wirelesstransmitter; - -import com.refinedmods.refinedstorage.api.core.FieldsAndMethodsAreNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/lang/en_us.json b/refinedstorage-common/src/main/resources/assets/refinedstorage/lang/en_us.json index 0b27c5da6..155d1e882 100644 --- a/refinedstorage-common/src/main/resources/assets/refinedstorage/lang/en_us.json +++ b/refinedstorage-common/src/main/resources/assets/refinedstorage/lang/en_us.json @@ -98,6 +98,7 @@ "gui.refinedstorage.importer.filter_mode.allow.help": "Only allow resources into the storage network that are configured in the filters.", "gui.refinedstorage.importer.filter_mode.block.help": "Disallow resources into the storage network that are configured in the filters.", "gui.refinedstorage.wireless_transmitter.distance": "%d block(s)", + "gui.refinedstorage.wireless_transmitter.inactive": "Inactive", "gui.refinedstorage.storage_monitor.filter_help": "The resource to display.", "gui.refinedstorage.redstone_mode": "Redstone mode", "gui.refinedstorage.redstone_mode.ignore": "Ignore", diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/network_transmitter.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/network_transmitter.png index 1d25ea190..f1cb4e781 100644 Binary files a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/network_transmitter.png and b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/network_transmitter.png differ diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/transmitting/0.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/transmitting/0.png new file mode 100644 index 000000000..e9de0e716 Binary files /dev/null and b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/transmitting/0.png differ diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/transmitting/1.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/transmitting/1.png new file mode 100644 index 000000000..04448e774 Binary files /dev/null and b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/transmitting/1.png differ diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/transmitting/2.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/transmitting/2.png new file mode 100644 index 000000000..822413dfc Binary files /dev/null and b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/transmitting/2.png differ diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/transmitting/3.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/transmitting/3.png new file mode 100644 index 000000000..166cd463e Binary files /dev/null and b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/transmitting/3.png differ diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/wireless_transmitter.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/wireless_transmitter.png index bd9fe3393..0e140b6de 100644 Binary files a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/wireless_transmitter.png and b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/wireless_transmitter.png differ diff --git a/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/TestPlatform.java b/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/TestPlatform.java deleted file mode 100644 index e15c86a2f..000000000 --- a/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/TestPlatform.java +++ /dev/null @@ -1,241 +0,0 @@ -package com.refinedmods.refinedstorage.common; - -import com.refinedmods.refinedstorage.api.core.Action; -import com.refinedmods.refinedstorage.api.grid.view.GridResourceFactory; -import com.refinedmods.refinedstorage.api.network.energy.EnergyStorage; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; -import com.refinedmods.refinedstorage.common.api.grid.strategy.GridInsertionStrategyFactory; -import com.refinedmods.refinedstorage.common.api.support.network.NetworkNodeContainerProvider; -import com.refinedmods.refinedstorage.common.api.support.resource.FluidOperationResult; -import com.refinedmods.refinedstorage.common.support.containermenu.MenuOpener; -import com.refinedmods.refinedstorage.common.support.containermenu.TransferManager; -import com.refinedmods.refinedstorage.common.support.render.FluidRenderer; -import com.refinedmods.refinedstorage.common.support.resource.FluidResource; -import com.refinedmods.refinedstorage.common.support.resource.ItemResource; - -import java.io.File; -import java.util.List; -import java.util.Optional; -import java.util.UUID; -import java.util.function.BiConsumer; -import javax.annotation.Nullable; - -import net.minecraft.client.KeyMapping; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.gui.components.EditBox; -import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.core.HolderLookup; -import net.minecraft.core.NonNullList; -import net.minecraft.network.chat.Component; -import net.minecraft.network.protocol.common.custom.CustomPacketPayload; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.sounds.SoundEvent; -import net.minecraft.world.Container; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraft.world.inventory.CraftingContainer; -import net.minecraft.world.inventory.Slot; -import net.minecraft.world.inventory.tooltip.TooltipComponent; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.CraftingInput; -import net.minecraft.world.item.crafting.CraftingRecipe; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.LevelReader; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.LiquidBlock; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.saveddata.SavedData; -import net.minecraft.world.phys.BlockHitResult; - -public class TestPlatform implements Platform { - private final long bucketAmount; - - public TestPlatform(final long bucketAmount) { - this.bucketAmount = bucketAmount; - } - - @Override - public MenuOpener getMenuOpener() { - throw new UnsupportedOperationException(); - } - - @Override - public long getBucketAmount() { - return bucketAmount; - } - - @Override - public Config getConfig() { - throw new UnsupportedOperationException(); - } - - @Override - public boolean canEditBoxLoseFocus(final EditBox editBox) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean isKeyDown(final KeyMapping keyMapping) { - throw new UnsupportedOperationException(); - } - - @Override - public GridResourceFactory getItemGridResourceFactory() { - throw new UnsupportedOperationException(); - } - - @Override - public GridResourceFactory getFluidGridResourceFactory() { - throw new UnsupportedOperationException(); - } - - @Override - public GridInsertionStrategyFactory getDefaultGridInsertionStrategyFactory() { - throw new UnsupportedOperationException(); - } - - @Override - public FluidRenderer getFluidRenderer() { - throw new UnsupportedOperationException(); - } - - @Override - public Optional drainContainer(final ItemStack container) { - throw new UnsupportedOperationException(); - } - - @Override - public Optional fillContainer(final ItemStack container, - final ResourceAmount resourceAmount) { - throw new UnsupportedOperationException(); - } - - @Override - public Optional getFilledBucket(final FluidResource fluidResource) { - throw new UnsupportedOperationException(); - } - - @Override - public TransferManager createTransferManager(final AbstractContainerMenu containerMenu) { - throw new UnsupportedOperationException(); - } - - @Override - public long insertIntoContainer(final Container container, final ItemResource itemResource, final long amount, - final Action action) { - throw new UnsupportedOperationException(); - } - - @Override - public ItemStack getCloneItemStack(final BlockState state, final Level level, final BlockHitResult hitResult, - final Player player) { - throw new UnsupportedOperationException(); - } - - @Override - public NonNullList getRemainingCraftingItems(final Player player, final CraftingRecipe craftingRecipe, - final CraftingInput input) { - throw new UnsupportedOperationException(); - } - - @Override - public void onItemCrafted(final Player player, final ItemStack craftedStack, final CraftingContainer container) { - throw new UnsupportedOperationException(); - } - - @Override - public Player getFakePlayer(final ServerLevel level, @Nullable final UUID playerId) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean canBreakBlock(final Level level, final BlockPos pos, final BlockState state, final Player player) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean placeBlock(final Level level, final BlockPos pos, final Direction direction, final Player player, - final ItemStack stack) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean placeFluid(final Level level, final BlockPos pos, final Direction direction, final Player player, - final FluidResource fluidResource) { - throw new UnsupportedOperationException(); - } - - @Override - public ItemStack getBlockAsItemStack(final Block block, final BlockState state, final Direction direction, - final LevelReader level, - final BlockPos pos, final Player player) { - throw new UnsupportedOperationException(); - } - - @Override - public Optional getBucketPickupSound(final LiquidBlock liquidBlock, final BlockState state) { - throw new UnsupportedOperationException(); - } - - @Override - public List processTooltipComponents(final ItemStack stack, final GuiGraphics graphics, - final int mouseX, - final Optional imageComponent, - final List components) { - throw new UnsupportedOperationException(); - } - - @Override - public void renderTooltip(final GuiGraphics graphics, final List components, final int x, - final int y) { - throw new UnsupportedOperationException(); - } - - @Override - public Optional getEnergyStorage(final ItemStack stack) { - throw new UnsupportedOperationException(); - } - - @Override - public void sendPacketToServer(final T packet) { - throw new UnsupportedOperationException(); - } - - @Override - public void sendPacketToClient(final ServerPlayer player, final T packet) { - throw new UnsupportedOperationException(); - } - - @Override - public void saveSavedData(final SavedData savedData, final File file, final HolderLookup.Provider provider, - final BiConsumer defaultSaveFunction) { - throw new UnsupportedOperationException(); - } - - @Nullable - @Override - public NetworkNodeContainerProvider getContainerProvider(final Level level, final BlockPos pos, - @Nullable final Direction direction) { - throw new UnsupportedOperationException(); - } - - @Nullable - @Override - public NetworkNodeContainerProvider getContainerProviderSafely(final Level level, final BlockPos pos, - @Nullable final Direction direction) { - throw new UnsupportedOperationException(); - } - - @Override - public int getItemColor(final ItemStack stack, final int tintIndex) { - throw new UnsupportedOperationException(); - } - - @Override - public void setSlotY(final Slot slot, final int y) { - throw new UnsupportedOperationException(); - } -} diff --git a/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/storage/ClientStorageRepositoryTest.java b/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/storage/ClientStorageRepositoryTest.java deleted file mode 100644 index 548c59d95..000000000 --- a/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/storage/ClientStorageRepositoryTest.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.refinedmods.refinedstorage.common.storage; - -import com.refinedmods.refinedstorage.common.api.storage.StorageInfo; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -class ClientStorageRepositoryTest { - private List uuidsRequested; - private ClientStorageRepository sut; - - @BeforeEach - void setup() { - uuidsRequested = new ArrayList<>(); - sut = new ClientStorageRepository(uuidsRequested::add); - } - - @Test - void shouldSendRequestWhenRetrievingInfo() { - // Arrange - final UUID a = UUID.randomUUID(); - final UUID b = UUID.randomUUID(); - - // Act - final StorageInfo aInfo = sut.getInfo(a); - final StorageInfo bInfo = sut.getInfo(b); - - // Assert - assertThat(uuidsRequested).containsExactly(a); - assertThat(aInfo).usingRecursiveComparison().isEqualTo(StorageInfo.UNKNOWN); - assertThat(bInfo).usingRecursiveComparison().isEqualTo(StorageInfo.UNKNOWN); - } - - @Test - void shouldRetrieveInfo() { - // Arrange - final UUID a = UUID.randomUUID(); - sut.setInfo(a, 10, 100); - - final UUID b = UUID.randomUUID(); - - // Act - final StorageInfo aInfo = sut.getInfo(a); - final StorageInfo bInfo = sut.getInfo(b); - - // Assert - assertThat(uuidsRequested).containsExactly(a); - assertThat(aInfo).usingRecursiveComparison().isEqualTo(new StorageInfo(10, 100)); - assertThat(bInfo).usingRecursiveComparison().isEqualTo(StorageInfo.UNKNOWN); - } -} diff --git a/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/support/resource/FluidResourceRenderingTest.java b/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/support/resource/FluidResourceRenderingTest.java index e72d9b78a..29a6295ad 100644 --- a/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/support/resource/FluidResourceRenderingTest.java +++ b/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/support/resource/FluidResourceRenderingTest.java @@ -1,9 +1,5 @@ package com.refinedmods.refinedstorage.common.support.resource; -import com.refinedmods.refinedstorage.common.PlatformProxy; -import com.refinedmods.refinedstorage.common.TestPlatform; - -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -11,37 +7,34 @@ class FluidResourceRenderingTest { private static final long BUCKET_AMOUNT = 1000; - @BeforeAll - static void setUp() { - PlatformProxy.loadPlatform(new TestPlatform(BUCKET_AMOUNT)); - } + private final FluidResourceRendering sut = new FluidResourceRendering(BUCKET_AMOUNT); @Test void shouldFormatWithUnitsForCompleteBuckets() { - assertThat(FluidResourceRendering.formatWithUnits(BUCKET_AMOUNT)).isEqualTo("1"); - assertThat(FluidResourceRendering.formatWithUnits(BUCKET_AMOUNT * 2)).isEqualTo("2"); - assertThat(FluidResourceRendering.formatWithUnits(BUCKET_AMOUNT * 3)).isEqualTo("3"); - assertThat(FluidResourceRendering.formatWithUnits(BUCKET_AMOUNT * 1000)).isEqualTo("1K"); + assertThat(sut.formatAmount(BUCKET_AMOUNT, true)).isEqualTo("1"); + assertThat(sut.formatAmount(BUCKET_AMOUNT * 2, true)).isEqualTo("2"); + assertThat(sut.formatAmount(BUCKET_AMOUNT * 3, true)).isEqualTo("3"); + assertThat(sut.formatAmount(BUCKET_AMOUNT * 1000, true)).isEqualTo("1K"); } @Test void shouldFormatWithUnitsForPartialBuckets() { - assertThat(FluidResourceRendering.formatWithUnits(BUCKET_AMOUNT + (BUCKET_AMOUNT / 2))).isEqualTo("1"); - assertThat(FluidResourceRendering.formatWithUnits(BUCKET_AMOUNT + 1)).isEqualTo("1"); + assertThat(sut.formatAmount(BUCKET_AMOUNT + (BUCKET_AMOUNT / 2), true)).isEqualTo("1"); + assertThat(sut.formatAmount(BUCKET_AMOUNT + 1, true)).isEqualTo("1"); } @Test void shouldFormatWithUnitsForLessThan1Bucket() { - assertThat(FluidResourceRendering.formatWithUnits(BUCKET_AMOUNT / 2)).isEqualTo("0.5"); - assertThat(FluidResourceRendering.formatWithUnits(BUCKET_AMOUNT / 3)).isEqualTo("0.3"); + assertThat(sut.formatAmount(BUCKET_AMOUNT / 2, true)).isEqualTo("0.5"); + assertThat(sut.formatAmount(BUCKET_AMOUNT / 3, true)).isEqualTo("0.3"); } @Test void shouldFormatWithoutUnits() { - assertThat(FluidResourceRendering.format(BUCKET_AMOUNT)).isEqualTo("1"); - assertThat(FluidResourceRendering.format(BUCKET_AMOUNT + (BUCKET_AMOUNT / 2))).isEqualTo("1.5"); - assertThat(FluidResourceRendering.format(BUCKET_AMOUNT + (BUCKET_AMOUNT / 3))).isEqualTo("1.3"); - assertThat(FluidResourceRendering.format(BUCKET_AMOUNT * 1000)).isEqualTo("1,000"); - assertThat(FluidResourceRendering.format((BUCKET_AMOUNT * 1000) + (BUCKET_AMOUNT / 3))).isEqualTo("1,000.3"); + assertThat(sut.formatAmount(BUCKET_AMOUNT)).isEqualTo("1"); + assertThat(sut.formatAmount(BUCKET_AMOUNT + (BUCKET_AMOUNT / 2))).isEqualTo("1.5"); + assertThat(sut.formatAmount(BUCKET_AMOUNT + (BUCKET_AMOUNT / 3))).isEqualTo("1.3"); + assertThat(sut.formatAmount(BUCKET_AMOUNT * 1000)).isEqualTo("1,000"); + assertThat(sut.formatAmount((BUCKET_AMOUNT * 1000) + (BUCKET_AMOUNT / 3))).isEqualTo("1,000.3"); } } diff --git a/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/util/IdentifierUtilTest.java b/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/util/IdentifierUtilTest.java new file mode 100644 index 000000000..27c5c828a --- /dev/null +++ b/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/util/IdentifierUtilTest.java @@ -0,0 +1,90 @@ +package com.refinedmods.refinedstorage.common.util; + +import net.minecraft.resources.ResourceLocation; +import org.junit.jupiter.api.Test; + +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.MOD_ID; +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.format; +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.formatWithUnits; +import static org.assertj.core.api.Assertions.assertThat; + +class IdentifierUtilTest { + @Test + void verifyModId() { + assertThat(MOD_ID).isEqualTo("refinedstorage"); + assertThat(createIdentifier("test")).isEqualTo( + ResourceLocation.fromNamespaceAndPath("refinedstorage", "test") + ); + } + + @Test + void shouldFormatWithUnitsForSmallNumber() { + // Act & assert + assertThat(formatWithUnits(0)).isEqualTo("0"); + assertThat(formatWithUnits(1)).isEqualTo("1"); + assertThat(formatWithUnits(10)).isEqualTo("10"); + assertThat(formatWithUnits(105)).isEqualTo("105"); + } + + @Test + void shouldFormatWithUnitsForThousands() { + // Act & assert + assertThat(formatWithUnits(1000)).isEqualTo("1K"); + assertThat(formatWithUnits(1510)).isEqualTo("1.5K"); + + assertThat(formatWithUnits(10_000)).isEqualTo("10K"); + assertThat(formatWithUnits(10_510)).isEqualTo("10.5K"); + assertThat(formatWithUnits(99_999)).isEqualTo("99.9K"); + + assertThat(formatWithUnits(100_000)).isEqualTo("100K"); + assertThat(formatWithUnits(100_500)).isEqualTo("100K"); + assertThat(formatWithUnits(100_999)).isEqualTo("100K"); + + assertThat(formatWithUnits(101_000)).isEqualTo("101K"); + assertThat(formatWithUnits(101_500)).isEqualTo("101K"); + assertThat(formatWithUnits(101_999)).isEqualTo("101K"); + } + + @Test + void shouldFormatWithUnitsForMillions() { + // Act & assert + assertThat(formatWithUnits(1_000_000)).isEqualTo("1M"); + assertThat(formatWithUnits(1_510_000)).isEqualTo("1.5M"); + + assertThat(formatWithUnits(10_000_000)).isEqualTo("10M"); + assertThat(formatWithUnits(10_510_000)).isEqualTo("10.5M"); + assertThat(formatWithUnits(99_999_999)).isEqualTo("99.9M"); + + assertThat(formatWithUnits(100_000_000)).isEqualTo("100M"); + assertThat(formatWithUnits(100_510_000)).isEqualTo("100M"); + assertThat(formatWithUnits(100_999_000)).isEqualTo("100M"); + + assertThat(formatWithUnits(101_000_000)).isEqualTo("101M"); + assertThat(formatWithUnits(101_510_000)).isEqualTo("101M"); + assertThat(formatWithUnits(101_999_000)).isEqualTo("101M"); + } + + @Test + void shouldFormatWithUnitsForBillions() { + // Act & assert + assertThat(formatWithUnits(1_000_000_000)).isEqualTo("1B"); + assertThat(formatWithUnits(1_010_000_000)).isEqualTo("1B"); + assertThat(formatWithUnits(1_100_000_000)).isEqualTo("1.1B"); + assertThat(formatWithUnits(1_100_001_000)).isEqualTo("1.1B"); + assertThat(formatWithUnits(1_920_001_000)).isEqualTo("1.9B"); + } + + @Test + void shouldFormatWithoutUnits() { + // Act & assert + assertThat(format(0)).isEqualTo("0"); + assertThat(format(1)).isEqualTo("1"); + assertThat(format(10)).isEqualTo("10"); + assertThat(format(105)).isEqualTo("105"); + assertThat(format(1050)).isEqualTo("1,050"); + assertThat(format(10500)).isEqualTo("10,500"); + assertThat(format(100500)).isEqualTo("100,500"); + assertThat(format(1000500)).isEqualTo("1,000,500"); + } +} 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 976d51f7a..9dbd105d8 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 @@ -29,7 +29,7 @@ import com.refinedmods.refinedstorage.common.support.packet.s2c.PatternGridAllowedAlternativesUpdatePacket; import com.refinedmods.refinedstorage.common.support.packet.s2c.ResourceSlotUpdatePacket; import com.refinedmods.refinedstorage.common.support.packet.s2c.StorageInfoResponsePacket; -import com.refinedmods.refinedstorage.common.support.packet.s2c.WirelessTransmitterRangePacket; +import com.refinedmods.refinedstorage.common.support.packet.s2c.WirelessTransmitterDataPacket; import com.refinedmods.refinedstorage.common.support.tooltip.CompositeClientTooltipComponent; import com.refinedmods.refinedstorage.common.support.tooltip.HelpClientTooltipComponent; import com.refinedmods.refinedstorage.common.support.tooltip.ResourceClientTooltipComponent; @@ -255,8 +255,8 @@ private void registerPacketHandlers() { wrapHandler(EnergyInfoPacket::handle) ); ClientPlayNetworking.registerGlobalReceiver( - WirelessTransmitterRangePacket.PACKET_TYPE, - wrapHandler(WirelessTransmitterRangePacket::handle) + WirelessTransmitterDataPacket.PACKET_TYPE, + wrapHandler(WirelessTransmitterDataPacket::handle) ); ClientPlayNetworking.registerGlobalReceiver( ResourceSlotUpdatePacket.PACKET_TYPE, diff --git a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/ModInitializerImpl.java b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/ModInitializerImpl.java index 49a6866f2..d0608612f 100644 --- a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/ModInitializerImpl.java +++ b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/ModInitializerImpl.java @@ -59,7 +59,7 @@ import com.refinedmods.refinedstorage.common.support.packet.s2c.PatternGridAllowedAlternativesUpdatePacket; import com.refinedmods.refinedstorage.common.support.packet.s2c.ResourceSlotUpdatePacket; import com.refinedmods.refinedstorage.common.support.packet.s2c.StorageInfoResponsePacket; -import com.refinedmods.refinedstorage.common.support.packet.s2c.WirelessTransmitterRangePacket; +import com.refinedmods.refinedstorage.common.support.packet.s2c.WirelessTransmitterDataPacket; import com.refinedmods.refinedstorage.common.support.resource.FluidResource; import com.refinedmods.refinedstorage.common.support.resource.ItemResource; import com.refinedmods.refinedstorage.common.upgrade.RegulatorUpgradeItem; @@ -400,8 +400,8 @@ private void registerPackets() { private void registerServerToClientPackets() { PayloadTypeRegistry.playS2C().register(EnergyInfoPacket.PACKET_TYPE, EnergyInfoPacket.STREAM_CODEC); PayloadTypeRegistry.playS2C().register( - WirelessTransmitterRangePacket.PACKET_TYPE, - WirelessTransmitterRangePacket.STREAM_CODEC + WirelessTransmitterDataPacket.PACKET_TYPE, + WirelessTransmitterDataPacket.STREAM_CODEC ); PayloadTypeRegistry.playS2C().register(GridActivePacket.PACKET_TYPE, GridActivePacket.STREAM_CODEC); PayloadTypeRegistry.playS2C().register(GridClearPacket.PACKET_TYPE, GridClearPacket.STREAM_CODEC); diff --git a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/storage/AbstractDiskContainerBakedModel.java b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/storage/AbstractDiskContainerBakedModel.java index 03d3c9728..ee6ac9069 100644 --- a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/storage/AbstractDiskContainerBakedModel.java +++ b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/storage/AbstractDiskContainerBakedModel.java @@ -3,7 +3,7 @@ import com.refinedmods.refinedstorage.api.storage.StorageState; import com.refinedmods.refinedstorage.common.storage.AbstractDiskContainerBlockEntity; import com.refinedmods.refinedstorage.common.storage.Disk; -import com.refinedmods.refinedstorage.common.util.PlatformUtil; +import com.refinedmods.refinedstorage.common.util.ClientPlatformUtil; import com.refinedmods.refinedstorage.fabric.support.render.QuadTranslator; import java.util.Map; @@ -58,7 +58,7 @@ public void emitBlockQuads(final BlockAndTintGetter blockView, public void emitItemQuads(final ItemStack stack, final Supplier randomSupplier, final RenderContext context) { - final Level level = PlatformUtil.getClientLevel(); + final Level level = ClientPlatformUtil.getClientLevel(); final CustomData customData = stack.get(DataComponents.BLOCK_ENTITY_DATA); if (customData == null || level == null) { return; diff --git a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/storage/portablegrid/PortableGridBakedModel.java b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/storage/portablegrid/PortableGridBakedModel.java index 2c490a217..e0e3658d9 100644 --- a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/storage/portablegrid/PortableGridBakedModel.java +++ b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/storage/portablegrid/PortableGridBakedModel.java @@ -6,7 +6,7 @@ import com.refinedmods.refinedstorage.common.storage.portablegrid.PortableGridBlockItem; import com.refinedmods.refinedstorage.common.storage.portablegrid.PortableGridBlockItemRenderInfo; import com.refinedmods.refinedstorage.common.support.direction.BiDirection; -import com.refinedmods.refinedstorage.common.util.PlatformUtil; +import com.refinedmods.refinedstorage.common.util.ClientPlatformUtil; import com.refinedmods.refinedstorage.fabric.support.render.QuadRotators; import com.refinedmods.refinedstorage.fabric.support.render.QuadTranslator; @@ -56,7 +56,7 @@ public boolean isVanillaAdapter() { public void emitItemQuads(final ItemStack stack, final Supplier randomSupplier, final RenderContext context) { - final Level level = PlatformUtil.getClientLevel(); + final Level level = ClientPlatformUtil.getClientLevel(); if (level == null) { return; } diff --git a/refinedstorage-grid-api/src/test/java/com/refinedmods/refinedstorage/api/grid/watcher/GridWatcherManagerImplTest.java b/refinedstorage-grid-api/src/test/java/com/refinedmods/refinedstorage/api/grid/watcher/GridWatcherManagerImplTest.java index 77e0b2814..c7c8ecb91 100644 --- a/refinedstorage-grid-api/src/test/java/com/refinedmods/refinedstorage/api/grid/watcher/GridWatcherManagerImplTest.java +++ b/refinedstorage-grid-api/src/test/java/com/refinedmods/refinedstorage/api/grid/watcher/GridWatcherManagerImplTest.java @@ -2,7 +2,7 @@ import com.refinedmods.refinedstorage.api.core.Action; import com.refinedmods.refinedstorage.api.storage.Actor; -import com.refinedmods.refinedstorage.api.storage.InMemoryStorageImpl; +import com.refinedmods.refinedstorage.api.storage.StorageImpl; import com.refinedmods.refinedstorage.api.storage.root.RootStorage; import com.refinedmods.refinedstorage.api.storage.root.RootStorageImpl; @@ -30,7 +30,7 @@ class GridWatcherManagerImplTest { void setUp() { sut = new GridWatcherManagerImpl(); rootStorage = new RootStorageImpl(); - rootStorage.addSource(new InMemoryStorageImpl()); + rootStorage.addSource(new StorageImpl()); } @Test diff --git a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/ConfigImpl.java b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/ConfigImpl.java index 1fe2b5685..504c04be9 100644 --- a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/ConfigImpl.java +++ b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/ConfigImpl.java @@ -119,7 +119,10 @@ public int getMaxRowsStretch() { @Override public void setScreenSize(final ScreenSize screenSize) { - this.screenSize.set(screenSize); + if (screenSize != this.screenSize.get()) { + this.screenSize.set(screenSize); + this.spec.save(); + } } @Override @@ -427,7 +430,10 @@ public boolean isAutoSelected() { @Override public void setAutoSelected(final boolean autoSelected) { - this.autoSelected.set(autoSelected); + if (autoSelected != this.autoSelected.get()) { + this.autoSelected.set(autoSelected); + ConfigImpl.this.spec.save(); + } } @Override @@ -440,12 +446,18 @@ public Optional getSynchronizer() { @Override public void setSynchronizer(final ResourceLocation synchronizerId) { - this.synchronizer.set(synchronizerId.toString()); + if (!synchronizerId.toString().equals(this.synchronizer.get())) { + this.synchronizer.set(synchronizerId.toString()); + ConfigImpl.this.spec.save(); + } } @Override public void clearSynchronizer() { - this.synchronizer.set(""); + if (!synchronizer.get().isEmpty()) { + this.synchronizer.set(""); + ConfigImpl.this.spec.save(); + } } @Override @@ -455,7 +467,10 @@ public GridSortingDirection getSortingDirection() { @Override public void setSortingDirection(final GridSortingDirection sortingDirection) { - this.sortingDirection.set(sortingDirection); + if (sortingDirection != this.sortingDirection.get()) { + this.sortingDirection.set(sortingDirection); + ConfigImpl.this.spec.save(); + } } @Override @@ -465,7 +480,10 @@ public GridSortingTypes getSortingType() { @Override public void setSortingType(final GridSortingTypes sortingType) { - this.sortingType.set(sortingType); + if (sortingType != this.sortingType.get()) { + this.sortingType.set(sortingType); + ConfigImpl.this.spec.save(); + } } @Override @@ -478,12 +496,18 @@ public Optional getResourceType() { @Override public void setResourceType(final ResourceLocation resourceTypeId) { - this.resourceType.set(resourceTypeId.toString()); + if (!resourceTypeId.toString().equals(this.resourceType.get())) { + this.resourceType.set(resourceTypeId.toString()); + ConfigImpl.this.spec.save(); + } } @Override public void clearResourceType() { - this.resourceType.set(""); + if (!resourceType.get().isEmpty()) { + this.resourceType.set(""); + ConfigImpl.this.spec.save(); + } } } 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 176b5a7d0..78cd28929 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 @@ -59,7 +59,7 @@ import com.refinedmods.refinedstorage.common.support.packet.s2c.PatternGridAllowedAlternativesUpdatePacket; import com.refinedmods.refinedstorage.common.support.packet.s2c.ResourceSlotUpdatePacket; import com.refinedmods.refinedstorage.common.support.packet.s2c.StorageInfoResponsePacket; -import com.refinedmods.refinedstorage.common.support.packet.s2c.WirelessTransmitterRangePacket; +import com.refinedmods.refinedstorage.common.support.packet.s2c.WirelessTransmitterDataPacket; import com.refinedmods.refinedstorage.common.upgrade.RegulatorUpgradeItem; import com.refinedmods.refinedstorage.common.util.IdentifierUtil; import com.refinedmods.refinedstorage.common.util.ServerEventQueue; @@ -597,9 +597,9 @@ private static void registerServerToClientPackets(final PayloadRegistrar registr wrapHandler((packet, ctx) -> StorageInfoResponsePacket.handle(packet)) ); registrar.playToClient( - WirelessTransmitterRangePacket.PACKET_TYPE, - WirelessTransmitterRangePacket.STREAM_CODEC, - wrapHandler(WirelessTransmitterRangePacket::handle) + WirelessTransmitterDataPacket.PACKET_TYPE, + WirelessTransmitterDataPacket.STREAM_CODEC, + wrapHandler(WirelessTransmitterDataPacket::handle) ); registrar.playToClient( NoPermissionPacket.PACKET_TYPE, diff --git a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/datagen/ItemModelProviderImpl.java b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/datagen/ItemModelProviderImpl.java index 3eb2074d0..72ae46e81 100644 --- a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/datagen/ItemModelProviderImpl.java +++ b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/datagen/ItemModelProviderImpl.java @@ -9,8 +9,8 @@ import com.refinedmods.refinedstorage.common.networking.CableBlock; import com.refinedmods.refinedstorage.common.networking.NetworkReceiverBlock; import com.refinedmods.refinedstorage.common.networking.NetworkTransmitterBlock; +import com.refinedmods.refinedstorage.common.networking.WirelessTransmitterBlock; import com.refinedmods.refinedstorage.common.storage.externalstorage.ExternalStorageBlock; -import com.refinedmods.refinedstorage.common.wirelesstransmitter.WirelessTransmitterBlock; import net.minecraft.data.PackOutput; import net.minecraft.resources.ResourceLocation; diff --git a/refinedstorage-neoforge/src/test/java/com/refinedmods/refinedstorage/common/GameTestUtil.java b/refinedstorage-neoforge/src/test/java/com/refinedmods/refinedstorage/common/GameTestUtil.java index 2c68b9160..d822d237a 100644 --- a/refinedstorage-neoforge/src/test/java/com/refinedmods/refinedstorage/common/GameTestUtil.java +++ b/refinedstorage-neoforge/src/test/java/com/refinedmods/refinedstorage/common/GameTestUtil.java @@ -6,6 +6,8 @@ import com.refinedmods.refinedstorage.api.network.storage.StorageNetworkComponent; import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.resource.ResourceKey; +import com.refinedmods.refinedstorage.api.resource.list.ResourceList; +import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; import com.refinedmods.refinedstorage.api.storage.EmptyActor; import com.refinedmods.refinedstorage.common.api.support.network.AbstractNetworkNodeContainerBlockEntity; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceContainer; @@ -16,9 +18,9 @@ import com.refinedmods.refinedstorage.common.support.resource.ItemResource; import java.util.Arrays; +import java.util.Collection; import java.util.Iterator; import java.util.function.Consumer; -import java.util.stream.IntStream; import javax.annotation.Nullable; import net.minecraft.core.BlockPos; @@ -129,7 +131,6 @@ public static void assertItemEntityPresentExactly(final GameTestHelper helper, throw new GameTestAssertException("Expected " + itemStack.getItem().getDescription().getString() + " item at: " + blockpos + " with count: " + itemStack.getCount()); } - itemEntity = entityIterator.next(); } while (!itemEntity.getItem().getItem().equals(itemStack.getItem()) || itemEntity.getItem().getCount() != itemStack.getCount()); @@ -138,18 +139,17 @@ public static void assertItemEntityPresentExactly(final GameTestHelper helper, public static Runnable assertInterfaceEmpty(final GameTestHelper helper, final BlockPos pos) { final var interfaceBlockEntity = requireBlockEntity(helper, pos, InterfaceBlockEntity.class); - - return assertResourceContainerEmpty(interfaceBlockEntity.getDisplayName(), - interfaceBlockEntity.getExportedResources()); + return assertResourceContainerEmpty( + interfaceBlockEntity.getDisplayName(), + interfaceBlockEntity.getExportedResources() + ); } private static Runnable assertResourceContainerEmpty(final Component displayName, final ResourceContainer container) { return () -> { - for (int i = 0; i < container.size(); i++) { - if (!container.isEmpty(i)) { - throw new GameTestAssertException(displayName.getString() + " should be empty"); - } + if (!container.isEmpty()) { + throw new GameTestAssertException(displayName.getString() + " should be empty"); } }; } @@ -158,41 +158,21 @@ public static Runnable interfaceContainsExactly(final GameTestHelper helper, final BlockPos pos, final ResourceAmount... expected) { final var interfaceBlockEntity = requireBlockEntity(helper, pos, InterfaceBlockEntity.class); - - return resourceContainerContainsExactly(helper, interfaceBlockEntity.getDisplayName(), - interfaceBlockEntity.getExportedResources(), expected); + return resourceContainerContainsExactly(interfaceBlockEntity.getExportedResources(), expected); } - private static Runnable resourceContainerContainsExactly(final GameTestHelper helper, - final Component displayName, - final ResourceContainer container, + private static Runnable resourceContainerContainsExactly(final ResourceContainer container, final ResourceAmount... expected) { + final ResourceList expectedList = toResourceList(expected); return () -> { - // todo: investigate issue with EnderIO integration - // TODO: This does not take duplicate ResourceAmount into account - for (final ResourceAmount expectedStack : expected) { - final boolean contains = IntStream.range(0, container.size()) - .mapToObj(container::get) - .anyMatch(resource -> resource != null - && resource.resource().equals(expectedStack.resource()) - && resource.amount() == expectedStack.amount()); - - helper.assertTrue(contains, "Expected resource is missing from " + displayName.getString() + ": " - + expectedStack + " with count: " + expectedStack.amount()); - } - + final ResourceList given = ResourceListImpl.create(); for (int i = 0; i < container.size(); i++) { - final ResourceAmount resource = container.get(i); - if (resource != null) { - final boolean wasExpected = Arrays.stream(expected).anyMatch( - expectedResource -> expectedResource.resource().equals(resource.resource()) - && expectedResource.amount() == resource.amount() - ); - - helper.assertTrue(wasExpected, "Unexpected resource found in " + displayName.getString() + ": " - + resource.resource() + " with count: " + resource.amount()); + final ResourceAmount item = container.get(i); + if (item != null) { + given.add(item); } } + listContainsExactly(given, expectedList); }; } @@ -200,52 +180,58 @@ public static Runnable containerContainsExactly(final GameTestHelper helper, final BlockPos pos, final ResourceAmount... expected) { final var containerBlockEntity = requireBlockEntity(helper, pos, BaseContainerBlockEntity.class); - + final ResourceList expectedList = toResourceList(expected); return () -> { - // TODO: This does not take duplicate ResourceAmount into account - for (final ResourceAmount expectedStack : expected) { - final boolean contains = IntStream.range(0, containerBlockEntity.getContainerSize()) - .mapToObj(containerBlockEntity::getItem) - .anyMatch(inContainer -> asResource(inContainer).equals(expectedStack.resource()) - && inContainer.getCount() == expectedStack.amount()); - helper.assertTrue(contains, "Expected resource is missing from container: " - + expectedStack + " with count: " + expectedStack.amount()); - } + final ResourceList given = ResourceListImpl.create(); for (int i = 0; i < containerBlockEntity.getContainerSize(); i++) { - final ItemStack inContainer = containerBlockEntity.getItem(i); - - if (!inContainer.isEmpty()) { - final boolean wasExpected = Arrays.stream(expected).anyMatch( - expectedStack -> expectedStack.resource().equals(asResource(inContainer)) - && expectedStack.amount() == inContainer.getCount() - ); - helper.assertTrue(wasExpected, "Unexpected resource found in container: " - + inContainer.getDescriptionId() + " with count: " + inContainer.getCount()); + final ItemStack itemStack = containerBlockEntity.getItem(i); + if (!itemStack.isEmpty()) { + given.add(asResource(itemStack), itemStack.getCount()); } } + listContainsExactly(given, expectedList); }; } public static Runnable storageContainsExactly(final GameTestHelper helper, final BlockPos networkPos, final ResourceAmount... expected) { + final ResourceList expectedList = toResourceList(expected); return networkIsAvailable(helper, networkPos, network -> { final StorageNetworkComponent storage = network.getComponent(StorageNetworkComponent.class); - for (final ResourceAmount expectedResource : expected) { - final boolean contains = storage.getAll() - .stream() - .anyMatch(inStorage -> inStorage.resource().equals(expectedResource.resource()) - && inStorage.amount() == expectedResource.amount()); - helper.assertTrue(contains, "Expected resource is missing from storage: " + expectedResource); + listContainsExactly(toResourceList(storage.getAll()), expectedList); + }); + } + + private static ResourceList toResourceList(final ResourceAmount... resources) { + return toResourceList(Arrays.asList(resources)); + } + + private static ResourceList toResourceList(final Collection resources) { + final ResourceList list = ResourceListImpl.create(); + for (final ResourceAmount resource : resources) { + list.add(resource); + } + return list; + } + + private static void listContainsExactly(final ResourceList given, final ResourceList expected) { + for (final ResourceAmount expectedItem : expected.copyState()) { + final long givenAmount = given.get(expectedItem.resource()); + if (givenAmount != expectedItem.amount()) { + throw new GameTestAssertException( + "Expected " + expectedItem.amount() + " of " + expectedItem.resource() + ", but was " + givenAmount + ); } - for (final ResourceAmount inStorage : storage.getAll()) { - final boolean wasExpected = Arrays.stream(expected).anyMatch( - expectedResource -> expectedResource.resource().equals(inStorage.resource()) - && expectedResource.amount() == inStorage.amount() + } + for (final ResourceAmount givenItem : given.copyState()) { + final long expectedAmount = expected.get(givenItem.resource()); + if (expectedAmount != givenItem.amount()) { + throw new GameTestAssertException( + "Expected " + expectedAmount + " of " + givenItem.resource() + ", but was " + givenItem.amount() ); - helper.assertTrue(wasExpected, "Unexpected resource found in storage: " + inStorage); } - }); + } } public static ItemResource asResource(final Item item) { diff --git a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/PriorityNetworkBuilderImplTest.java b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/PriorityNetworkBuilderImplTest.java index 7920bfef2..7b1ef3c53 100644 --- a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/PriorityNetworkBuilderImplTest.java +++ b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/PriorityNetworkBuilderImplTest.java @@ -10,7 +10,7 @@ import com.refinedmods.refinedstorage.api.network.node.container.NetworkNodeContainer; import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.api.storage.EmptyActor; -import com.refinedmods.refinedstorage.api.storage.InMemoryStorageImpl; +import com.refinedmods.refinedstorage.api.storage.StorageImpl; import com.refinedmods.refinedstorage.network.test.fake.FakeActor; import java.util.Optional; @@ -117,7 +117,7 @@ void shouldRespectPriorityWhenMerging() { private NetworkSide createNetworkSide(final MasterSlave side, final Supplier networkFactory) { final StorageNetworkNode nodeA = new StorageNetworkNode(0, 0, 1); - final InMemoryStorageImpl storage = new InMemoryStorageImpl(); + final StorageImpl storage = new StorageImpl(); storage.insert(side, 10, Action.EXECUTE, FakeActor.INSTANCE); nodeA.setProvider(index -> Optional.of(storage)); final NetworkNodeContainer a = createContainerWithNetwork( diff --git a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/detector/DetectorNetworkNodeTest.java b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/detector/DetectorNetworkNodeTest.java index b2e1d165a..bce2d6535 100644 --- a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/detector/DetectorNetworkNodeTest.java +++ b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/detector/DetectorNetworkNodeTest.java @@ -3,7 +3,7 @@ import com.refinedmods.refinedstorage.api.core.Action; import com.refinedmods.refinedstorage.api.network.storage.StorageNetworkComponent; import com.refinedmods.refinedstorage.api.storage.EmptyActor; -import com.refinedmods.refinedstorage.api.storage.InMemoryStorageImpl; +import com.refinedmods.refinedstorage.api.storage.StorageImpl; import com.refinedmods.refinedstorage.network.test.AddNetworkNode; import com.refinedmods.refinedstorage.network.test.InjectNetworkStorageComponent; import com.refinedmods.refinedstorage.network.test.NetworkTest; @@ -34,7 +34,7 @@ class DetectorNetworkNodeTest { @BeforeEach void setUp(@InjectNetworkStorageComponent final StorageNetworkComponent storage) { - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); sut.setAmountStrategy(new DetectorAmountStrategyImpl()); } diff --git a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/exporter/AbstractExporterNetworkNodeTest.java b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/exporter/AbstractExporterNetworkNodeTest.java index fa57ebdce..6d82477d0 100644 --- a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/exporter/AbstractExporterNetworkNodeTest.java +++ b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/exporter/AbstractExporterNetworkNodeTest.java @@ -9,9 +9,9 @@ import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.api.storage.Actor; import com.refinedmods.refinedstorage.api.storage.EmptyActor; -import com.refinedmods.refinedstorage.api.storage.InMemoryStorageImpl; import com.refinedmods.refinedstorage.api.storage.InsertableStorage; import com.refinedmods.refinedstorage.api.storage.Storage; +import com.refinedmods.refinedstorage.api.storage.StorageImpl; import com.refinedmods.refinedstorage.api.storage.limited.LimitedStorageImpl; import com.refinedmods.refinedstorage.network.test.AddNetworkNode; import com.refinedmods.refinedstorage.network.test.InjectNetworkEnergyComponent; @@ -58,7 +58,7 @@ void shouldUseFirstSuccessfulStrategy( @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(A, 100, Action.EXECUTE, EmptyActor.INSTANCE); storage.insert(B, 100, Action.EXECUTE, EmptyActor.INSTANCE); @@ -90,7 +90,7 @@ void shouldUseFirstSuccessfulResourceInTheStrategy( @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(A, 100, Action.EXECUTE, EmptyActor.INSTANCE); storage.insert(B, 100, Action.EXECUTE, EmptyActor.INSTANCE); @@ -145,11 +145,11 @@ void shouldNotTransferWithoutTaskExecutor( @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(A, 100, Action.EXECUTE, EmptyActor.INSTANCE); storage.insert(B, 100, Action.EXECUTE, EmptyActor.INSTANCE); - final Storage destination = new InMemoryStorageImpl(); + final Storage destination = new StorageImpl(); sut.setFilters(List.of(A, B)); sut.setTransferStrategy(createTransferStrategy(destination, 1)); @@ -169,11 +169,11 @@ void shouldNotTransferWithoutTaskExecutor( @Test void shouldNotTransferWithoutStrategy(@InjectNetworkStorageComponent final StorageNetworkComponent storage) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(A, 100, Action.EXECUTE, EmptyActor.INSTANCE); storage.insert(B, 100, Action.EXECUTE, EmptyActor.INSTANCE); - final Storage destination = new InMemoryStorageImpl(); + final Storage destination = new StorageImpl(); sut.setFilters(List.of(A, B)); @@ -191,11 +191,11 @@ void shouldNotTransferWithoutStrategy(@InjectNetworkStorageComponent final Stora @Test void shouldNotTransferIfInactive(@InjectNetworkStorageComponent final StorageNetworkComponent storage) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(A, 100, Action.EXECUTE, EmptyActor.INSTANCE); storage.insert(B, 100, Action.EXECUTE, EmptyActor.INSTANCE); - final Storage destination = new InMemoryStorageImpl(); + final Storage destination = new StorageImpl(); final ExporterTransferStrategy strategy = createTransferStrategy(destination, 1); sut.setTransferStrategy(strategy); @@ -216,11 +216,11 @@ void shouldNotTransferIfInactive(@InjectNetworkStorageComponent final StorageNet @Test void shouldNotTransferWithoutFilters(@InjectNetworkStorageComponent final StorageNetworkComponent storage) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(A, 100, Action.EXECUTE, EmptyActor.INSTANCE); storage.insert(B, 100, Action.EXECUTE, EmptyActor.INSTANCE); - final Storage destination = new InMemoryStorageImpl(); + final Storage destination = new StorageImpl(); final ExporterTransferStrategy strategy = createTransferStrategy(destination, 1); sut.setTransferStrategy(strategy); @@ -242,7 +242,7 @@ void shouldNotTransferIfNoResourcesAreAvailable( @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - final Storage destination = new InMemoryStorageImpl(); + final Storage destination = new StorageImpl(); final ExporterTransferStrategy strategy = createTransferStrategy(destination, 10); sut.setTransferStrategy(strategy); @@ -263,7 +263,7 @@ void shouldTransferWithLimitedSpaceInDestination( @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(A, 100, Action.EXECUTE, EmptyActor.INSTANCE); storage.insert(B, 100, Action.EXECUTE, EmptyActor.INSTANCE); storage.insert(C, 100, Action.EXECUTE, EmptyActor.INSTANCE); @@ -308,7 +308,7 @@ void shouldNotTransferIfThereIsNoSpaceInTheDestination( @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(A, 100, Action.EXECUTE, EmptyActor.INSTANCE); storage.insert(B, 100, Action.EXECUTE, EmptyActor.INSTANCE); @@ -338,11 +338,11 @@ void shouldTransferSingleResourceEvenIfTransferQuotaHasNotBeenMet( @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(A, 6, Action.EXECUTE, EmptyActor.INSTANCE); storage.insert(B, 7, Action.EXECUTE, EmptyActor.INSTANCE); - final Storage destination = new InMemoryStorageImpl(); + final Storage destination = new StorageImpl(); final ExporterTransferStrategy strategy = createTransferStrategy(destination, 10); sut.setTransferStrategy(strategy); diff --git a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/exporter/FirstAvailableExporterNetworkNodeTest.java b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/exporter/FirstAvailableExporterNetworkNodeTest.java index ea89e9214..db9bf6b7f 100644 --- a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/exporter/FirstAvailableExporterNetworkNodeTest.java +++ b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/exporter/FirstAvailableExporterNetworkNodeTest.java @@ -10,8 +10,8 @@ import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.api.storage.Actor; import com.refinedmods.refinedstorage.api.storage.EmptyActor; -import com.refinedmods.refinedstorage.api.storage.InMemoryStorageImpl; import com.refinedmods.refinedstorage.api.storage.Storage; +import com.refinedmods.refinedstorage.api.storage.StorageImpl; import com.refinedmods.refinedstorage.api.storage.tracked.TrackedResource; import com.refinedmods.refinedstorage.api.storage.tracked.TrackedStorageImpl; import com.refinedmods.refinedstorage.network.test.InjectNetworkStorageComponent; @@ -35,11 +35,11 @@ protected TaskExecutor createTaskExecutor() { @Test void shouldTransfer(@InjectNetworkStorageComponent final StorageNetworkComponent storage) { // Arrange - storage.addSource(new TrackedStorageImpl(new InMemoryStorageImpl(), () -> 1L)); + storage.addSource(new TrackedStorageImpl(new StorageImpl(), () -> 1L)); storage.insert(A, 100, Action.EXECUTE, EmptyActor.INSTANCE); storage.insert(B, 100, Action.EXECUTE, EmptyActor.INSTANCE); - final Storage destination = new InMemoryStorageImpl(); + final Storage destination = new StorageImpl(); final ExporterTransferStrategy strategy = createTransferStrategy(destination, 1); sut.setTransferStrategy(strategy); @@ -68,10 +68,10 @@ void shouldUseNextResourceIfFirstOneIsNotAvailableInSameCycle( @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(B, 7, Action.EXECUTE, EmptyActor.INSTANCE); - final Storage destination = new InMemoryStorageImpl(); + final Storage destination = new StorageImpl(); final ExporterTransferStrategy strategy = createTransferStrategy(destination, 10); sut.setTransferStrategy(strategy); @@ -92,12 +92,12 @@ void shouldUseNextResourceIfFirstOneIsNotAcceptedInSameCycle( @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); storage.insert(B, 10, Action.EXECUTE, EmptyActor.INSTANCE); storage.insert(C, 10, Action.EXECUTE, EmptyActor.INSTANCE); - final Storage destination = new InMemoryStorageImpl() { + final Storage destination = new StorageImpl() { @Override public long insert(final ResourceKey resource, final long amount, final Action action, final Actor actor) { if (A.equals(resource)) { diff --git a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/exporter/RandomExporterNetworkNodeTest.java b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/exporter/RandomExporterNetworkNodeTest.java index 57c7d9446..e357f7218 100644 --- a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/exporter/RandomExporterNetworkNodeTest.java +++ b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/exporter/RandomExporterNetworkNodeTest.java @@ -7,8 +7,8 @@ import com.refinedmods.refinedstorage.api.network.storage.StorageNetworkComponent; import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.storage.EmptyActor; -import com.refinedmods.refinedstorage.api.storage.InMemoryStorageImpl; import com.refinedmods.refinedstorage.api.storage.Storage; +import com.refinedmods.refinedstorage.api.storage.StorageImpl; import com.refinedmods.refinedstorage.network.test.InjectNetworkStorageComponent; import java.util.List; @@ -32,11 +32,11 @@ protected TaskExecutor createTaskExecutor() { @Test void shouldTransfer(@InjectNetworkStorageComponent final StorageNetworkComponent storage) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(A, 100, Action.EXECUTE, EmptyActor.INSTANCE); storage.insert(B, 100, Action.EXECUTE, EmptyActor.INSTANCE); - final Storage destination = new InMemoryStorageImpl(); + final Storage destination = new StorageImpl(); final ExporterTransferStrategy strategy = createTransferStrategy(destination, 5); sut.setTransferStrategy(strategy); @@ -69,10 +69,10 @@ void shouldUseNextResourceIfFirstOneIsNotAvailableInSameCycle( @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(B, 7, Action.EXECUTE, EmptyActor.INSTANCE); - final Storage destination = new InMemoryStorageImpl(); + final Storage destination = new StorageImpl(); final ExporterTransferStrategy strategy = createTransferStrategy(destination, 10); sut.setTransferStrategy(strategy); diff --git a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/exporter/RoundRobinExporterNetworkNodeTest.java b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/exporter/RoundRobinExporterNetworkNodeTest.java index 8b0f7cc98..5dbdb29c3 100644 --- a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/exporter/RoundRobinExporterNetworkNodeTest.java +++ b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/exporter/RoundRobinExporterNetworkNodeTest.java @@ -7,8 +7,8 @@ import com.refinedmods.refinedstorage.api.network.storage.StorageNetworkComponent; import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.storage.EmptyActor; -import com.refinedmods.refinedstorage.api.storage.InMemoryStorageImpl; import com.refinedmods.refinedstorage.api.storage.Storage; +import com.refinedmods.refinedstorage.api.storage.StorageImpl; import com.refinedmods.refinedstorage.network.test.InjectNetworkStorageComponent; import java.util.List; @@ -44,11 +44,11 @@ protected TaskExecutor createTaskExecutor() { @Test void shouldTransfer(@InjectNetworkStorageComponent final StorageNetworkComponent storage) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(A, 100, Action.EXECUTE, EmptyActor.INSTANCE); storage.insert(B, 100, Action.EXECUTE, EmptyActor.INSTANCE); - final Storage destination = new InMemoryStorageImpl(); + final Storage destination = new StorageImpl(); final ExporterTransferStrategy strategy = createTransferStrategy(destination, 5); sut.setTransferStrategy(strategy); @@ -97,7 +97,7 @@ void shouldTransfer(@InjectNetworkStorageComponent final StorageNetworkComponent @Test void shouldNotTransferIfThereAreNoResourcesInSource() { // Arrange - final Storage destination = new InMemoryStorageImpl(); + final Storage destination = new StorageImpl(); final ExporterTransferStrategy strategy = createTransferStrategy(destination, 5); sut.setTransferStrategy(strategy); @@ -113,11 +113,11 @@ void shouldUseNextResourceIfFirstOneIsNotAvailableInSameCycle( @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(C, 8, Action.EXECUTE, EmptyActor.INSTANCE); storage.insert(D, 9, Action.EXECUTE, EmptyActor.INSTANCE); - final Storage destination = new InMemoryStorageImpl(); + final Storage destination = new StorageImpl(); final ExporterTransferStrategy strategy = createTransferStrategy(destination, 10); sut.setTransferStrategy(strategy); @@ -189,12 +189,12 @@ void shouldResetRoundRobinStateAfterChangingFilters( @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(A, 100, Action.EXECUTE, EmptyActor.INSTANCE); storage.insert(B, 100, Action.EXECUTE, EmptyActor.INSTANCE); storage.insert(C, 100, Action.EXECUTE, EmptyActor.INSTANCE); - final Storage destination = new InMemoryStorageImpl(); + final Storage destination = new StorageImpl(); final ExporterTransferStrategy strategy = createTransferStrategy(destination, 5); sut.setTransferStrategy(strategy); diff --git a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/externalstorage/ExternalStorageNetworkNodeTest.java b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/externalstorage/ExternalStorageNetworkNodeTest.java index 89489c30e..1f52e431f 100644 --- a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/externalstorage/ExternalStorageNetworkNodeTest.java +++ b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/externalstorage/ExternalStorageNetworkNodeTest.java @@ -7,8 +7,8 @@ import com.refinedmods.refinedstorage.api.resource.filter.FilterMode; import com.refinedmods.refinedstorage.api.storage.AccessMode; import com.refinedmods.refinedstorage.api.storage.EmptyActor; -import com.refinedmods.refinedstorage.api.storage.InMemoryStorageImpl; import com.refinedmods.refinedstorage.api.storage.Storage; +import com.refinedmods.refinedstorage.api.storage.StorageImpl; import com.refinedmods.refinedstorage.api.storage.external.ExternalStorageProvider; import com.refinedmods.refinedstorage.api.storage.limited.LimitedStorageImpl; import com.refinedmods.refinedstorage.api.storage.tracked.TrackedResource; @@ -68,7 +68,7 @@ void testInitialState(@InjectNetworkStorageComponent final StorageNetworkCompone @Test void shouldInitialize(@InjectNetworkStorageComponent final StorageNetworkComponent networkStorage) { // Arrange - final Storage storage = new InMemoryStorageImpl(); + final Storage storage = new StorageImpl(); final ExternalStorageProvider provider = new StorageExternalStorageProvider(storage); // Act @@ -84,10 +84,10 @@ void shouldBeAbleToInitializeMultipleTimes( @InjectNetworkStorageComponent final StorageNetworkComponent networkStorage ) { // Arrange - final Storage storage1 = new InMemoryStorageImpl(); + final Storage storage1 = new StorageImpl(); final ExternalStorageProvider provider1 = new StorageExternalStorageProvider(storage1); - final Storage storage2 = new InMemoryStorageImpl(); + final Storage storage2 = new StorageImpl(); final ExternalStorageProvider provider2 = new StorageExternalStorageProvider(storage2); // Act @@ -113,7 +113,7 @@ void shouldBeAbleToInitializeMultipleTimes( @Test void shouldInsert(@InjectNetworkStorageComponent final StorageNetworkComponent networkStorage) { // Arrange - final Storage storage = new InMemoryStorageImpl(); + final Storage storage = new StorageImpl(); final ExternalStorageProvider provider = new StorageExternalStorageProvider(storage); sut.initialize(new ExternalStorageProviderFactoryImpl(provider)); @@ -134,7 +134,7 @@ void shouldInsert(@InjectNetworkStorageComponent final StorageNetworkComponent n @Test void shouldExtract(@InjectNetworkStorageComponent final StorageNetworkComponent networkStorage) { // Arrange - final Storage storage = new InMemoryStorageImpl(); + final Storage storage = new StorageImpl(); storage.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); final ExternalStorageProvider provider = new StorageExternalStorageProvider(storage); sut.initialize(new ExternalStorageProviderFactoryImpl(provider)); @@ -160,7 +160,7 @@ void shouldRespectAllowlistWhenInserting( sut.getStorageConfiguration().setFilterMode(FilterMode.ALLOW); sut.getStorageConfiguration().setFilters(Set.of(A, B)); - final Storage storage = new InMemoryStorageImpl(); + final Storage storage = new StorageImpl(); final ExternalStorageProvider provider = new StorageExternalStorageProvider(storage); sut.initialize(new ExternalStorageProviderFactoryImpl(provider)); @@ -183,7 +183,7 @@ void shouldRespectEmptyAllowlistWhenInserting( sut.getStorageConfiguration().setFilterMode(FilterMode.ALLOW); sut.getStorageConfiguration().setFilters(Set.of()); - final Storage storage = new InMemoryStorageImpl(); + final Storage storage = new StorageImpl(); final ExternalStorageProvider provider = new StorageExternalStorageProvider(storage); sut.initialize(new ExternalStorageProviderFactoryImpl(provider)); @@ -205,7 +205,7 @@ void shouldRespectBlocklistWhenInserting( sut.getStorageConfiguration().setFilterMode(FilterMode.BLOCK); sut.getStorageConfiguration().setFilters(Set.of(A, B)); - final Storage storage = new InMemoryStorageImpl(); + final Storage storage = new StorageImpl(); final ExternalStorageProvider provider = new StorageExternalStorageProvider(storage); sut.initialize(new ExternalStorageProviderFactoryImpl(provider)); @@ -227,7 +227,7 @@ void shouldRespectEmptyBlocklistWhenInserting( sut.getStorageConfiguration().setFilterMode(FilterMode.BLOCK); sut.getStorageConfiguration().setFilters(Set.of()); - final Storage storage = new InMemoryStorageImpl(); + final Storage storage = new StorageImpl(); final ExternalStorageProvider provider = new StorageExternalStorageProvider(storage); sut.initialize(new ExternalStorageProviderFactoryImpl(provider)); @@ -251,7 +251,7 @@ void shouldRespectAccessModeWhenInserting(final AccessMode accessMode, // Arrange sut.getStorageConfiguration().setAccessMode(accessMode); - final Storage storage = new InMemoryStorageImpl(); + final Storage storage = new StorageImpl(); final ExternalStorageProvider provider = new StorageExternalStorageProvider(storage); sut.initialize(new ExternalStorageProviderFactoryImpl(provider)); @@ -274,7 +274,7 @@ void shouldRespectAccessModeWhenExtracting(final AccessMode accessMode, // Arrange sut.getStorageConfiguration().setAccessMode(accessMode); - final Storage storage = new InMemoryStorageImpl(); + final Storage storage = new StorageImpl(); storage.insert(A, 20, Action.EXECUTE, EmptyActor.INSTANCE); final ExternalStorageProvider provider = new StorageExternalStorageProvider(storage); @@ -293,7 +293,7 @@ void shouldRespectAccessModeWhenExtracting(final AccessMode accessMode, @Test void shouldNotInsertWhenInactive(@InjectNetworkStorageComponent final StorageNetworkComponent networkStorage) { // Arrange - final Storage storage = new InMemoryStorageImpl(); + final Storage storage = new StorageImpl(); final ExternalStorageProvider provider = new StorageExternalStorageProvider(storage); sut.initialize(new ExternalStorageProviderFactoryImpl(provider)); @@ -309,7 +309,7 @@ void shouldNotInsertWhenInactive(@InjectNetworkStorageComponent final StorageNet @Test void shouldNotExtractWhenInactive(@InjectNetworkStorageComponent final StorageNetworkComponent networkStorage) { // Arrange - final Storage storage = new InMemoryStorageImpl(); + final Storage storage = new StorageImpl(); storage.insert(A, 5, Action.EXECUTE, EmptyActor.INSTANCE); final ExternalStorageProvider provider = new StorageExternalStorageProvider(storage); diff --git a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/grid/GridNetworkNodeTest.java b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/grid/GridNetworkNodeTest.java index b8407205c..9223a2105 100644 --- a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/grid/GridNetworkNodeTest.java +++ b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/grid/GridNetworkNodeTest.java @@ -7,7 +7,7 @@ import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.api.storage.Actor; import com.refinedmods.refinedstorage.api.storage.EmptyActor; -import com.refinedmods.refinedstorage.api.storage.InMemoryStorageImpl; +import com.refinedmods.refinedstorage.api.storage.StorageImpl; import com.refinedmods.refinedstorage.api.storage.limited.LimitedStorageImpl; import com.refinedmods.refinedstorage.api.storage.tracked.TrackedResource; import com.refinedmods.refinedstorage.api.storage.tracked.TrackedStorageImpl; @@ -55,7 +55,7 @@ void setUp( storage.insert(A, 100, Action.EXECUTE, EmptyActor.INSTANCE); storage.insert(B, 200, Action.EXECUTE, EmptyActor.INSTANCE); - otherStorage.addSource(new TrackedStorageImpl(new InMemoryStorageImpl(), () -> 3L)); + otherStorage.addSource(new TrackedStorageImpl(new StorageImpl(), () -> 3L)); } @Test diff --git a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/ClearSlotInterfaceNetworkNodeTest.java b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/ClearSlotInterfaceNetworkNodeTest.java index e99fa2e1a..39c114372 100644 --- a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/ClearSlotInterfaceNetworkNodeTest.java +++ b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/ClearSlotInterfaceNetworkNodeTest.java @@ -2,7 +2,7 @@ import com.refinedmods.refinedstorage.api.network.storage.StorageNetworkComponent; import com.refinedmods.refinedstorage.api.resource.ResourceAmount; -import com.refinedmods.refinedstorage.api.storage.InMemoryStorageImpl; +import com.refinedmods.refinedstorage.api.storage.StorageImpl; import com.refinedmods.refinedstorage.api.storage.limited.LimitedStorageImpl; import com.refinedmods.refinedstorage.network.test.AddNetworkNode; import com.refinedmods.refinedstorage.network.test.InjectNetworkStorageComponent; @@ -37,7 +37,7 @@ void shouldClearSlotWhenNoLongerRequestingAnything( @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); exportState.setCurrentlyExported(1, A, 7); exportState.setCurrentlyExported(2, B, 2); diff --git a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/ExportToEmptySlotInterfaceNetworkNodeTest.java b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/ExportToEmptySlotInterfaceNetworkNodeTest.java index e8e52f5e4..73200d251 100644 --- a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/ExportToEmptySlotInterfaceNetworkNodeTest.java +++ b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/ExportToEmptySlotInterfaceNetworkNodeTest.java @@ -4,7 +4,7 @@ import com.refinedmods.refinedstorage.api.network.storage.StorageNetworkComponent; import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.storage.EmptyActor; -import com.refinedmods.refinedstorage.api.storage.InMemoryStorageImpl; +import com.refinedmods.refinedstorage.api.storage.StorageImpl; import com.refinedmods.refinedstorage.network.test.AddNetworkNode; import com.refinedmods.refinedstorage.network.test.InjectNetworkStorageComponent; import com.refinedmods.refinedstorage.network.test.NetworkTest; @@ -58,7 +58,7 @@ void shouldExportToEmptySlotWhenRequestedIsNotEntirelyAvailable( @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(A, 2, Action.EXECUTE, EmptyActor.INSTANCE); exportState.setRequestedResource(1, A, 10); @@ -82,7 +82,7 @@ void shouldExportToEmptySlotWhenRequestedIsLessThanTransferQuota( @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); exportState.setRequestedResource(1, A, 1); @@ -106,7 +106,7 @@ void shouldExportToEmptySlot( @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); storage.insert(B, 10, Action.EXECUTE, EmptyActor.INSTANCE); @@ -136,7 +136,7 @@ void shouldExportResourceFuzzilyToEmptySlot( @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(A_ALTERNATIVE, 10, Action.EXECUTE, EmptyActor.INSTANCE); storage.insert(A_ALTERNATIVE2, 10, Action.EXECUTE, EmptyActor.INSTANCE); diff --git a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/InterfaceNetworkNodeTest.java b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/InterfaceNetworkNodeTest.java index 421a724a6..365c23c95 100644 --- a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/InterfaceNetworkNodeTest.java +++ b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/InterfaceNetworkNodeTest.java @@ -5,7 +5,7 @@ import com.refinedmods.refinedstorage.api.network.storage.StorageNetworkComponent; import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.storage.EmptyActor; -import com.refinedmods.refinedstorage.api.storage.InMemoryStorageImpl; +import com.refinedmods.refinedstorage.api.storage.StorageImpl; import com.refinedmods.refinedstorage.network.test.AddNetworkNode; import com.refinedmods.refinedstorage.network.test.InjectNetworkEnergyComponent; import com.refinedmods.refinedstorage.network.test.InjectNetworkStorageComponent; @@ -50,7 +50,7 @@ void shouldExportAllWithDefaultTransferQuota( @InjectNetworkEnergyComponent final EnergyNetworkComponent energy ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(A, Long.MAX_VALUE, Action.EXECUTE, EmptyActor.INSTANCE); exportState.setRequestedResource(1, A, Long.MAX_VALUE); @@ -72,7 +72,7 @@ void shouldNotExportAnythingWithoutBeingActive( @InjectNetworkEnergyComponent final EnergyNetworkComponent energy ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); exportState.setRequestedResource(1, A, 1); @@ -98,7 +98,7 @@ void shouldNotExportAnythingWithoutNetwork( @InjectNetworkEnergyComponent final EnergyNetworkComponent energy ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); exportState.setRequestedResource(1, A, 1); @@ -124,7 +124,7 @@ void shouldNotExportAnythingWithoutExportState( @InjectNetworkEnergyComponent final EnergyNetworkComponent energy ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); sut.setExportState(null); diff --git a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/KeepExportingInterfaceNetworkNodeTest.java b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/KeepExportingInterfaceNetworkNodeTest.java index a8b780434..f9f4b7540 100644 --- a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/KeepExportingInterfaceNetworkNodeTest.java +++ b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/KeepExportingInterfaceNetworkNodeTest.java @@ -4,7 +4,7 @@ import com.refinedmods.refinedstorage.api.network.storage.StorageNetworkComponent; import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.storage.EmptyActor; -import com.refinedmods.refinedstorage.api.storage.InMemoryStorageImpl; +import com.refinedmods.refinedstorage.api.storage.StorageImpl; import com.refinedmods.refinedstorage.api.storage.limited.LimitedStorageImpl; import com.refinedmods.refinedstorage.network.test.AddNetworkNode; import com.refinedmods.refinedstorage.network.test.InjectNetworkStorageComponent; @@ -41,7 +41,7 @@ void shouldKeepExportingResourceUntilWantedAmountIsReached( @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); exportState.setRequestedResource(1, A, 7); @@ -95,7 +95,7 @@ void shouldKeepExportingResourceUntilWantedAmountIsReachedAndNetworkHasEnoughRes @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(A, 7, Action.EXECUTE, EmptyActor.INSTANCE); exportState.setRequestedResource(1, A, 10); @@ -145,7 +145,7 @@ void shouldKeepExportingResourceFuzzilyUntilWantedAmountIsReached( @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(A_ALTERNATIVE, 10, Action.EXECUTE, EmptyActor.INSTANCE); storage.insert(A_ALTERNATIVE2, 10, Action.EXECUTE, EmptyActor.INSTANCE); @@ -180,7 +180,7 @@ void shouldKeepExportingResourceFuzzilyUntilWantedAmountIsReachedEvenIfTheResour @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(A_ALTERNATIVE, 1, Action.EXECUTE, EmptyActor.INSTANCE); exportState.setRequestedResource(1, A, 1); @@ -204,7 +204,7 @@ void shouldReturnResourceToNetworkUntilWantedAmountIsReached( @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); exportState.setRequestedResource(1, A, 7); exportState.setCurrentlyExported(1, A, 10); @@ -280,7 +280,7 @@ void shouldReturnResourceToNetworkAndExportOtherResourceIfSpecified( @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(B, 10, Action.EXECUTE, EmptyActor.INSTANCE); exportState.setRequestedResource(1, B, 3); diff --git a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/externalstorage/IoLoopInterfaceExternalStorageProviderImplTest.java b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/externalstorage/IoLoopInterfaceExternalStorageProviderImplTest.java index 08c862be6..2119d07e7 100644 --- a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/externalstorage/IoLoopInterfaceExternalStorageProviderImplTest.java +++ b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/externalstorage/IoLoopInterfaceExternalStorageProviderImplTest.java @@ -10,8 +10,8 @@ import com.refinedmods.refinedstorage.api.network.storage.StorageNetworkComponent; import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.storage.EmptyActor; -import com.refinedmods.refinedstorage.api.storage.InMemoryStorageImpl; import com.refinedmods.refinedstorage.api.storage.Storage; +import com.refinedmods.refinedstorage.api.storage.StorageImpl; import com.refinedmods.refinedstorage.network.test.AddNetworkNode; import com.refinedmods.refinedstorage.network.test.InjectNetwork; import com.refinedmods.refinedstorage.network.test.InjectNetworkStorageComponent; @@ -76,12 +76,12 @@ void setUp(@InjectNetworkStorageComponent final StorageNetworkComponent networkS regularInterface.setExportState(regularInterfaceState); regularInterface.setTransferQuotaProvider(resource -> 100); - regularStorageInNetwork = new InMemoryStorageImpl(); + regularStorageInNetwork = new StorageImpl(); regularStorageInNetwork.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); networkStorage.addSource(regularStorageInNetwork); externalStorageWithNonInterfaceConnection.initialize(new ExternalStorageProviderFactoryImpl( - new StorageExternalStorageProvider(new InMemoryStorageImpl()) + new StorageExternalStorageProvider(new StorageImpl()) )); } diff --git a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/importer/FakeImporterSource.java b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/importer/FakeImporterSource.java index 5c89ea603..4a2f4419b 100644 --- a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/importer/FakeImporterSource.java +++ b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/importer/FakeImporterSource.java @@ -5,7 +5,7 @@ import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.api.storage.Actor; import com.refinedmods.refinedstorage.api.storage.EmptyActor; -import com.refinedmods.refinedstorage.api.storage.InMemoryStorageImpl; +import com.refinedmods.refinedstorage.api.storage.StorageImpl; import java.util.Arrays; import java.util.Collection; @@ -14,7 +14,7 @@ public class FakeImporterSource implements ImporterSource { private final List resources; - private final InMemoryStorageImpl storage = new InMemoryStorageImpl(); + private final StorageImpl storage = new StorageImpl(); public FakeImporterSource(final ResourceKey... resources) { this.resources = Arrays.stream(resources).toList(); diff --git a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/importer/ImporterNetworkNodeTest.java b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/importer/ImporterNetworkNodeTest.java index 9bb000da5..c37a31d61 100644 --- a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/importer/ImporterNetworkNodeTest.java +++ b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/importer/ImporterNetworkNodeTest.java @@ -9,7 +9,7 @@ import com.refinedmods.refinedstorage.api.resource.filter.FilterMode; import com.refinedmods.refinedstorage.api.storage.Actor; import com.refinedmods.refinedstorage.api.storage.EmptyActor; -import com.refinedmods.refinedstorage.api.storage.InMemoryStorageImpl; +import com.refinedmods.refinedstorage.api.storage.StorageImpl; import com.refinedmods.refinedstorage.api.storage.limited.LimitedStorageImpl; import com.refinedmods.refinedstorage.network.test.AddNetworkNode; import com.refinedmods.refinedstorage.network.test.InjectNetworkEnergyComponent; @@ -89,7 +89,7 @@ void shouldNotWorkOrExtractEnergyWithoutBeingActive( @InjectNetworkEnergyComponent final EnergyNetworkComponent energy ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); final FakeImporterSource source = new FakeImporterSource(A, B) .add(A, 100) @@ -113,7 +113,7 @@ void shouldNotWorkOrExtractEnergyWithoutBeingActive( @Test void testTransfer(@InjectNetworkStorageComponent final StorageNetworkComponent storage) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); final FakeImporterSource source = new FakeImporterSource(A, B, A) .add(A, 100) @@ -139,7 +139,7 @@ void shouldUseFirstSuccessfulTransferStrategy( @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); final FakeImporterSource emptySource = new FakeImporterSource(); final FakeImporterSource outdatedSource = new FakeImporterSource(C) @@ -202,7 +202,7 @@ void testTransferDifferentResourceOverMultipleSlots( @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); final FakeImporterSource source = new FakeImporterSource(A, B, A, B) .add(A, 11) @@ -228,7 +228,7 @@ void testTransferSameResourceOverMultipleSlots( @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); final FakeImporterSource source = new FakeImporterSource(A, A, A, B) .add(A, 20) @@ -255,7 +255,7 @@ void testTransferWhereResourceIsNotAccepted( @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - storage.addSource(new InMemoryStorageImpl() { + storage.addSource(new StorageImpl() { @Override public long insert(final ResourceKey resource, final long amount, final Action action, final Actor actor) { if (A.equals(resource)) { @@ -289,7 +289,7 @@ void testTransferWithoutAnyResourcesInSource( @InjectNetworkStorageComponent final StorageNetworkComponent storage ) { // Arrange - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); final FakeImporterSource source = new FakeImporterSource(); final ImporterTransferStrategy strategy = new ImporterTransferStrategyImpl(source, 10); @@ -309,7 +309,7 @@ void shouldRespectAllowlist(@InjectNetworkStorageComponent final StorageNetworkC sut.setFilterMode(FilterMode.ALLOW); sut.setFilters(Set.of(A)); - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); final FakeImporterSource source = new FakeImporterSource(B, A) .add(B, 10) @@ -345,7 +345,7 @@ void shouldRespectAllowlistWithNormalizer( return resource; }); - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); final FakeImporterSource source = new FakeImporterSource(B, A_ALTERNATIVE, A_ALTERNATIVE2) .add(B, 10) @@ -377,7 +377,7 @@ void shouldRespectAllowlistWithoutAlternative( sut.setFilterMode(FilterMode.ALLOW); sut.setFilters(Set.of(A)); - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); final FakeImporterSource source = new FakeImporterSource(B) .add(B, 10); @@ -401,7 +401,7 @@ void shouldRespectEmptyAllowlist(@InjectNetworkStorageComponent final StorageNet sut.setFilterMode(FilterMode.ALLOW); sut.setFilters(Set.of()); - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); final FakeImporterSource source = new FakeImporterSource(B, A) .add(B, 10) @@ -427,7 +427,7 @@ void shouldRespectBlocklist(@InjectNetworkStorageComponent final StorageNetworkC sut.setFilterMode(FilterMode.BLOCK); sut.setFilters(Set.of(A)); - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); final FakeImporterSource source = new FakeImporterSource(A, B) .add(A, 10) @@ -457,7 +457,7 @@ void shouldRespectBlocklistWithoutAlternative( sut.setFilterMode(FilterMode.BLOCK); sut.setFilters(Set.of(A)); - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); final FakeImporterSource source = new FakeImporterSource(A) .add(A, 10); @@ -481,7 +481,7 @@ void shouldRespectEmptyBlocklist(@InjectNetworkStorageComponent final StorageNet sut.setFilterMode(FilterMode.BLOCK); sut.setFilters(Set.of()); - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); final FakeImporterSource source = new FakeImporterSource(A, B) .add(A, 10) diff --git a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/relay/RelayNetworkNodeTest.java b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/relay/RelayNetworkNodeTest.java index 3c766ecf3..7a396353a 100644 --- a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/relay/RelayNetworkNodeTest.java +++ b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/relay/RelayNetworkNodeTest.java @@ -10,7 +10,7 @@ import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.storage.AccessMode; import com.refinedmods.refinedstorage.api.storage.EmptyActor; -import com.refinedmods.refinedstorage.api.storage.InMemoryStorageImpl; +import com.refinedmods.refinedstorage.api.storage.StorageImpl; import com.refinedmods.refinedstorage.network.test.AddNetworkNode; import com.refinedmods.refinedstorage.network.test.InjectNetwork; import com.refinedmods.refinedstorage.network.test.InjectNetworkEnergyComponent; @@ -259,12 +259,12 @@ void shouldResetComponentsIfNetworkIsChanged( RelayComponentType.STORAGE )); - inputStorage.addSource(new InMemoryStorageImpl()); + inputStorage.addSource(new StorageImpl()); inputStorage.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); inputStorage.insert(B, 5, Action.EXECUTE, EmptyActor.INSTANCE); inputStorage.extract(B, 3, Action.EXECUTE, EmptyActor.INSTANCE); - inputAlternativeStorage.addSource(new InMemoryStorageImpl()); + inputAlternativeStorage.addSource(new StorageImpl()); inputAlternativeStorage.insert(A, 33, Action.EXECUTE, EmptyActor.INSTANCE); addSecurityPolicy(inputSecurity, FakePermissions.OTHER); @@ -400,7 +400,7 @@ static void addSecurityPolicy(final SecurityNetworkComponent security, final Fak } static void addStorageSource(final StorageNetworkComponent storage) { - storage.addSource(new InMemoryStorageImpl()); + storage.addSource(new StorageImpl()); storage.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); } } diff --git a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/relay/RelayStorageNetworkNodeTest.java b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/relay/RelayStorageNetworkNodeTest.java index 12464d396..f7f095ff8 100644 --- a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/relay/RelayStorageNetworkNodeTest.java +++ b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/relay/RelayStorageNetworkNodeTest.java @@ -9,8 +9,8 @@ import com.refinedmods.refinedstorage.api.resource.filter.FilterMode; import com.refinedmods.refinedstorage.api.storage.AccessMode; import com.refinedmods.refinedstorage.api.storage.EmptyActor; -import com.refinedmods.refinedstorage.api.storage.InMemoryStorageImpl; import com.refinedmods.refinedstorage.api.storage.Storage; +import com.refinedmods.refinedstorage.api.storage.StorageImpl; import com.refinedmods.refinedstorage.api.storage.composite.PriorityStorage; import com.refinedmods.refinedstorage.api.storage.limited.LimitedStorageImpl; import com.refinedmods.refinedstorage.network.test.AddNetworkNode; @@ -62,7 +62,7 @@ void shouldPassStorageComponent( addSecurityPolicy(inputSecurity, FakePermissions.OTHER); - inputStorage.addSource(new InMemoryStorageImpl()); + inputStorage.addSource(new StorageImpl()); inputStorage.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); // Act @@ -100,7 +100,7 @@ void shouldRemoveStorageWhenNetworkIsRemoved( input.setActive(true); input.setOutputNode(output); - inputStorage.addSource(new InMemoryStorageImpl()); + inputStorage.addSource(new StorageImpl()); inputStorage.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); input.setComponentTypes(Set.of(RelayComponentType.STORAGE)); inputStorage.insert(B, 5, Action.EXECUTE, EmptyActor.INSTANCE); @@ -136,7 +136,7 @@ void shouldNotNotifyOldOutputNetworkWhenOutputNetworkHasChanged( input.setActive(true); input.setOutputNode(output); - inputStorage.addSource(new InMemoryStorageImpl()); + inputStorage.addSource(new StorageImpl()); inputStorage.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); input.setComponentTypes(Set.of(RelayComponentType.STORAGE)); @@ -165,7 +165,7 @@ void shouldInsertResourcesIntoInputStorageFromOutputStorage( input.setOutputNode(output); input.setComponentTypes(Set.of(RelayComponentType.STORAGE)); - inputStorage.addSource(new InMemoryStorageImpl()); + inputStorage.addSource(new StorageImpl()); inputStorage.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); // Act @@ -195,7 +195,7 @@ void shouldExtractResourcesFromInputStorageIntoOutputStorage( input.setOutputNode(output); input.setComponentTypes(Set.of(RelayComponentType.STORAGE)); - inputStorage.addSource(new InMemoryStorageImpl()); + inputStorage.addSource(new StorageImpl()); inputStorage.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); // Act @@ -224,7 +224,7 @@ void shouldNotInsertInExtractOnlyMode( input.setAccessMode(AccessMode.EXTRACT); input.setComponentTypes(Set.of(RelayComponentType.STORAGE)); - inputStorage.addSource(new InMemoryStorageImpl()); + inputStorage.addSource(new StorageImpl()); inputStorage.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); // Act @@ -255,7 +255,7 @@ void shouldNotExtractInInsertOnlyMode( input.setAccessMode(AccessMode.INSERT); input.setComponentTypes(Set.of(RelayComponentType.STORAGE)); - inputStorage.addSource(new InMemoryStorageImpl()); + inputStorage.addSource(new StorageImpl()); inputStorage.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); // Act @@ -287,14 +287,14 @@ void shouldRespectPriorityOfOutput( input.setOutputNode(output); input.setPriority(3); input.setComponentTypes(Set.of(RelayComponentType.STORAGE)); - inputStorage.addSource(new InMemoryStorageImpl()); + inputStorage.addSource(new StorageImpl()); inputStorage.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); - final Storage fallbackStorage1 = PriorityStorage.of(new InMemoryStorageImpl(), 2); + final Storage fallbackStorage1 = PriorityStorage.of(new StorageImpl(), 2); fallbackStorage1.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); outputStorage.addSource(fallbackStorage1); - final Storage fallbackStorage2 = PriorityStorage.of(new InMemoryStorageImpl(), 1); + final Storage fallbackStorage2 = PriorityStorage.of(new StorageImpl(), 1); fallbackStorage2.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); outputStorage.addSource(fallbackStorage2); @@ -364,7 +364,7 @@ void shouldRespectBlocklistFilter( input.setOutputNode(output); input.setFilters(Set.of(A, B)); - inputStorage.addSource(new InMemoryStorageImpl()); + inputStorage.addSource(new StorageImpl()); inputStorage.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); inputStorage.insert(B, 9, Action.EXECUTE, EmptyActor.INSTANCE); inputStorage.insert(C, 8, Action.EXECUTE, EmptyActor.INSTANCE); @@ -414,7 +414,7 @@ void shouldRespectAllowlistFilter( input.setFilters(Set.of(A, B)); input.setFilterMode(FilterMode.ALLOW); - inputStorage.addSource(new InMemoryStorageImpl()); + inputStorage.addSource(new StorageImpl()); inputStorage.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); inputStorage.insert(B, 9, Action.EXECUTE, EmptyActor.INSTANCE); inputStorage.insert(C, 8, Action.EXECUTE, EmptyActor.INSTANCE); @@ -471,7 +471,7 @@ void shouldRespectFilterNormalizer( return resource; }); - inputStorage.addSource(new InMemoryStorageImpl()); + inputStorage.addSource(new StorageImpl()); inputStorage.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); inputStorage.insert(A_ALTERNATIVE, 3, Action.EXECUTE, EmptyActor.INSTANCE); inputStorage.insert(B, 9, Action.EXECUTE, EmptyActor.INSTANCE); @@ -530,7 +530,7 @@ void shouldUpdateOutputStorageWhenFiltersAreChanged( input.setFilters(Set.of(A)); input.setFilterMode(FilterMode.BLOCK); - inputStorage.addSource(new InMemoryStorageImpl()); + inputStorage.addSource(new StorageImpl()); inputStorage.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); inputStorage.insert(B, 9, Action.EXECUTE, EmptyActor.INSTANCE); inputStorage.insert(C, 8, Action.EXECUTE, EmptyActor.INSTANCE); @@ -565,7 +565,7 @@ void shouldUpdateOutputStorageWhenFilterModeIsChanged( input.setFilters(Set.of(A)); input.setFilterMode(FilterMode.BLOCK); - inputStorage.addSource(new InMemoryStorageImpl()); + inputStorage.addSource(new StorageImpl()); inputStorage.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); inputStorage.insert(B, 9, Action.EXECUTE, EmptyActor.INSTANCE); inputStorage.insert(C, 8, Action.EXECUTE, EmptyActor.INSTANCE); @@ -609,7 +609,7 @@ void shouldDetectStorageCycles( cycleOutputAlternative.setNetwork(inputAlternativeNetwork); inputAlternativeNetwork.addContainer(() -> cycleOutputAlternative); - inputStorage.addSource(new InMemoryStorageImpl()); + inputStorage.addSource(new StorageImpl()); // Assert final long inserted1 = inputStorage.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); diff --git a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/storage/StorageNetworkNodeTest.java b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/storage/StorageNetworkNodeTest.java index b7045a0e6..7e21a3da7 100644 --- a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/storage/StorageNetworkNodeTest.java +++ b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/storage/StorageNetworkNodeTest.java @@ -8,9 +8,9 @@ import com.refinedmods.refinedstorage.api.resource.filter.FilterMode; import com.refinedmods.refinedstorage.api.storage.AccessMode; import com.refinedmods.refinedstorage.api.storage.EmptyActor; -import com.refinedmods.refinedstorage.api.storage.InMemoryStorageImpl; import com.refinedmods.refinedstorage.api.storage.StateTrackedStorage; import com.refinedmods.refinedstorage.api.storage.Storage; +import com.refinedmods.refinedstorage.api.storage.StorageImpl; import com.refinedmods.refinedstorage.api.storage.StorageState; import com.refinedmods.refinedstorage.api.storage.limited.LimitedStorageImpl; import com.refinedmods.refinedstorage.api.storage.tracked.TrackedStorageImpl; @@ -153,7 +153,7 @@ void testState(final boolean active) { final Storage fullStorage = new LimitedStorageImpl(100); fullStorage.insert(A, 100, Action.EXECUTE, EmptyActor.INSTANCE); - final Storage unlimitedStorage = new InMemoryStorageImpl(); + final Storage unlimitedStorage = new StorageImpl(); provider.set(2, unlimitedStorage); provider.set(3, normalStorage); diff --git a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/storagetransfer/StorageTransferNetworkNodeTest.java b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/storagetransfer/StorageTransferNetworkNodeTest.java index 9ee64fdf1..685591a0d 100644 --- a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/storagetransfer/StorageTransferNetworkNodeTest.java +++ b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/storagetransfer/StorageTransferNetworkNodeTest.java @@ -9,8 +9,8 @@ import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; import com.refinedmods.refinedstorage.api.storage.Actor; import com.refinedmods.refinedstorage.api.storage.EmptyActor; -import com.refinedmods.refinedstorage.api.storage.InMemoryStorageImpl; import com.refinedmods.refinedstorage.api.storage.Storage; +import com.refinedmods.refinedstorage.api.storage.StorageImpl; import com.refinedmods.refinedstorage.api.storage.limited.LimitedStorageImpl; import com.refinedmods.refinedstorage.network.test.AddNetworkNode; import com.refinedmods.refinedstorage.network.test.InjectNetworkStorageComponent; @@ -54,9 +54,9 @@ void setUp() { @Test void shouldNotTransferWithoutNetwork(@InjectNetworkStorageComponent final StorageNetworkComponent networkStorage) { // Arrange - networkStorage.addSource(new InMemoryStorageImpl()); + networkStorage.addSource(new StorageImpl()); - final Storage source = new InMemoryStorageImpl(ResourceListImpl.orderPreserving()); + final Storage source = new StorageImpl(ResourceListImpl.orderPreserving()); source.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(0, source); @@ -75,9 +75,9 @@ void shouldNotTransferWithoutNetwork(@InjectNetworkStorageComponent final Storag @Test void shouldNotTransferWhenInactive(@InjectNetworkStorageComponent final StorageNetworkComponent networkStorage) { // Arrange - networkStorage.addSource(new InMemoryStorageImpl()); + networkStorage.addSource(new StorageImpl()); - final Storage source = new InMemoryStorageImpl(ResourceListImpl.orderPreserving()); + final Storage source = new StorageImpl(ResourceListImpl.orderPreserving()); source.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(0, source); @@ -100,10 +100,10 @@ void shouldNotTransferWithoutTransferQuotaProvider( @InjectNetworkStorageComponent final StorageNetworkComponent networkStorage ) { // Arrange - networkStorage.addSource(new InMemoryStorageImpl()); + networkStorage.addSource(new StorageImpl()); networkStorage.insert(A, 5, Action.EXECUTE, EmptyActor.INSTANCE); - final Storage source = new InMemoryStorageImpl(); + final Storage source = new StorageImpl(); source.insert(B, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(0, source); @@ -125,7 +125,7 @@ void shouldNotTransferWithoutTransferQuotaProvider( @Test void shouldInsert(@InjectNetworkStorageComponent final StorageNetworkComponent networkStorage) { // Arrange - networkStorage.addSource(new InMemoryStorageImpl()); + networkStorage.addSource(new StorageImpl()); final Storage source0 = new LimitedStorageImpl(1) { @Override @@ -139,14 +139,14 @@ public long extract(final ResourceKey resource, source0.insert(A, 1, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(0, source0); - final Storage source1 = new InMemoryStorageImpl(ResourceListImpl.orderPreserving()); + final Storage source1 = new StorageImpl(ResourceListImpl.orderPreserving()); source1.insert(A, 5, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(B, 5, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(C, 35, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(1, source1); - final Storage source2 = new InMemoryStorageImpl(ResourceListImpl.orderPreserving()); + final Storage source2 = new StorageImpl(ResourceListImpl.orderPreserving()); source2.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(2, source2); @@ -178,16 +178,16 @@ public long extract(final ResourceKey resource, @Test void shouldInsertAllowlist(@InjectNetworkStorageComponent final StorageNetworkComponent networkStorage) { // Arrange - networkStorage.addSource(new InMemoryStorageImpl()); + networkStorage.addSource(new StorageImpl()); - final Storage source1 = new InMemoryStorageImpl(ResourceListImpl.orderPreserving()); + final Storage source1 = new StorageImpl(ResourceListImpl.orderPreserving()); source1.insert(A, 5, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(B, 5, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(C, 35, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set((sut.getSize() / 2) - 2, source1); - final Storage source2 = new InMemoryStorageImpl(ResourceListImpl.orderPreserving()); + final Storage source2 = new StorageImpl(ResourceListImpl.orderPreserving()); source2.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set((sut.getSize() / 2) - 1, source2); @@ -217,16 +217,16 @@ void shouldInsertAllowlist(@InjectNetworkStorageComponent final StorageNetworkCo @Test void shouldInsertBlocklist(@InjectNetworkStorageComponent final StorageNetworkComponent networkStorage) { // Arrange - networkStorage.addSource(new InMemoryStorageImpl()); + networkStorage.addSource(new StorageImpl()); - final Storage source1 = new InMemoryStorageImpl(ResourceListImpl.orderPreserving()); + final Storage source1 = new StorageImpl(ResourceListImpl.orderPreserving()); source1.insert(A, 5, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(B, 5, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(C, 35, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(0, source1); - final Storage source2 = new InMemoryStorageImpl(ResourceListImpl.orderPreserving()); + final Storage source2 = new StorageImpl(ResourceListImpl.orderPreserving()); source2.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(1, source2); @@ -257,7 +257,7 @@ void shouldInsertBlocklist(@InjectNetworkStorageComponent final StorageNetworkCo @Test void shouldNotifyListenerWhenReadyInsertingBecauseStorageWasAlreadyEmpty() { // Arrange - final Storage source = new InMemoryStorageImpl(); + final Storage source = new StorageImpl(); provider.set(0, source); sut.setProvider(provider); @@ -275,9 +275,9 @@ void shouldNotifyListenerWhenReadyInsertingAllResources( @InjectNetworkStorageComponent final StorageNetworkComponent networkStorage ) { // Arrange - networkStorage.addSource(new InMemoryStorageImpl()); + networkStorage.addSource(new StorageImpl()); - final Storage source = new InMemoryStorageImpl(ResourceListImpl.orderPreserving()); + final Storage source = new StorageImpl(ResourceListImpl.orderPreserving()); source.insert(A, 5, Action.EXECUTE, EmptyActor.INSTANCE); source.insert(B, 5, Action.EXECUTE, EmptyActor.INSTANCE); source.insert(C, 5, Action.EXECUTE, EmptyActor.INSTANCE); @@ -297,12 +297,12 @@ void shouldNotifyListenerWhenReadyInsertingAllResources( @Test void shouldNotifyListenerWhenReadyInsertingAllResourcesAndUsingFilterButInsertedNothing() { // Arrange - final Storage source1 = new InMemoryStorageImpl(ResourceListImpl.orderPreserving()); + final Storage source1 = new StorageImpl(ResourceListImpl.orderPreserving()); source1.insert(B, 5, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(C, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(0, source1); - final Storage source2 = new InMemoryStorageImpl(ResourceListImpl.orderPreserving()); + final Storage source2 = new StorageImpl(ResourceListImpl.orderPreserving()); source2.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(1, source2); @@ -330,15 +330,15 @@ void shouldNotifyListenerWhenReadyInsertingAllResourcesAndUsingFilterButStillIns @InjectNetworkStorageComponent final StorageNetworkComponent networkStorage ) { // Arrange - networkStorage.addSource(new InMemoryStorageImpl()); + networkStorage.addSource(new StorageImpl()); - final Storage source1 = new InMemoryStorageImpl(ResourceListImpl.orderPreserving()); + final Storage source1 = new StorageImpl(ResourceListImpl.orderPreserving()); source1.insert(A, 5, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(B, 5, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(C, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(0, source1); - final Storage source2 = new InMemoryStorageImpl(ResourceListImpl.orderPreserving()); + final Storage source2 = new StorageImpl(ResourceListImpl.orderPreserving()); source2.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(1, source2); @@ -368,14 +368,14 @@ void shouldNotNotifyListenerWhenReadyInsertingAllResourcesAndNetworkIsFull( // Arrange networkStorage.addSource(new LimitedStorageImpl(15)); - final Storage source1 = new InMemoryStorageImpl(ResourceListImpl.orderPreserving()); + final Storage source1 = new StorageImpl(ResourceListImpl.orderPreserving()); source1.insert(A, 5, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(B, 5, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(C, 5, Action.EXECUTE, EmptyActor.INSTANCE); source1.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(0, source1); - final Storage source2 = new InMemoryStorageImpl(ResourceListImpl.orderPreserving()); + final Storage source2 = new StorageImpl(ResourceListImpl.orderPreserving()); source2.insert(A, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(1, source2); @@ -404,7 +404,7 @@ void shouldNotNotifyListenerWhenReadyInsertingAllResourcesAndNetworkIsFull( @Test void shouldExtract(@InjectNetworkStorageComponent final StorageNetworkComponent networkStorage) { // Arrange - networkStorage.addSource(new InMemoryStorageImpl()); + networkStorage.addSource(new StorageImpl()); networkStorage.insert(A, 5, Action.EXECUTE, EmptyActor.INSTANCE); networkStorage.insert(B, 5, Action.EXECUTE, EmptyActor.INSTANCE); networkStorage.insert(C, 35, Action.EXECUTE, EmptyActor.INSTANCE); @@ -413,7 +413,7 @@ void shouldExtract(@InjectNetworkStorageComponent final StorageNetworkComponent final Storage source1 = new LimitedStorageImpl(0); provider.set(0, source1); - final Storage source2 = new InMemoryStorageImpl(); + final Storage source2 = new StorageImpl(); provider.set(1, source2); sut.setProvider(provider); @@ -440,16 +440,16 @@ void shouldExtract(@InjectNetworkStorageComponent final StorageNetworkComponent @Test void shouldExtractAllowlist(@InjectNetworkStorageComponent final StorageNetworkComponent networkStorage) { // Arrange - networkStorage.addSource(new InMemoryStorageImpl()); + networkStorage.addSource(new StorageImpl()); networkStorage.insert(A, 5, Action.EXECUTE, EmptyActor.INSTANCE); networkStorage.insert(B, 5, Action.EXECUTE, EmptyActor.INSTANCE); networkStorage.insert(C, 35, Action.EXECUTE, EmptyActor.INSTANCE); networkStorage.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); - final Storage source1 = new InMemoryStorageImpl(); + final Storage source1 = new StorageImpl(); provider.set(0, source1); - final Storage source2 = new InMemoryStorageImpl(); + final Storage source2 = new StorageImpl(); provider.set(1, source2); sut.setProvider(provider); @@ -477,16 +477,16 @@ void shouldExtractAllowlist(@InjectNetworkStorageComponent final StorageNetworkC @Test void shouldExtractBlocklist(@InjectNetworkStorageComponent final StorageNetworkComponent networkStorage) { // Arrange - networkStorage.addSource(new InMemoryStorageImpl()); + networkStorage.addSource(new StorageImpl()); networkStorage.insert(A, 5, Action.EXECUTE, EmptyActor.INSTANCE); networkStorage.insert(B, 5, Action.EXECUTE, EmptyActor.INSTANCE); networkStorage.insert(C, 35, Action.EXECUTE, EmptyActor.INSTANCE); networkStorage.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); - final Storage source1 = new InMemoryStorageImpl(); + final Storage source1 = new StorageImpl(); provider.set(0, source1); - final Storage source2 = new InMemoryStorageImpl(); + final Storage source2 = new StorageImpl(); provider.set(1, source2); sut.setProvider(provider); @@ -515,7 +515,7 @@ void shouldExtractBlocklist(@InjectNetworkStorageComponent final StorageNetworkC @Test void shouldNotifyListenerWhenReadyExtractingBecauseStorageWasAlreadyEmpty() { // Arrange - final Storage source = new InMemoryStorageImpl(); + final Storage source = new StorageImpl(); provider.set(0, source); sut.setProvider(provider); @@ -534,12 +534,12 @@ void shouldNotifyListenerWhenReadyExtractingAllResources( @InjectNetworkStorageComponent final StorageNetworkComponent networkStorage ) { // Arrange - networkStorage.addSource(new InMemoryStorageImpl()); + networkStorage.addSource(new StorageImpl()); networkStorage.insert(A, 5, Action.EXECUTE, EmptyActor.INSTANCE); networkStorage.insert(B, 5, Action.EXECUTE, EmptyActor.INSTANCE); networkStorage.insert(C, 5, Action.EXECUTE, EmptyActor.INSTANCE); - final Storage source = new InMemoryStorageImpl(); + final Storage source = new StorageImpl(); provider.set(0, source); sut.setProvider(provider); @@ -564,12 +564,12 @@ void shouldNotifyListenerWhenReadyExtractingAllResourcesAndUsingFilterButInserte @InjectNetworkStorageComponent final StorageNetworkComponent networkStorage ) { // Arrange - networkStorage.addSource(new InMemoryStorageImpl()); + networkStorage.addSource(new StorageImpl()); networkStorage.insert(B, 5, Action.EXECUTE, EmptyActor.INSTANCE); networkStorage.insert(C, 5, Action.EXECUTE, EmptyActor.INSTANCE); networkStorage.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); - final Storage source = new InMemoryStorageImpl(); + final Storage source = new StorageImpl(); provider.set(0, source); sut.setProvider(provider); @@ -596,12 +596,12 @@ void shouldNotifyListenerWhenReadyExtractingAllResourcesAndUsingFilterButStillEx @InjectNetworkStorageComponent final StorageNetworkComponent networkStorage ) { // Arrange - networkStorage.addSource(new InMemoryStorageImpl(ResourceListImpl.orderPreserving())); + networkStorage.addSource(new StorageImpl(ResourceListImpl.orderPreserving())); networkStorage.insert(A, 5, Action.EXECUTE, EmptyActor.INSTANCE); networkStorage.insert(B, 5, Action.EXECUTE, EmptyActor.INSTANCE); networkStorage.insert(C, 5, Action.EXECUTE, EmptyActor.INSTANCE); - final Storage source = new InMemoryStorageImpl(ResourceListImpl.orderPreserving()); + final Storage source = new StorageImpl(ResourceListImpl.orderPreserving()); provider.set(0, source); sut.setProvider(provider); @@ -629,7 +629,7 @@ void shouldNotifyListenerWhenExtractingAllResourcesAndReachingCapacity( @InjectNetworkStorageComponent final StorageNetworkComponent networkStorage ) { // Arrange - networkStorage.addSource(new InMemoryStorageImpl()); + networkStorage.addSource(new StorageImpl()); networkStorage.insert(A, 5, Action.EXECUTE, EmptyActor.INSTANCE); networkStorage.insert(B, 5, Action.EXECUTE, EmptyActor.INSTANCE); networkStorage.insert(C, 5, Action.EXECUTE, EmptyActor.INSTANCE); @@ -660,9 +660,9 @@ void shouldRespectNormalizer( @InjectNetworkStorageComponent final StorageNetworkComponent networkStorage ) { // Arrange - networkStorage.addSource(new InMemoryStorageImpl()); + networkStorage.addSource(new StorageImpl()); - final Storage source = new InMemoryStorageImpl(ResourceListImpl.orderPreserving()); + final Storage source = new StorageImpl(ResourceListImpl.orderPreserving()); source.insert(A, 5, Action.EXECUTE, EmptyActor.INSTANCE); source.insert(A_ALTERNATIVE, 5, Action.EXECUTE, EmptyActor.INSTANCE); source.insert(B, 5, Action.EXECUTE, EmptyActor.INSTANCE); @@ -695,9 +695,9 @@ void shouldNotTransferAtIndexHigherThanHalf( @InjectNetworkStorageComponent final StorageNetworkComponent networkStorage ) { // Arrange - networkStorage.addSource(new InMemoryStorageImpl()); + networkStorage.addSource(new StorageImpl()); - final Storage source = new InMemoryStorageImpl(); + final Storage source = new StorageImpl(); source.insert(A, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(sut.getSize() / 2, source); diff --git a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/InMemoryStorageImpl.java b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/StorageImpl.java similarity index 88% rename from refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/InMemoryStorageImpl.java rename to refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/StorageImpl.java index e21e42836..d82909000 100644 --- a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/InMemoryStorageImpl.java +++ b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/StorageImpl.java @@ -11,18 +11,18 @@ import org.apiguardian.api.API; /** - * An implementation of a {@link Storage} which has an in-memory resource list as a backing list. + * An implementation of a {@link Storage} which has a resource list as a backing list. */ @API(status = API.Status.STABLE, since = "2.0.0-milestone.1.0") -public class InMemoryStorageImpl implements Storage { +public class StorageImpl implements Storage { private final ResourceList list; private long stored; - public InMemoryStorageImpl(final ResourceList list) { + public StorageImpl(final ResourceList list) { this.list = list; } - public InMemoryStorageImpl() { + public StorageImpl() { this(ResourceListImpl.create()); } diff --git a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/limited/LimitedStorageImpl.java b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/limited/LimitedStorageImpl.java index c14b1a5cc..d03f7e58f 100644 --- a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/limited/LimitedStorageImpl.java +++ b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/limited/LimitedStorageImpl.java @@ -5,9 +5,9 @@ import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.api.storage.AbstractProxyStorage; import com.refinedmods.refinedstorage.api.storage.Actor; -import com.refinedmods.refinedstorage.api.storage.InMemoryStorageImpl; import com.refinedmods.refinedstorage.api.storage.InsertableStorage; import com.refinedmods.refinedstorage.api.storage.Storage; +import com.refinedmods.refinedstorage.api.storage.StorageImpl; import org.apiguardian.api.API; @@ -30,12 +30,12 @@ public LimitedStorageImpl(final Storage delegate, final long capacity) { } /** - * Constructs the limited storage with a {@link InMemoryStorageImpl} storage. + * Constructs the limited storage with a {@link StorageImpl} storage. * * @param capacity the capacity, must be 0 or larger than 0 */ public LimitedStorageImpl(final long capacity) { - this(new InMemoryStorageImpl(), capacity); + this(new StorageImpl(), capacity); } @Override diff --git a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/LimitedStorageImplTest.java b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/LimitedStorageImplTest.java index 810f793a3..7aa757696 100644 --- a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/LimitedStorageImplTest.java +++ b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/LimitedStorageImplTest.java @@ -20,7 +20,7 @@ class LimitedStorageImplTest { @BeforeEach void setUp() { - backed = new ActorCapturingStorage(new InMemoryStorageImpl()); + backed = new ActorCapturingStorage(new StorageImpl()); sut = new LimitedStorageImpl(backed, 100); } diff --git a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/ProxyStorageTest.java b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/ProxyStorageTest.java index cfb314432..7fe11e2c1 100644 --- a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/ProxyStorageTest.java +++ b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/ProxyStorageTest.java @@ -18,7 +18,7 @@ class ProxyStorageTest { @BeforeEach void setUp() { - backed = new ActorCapturingStorage(new InMemoryStorageImpl()); + backed = new ActorCapturingStorage(new StorageImpl()); sut = new AbstractProxyStorage(backed) { }; } diff --git a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/StateTrackedStorageTest.java b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/StateTrackedStorageTest.java index 243556d66..bdfe2e6c0 100644 --- a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/StateTrackedStorageTest.java +++ b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/StateTrackedStorageTest.java @@ -51,7 +51,7 @@ private static Stream states() { void shouldSetInitialState() { // Arrange final StateTrackedStorage.Listener listener = mock(StateTrackedStorage.Listener.class); - final Storage underlyingStorage = new InMemoryStorageImpl(); + final Storage underlyingStorage = new StorageImpl(); underlyingStorage.insert(TestResource.A, 75, Action.EXECUTE, EmptyActor.INSTANCE); final StateTrackedStorage sut = new StateTrackedStorage(underlyingStorage, listener); diff --git a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/InMemoryStorageImplTest.java b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/StorageImplTest.java similarity index 98% rename from refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/InMemoryStorageImplTest.java rename to refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/StorageImplTest.java index 0f7447f95..1221c742e 100644 --- a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/InMemoryStorageImplTest.java +++ b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/StorageImplTest.java @@ -11,8 +11,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; -class InMemoryStorageImplTest { - private final Storage sut = new InMemoryStorageImpl(); +class StorageImplTest { + private final Storage sut = new StorageImpl(); @ParameterizedTest @EnumSource(Action.class) diff --git a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/TransferHelperTest.java b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/TransferHelperTest.java index d25d33057..395abc09f 100644 --- a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/TransferHelperTest.java +++ b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/TransferHelperTest.java @@ -199,7 +199,7 @@ public long insert(final ResourceKey resource, final long amount, final Action a @Test void shouldRefundLeftoversToFallbackWhenEventualExecutedInsertToDestinationFailedEvenIfFallbackDoesNotAcceptAll() { // Arrange - final InMemoryStorageImpl underlyingSource = new InMemoryStorageImpl(); + final StorageImpl underlyingSource = new StorageImpl(); final Storage source = new LimitedStorageImpl(underlyingSource, 100) { @Override public long insert(final ResourceKey resource, final long amount, final Action action, final Actor actor) { diff --git a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/CompositeStorageImplTest.java b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/CompositeStorageImplTest.java index f956e531d..985ca196a 100644 --- a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/CompositeStorageImplTest.java +++ b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/CompositeStorageImplTest.java @@ -5,8 +5,8 @@ import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; import com.refinedmods.refinedstorage.api.storage.EmptyActor; import com.refinedmods.refinedstorage.api.storage.FakeActors; -import com.refinedmods.refinedstorage.api.storage.InMemoryStorageImpl; import com.refinedmods.refinedstorage.api.storage.Storage; +import com.refinedmods.refinedstorage.api.storage.StorageImpl; import com.refinedmods.refinedstorage.api.storage.limited.LimitedStorageImpl; import com.refinedmods.refinedstorage.api.storage.tracked.TrackedResource; import com.refinedmods.refinedstorage.api.storage.tracked.TrackedStorage; @@ -210,8 +210,8 @@ void shouldFindMostRecentChange() { // Arrange final AtomicLong clock = new AtomicLong(0L); - final TrackedStorage a = new TrackedStorageImpl(new InMemoryStorageImpl(), clock::get); - final TrackedStorage b = new TrackedStorageImpl(new InMemoryStorageImpl(), clock::get); + final TrackedStorage a = new TrackedStorageImpl(new StorageImpl(), clock::get); + final TrackedStorage b = new TrackedStorageImpl(new StorageImpl(), clock::get); // Test if it uses the latest across 2 different storages a.insert(A, 1, Action.EXECUTE, FakeActors.FakeActor1.INSTANCE); diff --git a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/SubCompositeCompositeStorageImplTest.java b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/SubCompositeCompositeStorageImplTest.java index 9e3cd603d..fc051b6b1 100644 --- a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/SubCompositeCompositeStorageImplTest.java +++ b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/SubCompositeCompositeStorageImplTest.java @@ -4,8 +4,8 @@ import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; import com.refinedmods.refinedstorage.api.storage.EmptyActor; -import com.refinedmods.refinedstorage.api.storage.InMemoryStorageImpl; import com.refinedmods.refinedstorage.api.storage.Storage; +import com.refinedmods.refinedstorage.api.storage.StorageImpl; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -26,7 +26,7 @@ void setUp() { void testAddingSubCompositeShouldAddAllResourcesToParent() { // Arrange final CompositeStorage subComposite = new CompositeStorageImpl(ResourceListImpl.create()); - subComposite.addSource(new InMemoryStorageImpl()); + subComposite.addSource(new StorageImpl()); subComposite.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); // Act @@ -42,12 +42,12 @@ void testAddingSubCompositeShouldAddAllResourcesToParent() { void testRemovingSubCompositeShouldRemoveAllResourcesFromParent() { // Arrange final CompositeStorage subComposite = new CompositeStorageImpl(ResourceListImpl.create()); - subComposite.addSource(new InMemoryStorageImpl()); + subComposite.addSource(new StorageImpl()); subComposite.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); sut.addSource(subComposite); - final Storage subCompositeStorage = new InMemoryStorageImpl(); + final Storage subCompositeStorage = new StorageImpl(); subCompositeStorage.insert(B, 10, Action.EXECUTE, EmptyActor.INSTANCE); // Act @@ -63,13 +63,13 @@ void testRemovingSubCompositeShouldRemoveAllResourcesFromParent() { void testAddingSourceToSubCompositeShouldNotifyParent() { // Arrange final CompositeStorage subComposite = new CompositeStorageImpl(ResourceListImpl.create()); - final Storage subStorage = new InMemoryStorageImpl(); + final Storage subStorage = new StorageImpl(); subStorage.insert(B, 10, Action.EXECUTE, EmptyActor.INSTANCE); sut.addSource(subComposite); sut.addSource(subStorage); - final Storage subCompositeStorage = new InMemoryStorageImpl(); + final Storage subCompositeStorage = new StorageImpl(); subCompositeStorage.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); // Act @@ -90,13 +90,13 @@ void testAddingSourceToSubCompositeShouldNotifyParent() { void testRemovingSourceFromSubCompositeShouldNotifyParent() { // Arrange final CompositeStorage subComposite = new CompositeStorageImpl(ResourceListImpl.create()); - final Storage subStorage = new InMemoryStorageImpl(); + final Storage subStorage = new StorageImpl(); subStorage.insert(B, 10, Action.EXECUTE, EmptyActor.INSTANCE); sut.addSource(subComposite); sut.addSource(subStorage); - final Storage subCompositeStorage = new InMemoryStorageImpl(); + final Storage subCompositeStorage = new StorageImpl(); subCompositeStorage.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); subComposite.addSource(subCompositeStorage); diff --git a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/external/TransformingStorage.java b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/external/TransformingStorage.java index 54301376d..2b57dac0f 100644 --- a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/external/TransformingStorage.java +++ b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/external/TransformingStorage.java @@ -4,14 +4,14 @@ import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.api.storage.AbstractProxyStorage; import com.refinedmods.refinedstorage.api.storage.Actor; -import com.refinedmods.refinedstorage.api.storage.InMemoryStorageImpl; +import com.refinedmods.refinedstorage.api.storage.StorageImpl; import static com.refinedmods.refinedstorage.api.storage.external.ExternalTestResource.A_ALTERNATIVE; import static com.refinedmods.refinedstorage.api.storage.external.ExternalTestResource.A_TRANSFORMED; class TransformingStorage extends AbstractProxyStorage { TransformingStorage() { - super(new InMemoryStorageImpl()); + super(new StorageImpl()); } private ResourceKey transform(final ResourceKey resource) {