From f93cfa531b5d54399af94be26bc3971ca3220c82 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Fri, 26 Jul 2024 21:54:41 +0200 Subject: [PATCH 01/36] feat: pattern grid and pattern Only crafting patterns. --- CHANGELOG.md | 5 + build.gradle.kts | 9 - .../common/api/RefinedStorageApi.java | 3 + .../common/api/RefinedStorageApiProxy.java | 6 + .../api/autocrafting/CraftingPattern.java | 19 ++ .../common/api/autocrafting/Pattern.java | 12 + .../api/autocrafting/PatternProviderItem.java | 17 ++ .../api/autocrafting/ProcessingPattern.java | 16 ++ .../common/api/autocrafting/package-info.java | 7 + .../blockstates/black_pattern_grid.json | 110 ++++++++ .../blockstates/blue_pattern_grid.json | 110 ++++++++ .../blockstates/brown_pattern_grid.json | 110 ++++++++ .../blockstates/cyan_pattern_grid.json | 110 ++++++++ .../blockstates/gray_pattern_grid.json | 110 ++++++++ .../blockstates/green_pattern_grid.json | 110 ++++++++ .../blockstates/light_gray_pattern_grid.json | 110 ++++++++ .../blockstates/lime_pattern_grid.json | 110 ++++++++ .../blockstates/magenta_pattern_grid.json | 110 ++++++++ .../blockstates/orange_pattern_grid.json | 110 ++++++++ .../blockstates/pattern_grid.json | 110 ++++++++ .../blockstates/pink_pattern_grid.json | 110 ++++++++ .../blockstates/purple_pattern_grid.json | 110 ++++++++ .../blockstates/red_pattern_grid.json | 110 ++++++++ .../blockstates/white_pattern_grid.json | 110 ++++++++ .../blockstates/yellow_pattern_grid.json | 110 ++++++++ .../models/block/pattern_grid/black.json | 13 + .../models/block/pattern_grid/blue.json | 13 + .../models/block/pattern_grid/brown.json | 13 + .../models/block/pattern_grid/cyan.json | 13 + .../models/block/pattern_grid/gray.json | 13 + .../models/block/pattern_grid/green.json | 13 + .../models/block/pattern_grid/inactive.json | 13 + .../models/block/pattern_grid/light_blue.json | 13 + .../models/block/pattern_grid/light_gray.json | 13 + .../models/block/pattern_grid/lime.json | 13 + .../models/block/pattern_grid/magenta.json | 13 + .../models/block/pattern_grid/orange.json | 13 + .../models/block/pattern_grid/pink.json | 13 + .../models/block/pattern_grid/purple.json | 13 + .../models/block/pattern_grid/red.json | 13 + .../models/block/pattern_grid/white.json | 13 + .../models/block/pattern_grid/yellow.json | 13 + .../models/item/black_pattern_grid.json | 3 + .../models/item/blue_pattern_grid.json | 3 + .../models/item/brown_pattern_grid.json | 3 + .../models/item/cyan_pattern_grid.json | 3 + .../models/item/gray_pattern_grid.json | 3 + .../models/item/green_pattern_grid.json | 3 + .../models/item/light_gray_pattern_grid.json | 3 + .../models/item/lime_pattern_grid.json | 3 + .../models/item/magenta_pattern_grid.json | 3 + .../models/item/orange_pattern_grid.json | 3 + .../models/item/pattern_grid.json | 3 + .../models/item/pink_pattern_grid.json | 3 + .../models/item/purple_pattern_grid.json | 3 + .../models/item/red_pattern_grid.json | 3 + .../models/item/white_pattern_grid.json | 3 + .../models/item/yellow_pattern_grid.json | 3 + .../misc/coloring/black_pattern_grid.json | 32 +++ .../misc/coloring/blue_pattern_grid.json | 32 +++ .../misc/coloring/brown_pattern_grid.json | 32 +++ .../misc/coloring/cyan_pattern_grid.json | 32 +++ .../misc/coloring/gray_pattern_grid.json | 32 +++ .../misc/coloring/green_pattern_grid.json | 32 +++ .../coloring/light_blue_pattern_grid.json | 32 +++ .../coloring/light_gray_pattern_grid.json | 32 +++ .../misc/coloring/lime_pattern_grid.json | 32 +++ .../misc/coloring/magenta_pattern_grid.json | 32 +++ .../misc/coloring/orange_pattern_grid.json | 32 +++ .../misc/coloring/pink_pattern_grid.json | 32 +++ .../misc/coloring/purple_pattern_grid.json | 32 +++ .../misc/coloring/red_pattern_grid.json | 32 +++ .../misc/coloring/white_pattern_grid.json | 32 +++ .../misc/coloring/yellow_pattern_grid.json | 32 +++ .../loot_table/blocks/black_pattern_grid.json | 21 ++ .../loot_table/blocks/blue_pattern_grid.json | 21 ++ .../loot_table/blocks/brown_pattern_grid.json | 21 ++ .../loot_table/blocks/cyan_pattern_grid.json | 21 ++ .../loot_table/blocks/gray_pattern_grid.json | 21 ++ .../loot_table/blocks/green_pattern_grid.json | 21 ++ .../blocks/light_gray_pattern_grid.json | 21 ++ .../loot_table/blocks/lime_pattern_grid.json | 21 ++ .../blocks/magenta_pattern_grid.json | 21 ++ .../blocks/orange_pattern_grid.json | 21 ++ .../loot_table/blocks/pattern_grid.json | 21 ++ .../loot_table/blocks/pink_pattern_grid.json | 21 ++ .../blocks/purple_pattern_grid.json | 21 ++ .../loot_table/blocks/red_pattern_grid.json | 21 ++ .../loot_table/blocks/white_pattern_grid.json | 21 ++ .../blocks/yellow_pattern_grid.json | 21 ++ .../recipe/coloring/black_pattern_grid.json | 16 ++ .../recipe/coloring/blue_pattern_grid.json | 16 ++ .../recipe/coloring/brown_pattern_grid.json | 16 ++ .../recipe/coloring/cyan_pattern_grid.json | 16 ++ .../recipe/coloring/gray_pattern_grid.json | 16 ++ .../recipe/coloring/green_pattern_grid.json | 16 ++ .../coloring/light_blue_pattern_grid.json | 16 ++ .../coloring/light_gray_pattern_grid.json | 16 ++ .../recipe/coloring/lime_pattern_grid.json | 16 ++ .../recipe/coloring/magenta_pattern_grid.json | 16 ++ .../recipe/coloring/orange_pattern_grid.json | 16 ++ .../recipe/coloring/pink_pattern_grid.json | 16 ++ .../recipe/coloring/purple_pattern_grid.json | 16 ++ .../recipe/coloring/red_pattern_grid.json | 16 ++ .../recipe/coloring/white_pattern_grid.json | 16 ++ .../recipe/coloring/yellow_pattern_grid.json | 16 ++ .../tags/item/pattern_grids.json | 20 ++ .../common/AbstractClientModInitializer.java | 2 + .../common/AbstractModInitializer.java | 29 ++ .../refinedstorage/common/Config.java | 2 + .../refinedstorage/common/Platform.java | 2 + .../refinedstorage/common/PlatformProxy.java | 5 + .../common/RefinedStorageApiImpl.java | 22 ++ ...CraftingPatternClientTooltipComponent.java | 132 +++++++++ .../autocrafting/CraftingPatternState.java | 52 ++++ ...atternBlockEntityWithoutLevelRenderer.java | 48 ++++ .../common/autocrafting/PatternGridBlock.java | 62 +++++ .../autocrafting/PatternGridBlockEntity.java | 251 ++++++++++++++++++ .../PatternGridContainerMenu.java | 221 +++++++++++++++ .../common/autocrafting/PatternGridData.java | 15 ++ .../PatternGridPropertyTypes.java | 16 ++ .../autocrafting/PatternGridScreen.java | 174 ++++++++++++ .../common/autocrafting/PatternItem.java | 220 +++++++++++++++ .../common/autocrafting/PatternItemColor.java | 18 ++ .../autocrafting/PatternItemOverrides.java | 57 ++++ .../autocrafting/PatternOutputContainer.java | 21 ++ .../common/autocrafting/PatternRendering.java | 38 +++ .../common/autocrafting/PatternState.java | 25 ++ .../common/autocrafting/PatternType.java | 43 +++ .../autocrafting/PatternTypeButton.java | 44 +++ .../autocrafting/PatternTypeSettings.java | 29 ++ .../common/autocrafting/package-info.java | 7 + .../common/content/BlockEntities.java | 11 + .../refinedstorage/common/content/Blocks.java | 11 + .../common/content/ContentIds.java | 2 + .../common/content/ContentNames.java | 1 + .../common/content/CreativeModeTabItems.java | 2 + .../common/content/DataComponents.java | 26 ++ .../common/content/DefaultEnergyUsage.java | 1 + .../refinedstorage/common/content/Items.java | 11 + .../refinedstorage/common/content/Menus.java | 11 + .../refinedstorage/common/content/Tags.java | 1 + .../common/grid/AbstractGridBlockEntity.java | 15 +- .../grid/AbstractGridContainerMenu.java | 6 +- .../common/grid/ClientCraftingGridSource.java | 3 +- .../common/grid/CraftingGridBlockEntity.java | 84 ++---- .../grid/CraftingGridContainerMenu.java | 5 +- .../common/grid/CraftingGridResultSlot.java | 4 +- .../common/grid/CraftingGridSource.java | 1 + .../common/grid/CraftingGridSourceImpl.java | 1 + .../common/grid/CraftingState.java | 106 ++++++++ .../common/grid/GridBlockEntity.java | 15 +- .../SnapshotCraftingGridRefillContext.java | 1 + .../grid/screen/AbstractGridScreen.java | 7 +- .../grid/screen/CraftingGridScreen.java | 9 +- .../security/AbstractSecurityCardScreen.java | 3 +- .../support/AbstractBaseContainerMenu.java | 18 ++ .../{grid => support}/CraftingMatrix.java | 8 +- .../CraftingMatrixContainerMenu.java | 2 +- .../support/containermenu/FilterSlot.java | 25 ++ .../containermenu/TransferManager.java | 17 +- .../common/support/packet/c2s/C2SPackets.java | 8 + .../packet/c2s/PatternGridClearPacket.java | 28 ++ .../c2s/PatternGridCreatePatternPacket.java | 29 ++ .../support/widget/CustomCheckboxWidget.java | 28 +- .../assets/refinedstorage/lang/en_us.json | 18 ++ .../refinedstorage/models/item/pattern.json | 3 + .../models/item/pattern/crafting.json | 6 + .../models/item/pattern/empty.json | 6 + .../textures/block/pattern_grid/back.png | Bin 0 -> 1415 bytes .../block/pattern_grid/cutouts/black.png | Bin 0 -> 3047 bytes .../block/pattern_grid/cutouts/blue.png | Bin 0 -> 3070 bytes .../block/pattern_grid/cutouts/brown.png | Bin 0 -> 3079 bytes .../block/pattern_grid/cutouts/cyan.png | Bin 0 -> 3096 bytes .../block/pattern_grid/cutouts/gray.png | Bin 0 -> 3057 bytes .../block/pattern_grid/cutouts/green.png | Bin 0 -> 3091 bytes .../block/pattern_grid/cutouts/inactive.png | Bin 0 -> 330 bytes .../block/pattern_grid/cutouts/light_blue.png | Bin 0 -> 551 bytes .../block/pattern_grid/cutouts/light_gray.png | Bin 0 -> 3024 bytes .../block/pattern_grid/cutouts/lime.png | Bin 0 -> 3079 bytes .../block/pattern_grid/cutouts/magenta.png | Bin 0 -> 3068 bytes .../block/pattern_grid/cutouts/orange.png | Bin 0 -> 3042 bytes .../block/pattern_grid/cutouts/pink.png | Bin 0 -> 2976 bytes .../block/pattern_grid/cutouts/purple.png | Bin 0 -> 3094 bytes .../block/pattern_grid/cutouts/red.png | Bin 0 -> 3054 bytes .../block/pattern_grid/cutouts/white.png | Bin 0 -> 2978 bytes .../block/pattern_grid/cutouts/yellow.png | Bin 0 -> 3043 bytes .../textures/block/pattern_grid/front.png | Bin 0 -> 554 bytes .../textures/block/pattern_grid/left.png | Bin 0 -> 1445 bytes .../textures/block/pattern_grid/right.png | Bin 0 -> 1444 bytes .../textures/block/pattern_grid/top.png | Bin 0 -> 1411 bytes .../textures/gui/crafting_grid.png | Bin 2163 -> 2277 bytes .../refinedstorage/textures/gui/grid.png | Bin 910 -> 850 bytes .../textures/gui/pattern_grid.png | Bin 0 -> 930 bytes .../textures/gui/sprites/grid_row.png | Bin 0 -> 168 bytes .../textures/gui/sprites/large_slot.png | Bin 0 -> 154 bytes .../textures/gui/sprites/light_arrow.png | Bin 0 -> 200 bytes .../gui/sprites/pattern_grid/crafting.png | Bin 0 -> 354 bytes .../textures/gui/sprites/slot.png | Bin 0 -> 153 bytes .../textures/gui/sprites/widget/clear.png | Bin 0 -> 158 bytes .../gui/sprites/widget/clear_disabled.png | Bin 0 -> 158 bytes .../gui/sprites/widget/clear_focused.png | Bin 0 -> 158 bytes .../gui/sprites/widget/create_pattern.png | Bin 0 -> 363 bytes .../widget/create_pattern_disabled.png | Bin 0 -> 332 bytes .../sprites/widget/create_pattern_focused.png | Bin 0 -> 369 bytes .../sprites/widget/generic_small_button.png | Bin 0 -> 356 bytes .../widget/generic_small_button_disabled.png | Bin 0 -> 325 bytes .../widget/generic_small_button_focused.png | Bin 0 -> 423 bytes .../textures/item/pattern/crafting.png | Bin 0 -> 489 bytes .../textures/item/pattern/empty.png | Bin 0 -> 15031 bytes .../data/refinedstorage/recipe/pattern.json | 22 ++ .../refinedstorage/recipe/pattern_grid.json | 17 ++ .../refinedstorage/common/TestPlatform.java | 5 + .../fabric/ClientModInitializerImpl.java | 43 +++ .../refinedstorage/fabric/ConfigImpl.java | 8 + .../fabric/ModInitializerImpl.java | 19 ++ .../refinedstorage/fabric/PlatformImpl.java | 11 + .../autocrafting/PatternBakedModel.java | 24 ++ .../autocrafting/PatternUnbakedModel.java | 45 ++++ .../fabric/autocrafting/package-info.java | 7 + ...tBlockEntityWithoutLevelRendererMixin.java | 34 +++ .../resources/refinedstorage.accesswidener | 3 +- .../main/resources/refinedstorage.mixins.json | 3 +- .../neoforge/ClientModInitializer.java | 40 +++ .../refinedstorage/neoforge/ConfigImpl.java | 7 + .../neoforge/ModInitializer.java | 15 ++ .../refinedstorage/neoforge/PlatformImpl.java | 5 + .../autocrafting/PatternBakedModel.java | 22 ++ .../autocrafting/PatternGeometryLoader.java | 15 ++ .../autocrafting/PatternUnbakedGeometry.java | 42 +++ .../neoforge/autocrafting/package-info.java | 7 + .../datagen/BlockModelProviderImpl.java | 1 + .../datagen/BlockStateProviderImpl.java | 5 + .../datagen/ItemModelProviderImpl.java | 9 + .../datagen/loot/BlockDropProvider.java | 2 + .../recipe/RecoloringRecipeProvider.java | 3 + .../datagen/tag/ItemTagsProviderImpl.java | 5 + .../refinedstorage/common/GameTestUtil.java | 1 + 238 files changed, 5622 insertions(+), 113 deletions(-) create mode 100644 refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/CraftingPattern.java create mode 100644 refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/Pattern.java create mode 100644 refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/PatternProviderItem.java create mode 100644 refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/ProcessingPattern.java create mode 100644 refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/package-info.java create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/black_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/blue_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/brown_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/cyan_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/gray_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/green_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/light_gray_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/lime_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/magenta_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/orange_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/pink_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/purple_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/red_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/white_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/yellow_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/black.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/blue.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/brown.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/cyan.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/gray.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/green.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/inactive.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/light_blue.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/light_gray.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/lime.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/magenta.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/orange.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/pink.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/purple.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/red.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/white.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/yellow.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/black_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/blue_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/brown_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/cyan_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/gray_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/green_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/light_gray_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/lime_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/magenta_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/orange_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/pink_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/purple_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/red_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/white_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/yellow_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/black_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/blue_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/brown_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/cyan_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/gray_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/green_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/light_blue_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/light_gray_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/lime_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/magenta_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/orange_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/pink_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/purple_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/red_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/white_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/yellow_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/black_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/blue_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/brown_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/cyan_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/gray_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/green_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/light_gray_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/lime_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/magenta_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/orange_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/pink_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/purple_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/red_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/white_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/yellow_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/black_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/blue_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/brown_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/cyan_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/gray_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/green_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/light_blue_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/light_gray_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/lime_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/magenta_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/orange_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/pink_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/purple_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/red_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/white_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/yellow_pattern_grid.json create mode 100644 refinedstorage-common/src/generated/resources/data/refinedstorage/tags/item/pattern_grids.json create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/CraftingPatternClientTooltipComponent.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/CraftingPatternState.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternBlockEntityWithoutLevelRenderer.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridBlock.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridBlockEntity.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridContainerMenu.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridData.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridPropertyTypes.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridScreen.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternItem.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternItemColor.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternItemOverrides.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternOutputContainer.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternRendering.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternState.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternType.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternTypeButton.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternTypeSettings.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/package-info.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingState.java rename refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/{grid => support}/CraftingMatrix.java (57%) rename refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/{grid => support}/CraftingMatrixContainerMenu.java (94%) create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/containermenu/FilterSlot.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/packet/c2s/PatternGridClearPacket.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/packet/c2s/PatternGridCreatePatternPacket.java create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/models/item/pattern.json create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/models/item/pattern/crafting.json create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/models/item/pattern/empty.json create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/back.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/black.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/blue.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/brown.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/cyan.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/gray.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/green.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/inactive.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/light_blue.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/light_gray.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/lime.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/magenta.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/orange.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/pink.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/purple.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/red.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/white.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/yellow.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/front.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/left.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/right.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/top.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/pattern_grid.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/grid_row.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/large_slot.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/light_arrow.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/pattern_grid/crafting.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/slot.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/clear.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/clear_disabled.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/clear_focused.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/create_pattern.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/create_pattern_disabled.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/create_pattern_focused.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/generic_small_button.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/generic_small_button_disabled.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/generic_small_button_focused.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/item/pattern/crafting.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/item/pattern/empty.png create mode 100644 refinedstorage-common/src/main/resources/data/refinedstorage/recipe/pattern.json create mode 100644 refinedstorage-common/src/main/resources/data/refinedstorage/recipe/pattern_grid.json create mode 100644 refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/autocrafting/PatternBakedModel.java create mode 100644 refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/autocrafting/PatternUnbakedModel.java create mode 100644 refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/autocrafting/package-info.java create mode 100644 refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/mixin/AbstractBlockEntityWithoutLevelRendererMixin.java create mode 100644 refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/autocrafting/PatternBakedModel.java create mode 100644 refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/autocrafting/PatternGeometryLoader.java create mode 100644 refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/autocrafting/PatternUnbakedGeometry.java create mode 100644 refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/autocrafting/package-info.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 367afbe1d..82bfadeec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added + +- Pattern Grid +- Pattern + ## [2.0.0-milestone.4.5] - 2024-07-26 ### Added diff --git a/build.gradle.kts b/build.gradle.kts index d99f52400..e7891180d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -21,12 +21,3 @@ project.extensions.getByType().apply { ) } } - -allprojects { - apply(plugin = "maven-publish") - publishing { - repositories { - mavenLocal() - } - } -} \ No newline at end of file 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 4afc37e7b..7d2ac7548 100644 --- a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/RefinedStorageApi.java +++ b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/RefinedStorageApi.java @@ -7,6 +7,7 @@ import com.refinedmods.refinedstorage.api.network.node.NetworkNode; import com.refinedmods.refinedstorage.api.network.security.SecurityPolicy; import com.refinedmods.refinedstorage.api.resource.ResourceKey; +import com.refinedmods.refinedstorage.common.api.autocrafting.Pattern; import com.refinedmods.refinedstorage.common.api.constructordestructor.ConstructorStrategyFactory; import com.refinedmods.refinedstorage.common.api.constructordestructor.DestructorStrategyFactory; import com.refinedmods.refinedstorage.common.api.exporter.ExporterTransferStrategyFactory; @@ -200,4 +201,6 @@ EnergyStorage asBlockItemEnergyStorage( void sendNoPermissionMessage(ServerPlayer player, Component message); boolean canPlaceNetworkNode(ServerPlayer player, Level level, BlockPos pos, BlockState state); + + Optional getPattern(ItemStack stack, Level level); } 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 9f9553678..d30707043 100644 --- a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/RefinedStorageApiProxy.java +++ b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/RefinedStorageApiProxy.java @@ -7,6 +7,7 @@ import com.refinedmods.refinedstorage.api.network.node.NetworkNode; import com.refinedmods.refinedstorage.api.network.security.SecurityPolicy; import com.refinedmods.refinedstorage.api.resource.ResourceKey; +import com.refinedmods.refinedstorage.common.api.autocrafting.Pattern; import com.refinedmods.refinedstorage.common.api.constructordestructor.ConstructorStrategyFactory; import com.refinedmods.refinedstorage.common.api.constructordestructor.DestructorStrategyFactory; import com.refinedmods.refinedstorage.common.api.exporter.ExporterTransferStrategyFactory; @@ -395,6 +396,11 @@ public boolean canPlaceNetworkNode(final ServerPlayer player, return ensureLoaded().canPlaceNetworkNode(player, level, pos, state); } + @Override + public Optional getPattern(final ItemStack stack, final Level level) { + return ensureLoaded().getPattern(stack, level); + } + private RefinedStorageApi ensureLoaded() { if (delegate == null) { throw new IllegalStateException("API not loaded yet"); diff --git a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/CraftingPattern.java b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/CraftingPattern.java new file mode 100644 index 000000000..714a018fa --- /dev/null +++ b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/CraftingPattern.java @@ -0,0 +1,19 @@ +package com.refinedmods.refinedstorage.common.api.autocrafting; + +import com.refinedmods.refinedstorage.api.resource.ResourceAmount; +import com.refinedmods.refinedstorage.common.api.support.resource.PlatformResourceKey; + +import java.util.Collection; +import java.util.List; + +import org.apiguardian.api.API; + +@API(status = API.Status.STABLE, since = "2.0.0-milestone.4.6") +public record CraftingPattern(List> inputs, + ResourceAmount output, + List byproducts) implements Pattern { + @Override + public Collection getOutputs() { + return List.of(output); + } +} diff --git a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/Pattern.java b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/Pattern.java new file mode 100644 index 000000000..c055585f4 --- /dev/null +++ b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/Pattern.java @@ -0,0 +1,12 @@ +package com.refinedmods.refinedstorage.common.api.autocrafting; + +import com.refinedmods.refinedstorage.api.resource.ResourceAmount; + +import java.util.Collection; + +import org.apiguardian.api.API; + +@API(status = API.Status.STABLE, since = "2.0.0-milestone.4.6") +public interface Pattern { + Collection getOutputs(); +} diff --git a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/PatternProviderItem.java b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/PatternProviderItem.java new file mode 100644 index 000000000..3a5796e15 --- /dev/null +++ b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/PatternProviderItem.java @@ -0,0 +1,17 @@ +package com.refinedmods.refinedstorage.common.api.autocrafting; + +import java.util.Optional; +import java.util.UUID; +import javax.annotation.Nullable; + +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import org.apiguardian.api.API; + +@API(status = API.Status.STABLE, since = "2.0.0-milestone.4.6") +public interface PatternProviderItem { + @Nullable + UUID getId(ItemStack stack); + + Optional getPattern(ItemStack stack, Level level); +} diff --git a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/ProcessingPattern.java b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/ProcessingPattern.java new file mode 100644 index 000000000..ff9d33173 --- /dev/null +++ b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/ProcessingPattern.java @@ -0,0 +1,16 @@ +package com.refinedmods.refinedstorage.common.api.autocrafting; + +import com.refinedmods.refinedstorage.api.resource.ResourceAmount; + +import java.util.Collection; +import java.util.List; + +import org.apiguardian.api.API; + +@API(status = API.Status.STABLE, since = "2.0.0-milestone.4.6") +public record ProcessingPattern(List> inputs, List outputs) implements Pattern { + @Override + public Collection getOutputs() { + return outputs; + } +} diff --git a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/package-info.java b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/package-info.java new file mode 100644 index 000000000..8075977d5 --- /dev/null +++ b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/package-info.java @@ -0,0 +1,7 @@ +@ParametersAreNonnullByDefault +@FieldsAndMethodsAreNonnullByDefault +package com.refinedmods.refinedstorage.common.api.autocrafting; + +import com.refinedmods.refinedstorage.api.core.FieldsAndMethodsAreNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/black_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/black_pattern_grid.json new file mode 100644 index 000000000..7fa65e1c8 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/black_pattern_grid.json @@ -0,0 +1,110 @@ +{ + "variants": { + "active=false,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": -90 + }, + "active=false,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90 + }, + "active=false,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 180 + }, + "active=false,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 90 + }, + "active=false,direction=east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 90 + }, + "active=false,direction=north": { + "model": "refinedstorage:block/pattern_grid/inactive" + }, + "active=false,direction=south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 180 + }, + "active=false,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": -90 + }, + "active=false,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 180 + }, + "active=false,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90 + }, + "active=false,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 90 + }, + "active=false,direction=west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 270 + }, + "active=true,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/black", + "x": 90, + "y": -90 + }, + "active=true,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/black", + "x": 90 + }, + "active=true,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/black", + "x": 90, + "y": 180 + }, + "active=true,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/black", + "x": 90, + "y": 90 + }, + "active=true,direction=east": { + "model": "refinedstorage:block/pattern_grid/black", + "y": 90 + }, + "active=true,direction=north": { + "model": "refinedstorage:block/pattern_grid/black" + }, + "active=true,direction=south": { + "model": "refinedstorage:block/pattern_grid/black", + "y": 180 + }, + "active=true,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/black", + "x": -90, + "y": -90 + }, + "active=true,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/black", + "x": -90, + "y": 180 + }, + "active=true,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/black", + "x": -90 + }, + "active=true,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/black", + "x": -90, + "y": 90 + }, + "active=true,direction=west": { + "model": "refinedstorage:block/pattern_grid/black", + "y": 270 + } + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/blue_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/blue_pattern_grid.json new file mode 100644 index 000000000..705c04b2d --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/blue_pattern_grid.json @@ -0,0 +1,110 @@ +{ + "variants": { + "active=false,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": -90 + }, + "active=false,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90 + }, + "active=false,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 180 + }, + "active=false,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 90 + }, + "active=false,direction=east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 90 + }, + "active=false,direction=north": { + "model": "refinedstorage:block/pattern_grid/inactive" + }, + "active=false,direction=south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 180 + }, + "active=false,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": -90 + }, + "active=false,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 180 + }, + "active=false,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90 + }, + "active=false,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 90 + }, + "active=false,direction=west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 270 + }, + "active=true,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/blue", + "x": 90, + "y": -90 + }, + "active=true,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/blue", + "x": 90 + }, + "active=true,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/blue", + "x": 90, + "y": 180 + }, + "active=true,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/blue", + "x": 90, + "y": 90 + }, + "active=true,direction=east": { + "model": "refinedstorage:block/pattern_grid/blue", + "y": 90 + }, + "active=true,direction=north": { + "model": "refinedstorage:block/pattern_grid/blue" + }, + "active=true,direction=south": { + "model": "refinedstorage:block/pattern_grid/blue", + "y": 180 + }, + "active=true,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/blue", + "x": -90, + "y": -90 + }, + "active=true,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/blue", + "x": -90, + "y": 180 + }, + "active=true,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/blue", + "x": -90 + }, + "active=true,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/blue", + "x": -90, + "y": 90 + }, + "active=true,direction=west": { + "model": "refinedstorage:block/pattern_grid/blue", + "y": 270 + } + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/brown_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/brown_pattern_grid.json new file mode 100644 index 000000000..20af9ab41 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/brown_pattern_grid.json @@ -0,0 +1,110 @@ +{ + "variants": { + "active=false,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": -90 + }, + "active=false,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90 + }, + "active=false,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 180 + }, + "active=false,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 90 + }, + "active=false,direction=east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 90 + }, + "active=false,direction=north": { + "model": "refinedstorage:block/pattern_grid/inactive" + }, + "active=false,direction=south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 180 + }, + "active=false,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": -90 + }, + "active=false,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 180 + }, + "active=false,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90 + }, + "active=false,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 90 + }, + "active=false,direction=west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 270 + }, + "active=true,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/brown", + "x": 90, + "y": -90 + }, + "active=true,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/brown", + "x": 90 + }, + "active=true,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/brown", + "x": 90, + "y": 180 + }, + "active=true,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/brown", + "x": 90, + "y": 90 + }, + "active=true,direction=east": { + "model": "refinedstorage:block/pattern_grid/brown", + "y": 90 + }, + "active=true,direction=north": { + "model": "refinedstorage:block/pattern_grid/brown" + }, + "active=true,direction=south": { + "model": "refinedstorage:block/pattern_grid/brown", + "y": 180 + }, + "active=true,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/brown", + "x": -90, + "y": -90 + }, + "active=true,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/brown", + "x": -90, + "y": 180 + }, + "active=true,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/brown", + "x": -90 + }, + "active=true,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/brown", + "x": -90, + "y": 90 + }, + "active=true,direction=west": { + "model": "refinedstorage:block/pattern_grid/brown", + "y": 270 + } + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/cyan_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/cyan_pattern_grid.json new file mode 100644 index 000000000..f4f6e3c04 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/cyan_pattern_grid.json @@ -0,0 +1,110 @@ +{ + "variants": { + "active=false,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": -90 + }, + "active=false,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90 + }, + "active=false,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 180 + }, + "active=false,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 90 + }, + "active=false,direction=east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 90 + }, + "active=false,direction=north": { + "model": "refinedstorage:block/pattern_grid/inactive" + }, + "active=false,direction=south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 180 + }, + "active=false,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": -90 + }, + "active=false,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 180 + }, + "active=false,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90 + }, + "active=false,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 90 + }, + "active=false,direction=west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 270 + }, + "active=true,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/cyan", + "x": 90, + "y": -90 + }, + "active=true,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/cyan", + "x": 90 + }, + "active=true,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/cyan", + "x": 90, + "y": 180 + }, + "active=true,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/cyan", + "x": 90, + "y": 90 + }, + "active=true,direction=east": { + "model": "refinedstorage:block/pattern_grid/cyan", + "y": 90 + }, + "active=true,direction=north": { + "model": "refinedstorage:block/pattern_grid/cyan" + }, + "active=true,direction=south": { + "model": "refinedstorage:block/pattern_grid/cyan", + "y": 180 + }, + "active=true,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/cyan", + "x": -90, + "y": -90 + }, + "active=true,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/cyan", + "x": -90, + "y": 180 + }, + "active=true,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/cyan", + "x": -90 + }, + "active=true,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/cyan", + "x": -90, + "y": 90 + }, + "active=true,direction=west": { + "model": "refinedstorage:block/pattern_grid/cyan", + "y": 270 + } + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/gray_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/gray_pattern_grid.json new file mode 100644 index 000000000..b873667c3 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/gray_pattern_grid.json @@ -0,0 +1,110 @@ +{ + "variants": { + "active=false,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": -90 + }, + "active=false,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90 + }, + "active=false,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 180 + }, + "active=false,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 90 + }, + "active=false,direction=east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 90 + }, + "active=false,direction=north": { + "model": "refinedstorage:block/pattern_grid/inactive" + }, + "active=false,direction=south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 180 + }, + "active=false,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": -90 + }, + "active=false,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 180 + }, + "active=false,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90 + }, + "active=false,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 90 + }, + "active=false,direction=west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 270 + }, + "active=true,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/gray", + "x": 90, + "y": -90 + }, + "active=true,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/gray", + "x": 90 + }, + "active=true,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/gray", + "x": 90, + "y": 180 + }, + "active=true,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/gray", + "x": 90, + "y": 90 + }, + "active=true,direction=east": { + "model": "refinedstorage:block/pattern_grid/gray", + "y": 90 + }, + "active=true,direction=north": { + "model": "refinedstorage:block/pattern_grid/gray" + }, + "active=true,direction=south": { + "model": "refinedstorage:block/pattern_grid/gray", + "y": 180 + }, + "active=true,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/gray", + "x": -90, + "y": -90 + }, + "active=true,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/gray", + "x": -90, + "y": 180 + }, + "active=true,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/gray", + "x": -90 + }, + "active=true,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/gray", + "x": -90, + "y": 90 + }, + "active=true,direction=west": { + "model": "refinedstorage:block/pattern_grid/gray", + "y": 270 + } + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/green_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/green_pattern_grid.json new file mode 100644 index 000000000..61d42439a --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/green_pattern_grid.json @@ -0,0 +1,110 @@ +{ + "variants": { + "active=false,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": -90 + }, + "active=false,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90 + }, + "active=false,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 180 + }, + "active=false,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 90 + }, + "active=false,direction=east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 90 + }, + "active=false,direction=north": { + "model": "refinedstorage:block/pattern_grid/inactive" + }, + "active=false,direction=south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 180 + }, + "active=false,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": -90 + }, + "active=false,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 180 + }, + "active=false,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90 + }, + "active=false,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 90 + }, + "active=false,direction=west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 270 + }, + "active=true,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/green", + "x": 90, + "y": -90 + }, + "active=true,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/green", + "x": 90 + }, + "active=true,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/green", + "x": 90, + "y": 180 + }, + "active=true,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/green", + "x": 90, + "y": 90 + }, + "active=true,direction=east": { + "model": "refinedstorage:block/pattern_grid/green", + "y": 90 + }, + "active=true,direction=north": { + "model": "refinedstorage:block/pattern_grid/green" + }, + "active=true,direction=south": { + "model": "refinedstorage:block/pattern_grid/green", + "y": 180 + }, + "active=true,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/green", + "x": -90, + "y": -90 + }, + "active=true,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/green", + "x": -90, + "y": 180 + }, + "active=true,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/green", + "x": -90 + }, + "active=true,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/green", + "x": -90, + "y": 90 + }, + "active=true,direction=west": { + "model": "refinedstorage:block/pattern_grid/green", + "y": 270 + } + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/light_gray_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/light_gray_pattern_grid.json new file mode 100644 index 000000000..bea3f24d1 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/light_gray_pattern_grid.json @@ -0,0 +1,110 @@ +{ + "variants": { + "active=false,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": -90 + }, + "active=false,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90 + }, + "active=false,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 180 + }, + "active=false,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 90 + }, + "active=false,direction=east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 90 + }, + "active=false,direction=north": { + "model": "refinedstorage:block/pattern_grid/inactive" + }, + "active=false,direction=south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 180 + }, + "active=false,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": -90 + }, + "active=false,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 180 + }, + "active=false,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90 + }, + "active=false,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 90 + }, + "active=false,direction=west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 270 + }, + "active=true,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/light_gray", + "x": 90, + "y": -90 + }, + "active=true,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/light_gray", + "x": 90 + }, + "active=true,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/light_gray", + "x": 90, + "y": 180 + }, + "active=true,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/light_gray", + "x": 90, + "y": 90 + }, + "active=true,direction=east": { + "model": "refinedstorage:block/pattern_grid/light_gray", + "y": 90 + }, + "active=true,direction=north": { + "model": "refinedstorage:block/pattern_grid/light_gray" + }, + "active=true,direction=south": { + "model": "refinedstorage:block/pattern_grid/light_gray", + "y": 180 + }, + "active=true,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/light_gray", + "x": -90, + "y": -90 + }, + "active=true,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/light_gray", + "x": -90, + "y": 180 + }, + "active=true,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/light_gray", + "x": -90 + }, + "active=true,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/light_gray", + "x": -90, + "y": 90 + }, + "active=true,direction=west": { + "model": "refinedstorage:block/pattern_grid/light_gray", + "y": 270 + } + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/lime_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/lime_pattern_grid.json new file mode 100644 index 000000000..95d0756e1 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/lime_pattern_grid.json @@ -0,0 +1,110 @@ +{ + "variants": { + "active=false,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": -90 + }, + "active=false,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90 + }, + "active=false,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 180 + }, + "active=false,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 90 + }, + "active=false,direction=east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 90 + }, + "active=false,direction=north": { + "model": "refinedstorage:block/pattern_grid/inactive" + }, + "active=false,direction=south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 180 + }, + "active=false,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": -90 + }, + "active=false,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 180 + }, + "active=false,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90 + }, + "active=false,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 90 + }, + "active=false,direction=west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 270 + }, + "active=true,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/lime", + "x": 90, + "y": -90 + }, + "active=true,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/lime", + "x": 90 + }, + "active=true,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/lime", + "x": 90, + "y": 180 + }, + "active=true,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/lime", + "x": 90, + "y": 90 + }, + "active=true,direction=east": { + "model": "refinedstorage:block/pattern_grid/lime", + "y": 90 + }, + "active=true,direction=north": { + "model": "refinedstorage:block/pattern_grid/lime" + }, + "active=true,direction=south": { + "model": "refinedstorage:block/pattern_grid/lime", + "y": 180 + }, + "active=true,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/lime", + "x": -90, + "y": -90 + }, + "active=true,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/lime", + "x": -90, + "y": 180 + }, + "active=true,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/lime", + "x": -90 + }, + "active=true,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/lime", + "x": -90, + "y": 90 + }, + "active=true,direction=west": { + "model": "refinedstorage:block/pattern_grid/lime", + "y": 270 + } + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/magenta_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/magenta_pattern_grid.json new file mode 100644 index 000000000..ce9bac108 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/magenta_pattern_grid.json @@ -0,0 +1,110 @@ +{ + "variants": { + "active=false,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": -90 + }, + "active=false,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90 + }, + "active=false,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 180 + }, + "active=false,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 90 + }, + "active=false,direction=east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 90 + }, + "active=false,direction=north": { + "model": "refinedstorage:block/pattern_grid/inactive" + }, + "active=false,direction=south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 180 + }, + "active=false,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": -90 + }, + "active=false,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 180 + }, + "active=false,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90 + }, + "active=false,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 90 + }, + "active=false,direction=west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 270 + }, + "active=true,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/magenta", + "x": 90, + "y": -90 + }, + "active=true,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/magenta", + "x": 90 + }, + "active=true,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/magenta", + "x": 90, + "y": 180 + }, + "active=true,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/magenta", + "x": 90, + "y": 90 + }, + "active=true,direction=east": { + "model": "refinedstorage:block/pattern_grid/magenta", + "y": 90 + }, + "active=true,direction=north": { + "model": "refinedstorage:block/pattern_grid/magenta" + }, + "active=true,direction=south": { + "model": "refinedstorage:block/pattern_grid/magenta", + "y": 180 + }, + "active=true,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/magenta", + "x": -90, + "y": -90 + }, + "active=true,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/magenta", + "x": -90, + "y": 180 + }, + "active=true,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/magenta", + "x": -90 + }, + "active=true,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/magenta", + "x": -90, + "y": 90 + }, + "active=true,direction=west": { + "model": "refinedstorage:block/pattern_grid/magenta", + "y": 270 + } + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/orange_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/orange_pattern_grid.json new file mode 100644 index 000000000..7464404c8 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/orange_pattern_grid.json @@ -0,0 +1,110 @@ +{ + "variants": { + "active=false,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": -90 + }, + "active=false,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90 + }, + "active=false,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 180 + }, + "active=false,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 90 + }, + "active=false,direction=east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 90 + }, + "active=false,direction=north": { + "model": "refinedstorage:block/pattern_grid/inactive" + }, + "active=false,direction=south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 180 + }, + "active=false,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": -90 + }, + "active=false,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 180 + }, + "active=false,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90 + }, + "active=false,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 90 + }, + "active=false,direction=west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 270 + }, + "active=true,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/orange", + "x": 90, + "y": -90 + }, + "active=true,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/orange", + "x": 90 + }, + "active=true,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/orange", + "x": 90, + "y": 180 + }, + "active=true,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/orange", + "x": 90, + "y": 90 + }, + "active=true,direction=east": { + "model": "refinedstorage:block/pattern_grid/orange", + "y": 90 + }, + "active=true,direction=north": { + "model": "refinedstorage:block/pattern_grid/orange" + }, + "active=true,direction=south": { + "model": "refinedstorage:block/pattern_grid/orange", + "y": 180 + }, + "active=true,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/orange", + "x": -90, + "y": -90 + }, + "active=true,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/orange", + "x": -90, + "y": 180 + }, + "active=true,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/orange", + "x": -90 + }, + "active=true,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/orange", + "x": -90, + "y": 90 + }, + "active=true,direction=west": { + "model": "refinedstorage:block/pattern_grid/orange", + "y": 270 + } + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/pattern_grid.json new file mode 100644 index 000000000..5a4b1421a --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/pattern_grid.json @@ -0,0 +1,110 @@ +{ + "variants": { + "active=false,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": -90 + }, + "active=false,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90 + }, + "active=false,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 180 + }, + "active=false,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 90 + }, + "active=false,direction=east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 90 + }, + "active=false,direction=north": { + "model": "refinedstorage:block/pattern_grid/inactive" + }, + "active=false,direction=south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 180 + }, + "active=false,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": -90 + }, + "active=false,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 180 + }, + "active=false,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90 + }, + "active=false,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 90 + }, + "active=false,direction=west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 270 + }, + "active=true,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/light_blue", + "x": 90, + "y": -90 + }, + "active=true,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/light_blue", + "x": 90 + }, + "active=true,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/light_blue", + "x": 90, + "y": 180 + }, + "active=true,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/light_blue", + "x": 90, + "y": 90 + }, + "active=true,direction=east": { + "model": "refinedstorage:block/pattern_grid/light_blue", + "y": 90 + }, + "active=true,direction=north": { + "model": "refinedstorage:block/pattern_grid/light_blue" + }, + "active=true,direction=south": { + "model": "refinedstorage:block/pattern_grid/light_blue", + "y": 180 + }, + "active=true,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/light_blue", + "x": -90, + "y": -90 + }, + "active=true,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/light_blue", + "x": -90, + "y": 180 + }, + "active=true,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/light_blue", + "x": -90 + }, + "active=true,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/light_blue", + "x": -90, + "y": 90 + }, + "active=true,direction=west": { + "model": "refinedstorage:block/pattern_grid/light_blue", + "y": 270 + } + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/pink_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/pink_pattern_grid.json new file mode 100644 index 000000000..2ad8c0856 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/pink_pattern_grid.json @@ -0,0 +1,110 @@ +{ + "variants": { + "active=false,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": -90 + }, + "active=false,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90 + }, + "active=false,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 180 + }, + "active=false,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 90 + }, + "active=false,direction=east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 90 + }, + "active=false,direction=north": { + "model": "refinedstorage:block/pattern_grid/inactive" + }, + "active=false,direction=south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 180 + }, + "active=false,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": -90 + }, + "active=false,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 180 + }, + "active=false,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90 + }, + "active=false,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 90 + }, + "active=false,direction=west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 270 + }, + "active=true,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/pink", + "x": 90, + "y": -90 + }, + "active=true,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/pink", + "x": 90 + }, + "active=true,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/pink", + "x": 90, + "y": 180 + }, + "active=true,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/pink", + "x": 90, + "y": 90 + }, + "active=true,direction=east": { + "model": "refinedstorage:block/pattern_grid/pink", + "y": 90 + }, + "active=true,direction=north": { + "model": "refinedstorage:block/pattern_grid/pink" + }, + "active=true,direction=south": { + "model": "refinedstorage:block/pattern_grid/pink", + "y": 180 + }, + "active=true,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/pink", + "x": -90, + "y": -90 + }, + "active=true,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/pink", + "x": -90, + "y": 180 + }, + "active=true,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/pink", + "x": -90 + }, + "active=true,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/pink", + "x": -90, + "y": 90 + }, + "active=true,direction=west": { + "model": "refinedstorage:block/pattern_grid/pink", + "y": 270 + } + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/purple_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/purple_pattern_grid.json new file mode 100644 index 000000000..f5e8e4e2d --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/purple_pattern_grid.json @@ -0,0 +1,110 @@ +{ + "variants": { + "active=false,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": -90 + }, + "active=false,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90 + }, + "active=false,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 180 + }, + "active=false,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 90 + }, + "active=false,direction=east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 90 + }, + "active=false,direction=north": { + "model": "refinedstorage:block/pattern_grid/inactive" + }, + "active=false,direction=south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 180 + }, + "active=false,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": -90 + }, + "active=false,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 180 + }, + "active=false,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90 + }, + "active=false,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 90 + }, + "active=false,direction=west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 270 + }, + "active=true,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/purple", + "x": 90, + "y": -90 + }, + "active=true,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/purple", + "x": 90 + }, + "active=true,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/purple", + "x": 90, + "y": 180 + }, + "active=true,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/purple", + "x": 90, + "y": 90 + }, + "active=true,direction=east": { + "model": "refinedstorage:block/pattern_grid/purple", + "y": 90 + }, + "active=true,direction=north": { + "model": "refinedstorage:block/pattern_grid/purple" + }, + "active=true,direction=south": { + "model": "refinedstorage:block/pattern_grid/purple", + "y": 180 + }, + "active=true,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/purple", + "x": -90, + "y": -90 + }, + "active=true,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/purple", + "x": -90, + "y": 180 + }, + "active=true,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/purple", + "x": -90 + }, + "active=true,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/purple", + "x": -90, + "y": 90 + }, + "active=true,direction=west": { + "model": "refinedstorage:block/pattern_grid/purple", + "y": 270 + } + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/red_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/red_pattern_grid.json new file mode 100644 index 000000000..d2d3d92ec --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/red_pattern_grid.json @@ -0,0 +1,110 @@ +{ + "variants": { + "active=false,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": -90 + }, + "active=false,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90 + }, + "active=false,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 180 + }, + "active=false,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 90 + }, + "active=false,direction=east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 90 + }, + "active=false,direction=north": { + "model": "refinedstorage:block/pattern_grid/inactive" + }, + "active=false,direction=south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 180 + }, + "active=false,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": -90 + }, + "active=false,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 180 + }, + "active=false,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90 + }, + "active=false,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 90 + }, + "active=false,direction=west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 270 + }, + "active=true,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/red", + "x": 90, + "y": -90 + }, + "active=true,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/red", + "x": 90 + }, + "active=true,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/red", + "x": 90, + "y": 180 + }, + "active=true,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/red", + "x": 90, + "y": 90 + }, + "active=true,direction=east": { + "model": "refinedstorage:block/pattern_grid/red", + "y": 90 + }, + "active=true,direction=north": { + "model": "refinedstorage:block/pattern_grid/red" + }, + "active=true,direction=south": { + "model": "refinedstorage:block/pattern_grid/red", + "y": 180 + }, + "active=true,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/red", + "x": -90, + "y": -90 + }, + "active=true,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/red", + "x": -90, + "y": 180 + }, + "active=true,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/red", + "x": -90 + }, + "active=true,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/red", + "x": -90, + "y": 90 + }, + "active=true,direction=west": { + "model": "refinedstorage:block/pattern_grid/red", + "y": 270 + } + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/white_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/white_pattern_grid.json new file mode 100644 index 000000000..c85a98486 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/white_pattern_grid.json @@ -0,0 +1,110 @@ +{ + "variants": { + "active=false,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": -90 + }, + "active=false,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90 + }, + "active=false,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 180 + }, + "active=false,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 90 + }, + "active=false,direction=east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 90 + }, + "active=false,direction=north": { + "model": "refinedstorage:block/pattern_grid/inactive" + }, + "active=false,direction=south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 180 + }, + "active=false,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": -90 + }, + "active=false,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 180 + }, + "active=false,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90 + }, + "active=false,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 90 + }, + "active=false,direction=west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 270 + }, + "active=true,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/white", + "x": 90, + "y": -90 + }, + "active=true,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/white", + "x": 90 + }, + "active=true,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/white", + "x": 90, + "y": 180 + }, + "active=true,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/white", + "x": 90, + "y": 90 + }, + "active=true,direction=east": { + "model": "refinedstorage:block/pattern_grid/white", + "y": 90 + }, + "active=true,direction=north": { + "model": "refinedstorage:block/pattern_grid/white" + }, + "active=true,direction=south": { + "model": "refinedstorage:block/pattern_grid/white", + "y": 180 + }, + "active=true,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/white", + "x": -90, + "y": -90 + }, + "active=true,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/white", + "x": -90, + "y": 180 + }, + "active=true,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/white", + "x": -90 + }, + "active=true,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/white", + "x": -90, + "y": 90 + }, + "active=true,direction=west": { + "model": "refinedstorage:block/pattern_grid/white", + "y": 270 + } + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/yellow_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/yellow_pattern_grid.json new file mode 100644 index 000000000..dc5de3e73 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/blockstates/yellow_pattern_grid.json @@ -0,0 +1,110 @@ +{ + "variants": { + "active=false,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": -90 + }, + "active=false,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90 + }, + "active=false,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 180 + }, + "active=false,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": 90, + "y": 90 + }, + "active=false,direction=east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 90 + }, + "active=false,direction=north": { + "model": "refinedstorage:block/pattern_grid/inactive" + }, + "active=false,direction=south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 180 + }, + "active=false,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": -90 + }, + "active=false,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 180 + }, + "active=false,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90 + }, + "active=false,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "x": -90, + "y": 90 + }, + "active=false,direction=west": { + "model": "refinedstorage:block/pattern_grid/inactive", + "y": 270 + }, + "active=true,direction=down_east": { + "model": "refinedstorage:block/pattern_grid/yellow", + "x": 90, + "y": -90 + }, + "active=true,direction=down_north": { + "model": "refinedstorage:block/pattern_grid/yellow", + "x": 90 + }, + "active=true,direction=down_south": { + "model": "refinedstorage:block/pattern_grid/yellow", + "x": 90, + "y": 180 + }, + "active=true,direction=down_west": { + "model": "refinedstorage:block/pattern_grid/yellow", + "x": 90, + "y": 90 + }, + "active=true,direction=east": { + "model": "refinedstorage:block/pattern_grid/yellow", + "y": 90 + }, + "active=true,direction=north": { + "model": "refinedstorage:block/pattern_grid/yellow" + }, + "active=true,direction=south": { + "model": "refinedstorage:block/pattern_grid/yellow", + "y": 180 + }, + "active=true,direction=up_east": { + "model": "refinedstorage:block/pattern_grid/yellow", + "x": -90, + "y": -90 + }, + "active=true,direction=up_north": { + "model": "refinedstorage:block/pattern_grid/yellow", + "x": -90, + "y": 180 + }, + "active=true,direction=up_south": { + "model": "refinedstorage:block/pattern_grid/yellow", + "x": -90 + }, + "active=true,direction=up_west": { + "model": "refinedstorage:block/pattern_grid/yellow", + "x": -90, + "y": 90 + }, + "active=true,direction=west": { + "model": "refinedstorage:block/pattern_grid/yellow", + "y": 270 + } + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/black.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/black.json new file mode 100644 index 000000000..f873d09ba --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/black.json @@ -0,0 +1,13 @@ +{ + "parent": "refinedstorage:block/emissive_north_cutout", + "textures": { + "cutout": "refinedstorage:block/pattern_grid/cutouts/black", + "down": "refinedstorage:block/bottom", + "east": "refinedstorage:block/pattern_grid/right", + "north": "refinedstorage:block/pattern_grid/front", + "particle": "refinedstorage:block/pattern_grid/right", + "south": "refinedstorage:block/pattern_grid/back", + "up": "refinedstorage:block/pattern_grid/top", + "west": "refinedstorage:block/pattern_grid/left" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/blue.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/blue.json new file mode 100644 index 000000000..fcd91218f --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/blue.json @@ -0,0 +1,13 @@ +{ + "parent": "refinedstorage:block/emissive_north_cutout", + "textures": { + "cutout": "refinedstorage:block/pattern_grid/cutouts/blue", + "down": "refinedstorage:block/bottom", + "east": "refinedstorage:block/pattern_grid/right", + "north": "refinedstorage:block/pattern_grid/front", + "particle": "refinedstorage:block/pattern_grid/right", + "south": "refinedstorage:block/pattern_grid/back", + "up": "refinedstorage:block/pattern_grid/top", + "west": "refinedstorage:block/pattern_grid/left" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/brown.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/brown.json new file mode 100644 index 000000000..77d4ce11a --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/brown.json @@ -0,0 +1,13 @@ +{ + "parent": "refinedstorage:block/emissive_north_cutout", + "textures": { + "cutout": "refinedstorage:block/pattern_grid/cutouts/brown", + "down": "refinedstorage:block/bottom", + "east": "refinedstorage:block/pattern_grid/right", + "north": "refinedstorage:block/pattern_grid/front", + "particle": "refinedstorage:block/pattern_grid/right", + "south": "refinedstorage:block/pattern_grid/back", + "up": "refinedstorage:block/pattern_grid/top", + "west": "refinedstorage:block/pattern_grid/left" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/cyan.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/cyan.json new file mode 100644 index 000000000..c6a75e40e --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/cyan.json @@ -0,0 +1,13 @@ +{ + "parent": "refinedstorage:block/emissive_north_cutout", + "textures": { + "cutout": "refinedstorage:block/pattern_grid/cutouts/cyan", + "down": "refinedstorage:block/bottom", + "east": "refinedstorage:block/pattern_grid/right", + "north": "refinedstorage:block/pattern_grid/front", + "particle": "refinedstorage:block/pattern_grid/right", + "south": "refinedstorage:block/pattern_grid/back", + "up": "refinedstorage:block/pattern_grid/top", + "west": "refinedstorage:block/pattern_grid/left" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/gray.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/gray.json new file mode 100644 index 000000000..63c22bf1f --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/gray.json @@ -0,0 +1,13 @@ +{ + "parent": "refinedstorage:block/emissive_north_cutout", + "textures": { + "cutout": "refinedstorage:block/pattern_grid/cutouts/gray", + "down": "refinedstorage:block/bottom", + "east": "refinedstorage:block/pattern_grid/right", + "north": "refinedstorage:block/pattern_grid/front", + "particle": "refinedstorage:block/pattern_grid/right", + "south": "refinedstorage:block/pattern_grid/back", + "up": "refinedstorage:block/pattern_grid/top", + "west": "refinedstorage:block/pattern_grid/left" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/green.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/green.json new file mode 100644 index 000000000..30d1d5c98 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/green.json @@ -0,0 +1,13 @@ +{ + "parent": "refinedstorage:block/emissive_north_cutout", + "textures": { + "cutout": "refinedstorage:block/pattern_grid/cutouts/green", + "down": "refinedstorage:block/bottom", + "east": "refinedstorage:block/pattern_grid/right", + "north": "refinedstorage:block/pattern_grid/front", + "particle": "refinedstorage:block/pattern_grid/right", + "south": "refinedstorage:block/pattern_grid/back", + "up": "refinedstorage:block/pattern_grid/top", + "west": "refinedstorage:block/pattern_grid/left" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/inactive.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/inactive.json new file mode 100644 index 000000000..5e8af6e71 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/inactive.json @@ -0,0 +1,13 @@ +{ + "parent": "refinedstorage:block/north_cutout", + "textures": { + "cutout": "refinedstorage:block/pattern_grid/cutouts/inactive", + "down": "refinedstorage:block/bottom", + "east": "refinedstorage:block/pattern_grid/right", + "north": "refinedstorage:block/pattern_grid/front", + "particle": "refinedstorage:block/pattern_grid/right", + "south": "refinedstorage:block/pattern_grid/back", + "up": "refinedstorage:block/pattern_grid/top", + "west": "refinedstorage:block/pattern_grid/left" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/light_blue.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/light_blue.json new file mode 100644 index 000000000..d7a41c3fe --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/light_blue.json @@ -0,0 +1,13 @@ +{ + "parent": "refinedstorage:block/emissive_north_cutout", + "textures": { + "cutout": "refinedstorage:block/pattern_grid/cutouts/light_blue", + "down": "refinedstorage:block/bottom", + "east": "refinedstorage:block/pattern_grid/right", + "north": "refinedstorage:block/pattern_grid/front", + "particle": "refinedstorage:block/pattern_grid/right", + "south": "refinedstorage:block/pattern_grid/back", + "up": "refinedstorage:block/pattern_grid/top", + "west": "refinedstorage:block/pattern_grid/left" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/light_gray.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/light_gray.json new file mode 100644 index 000000000..bb54937da --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/light_gray.json @@ -0,0 +1,13 @@ +{ + "parent": "refinedstorage:block/emissive_north_cutout", + "textures": { + "cutout": "refinedstorage:block/pattern_grid/cutouts/light_gray", + "down": "refinedstorage:block/bottom", + "east": "refinedstorage:block/pattern_grid/right", + "north": "refinedstorage:block/pattern_grid/front", + "particle": "refinedstorage:block/pattern_grid/right", + "south": "refinedstorage:block/pattern_grid/back", + "up": "refinedstorage:block/pattern_grid/top", + "west": "refinedstorage:block/pattern_grid/left" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/lime.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/lime.json new file mode 100644 index 000000000..5ea22a48d --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/lime.json @@ -0,0 +1,13 @@ +{ + "parent": "refinedstorage:block/emissive_north_cutout", + "textures": { + "cutout": "refinedstorage:block/pattern_grid/cutouts/lime", + "down": "refinedstorage:block/bottom", + "east": "refinedstorage:block/pattern_grid/right", + "north": "refinedstorage:block/pattern_grid/front", + "particle": "refinedstorage:block/pattern_grid/right", + "south": "refinedstorage:block/pattern_grid/back", + "up": "refinedstorage:block/pattern_grid/top", + "west": "refinedstorage:block/pattern_grid/left" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/magenta.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/magenta.json new file mode 100644 index 000000000..2b855bbce --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/magenta.json @@ -0,0 +1,13 @@ +{ + "parent": "refinedstorage:block/emissive_north_cutout", + "textures": { + "cutout": "refinedstorage:block/pattern_grid/cutouts/magenta", + "down": "refinedstorage:block/bottom", + "east": "refinedstorage:block/pattern_grid/right", + "north": "refinedstorage:block/pattern_grid/front", + "particle": "refinedstorage:block/pattern_grid/right", + "south": "refinedstorage:block/pattern_grid/back", + "up": "refinedstorage:block/pattern_grid/top", + "west": "refinedstorage:block/pattern_grid/left" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/orange.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/orange.json new file mode 100644 index 000000000..ebfaff81e --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/orange.json @@ -0,0 +1,13 @@ +{ + "parent": "refinedstorage:block/emissive_north_cutout", + "textures": { + "cutout": "refinedstorage:block/pattern_grid/cutouts/orange", + "down": "refinedstorage:block/bottom", + "east": "refinedstorage:block/pattern_grid/right", + "north": "refinedstorage:block/pattern_grid/front", + "particle": "refinedstorage:block/pattern_grid/right", + "south": "refinedstorage:block/pattern_grid/back", + "up": "refinedstorage:block/pattern_grid/top", + "west": "refinedstorage:block/pattern_grid/left" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/pink.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/pink.json new file mode 100644 index 000000000..943cfd86d --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/pink.json @@ -0,0 +1,13 @@ +{ + "parent": "refinedstorage:block/emissive_north_cutout", + "textures": { + "cutout": "refinedstorage:block/pattern_grid/cutouts/pink", + "down": "refinedstorage:block/bottom", + "east": "refinedstorage:block/pattern_grid/right", + "north": "refinedstorage:block/pattern_grid/front", + "particle": "refinedstorage:block/pattern_grid/right", + "south": "refinedstorage:block/pattern_grid/back", + "up": "refinedstorage:block/pattern_grid/top", + "west": "refinedstorage:block/pattern_grid/left" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/purple.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/purple.json new file mode 100644 index 000000000..e68139e47 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/purple.json @@ -0,0 +1,13 @@ +{ + "parent": "refinedstorage:block/emissive_north_cutout", + "textures": { + "cutout": "refinedstorage:block/pattern_grid/cutouts/purple", + "down": "refinedstorage:block/bottom", + "east": "refinedstorage:block/pattern_grid/right", + "north": "refinedstorage:block/pattern_grid/front", + "particle": "refinedstorage:block/pattern_grid/right", + "south": "refinedstorage:block/pattern_grid/back", + "up": "refinedstorage:block/pattern_grid/top", + "west": "refinedstorage:block/pattern_grid/left" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/red.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/red.json new file mode 100644 index 000000000..59a29d955 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/red.json @@ -0,0 +1,13 @@ +{ + "parent": "refinedstorage:block/emissive_north_cutout", + "textures": { + "cutout": "refinedstorage:block/pattern_grid/cutouts/red", + "down": "refinedstorage:block/bottom", + "east": "refinedstorage:block/pattern_grid/right", + "north": "refinedstorage:block/pattern_grid/front", + "particle": "refinedstorage:block/pattern_grid/right", + "south": "refinedstorage:block/pattern_grid/back", + "up": "refinedstorage:block/pattern_grid/top", + "west": "refinedstorage:block/pattern_grid/left" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/white.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/white.json new file mode 100644 index 000000000..3360dd7c6 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/white.json @@ -0,0 +1,13 @@ +{ + "parent": "refinedstorage:block/emissive_north_cutout", + "textures": { + "cutout": "refinedstorage:block/pattern_grid/cutouts/white", + "down": "refinedstorage:block/bottom", + "east": "refinedstorage:block/pattern_grid/right", + "north": "refinedstorage:block/pattern_grid/front", + "particle": "refinedstorage:block/pattern_grid/right", + "south": "refinedstorage:block/pattern_grid/back", + "up": "refinedstorage:block/pattern_grid/top", + "west": "refinedstorage:block/pattern_grid/left" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/yellow.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/yellow.json new file mode 100644 index 000000000..802dc8683 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/block/pattern_grid/yellow.json @@ -0,0 +1,13 @@ +{ + "parent": "refinedstorage:block/emissive_north_cutout", + "textures": { + "cutout": "refinedstorage:block/pattern_grid/cutouts/yellow", + "down": "refinedstorage:block/bottom", + "east": "refinedstorage:block/pattern_grid/right", + "north": "refinedstorage:block/pattern_grid/front", + "particle": "refinedstorage:block/pattern_grid/right", + "south": "refinedstorage:block/pattern_grid/back", + "up": "refinedstorage:block/pattern_grid/top", + "west": "refinedstorage:block/pattern_grid/left" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/black_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/black_pattern_grid.json new file mode 100644 index 000000000..810318a65 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/black_pattern_grid.json @@ -0,0 +1,3 @@ +{ + "parent": "refinedstorage:block/pattern_grid/black" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/blue_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/blue_pattern_grid.json new file mode 100644 index 000000000..8dda3bed0 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/blue_pattern_grid.json @@ -0,0 +1,3 @@ +{ + "parent": "refinedstorage:block/pattern_grid/blue" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/brown_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/brown_pattern_grid.json new file mode 100644 index 000000000..a5400dad4 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/brown_pattern_grid.json @@ -0,0 +1,3 @@ +{ + "parent": "refinedstorage:block/pattern_grid/brown" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/cyan_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/cyan_pattern_grid.json new file mode 100644 index 000000000..89252445a --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/cyan_pattern_grid.json @@ -0,0 +1,3 @@ +{ + "parent": "refinedstorage:block/pattern_grid/cyan" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/gray_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/gray_pattern_grid.json new file mode 100644 index 000000000..5e093515c --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/gray_pattern_grid.json @@ -0,0 +1,3 @@ +{ + "parent": "refinedstorage:block/pattern_grid/gray" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/green_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/green_pattern_grid.json new file mode 100644 index 000000000..b3bd93505 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/green_pattern_grid.json @@ -0,0 +1,3 @@ +{ + "parent": "refinedstorage:block/pattern_grid/green" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/light_gray_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/light_gray_pattern_grid.json new file mode 100644 index 000000000..4c47549ff --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/light_gray_pattern_grid.json @@ -0,0 +1,3 @@ +{ + "parent": "refinedstorage:block/pattern_grid/light_gray" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/lime_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/lime_pattern_grid.json new file mode 100644 index 000000000..b35597270 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/lime_pattern_grid.json @@ -0,0 +1,3 @@ +{ + "parent": "refinedstorage:block/pattern_grid/lime" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/magenta_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/magenta_pattern_grid.json new file mode 100644 index 000000000..23d885ae5 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/magenta_pattern_grid.json @@ -0,0 +1,3 @@ +{ + "parent": "refinedstorage:block/pattern_grid/magenta" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/orange_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/orange_pattern_grid.json new file mode 100644 index 000000000..845618ebd --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/orange_pattern_grid.json @@ -0,0 +1,3 @@ +{ + "parent": "refinedstorage:block/pattern_grid/orange" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/pattern_grid.json new file mode 100644 index 000000000..b1aec2515 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/pattern_grid.json @@ -0,0 +1,3 @@ +{ + "parent": "refinedstorage:block/pattern_grid/light_blue" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/pink_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/pink_pattern_grid.json new file mode 100644 index 000000000..9358334f5 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/pink_pattern_grid.json @@ -0,0 +1,3 @@ +{ + "parent": "refinedstorage:block/pattern_grid/pink" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/purple_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/purple_pattern_grid.json new file mode 100644 index 000000000..2e63cdef3 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/purple_pattern_grid.json @@ -0,0 +1,3 @@ +{ + "parent": "refinedstorage:block/pattern_grid/purple" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/red_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/red_pattern_grid.json new file mode 100644 index 000000000..e117d9ece --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/red_pattern_grid.json @@ -0,0 +1,3 @@ +{ + "parent": "refinedstorage:block/pattern_grid/red" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/white_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/white_pattern_grid.json new file mode 100644 index 000000000..7073bd864 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/white_pattern_grid.json @@ -0,0 +1,3 @@ +{ + "parent": "refinedstorage:block/pattern_grid/white" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/yellow_pattern_grid.json b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/yellow_pattern_grid.json new file mode 100644 index 000000000..14d16648a --- /dev/null +++ b/refinedstorage-common/src/generated/resources/assets/refinedstorage/models/item/yellow_pattern_grid.json @@ -0,0 +1,3 @@ +{ + "parent": "refinedstorage:block/pattern_grid/yellow" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/black_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/black_pattern_grid.json new file mode 100644 index 000000000..0c82b45aa --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/black_pattern_grid.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_pattern_grids": { + "conditions": { + "items": [ + { + "items": "#refinedstorage:pattern_grids" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "refinedstorage:coloring/black_pattern_grid" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_pattern_grids" + ] + ], + "rewards": { + "recipes": [ + "refinedstorage:coloring/black_pattern_grid" + ] + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/blue_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/blue_pattern_grid.json new file mode 100644 index 000000000..3fc1dab5f --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/blue_pattern_grid.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_pattern_grids": { + "conditions": { + "items": [ + { + "items": "#refinedstorage:pattern_grids" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "refinedstorage:coloring/blue_pattern_grid" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_pattern_grids" + ] + ], + "rewards": { + "recipes": [ + "refinedstorage:coloring/blue_pattern_grid" + ] + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/brown_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/brown_pattern_grid.json new file mode 100644 index 000000000..21c6be6e1 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/brown_pattern_grid.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_pattern_grids": { + "conditions": { + "items": [ + { + "items": "#refinedstorage:pattern_grids" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "refinedstorage:coloring/brown_pattern_grid" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_pattern_grids" + ] + ], + "rewards": { + "recipes": [ + "refinedstorage:coloring/brown_pattern_grid" + ] + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/cyan_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/cyan_pattern_grid.json new file mode 100644 index 000000000..6e672ca6d --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/cyan_pattern_grid.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_pattern_grids": { + "conditions": { + "items": [ + { + "items": "#refinedstorage:pattern_grids" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "refinedstorage:coloring/cyan_pattern_grid" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_pattern_grids" + ] + ], + "rewards": { + "recipes": [ + "refinedstorage:coloring/cyan_pattern_grid" + ] + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/gray_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/gray_pattern_grid.json new file mode 100644 index 000000000..26706f8de --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/gray_pattern_grid.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_pattern_grids": { + "conditions": { + "items": [ + { + "items": "#refinedstorage:pattern_grids" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "refinedstorage:coloring/gray_pattern_grid" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_pattern_grids" + ] + ], + "rewards": { + "recipes": [ + "refinedstorage:coloring/gray_pattern_grid" + ] + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/green_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/green_pattern_grid.json new file mode 100644 index 000000000..7ba2a5c12 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/green_pattern_grid.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_pattern_grids": { + "conditions": { + "items": [ + { + "items": "#refinedstorage:pattern_grids" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "refinedstorage:coloring/green_pattern_grid" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_pattern_grids" + ] + ], + "rewards": { + "recipes": [ + "refinedstorage:coloring/green_pattern_grid" + ] + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/light_blue_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/light_blue_pattern_grid.json new file mode 100644 index 000000000..640a631d7 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/light_blue_pattern_grid.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_pattern_grids": { + "conditions": { + "items": [ + { + "items": "#refinedstorage:pattern_grids" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "refinedstorage:coloring/light_blue_pattern_grid" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_pattern_grids" + ] + ], + "rewards": { + "recipes": [ + "refinedstorage:coloring/light_blue_pattern_grid" + ] + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/light_gray_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/light_gray_pattern_grid.json new file mode 100644 index 000000000..ba001806e --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/light_gray_pattern_grid.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_pattern_grids": { + "conditions": { + "items": [ + { + "items": "#refinedstorage:pattern_grids" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "refinedstorage:coloring/light_gray_pattern_grid" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_pattern_grids" + ] + ], + "rewards": { + "recipes": [ + "refinedstorage:coloring/light_gray_pattern_grid" + ] + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/lime_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/lime_pattern_grid.json new file mode 100644 index 000000000..f12eeb903 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/lime_pattern_grid.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_pattern_grids": { + "conditions": { + "items": [ + { + "items": "#refinedstorage:pattern_grids" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "refinedstorage:coloring/lime_pattern_grid" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_pattern_grids" + ] + ], + "rewards": { + "recipes": [ + "refinedstorage:coloring/lime_pattern_grid" + ] + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/magenta_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/magenta_pattern_grid.json new file mode 100644 index 000000000..82f2879f7 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/magenta_pattern_grid.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_pattern_grids": { + "conditions": { + "items": [ + { + "items": "#refinedstorage:pattern_grids" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "refinedstorage:coloring/magenta_pattern_grid" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_pattern_grids" + ] + ], + "rewards": { + "recipes": [ + "refinedstorage:coloring/magenta_pattern_grid" + ] + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/orange_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/orange_pattern_grid.json new file mode 100644 index 000000000..27f904e4b --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/orange_pattern_grid.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_pattern_grids": { + "conditions": { + "items": [ + { + "items": "#refinedstorage:pattern_grids" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "refinedstorage:coloring/orange_pattern_grid" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_pattern_grids" + ] + ], + "rewards": { + "recipes": [ + "refinedstorage:coloring/orange_pattern_grid" + ] + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/pink_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/pink_pattern_grid.json new file mode 100644 index 000000000..358811ea4 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/pink_pattern_grid.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_pattern_grids": { + "conditions": { + "items": [ + { + "items": "#refinedstorage:pattern_grids" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "refinedstorage:coloring/pink_pattern_grid" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_pattern_grids" + ] + ], + "rewards": { + "recipes": [ + "refinedstorage:coloring/pink_pattern_grid" + ] + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/purple_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/purple_pattern_grid.json new file mode 100644 index 000000000..8bfef78a4 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/purple_pattern_grid.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_pattern_grids": { + "conditions": { + "items": [ + { + "items": "#refinedstorage:pattern_grids" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "refinedstorage:coloring/purple_pattern_grid" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_pattern_grids" + ] + ], + "rewards": { + "recipes": [ + "refinedstorage:coloring/purple_pattern_grid" + ] + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/red_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/red_pattern_grid.json new file mode 100644 index 000000000..ba14eca80 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/red_pattern_grid.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_pattern_grids": { + "conditions": { + "items": [ + { + "items": "#refinedstorage:pattern_grids" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "refinedstorage:coloring/red_pattern_grid" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_pattern_grids" + ] + ], + "rewards": { + "recipes": [ + "refinedstorage:coloring/red_pattern_grid" + ] + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/white_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/white_pattern_grid.json new file mode 100644 index 000000000..107127bbe --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/white_pattern_grid.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_pattern_grids": { + "conditions": { + "items": [ + { + "items": "#refinedstorage:pattern_grids" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "refinedstorage:coloring/white_pattern_grid" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_pattern_grids" + ] + ], + "rewards": { + "recipes": [ + "refinedstorage:coloring/white_pattern_grid" + ] + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/yellow_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/yellow_pattern_grid.json new file mode 100644 index 000000000..6dc392741 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/advancement/recipes/misc/coloring/yellow_pattern_grid.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_pattern_grids": { + "conditions": { + "items": [ + { + "items": "#refinedstorage:pattern_grids" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "refinedstorage:coloring/yellow_pattern_grid" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_pattern_grids" + ] + ], + "rewards": { + "recipes": [ + "refinedstorage:coloring/yellow_pattern_grid" + ] + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/black_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/black_pattern_grid.json new file mode 100644 index 000000000..1bbbc9cf6 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/black_pattern_grid.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "refinedstorage:black_pattern_grid" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "refinedstorage:blocks/black_pattern_grid" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/blue_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/blue_pattern_grid.json new file mode 100644 index 000000000..1158b0064 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/blue_pattern_grid.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "refinedstorage:blue_pattern_grid" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "refinedstorage:blocks/blue_pattern_grid" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/brown_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/brown_pattern_grid.json new file mode 100644 index 000000000..684d5e8c9 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/brown_pattern_grid.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "refinedstorage:brown_pattern_grid" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "refinedstorage:blocks/brown_pattern_grid" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/cyan_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/cyan_pattern_grid.json new file mode 100644 index 000000000..1e3e94404 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/cyan_pattern_grid.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "refinedstorage:cyan_pattern_grid" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "refinedstorage:blocks/cyan_pattern_grid" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/gray_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/gray_pattern_grid.json new file mode 100644 index 000000000..8d9660d5a --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/gray_pattern_grid.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "refinedstorage:gray_pattern_grid" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "refinedstorage:blocks/gray_pattern_grid" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/green_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/green_pattern_grid.json new file mode 100644 index 000000000..25e15cb87 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/green_pattern_grid.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "refinedstorage:green_pattern_grid" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "refinedstorage:blocks/green_pattern_grid" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/light_gray_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/light_gray_pattern_grid.json new file mode 100644 index 000000000..9346120a7 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/light_gray_pattern_grid.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "refinedstorage:light_gray_pattern_grid" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "refinedstorage:blocks/light_gray_pattern_grid" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/lime_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/lime_pattern_grid.json new file mode 100644 index 000000000..4c5fd5b37 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/lime_pattern_grid.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "refinedstorage:lime_pattern_grid" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "refinedstorage:blocks/lime_pattern_grid" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/magenta_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/magenta_pattern_grid.json new file mode 100644 index 000000000..d6da01e5b --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/magenta_pattern_grid.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "refinedstorage:magenta_pattern_grid" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "refinedstorage:blocks/magenta_pattern_grid" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/orange_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/orange_pattern_grid.json new file mode 100644 index 000000000..964916d38 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/orange_pattern_grid.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "refinedstorage:orange_pattern_grid" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "refinedstorage:blocks/orange_pattern_grid" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/pattern_grid.json new file mode 100644 index 000000000..f395323e7 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/pattern_grid.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "refinedstorage:pattern_grid" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "refinedstorage:blocks/pattern_grid" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/pink_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/pink_pattern_grid.json new file mode 100644 index 000000000..6bb450999 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/pink_pattern_grid.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "refinedstorage:pink_pattern_grid" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "refinedstorage:blocks/pink_pattern_grid" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/purple_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/purple_pattern_grid.json new file mode 100644 index 000000000..42404be9c --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/purple_pattern_grid.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "refinedstorage:purple_pattern_grid" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "refinedstorage:blocks/purple_pattern_grid" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/red_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/red_pattern_grid.json new file mode 100644 index 000000000..25237dce7 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/red_pattern_grid.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "refinedstorage:red_pattern_grid" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "refinedstorage:blocks/red_pattern_grid" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/white_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/white_pattern_grid.json new file mode 100644 index 000000000..c059207d4 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/white_pattern_grid.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "refinedstorage:white_pattern_grid" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "refinedstorage:blocks/white_pattern_grid" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/yellow_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/yellow_pattern_grid.json new file mode 100644 index 000000000..d2f5ce5e4 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/loot_table/blocks/yellow_pattern_grid.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "refinedstorage:yellow_pattern_grid" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "refinedstorage:blocks/yellow_pattern_grid" +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/black_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/black_pattern_grid.json new file mode 100644 index 000000000..c3944c15d --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/black_pattern_grid.json @@ -0,0 +1,16 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "ingredients": [ + { + "tag": "refinedstorage:pattern_grids" + }, + { + "tag": "c:dyes/black" + } + ], + "result": { + "count": 1, + "id": "refinedstorage:black_pattern_grid" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/blue_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/blue_pattern_grid.json new file mode 100644 index 000000000..f1e6a8f61 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/blue_pattern_grid.json @@ -0,0 +1,16 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "ingredients": [ + { + "tag": "refinedstorage:pattern_grids" + }, + { + "tag": "c:dyes/blue" + } + ], + "result": { + "count": 1, + "id": "refinedstorage:blue_pattern_grid" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/brown_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/brown_pattern_grid.json new file mode 100644 index 000000000..5491f4306 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/brown_pattern_grid.json @@ -0,0 +1,16 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "ingredients": [ + { + "tag": "refinedstorage:pattern_grids" + }, + { + "tag": "c:dyes/brown" + } + ], + "result": { + "count": 1, + "id": "refinedstorage:brown_pattern_grid" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/cyan_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/cyan_pattern_grid.json new file mode 100644 index 000000000..86eee2818 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/cyan_pattern_grid.json @@ -0,0 +1,16 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "ingredients": [ + { + "tag": "refinedstorage:pattern_grids" + }, + { + "tag": "c:dyes/cyan" + } + ], + "result": { + "count": 1, + "id": "refinedstorage:cyan_pattern_grid" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/gray_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/gray_pattern_grid.json new file mode 100644 index 000000000..1fc0ca27a --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/gray_pattern_grid.json @@ -0,0 +1,16 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "ingredients": [ + { + "tag": "refinedstorage:pattern_grids" + }, + { + "tag": "c:dyes/gray" + } + ], + "result": { + "count": 1, + "id": "refinedstorage:gray_pattern_grid" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/green_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/green_pattern_grid.json new file mode 100644 index 000000000..c1f31af5e --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/green_pattern_grid.json @@ -0,0 +1,16 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "ingredients": [ + { + "tag": "refinedstorage:pattern_grids" + }, + { + "tag": "c:dyes/green" + } + ], + "result": { + "count": 1, + "id": "refinedstorage:green_pattern_grid" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/light_blue_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/light_blue_pattern_grid.json new file mode 100644 index 000000000..6d94a92cd --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/light_blue_pattern_grid.json @@ -0,0 +1,16 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "ingredients": [ + { + "tag": "refinedstorage:pattern_grids" + }, + { + "tag": "c:dyes/light_blue" + } + ], + "result": { + "count": 1, + "id": "refinedstorage:pattern_grid" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/light_gray_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/light_gray_pattern_grid.json new file mode 100644 index 000000000..27e3a4a88 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/light_gray_pattern_grid.json @@ -0,0 +1,16 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "ingredients": [ + { + "tag": "refinedstorage:pattern_grids" + }, + { + "tag": "c:dyes/light_gray" + } + ], + "result": { + "count": 1, + "id": "refinedstorage:light_gray_pattern_grid" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/lime_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/lime_pattern_grid.json new file mode 100644 index 000000000..4e6b647a8 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/lime_pattern_grid.json @@ -0,0 +1,16 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "ingredients": [ + { + "tag": "refinedstorage:pattern_grids" + }, + { + "tag": "c:dyes/lime" + } + ], + "result": { + "count": 1, + "id": "refinedstorage:lime_pattern_grid" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/magenta_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/magenta_pattern_grid.json new file mode 100644 index 000000000..b9f7acce8 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/magenta_pattern_grid.json @@ -0,0 +1,16 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "ingredients": [ + { + "tag": "refinedstorage:pattern_grids" + }, + { + "tag": "c:dyes/magenta" + } + ], + "result": { + "count": 1, + "id": "refinedstorage:magenta_pattern_grid" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/orange_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/orange_pattern_grid.json new file mode 100644 index 000000000..a87159606 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/orange_pattern_grid.json @@ -0,0 +1,16 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "ingredients": [ + { + "tag": "refinedstorage:pattern_grids" + }, + { + "tag": "c:dyes/orange" + } + ], + "result": { + "count": 1, + "id": "refinedstorage:orange_pattern_grid" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/pink_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/pink_pattern_grid.json new file mode 100644 index 000000000..694be123d --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/pink_pattern_grid.json @@ -0,0 +1,16 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "ingredients": [ + { + "tag": "refinedstorage:pattern_grids" + }, + { + "tag": "c:dyes/pink" + } + ], + "result": { + "count": 1, + "id": "refinedstorage:pink_pattern_grid" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/purple_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/purple_pattern_grid.json new file mode 100644 index 000000000..e87a3e35b --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/purple_pattern_grid.json @@ -0,0 +1,16 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "ingredients": [ + { + "tag": "refinedstorage:pattern_grids" + }, + { + "tag": "c:dyes/purple" + } + ], + "result": { + "count": 1, + "id": "refinedstorage:purple_pattern_grid" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/red_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/red_pattern_grid.json new file mode 100644 index 000000000..342dbb45c --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/red_pattern_grid.json @@ -0,0 +1,16 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "ingredients": [ + { + "tag": "refinedstorage:pattern_grids" + }, + { + "tag": "c:dyes/red" + } + ], + "result": { + "count": 1, + "id": "refinedstorage:red_pattern_grid" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/white_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/white_pattern_grid.json new file mode 100644 index 000000000..545d3147c --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/white_pattern_grid.json @@ -0,0 +1,16 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "ingredients": [ + { + "tag": "refinedstorage:pattern_grids" + }, + { + "tag": "c:dyes/white" + } + ], + "result": { + "count": 1, + "id": "refinedstorage:white_pattern_grid" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/yellow_pattern_grid.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/yellow_pattern_grid.json new file mode 100644 index 000000000..1b910bad9 --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/recipe/coloring/yellow_pattern_grid.json @@ -0,0 +1,16 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "misc", + "ingredients": [ + { + "tag": "refinedstorage:pattern_grids" + }, + { + "tag": "c:dyes/yellow" + } + ], + "result": { + "count": 1, + "id": "refinedstorage:yellow_pattern_grid" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/generated/resources/data/refinedstorage/tags/item/pattern_grids.json b/refinedstorage-common/src/generated/resources/data/refinedstorage/tags/item/pattern_grids.json new file mode 100644 index 000000000..09212798c --- /dev/null +++ b/refinedstorage-common/src/generated/resources/data/refinedstorage/tags/item/pattern_grids.json @@ -0,0 +1,20 @@ +{ + "values": [ + "refinedstorage:white_pattern_grid", + "refinedstorage:orange_pattern_grid", + "refinedstorage:magenta_pattern_grid", + "refinedstorage:pattern_grid", + "refinedstorage:yellow_pattern_grid", + "refinedstorage:lime_pattern_grid", + "refinedstorage:pink_pattern_grid", + "refinedstorage:gray_pattern_grid", + "refinedstorage:light_gray_pattern_grid", + "refinedstorage:cyan_pattern_grid", + "refinedstorage:purple_pattern_grid", + "refinedstorage:blue_pattern_grid", + "refinedstorage:brown_pattern_grid", + "refinedstorage:green_pattern_grid", + "refinedstorage:red_pattern_grid", + "refinedstorage:black_pattern_grid" + ] +} \ No newline at end of file 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 b7a8be0fe..b9d9c997b 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 @@ -1,6 +1,7 @@ package com.refinedmods.refinedstorage.common; import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.autocrafting.PatternGridScreen; import com.refinedmods.refinedstorage.common.constructordestructor.ConstructorScreen; import com.refinedmods.refinedstorage.common.constructordestructor.DestructorScreen; import com.refinedmods.refinedstorage.common.content.Items; @@ -55,6 +56,7 @@ protected static void registerScreens(final ScreenRegistration registration) { registration.register(Menus.INSTANCE.getDiskDrive(), DiskDriveScreen::new); registration.register(Menus.INSTANCE.getGrid(), GridScreen::new); registration.register(Menus.INSTANCE.getCraftingGrid(), CraftingGridScreen::new); + registration.register(Menus.INSTANCE.getPatternGrid(), PatternGridScreen::new); registration.register(Menus.INSTANCE.getWirelessGrid(), GridScreen::new); registration.register(Menus.INSTANCE.getController(), ControllerScreen::new); registration.register(Menus.INSTANCE.getItemStorage(), ItemStorageBlockScreen::new); 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 5780792be..3a2ea3fe5 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 @@ -12,6 +12,12 @@ import com.refinedmods.refinedstorage.common.api.RefinedStorageApiProxy; import com.refinedmods.refinedstorage.common.api.security.PlatformSecurityNetworkComponent; import com.refinedmods.refinedstorage.common.api.upgrade.AbstractUpgradeItem; +import com.refinedmods.refinedstorage.common.autocrafting.CraftingPatternState; +import com.refinedmods.refinedstorage.common.autocrafting.PatternGridBlockEntity; +import com.refinedmods.refinedstorage.common.autocrafting.PatternGridContainerMenu; +import com.refinedmods.refinedstorage.common.autocrafting.PatternGridData; +import com.refinedmods.refinedstorage.common.autocrafting.PatternItem; +import com.refinedmods.refinedstorage.common.autocrafting.PatternState; import com.refinedmods.refinedstorage.common.configurationcard.ConfigurationCardItem; import com.refinedmods.refinedstorage.common.configurationcard.ConfigurationCardState; import com.refinedmods.refinedstorage.common.constructordestructor.BlockBreakDestructorStrategyFactory; @@ -312,6 +318,7 @@ protected final void registerBlocks( Blocks.INSTANCE.getCable().registerBlocks(callback); Blocks.INSTANCE.getGrid().registerBlocks(callback); Blocks.INSTANCE.getCraftingGrid().registerBlocks(callback); + Blocks.INSTANCE.getPatternGrid().registerBlocks(callback); Blocks.INSTANCE.getDetector().registerBlocks(callback); Blocks.INSTANCE.getImporter().registerBlocks(callback); Blocks.INSTANCE.getExporter().registerBlocks(callback); @@ -341,6 +348,7 @@ protected final void registerItems(final RegistryCallback callback) { registerSimpleItems(callback); Blocks.INSTANCE.getGrid().registerItems(callback); Blocks.INSTANCE.getCraftingGrid().registerItems(callback); + Blocks.INSTANCE.getPatternGrid().registerItems(callback); Blocks.INSTANCE.getCable().registerItems(callback, Items.INSTANCE::addCable); Blocks.INSTANCE.getController().registerItems(callback, Items.INSTANCE::addController); Blocks.INSTANCE.getCreativeController().registerItems(callback, Items.INSTANCE::addCreativeController); @@ -389,6 +397,7 @@ private void registerSimpleItems(final RegistryCallback callback) { ConfigurationCardItem::new )); Items.INSTANCE.setNetworkCard(callback.register(ContentIds.NETWORK_CARD, NetworkCardItem::new)); + Items.INSTANCE.setPattern(callback.register(ContentIds.PATTERN, PatternItem::new)); } private void registerProcessor(final RegistryCallback callback, final ProcessorItem.Type type) { @@ -562,6 +571,10 @@ protected final void registerBlockEntities( ContentIds.CRAFTING_GRID, () -> typeFactory.create(CraftingGridBlockEntity::new, Blocks.INSTANCE.getCraftingGrid().toArray()) )); + BlockEntities.INSTANCE.setPatternGrid(callback.register( + ContentIds.PATTERN_GRID, + () -> typeFactory.create(PatternGridBlockEntity::new, Blocks.INSTANCE.getPatternGrid().toArray()) + )); for (final ItemStorageVariant variant : ItemStorageVariant.values()) { BlockEntities.INSTANCE.setItemStorageBlock(variant, callback.register( ContentIds.forItemStorageBlock(variant), @@ -679,6 +692,10 @@ protected final void registerMenus(final RegistryCallback> callback, ContentIds.CRAFTING_GRID, () -> extendedMenuTypeFactory.create(CraftingGridContainerMenu::new, GridData.STREAM_CODEC) )); + Menus.INSTANCE.setPatternGrid(callback.register( + ContentIds.PATTERN_GRID, + () -> extendedMenuTypeFactory.create(PatternGridContainerMenu::new, PatternGridData.STREAM_CODEC) + )); Menus.INSTANCE.setWirelessGrid(callback.register( ContentIds.WIRELESS_GRID, () -> extendedMenuTypeFactory.create(WirelessGridContainerMenu::new, WirelessGridData.STREAM_CODEC) @@ -837,6 +854,18 @@ protected final void registerDataComponents(final RegistryCallback DataComponentType.builder() + .persistent(PatternState.CODEC) + .networkSynchronized(PatternState.STREAM_CODEC) + .build())); + DataComponents.INSTANCE.setCraftingPatternState( + callback.register(createIdentifier("crafting_pattern_state"), + () -> DataComponentType.builder() + .persistent(CraftingPatternState.CODEC) + .networkSynchronized(CraftingPatternState.STREAM_CODEC) + .build())); } protected final void registerInventorySlotReference() { diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/Config.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/Config.java index e828d1c07..6feeb0d92 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/Config.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/Config.java @@ -20,6 +20,8 @@ public interface Config { GridEntry getGrid(); + SimpleEnergyUsageEntry getPatternGrid(); + CraftingGridEntry getCraftingGrid(); ControllerEntry getController(); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/Platform.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/Platform.java index b1b96a0ff..00b0accf0 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/Platform.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/Platform.java @@ -131,4 +131,6 @@ void saveSavedData(SavedData savedData, @Nullable NetworkNodeContainerProvider getContainerProviderSafely(Level level, BlockPos pos, @Nullable Direction direction); + + int getItemColor(ItemStack stack, int tintIndex); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/PlatformProxy.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/PlatformProxy.java index 6c28ad8e5..00ff22c91 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/PlatformProxy.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/PlatformProxy.java @@ -254,6 +254,11 @@ public NetworkNodeContainerProvider getContainerProviderSafely(final Level level return ensureLoaded().getContainerProviderSafely(level, pos, direction); } + @Override + public int getItemColor(final ItemStack stack, final int tintIndex) { + return ensureLoaded().getItemColor(stack, tintIndex); + } + private Platform ensureLoaded() { if (platform == null) { throw new IllegalStateException("Platform not loaded yet"); 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 8a38b03fb..6e0c4ebc5 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 @@ -11,6 +11,8 @@ import com.refinedmods.refinedstorage.api.network.security.SecurityPolicy; import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.autocrafting.Pattern; +import com.refinedmods.refinedstorage.common.api.autocrafting.PatternProviderItem; import com.refinedmods.refinedstorage.common.api.constructordestructor.ConstructorStrategyFactory; import com.refinedmods.refinedstorage.common.api.constructordestructor.DestructorStrategyFactory; import com.refinedmods.refinedstorage.common.api.exporter.ExporterTransferStrategyFactory; @@ -93,6 +95,7 @@ import java.util.PriorityQueue; import java.util.Queue; import java.util.Set; +import java.util.UUID; import java.util.stream.Collectors; import javax.annotation.Nullable; @@ -166,6 +169,7 @@ public class RefinedStorageApiImpl implements RefinedStorageApi { private final CompositeSlotReferenceProvider slotReferenceProvider = new CompositeSlotReferenceProvider(); private final PlatformRegistry permissionRegistry = new PlatformRegistryImpl<>(); private final List resourceExtractStrategies = new ArrayList<>(); + private final Map patternCache = new HashMap<>(); public RefinedStorageApiImpl() { gridSynchronizerRegistry.register(createIdentifier("off"), NoopGridSynchronizer.INSTANCE); @@ -573,4 +577,22 @@ public boolean canPlaceNetworkNode(final ServerPlayer player, } return true; } + + @Override + public Optional getPattern(final ItemStack stack, final Level level) { + if (patternCache.size() > 2000) { + patternCache.clear(); + } + if (!(stack.getItem() instanceof PatternProviderItem providerItem)) { + return Optional.empty(); + } + final UUID id = providerItem.getId(stack); + if (id == null) { + return Optional.empty(); + } + return Optional.ofNullable(patternCache.computeIfAbsent( + id, + i -> providerItem.getPattern(stack, level).orElse(null) + )); + } } 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 new file mode 100644 index 000000000..04ea6397e --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/CraftingPatternClientTooltipComponent.java @@ -0,0 +1,132 @@ +package com.refinedmods.refinedstorage.common.autocrafting; + +import com.refinedmods.refinedstorage.api.resource.ResourceAmount; +import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.autocrafting.CraftingPattern; +import com.refinedmods.refinedstorage.common.api.support.resource.PlatformResourceKey; +import com.refinedmods.refinedstorage.common.support.resource.ItemResource; + +import java.util.List; +import java.util.Objects; + +import net.minecraft.ChatFormatting; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; + +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; + +public class CraftingPatternClientTooltipComponent implements ClientTooltipComponent { + private static final long CYCLE_MS = 1000; + private static long cycleStart = 0; + private static int currentCycle = 0; + + private static final int ARROW_SPACING = 8; + + private static final ResourceLocation SLOT = createIdentifier("slot"); + private static final ResourceLocation LARGE_SLOT = createIdentifier("large_slot"); + private static final ResourceLocation ARROW = createIdentifier("light_arrow"); + private static final int ARROW_WIDTH = 22; + private static final int ARROW_HEIGHT = 15; + private static final int LARGE_SLOT_WIDTH = 26; + private static final int LARGE_SLOT_HEIGHT = 26; + + private final int width; + private final int height; + private final CraftingPattern craftingPattern; + + public CraftingPatternClientTooltipComponent(final int width, + final int height, + final CraftingPattern craftingPattern) { + this.width = width; + this.height = height; + this.craftingPattern = craftingPattern; + } + + @Override + public int getHeight() { + return 9 + 2 + height * 18 + 3; + } + + @Override + public int getWidth(final Font font) { + return (width * 18) + ARROW_SPACING + ARROW_WIDTH + ARROW_SPACING + LARGE_SLOT_WIDTH; + } + + @Override + public void renderImage(final Font font, final int x, final int y, final GuiGraphics graphics) { + final long now = System.currentTimeMillis(); + if (cycleStart == 0) { + cycleStart = now; + } + if (now - cycleStart >= CYCLE_MS) { + currentCycle++; + cycleStart = now; + } + if (craftingPattern.output().getResource() instanceof ItemResource itemResource) { + graphics.drawString( + font, + Component.literal(String.format("%dx ", craftingPattern.output().getAmount())) + .append(itemResource.toItemStack().getHoverName()) + .withStyle(ChatFormatting.GRAY), + x, + y, + Objects.requireNonNullElse(ChatFormatting.GRAY.getColor(), 15) + ); + } + renderInputSlots(x, y + 9 + 2, graphics); + renderArrow(x, y + 9 + 2, graphics); + renderResultSlot(font, x, y + 9 + 2, graphics); + } + + private void renderInputSlots(final int x, final int y, final GuiGraphics graphics) { + for (int sx = 0; sx < width; ++sx) { + for (int sy = 0; sy < height; ++sy) { + renderInputSlot(x, y, graphics, sx, sy); + } + } + } + + private void renderInputSlot(final int x, final int y, final GuiGraphics graphics, final int sx, final int sy) { + graphics.blitSprite(SLOT, x + sx * 18, y + sy * 18, 18, 18); + final int index = sy * width + sx; + final List inputs = craftingPattern.inputs().get(index); + if (!inputs.isEmpty()) { + final int idx = currentCycle % inputs.size(); + final PlatformResourceKey resource = inputs.get(idx); + RefinedStorageApi.INSTANCE.getResourceRendering(resource).render( + resource, + graphics, + x + sx * 18 + 1, + y + sy * 18 + 1 + ); + } + } + + private void renderArrow(final int x, final int y, final GuiGraphics graphics) { + graphics.blitSprite( + ARROW, + x + width * 18 + ARROW_SPACING, + y + ((height * 18) / 2) - (ARROW_HEIGHT / 2), + ARROW_WIDTH, + ARROW_HEIGHT + ); + } + + private void renderResultSlot(final Font font, final int x, final int y, final GuiGraphics graphics) { + final int slotX = x + width * 18 + ARROW_SPACING + ARROW_WIDTH + ARROW_SPACING; + final int slotY = y + ((height * 18) / 2) - (LARGE_SLOT_HEIGHT / 2); + graphics.blitSprite(LARGE_SLOT, slotX, slotY, LARGE_SLOT_WIDTH, LARGE_SLOT_HEIGHT); + final ResourceAmount output = craftingPattern.output(); + if (output.getResource() instanceof ItemResource itemResource) { + final ItemStack resultItemStack = itemResource.toItemStack(output.getAmount()); + final int stackX = slotX + 5; + final int stackY = slotY + 5; + graphics.renderItem(resultItemStack, stackX, stackY); + graphics.renderItemDecorations(font, resultItemStack, stackX, stackY); + } + } +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/CraftingPatternState.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/CraftingPatternState.java new file mode 100644 index 000000000..ad87c630b --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/CraftingPatternState.java @@ -0,0 +1,52 @@ +package com.refinedmods.refinedstorage.common.autocrafting; + +import java.util.ArrayList; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.CraftingInput; + +public record CraftingPatternState(boolean fuzzyMode, CraftingInput.Positioned input) { + private static final Codec INPUT_CODEC = RecordCodecBuilder.create(instance -> instance.group( + Codec.INT.fieldOf("width").forGetter(CraftingInput::width), + Codec.INT.fieldOf("height").forGetter(CraftingInput::height), + Codec.list(ItemStack.OPTIONAL_CODEC).fieldOf("items").forGetter(CraftingInput::items) + ).apply(instance, CraftingInput::of)); + + private static final Codec POSITIONED_INPUT_CODEC = + RecordCodecBuilder.create(instance -> instance.group( + INPUT_CODEC.fieldOf("input").forGetter(CraftingInput.Positioned::input), + Codec.INT.fieldOf("left").forGetter(CraftingInput.Positioned::left), + Codec.INT.fieldOf("top").forGetter(CraftingInput.Positioned::top) + ).apply(instance, CraftingInput.Positioned::new)); + + public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( + Codec.BOOL.fieldOf("fuzzyMode").forGetter(CraftingPatternState::fuzzyMode), + POSITIONED_INPUT_CODEC.fieldOf("input").forGetter(CraftingPatternState::input) + ).apply(instance, CraftingPatternState::new)); + + private static final StreamCodec INPUT_STREAM_CODEC = StreamCodec.composite( + ByteBufCodecs.INT, CraftingInput::width, + ByteBufCodecs.INT, CraftingInput::height, + ByteBufCodecs.collection(ArrayList::new, ItemStack.OPTIONAL_STREAM_CODEC), CraftingInput::items, + CraftingInput::of + ); + + private static final StreamCodec POSITIONED_INPUT_STREAM_CODEC = + StreamCodec.composite( + INPUT_STREAM_CODEC, CraftingInput.Positioned::input, + ByteBufCodecs.INT, CraftingInput.Positioned::left, + ByteBufCodecs.INT, CraftingInput.Positioned::top, + CraftingInput.Positioned::new + ); + + public static final StreamCodec STREAM_CODEC = StreamCodec.composite( + ByteBufCodecs.BOOL, CraftingPatternState::fuzzyMode, + POSITIONED_INPUT_STREAM_CODEC, CraftingPatternState::input, + CraftingPatternState::new + ); +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternBlockEntityWithoutLevelRenderer.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternBlockEntityWithoutLevelRenderer.java new file mode 100644 index 000000000..96cc22c72 --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternBlockEntityWithoutLevelRenderer.java @@ -0,0 +1,48 @@ +package com.refinedmods.refinedstorage.common.autocrafting; + +import javax.annotation.Nullable; + +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.Minecraft; +import net.minecraft.client.model.geom.EntityModelSet; +import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.world.item.ItemDisplayContext; +import net.minecraft.world.item.ItemStack; + +public class PatternBlockEntityWithoutLevelRenderer extends BlockEntityWithoutLevelRenderer { + @Nullable + private static PatternBlockEntityWithoutLevelRenderer instance; + + private PatternBlockEntityWithoutLevelRenderer( + final BlockEntityRenderDispatcher blockEntityRenderDispatcher, + final EntityModelSet entityModelSet + ) { + super(blockEntityRenderDispatcher, entityModelSet); + } + + @Override + public void renderByItem(final ItemStack stack, + final ItemDisplayContext displayContext, + final PoseStack poseStack, + final MultiBufferSource buffer, + final int packedLight, + final int packedOverlay) { + if (PatternRendering.canDisplayOutput(stack)) { + PatternRendering.getOutput(stack).ifPresent( + output -> super.renderByItem(output, displayContext, poseStack, buffer, packedLight, packedOverlay) + ); + } + } + + public static PatternBlockEntityWithoutLevelRenderer getInstance() { + if (instance == null) { + instance = new PatternBlockEntityWithoutLevelRenderer( + Minecraft.getInstance().getBlockEntityRenderDispatcher(), + Minecraft.getInstance().getEntityModels() + ); + } + return instance; + } +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridBlock.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridBlock.java new file mode 100644 index 000000000..1315e9909 --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridBlock.java @@ -0,0 +1,62 @@ +package com.refinedmods.refinedstorage.common.autocrafting; + +import com.refinedmods.refinedstorage.common.content.BlockColorMap; +import com.refinedmods.refinedstorage.common.content.BlockEntities; +import com.refinedmods.refinedstorage.common.content.Blocks; +import com.refinedmods.refinedstorage.common.grid.AbstractGridBlock; +import com.refinedmods.refinedstorage.common.support.AbstractBlockEntityTicker; +import com.refinedmods.refinedstorage.common.support.BaseBlockItem; +import com.refinedmods.refinedstorage.common.support.BlockItemProvider; +import com.refinedmods.refinedstorage.common.support.NetworkNodeBlockItem; +import com.refinedmods.refinedstorage.common.support.network.NetworkNodeBlockEntityTicker; + +import javax.annotation.Nullable; + +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityTicker; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; + +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createTranslation; + +public class PatternGridBlock extends AbstractGridBlock + implements BlockItemProvider { + private static final Component HELP = createTranslation("item", "pattern_grid.help"); + private static final AbstractBlockEntityTicker TICKER = new NetworkNodeBlockEntityTicker<>( + BlockEntities.INSTANCE::getPatternGrid, + ACTIVE + ); + + public PatternGridBlock(final DyeColor color, final MutableComponent name) { + super(name, color); + } + + @Override + public BlockColorMap getBlockColorMap() { + return Blocks.INSTANCE.getPatternGrid(); + } + + @Nullable + @Override + public BlockEntity newBlockEntity(final BlockPos pos, final BlockState state) { + return new PatternGridBlockEntity(pos, state); + } + + @Nullable + @Override + public BlockEntityTicker getTicker(final Level level, + final BlockState blockState, + final BlockEntityType type) { + return TICKER.get(level, type); + } + + @Override + public BaseBlockItem createBlockItem() { + return new NetworkNodeBlockItem(this, HELP); + } +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridBlockEntity.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridBlockEntity.java new file mode 100644 index 000000000..ccbe0ad0d --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridBlockEntity.java @@ -0,0 +1,251 @@ +package com.refinedmods.refinedstorage.common.autocrafting; + +import com.refinedmods.refinedstorage.common.Platform; +import com.refinedmods.refinedstorage.common.content.BlockEntities; +import com.refinedmods.refinedstorage.common.content.ContentNames; +import com.refinedmods.refinedstorage.common.content.DataComponents; +import com.refinedmods.refinedstorage.common.content.Items; +import com.refinedmods.refinedstorage.common.grid.AbstractGridBlockEntity; +import com.refinedmods.refinedstorage.common.grid.AbstractGridContainerMenu; +import com.refinedmods.refinedstorage.common.grid.CraftingState; +import com.refinedmods.refinedstorage.common.grid.GridData; +import com.refinedmods.refinedstorage.common.support.BlockEntityWithDrops; +import com.refinedmods.refinedstorage.common.support.CraftingMatrix; +import com.refinedmods.refinedstorage.common.support.FilteredContainer; +import com.refinedmods.refinedstorage.common.support.containermenu.NetworkNodeExtendedMenuProvider; +import com.refinedmods.refinedstorage.common.util.ContainerUtil; + +import java.util.UUID; +import javax.annotation.Nullable; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.NonNullList; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.chat.Component; +import net.minecraft.network.codec.StreamEncoder; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.ResultContainer; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.CraftingInput; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; + +// TODO: servertest +// TODO: update changelog +// TODO: change "nbt" tooltips (en_us.json) +public class PatternGridBlockEntity extends AbstractGridBlockEntity implements BlockEntityWithDrops, + NetworkNodeExtendedMenuProvider { + private static final String TAG_PATTERN_INPUT = "pattern_input"; + private static final String TAG_PATTERN_OUTPUT = "pattern_output"; + private static final String TAG_FUZZY_MODE = "fuzzy_mode"; + private static final String TAG_PATTERN_TYPE = "processing"; + + private final CraftingState craftingState = new CraftingState(this::setChanged, this::getLevel); + private final FilteredContainer patternInput = new FilteredContainer(1, PatternGridBlockEntity::isValidPattern); + private final FilteredContainer patternOutput = new PatternOutputContainer(); + private boolean fuzzyMode; + private PatternType patternType = PatternType.CRAFTING; + + public PatternGridBlockEntity(final BlockPos pos, final BlockState state) { + super( + BlockEntities.INSTANCE.getPatternGrid(), + pos, + state, + Platform.INSTANCE.getConfig().getPatternGrid().getEnergyUsage() + ); + patternInput.addListener(container -> setChanged()); + patternOutput.addListener(container -> setChanged()); + } + + CraftingMatrix getCraftingMatrix() { + return craftingState.getCraftingMatrix(); + } + + ResultContainer getCraftingResult() { + return craftingState.getCraftingResult(); + } + + FilteredContainer getPatternInput() { + return patternInput; + } + + FilteredContainer getPatternOutput() { + return patternOutput; + } + + @Override + public void saveAdditional(final CompoundTag tag, final HolderLookup.Provider provider) { + super.saveAdditional(tag, provider); + tag.put(TAG_PATTERN_INPUT, ContainerUtil.write(patternInput, provider)); + tag.put(TAG_PATTERN_OUTPUT, ContainerUtil.write(patternOutput, provider)); + tag.putBoolean(TAG_FUZZY_MODE, fuzzyMode); + tag.putInt(TAG_PATTERN_TYPE, PatternTypeSettings.getPatternType(patternType)); + craftingState.writeToTag(tag, provider); + } + + @Override + public void loadAdditional(final CompoundTag tag, final HolderLookup.Provider provider) { + super.loadAdditional(tag, provider); + if (tag.contains(TAG_PATTERN_INPUT)) { + ContainerUtil.read(tag.getCompound(TAG_PATTERN_INPUT), patternInput, provider); + } + if (tag.contains(TAG_PATTERN_OUTPUT)) { + ContainerUtil.read(tag.getCompound(TAG_PATTERN_OUTPUT), patternOutput, provider); + } + fuzzyMode = tag.getBoolean(TAG_FUZZY_MODE); + patternType = PatternTypeSettings.getPatternType(tag.getInt(TAG_PATTERN_TYPE)); + craftingState.readFromTag(tag, provider); + } + + @Override + public void setLevel(final Level level) { + super.setLevel(level); + craftingState.updateResult(level); + } + + boolean isFuzzyMode() { + return fuzzyMode; + } + + PatternType getPatternType() { + return patternType; + } + + void setFuzzyMode(final boolean fuzzyMode) { + this.fuzzyMode = fuzzyMode; + setChanged(); + } + + void setPatternType(final PatternType patternType) { + this.patternType = patternType; + setChanged(); + } + + @Override + public Component getDisplayName() { + return ContentNames.PATTERN_GRID; + } + + @Override + @Nullable + public AbstractGridContainerMenu createMenu(final int syncId, final Inventory inventory, final Player player) { + return new PatternGridContainerMenu(syncId, inventory, this); + } + + @Override + public PatternGridData getMenuData() { + return new PatternGridData(GridData.of(this), patternType); + } + + @Override + public StreamEncoder getMenuCodec() { + return PatternGridData.STREAM_CODEC; + } + + @Override + public NonNullList getDrops() { + final NonNullList drops = NonNullList.create(); + drops.add(patternInput.getItem(0)); + drops.add(patternOutput.getItem(0)); + for (int i = 0; i < craftingState.getCraftingMatrix().getContainerSize(); ++i) { + drops.add(craftingState.getCraftingMatrix().getItem(i)); + } + return drops; + } + + void clear() { + if (level == null) { + return; + } + craftingState.getCraftingMatrix().clearContent(); + craftingState.updateResult(level); + } + + void createPattern() { + if (level == null || !isPatternAvailable()) { + return; + } + final ItemStack result = switch (patternType) { + case CRAFTING -> createCraftingPattern(); + default -> null; + }; + if (result != null) { + final boolean shouldExtractInputPattern = patternOutput.getItem(0).isEmpty(); + if (shouldExtractInputPattern) { + patternInput.removeItem(0, 1); + } + patternOutput.setItem(0, result); + } + } + + void copyPattern(final ItemStack stack) { + final PatternState state = stack.get(DataComponents.INSTANCE.getPatternState()); + if (state == null) { + return; + } + this.patternType = state.type(); + switch (state.type()) { + case CRAFTING -> { + final CraftingPatternState patternCraftingState = stack.get( + DataComponents.INSTANCE.getCraftingPatternState() + ); + if (patternCraftingState == null) { + return; + } + copyCraftingPattern(patternCraftingState); + } + } + setChanged(); + } + + private void copyCraftingPattern(final CraftingPatternState state) { + this.fuzzyMode = state.fuzzyMode(); + craftingState.getCraftingMatrix().clearContent(); + final CraftingInput.Positioned positionedInput = state.input(); + final int left = positionedInput.left(); + final int top = positionedInput.top(); + final CraftingInput input = positionedInput.input(); + for (int x = 0; x < input.width(); ++x) { + for (int y = 0; y < input.height(); ++y) { + final int matrixIndex = x + left + (y + top) * craftingState.getCraftingMatrix().getWidth(); + final int recipeIndex = x + y * input.width(); + final ItemStack stack = input.getItem(recipeIndex); + craftingState.getCraftingMatrix().setItem(matrixIndex, stack); + } + } + if (level != null) { + craftingState.updateResult(level); + } + } + + @Nullable + private ItemStack createCraftingPattern() { + if (!craftingState.hasCraftingResult()) { + return null; + } + final boolean shouldExtractInputPattern = patternOutput.getItem(0).isEmpty(); + if (shouldExtractInputPattern) { + patternInput.removeItem(0, 1); + } + final ItemStack result = new ItemStack(Items.INSTANCE.getPattern()); + final PatternState patternState = new PatternState(UUID.randomUUID(), PatternType.CRAFTING); + result.set(DataComponents.INSTANCE.getPatternState(), patternState); + final CraftingPatternState patternCraftingState = new CraftingPatternState( + fuzzyMode, + getCraftingMatrix().asPositionedCraftInput() + ); + result.set(DataComponents.INSTANCE.getCraftingPatternState(), patternCraftingState); + return result; + } + + private boolean isPatternAvailable() { + return !patternInput.getItem(0).isEmpty() || !patternOutput.getItem(0).isEmpty(); + } + + static boolean isValidPattern(final ItemStack stack) { + return stack.getItem() instanceof PatternItem; + } +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridContainerMenu.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridContainerMenu.java new file mode 100644 index 000000000..11b4193e5 --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridContainerMenu.java @@ -0,0 +1,221 @@ +package com.refinedmods.refinedstorage.common.autocrafting; + +import com.refinedmods.refinedstorage.common.content.Menus; +import com.refinedmods.refinedstorage.common.grid.AbstractGridContainerMenu; +import com.refinedmods.refinedstorage.common.support.CraftingMatrix; +import com.refinedmods.refinedstorage.common.support.FilteredContainer; +import com.refinedmods.refinedstorage.common.support.RedstoneMode; +import com.refinedmods.refinedstorage.common.support.containermenu.ClientProperty; +import com.refinedmods.refinedstorage.common.support.containermenu.DisabledSlot; +import com.refinedmods.refinedstorage.common.support.containermenu.FilterSlot; +import com.refinedmods.refinedstorage.common.support.containermenu.PropertyTypes; +import com.refinedmods.refinedstorage.common.support.containermenu.ServerProperty; +import com.refinedmods.refinedstorage.common.support.containermenu.ValidatedSlot; +import com.refinedmods.refinedstorage.common.support.packet.c2s.C2SPackets; + +import javax.annotation.Nullable; + +import net.minecraft.world.Container; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.ResultContainer; +import net.minecraft.world.item.ItemStack; + +public class PatternGridContainerMenu extends AbstractGridContainerMenu { + private static final int Y_OFFSET_BETWEEN_PLAYER_INVENTORY_AND_PATTERN_INPUT_SLOT = 81; + private static final int SPACING_BETWEEN_PATTERN_INPUT_AND_PATTERN_OUTPUT_SLOTS = 36; + private static final int Y_OFFSET_BETWEEN_PLAYER_INVENTORY_AND_FIRST_CRAFTING_MATRIX_SLOT = 86; + + private final Container patternInput; + private final Container patternOutput; + private final Container craftingMatrix; + private final Container craftingResult; + + @Nullable + private PatternGridListener listener; + @Nullable + private PatternGridBlockEntity patternGrid; + + public PatternGridContainerMenu(final int syncId, + final Inventory playerInventory, + final PatternGridData patternGridData) { + super(Menus.INSTANCE.getPatternGrid(), syncId, playerInventory, patternGridData.gridData()); + this.patternInput = new FilteredContainer(1, PatternGridBlockEntity::isValidPattern); + this.patternOutput = new PatternOutputContainer(); + this.craftingMatrix = new CraftingMatrix(null, 3, 3); + this.craftingResult = new ResultContainer(); + onScreenReady(0); + registerProperty(new ClientProperty<>(PropertyTypes.REDSTONE_MODE, RedstoneMode.IGNORE)); + registerProperty(new ClientProperty<>(PatternGridPropertyTypes.PATTERN_TYPE, patternGridData.patternType()) { + @Override + protected void onChangedOnClient(final PatternType newValue) { + super.onChangedOnClient(newValue); + if (listener != null) { + listener.patternTypeChanged(newValue); + } + } + }); + registerProperty(new ClientProperty<>(PropertyTypes.FUZZY_MODE, false) { + @Override + protected void onChangedOnClient(final Boolean newValue) { + super.onChangedOnClient(newValue); + if (listener != null) { + listener.fuzzyModeChanged(newValue); + } + } + }); + } + + PatternGridContainerMenu(final int syncId, + final Inventory playerInventory, + final PatternGridBlockEntity grid) { + super(Menus.INSTANCE.getPatternGrid(), syncId, playerInventory, grid); + this.patternInput = grid.getPatternInput(); + this.patternOutput = grid.getPatternOutput(); + this.craftingMatrix = grid.getCraftingMatrix(); + this.craftingResult = grid.getCraftingResult(); + this.patternGrid = grid; + onScreenReady(0); + registerProperty(new ServerProperty<>( + PropertyTypes.REDSTONE_MODE, + grid::getRedstoneMode, + grid::setRedstoneMode + )); + registerProperty(new ServerProperty<>( + PatternGridPropertyTypes.PATTERN_TYPE, + grid::getPatternType, + grid::setPatternType + )); + registerProperty(new ServerProperty<>( + PropertyTypes.FUZZY_MODE, + grid::isFuzzyMode, + grid::setFuzzyMode + )); + } + + void setListener(final PatternGridListener listener) { + this.listener = listener; + } + + PatternType getPatternType() { + return getProperty(PatternGridPropertyTypes.PATTERN_TYPE).getValue(); + } + + void setPatternType(final PatternType patternType) { + getProperty(PatternGridPropertyTypes.PATTERN_TYPE).setValue(patternType); + } + + boolean isFuzzyMode() { + return Boolean.TRUE.equals(getProperty(PropertyTypes.FUZZY_MODE).getValue()); + } + + void setFuzzyMode(final boolean fuzzyMode) { + getProperty(PropertyTypes.FUZZY_MODE).setValue(fuzzyMode); + } + + boolean canCreatePattern() { + if (patternInput.getItem(0).isEmpty() && patternOutput.getItem(0).isEmpty()) { + return false; + } + return switch (getPatternType()) { + case CRAFTING -> !craftingResult.getItem(0).isEmpty(); + default -> false; + }; + } + + @Override + public void onScreenReady(final int playerInventoryY) { + super.onScreenReady(playerInventoryY); + transferManager.clear(); + addPatternSlots(playerInventoryY); + addCraftingMatrixSlots(playerInventoryY); + } + + private void addPatternSlots(final int playerInventoryY) { + addSlot(new ValidatedSlot( + patternInput, + 0, + 152, + playerInventoryY - Y_OFFSET_BETWEEN_PLAYER_INVENTORY_AND_PATTERN_INPUT_SLOT, + PatternGridBlockEntity::isValidPattern + )); + addSlot(new ValidatedSlot( + patternOutput, + 0, + 152, + playerInventoryY + - Y_OFFSET_BETWEEN_PLAYER_INVENTORY_AND_PATTERN_INPUT_SLOT + + SPACING_BETWEEN_PATTERN_INPUT_AND_PATTERN_OUTPUT_SLOTS, + PatternGridBlockEntity::isValidPattern + ) { + @Override + public boolean mayPlace(final ItemStack stack) { + return patternOutput.canPlaceItem(0, stack); + } + + @Override + public void set(final ItemStack stack) { + super.set(stack); + if (patternGrid != null && !stack.isEmpty()) { + patternGrid.copyPattern(stack); + } + } + }); + transferManager.addBiTransfer(playerInventory, patternInput); + transferManager.addTransfer(patternOutput, playerInventory); + } + + private void addCraftingMatrixSlots(final int playerInventoryY) { + for (int y = 0; y < 3; ++y) { + for (int x = 0; x < 3; ++x) { + final int slotX = 12 + ((x % 3) * 18); + final int slotY = playerInventoryY + - Y_OFFSET_BETWEEN_PLAYER_INVENTORY_AND_FIRST_CRAFTING_MATRIX_SLOT + + ((y % 3) * 18); + addSlot(new FilterSlot(craftingMatrix, x + y * 3, slotX, slotY) { + @Override + public boolean isActive() { + return getPatternType() == PatternType.CRAFTING; + } + }); + } + } + // TODO: other fuzzy mode tooltips are wrong? + addSlot(new DisabledSlot( + craftingResult, + 0, + 116 + 4, + playerInventoryY - Y_OFFSET_BETWEEN_PLAYER_INVENTORY_AND_FIRST_CRAFTING_MATRIX_SLOT + 18 + ) { + @Override + public boolean isActive() { + return getPatternType() == PatternType.CRAFTING; + } + }); + } + + public void clear() { + if (patternGrid != null) { + patternGrid.clear(); + } + } + + void sendClear() { + C2SPackets.sendPatternGridClear(); + } + + public void createPattern() { + if (patternGrid != null) { + patternGrid.createPattern(); + } + } + + void sendCreatePattern() { + C2SPackets.sendPatternGridCreatePattern(); + } + + interface PatternGridListener { + void patternTypeChanged(PatternType value); + + void fuzzyModeChanged(boolean value); + } +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridData.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridData.java new file mode 100644 index 000000000..a04c8c6e7 --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridData.java @@ -0,0 +1,15 @@ +package com.refinedmods.refinedstorage.common.autocrafting; + +import com.refinedmods.refinedstorage.common.grid.GridData; +import com.refinedmods.refinedstorage.common.util.PacketUtil; + +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; + +public record PatternGridData(GridData gridData, PatternType patternType) { + public static final StreamCodec STREAM_CODEC = StreamCodec.composite( + GridData.STREAM_CODEC, PatternGridData::gridData, + PacketUtil.enumStreamCodec(PatternType.values()), PatternGridData::patternType, + PatternGridData::new + ); +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridPropertyTypes.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridPropertyTypes.java new file mode 100644 index 000000000..513cb0552 --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridPropertyTypes.java @@ -0,0 +1,16 @@ +package com.refinedmods.refinedstorage.common.autocrafting; + +import com.refinedmods.refinedstorage.common.support.containermenu.PropertyType; + +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; + +final class PatternGridPropertyTypes { + static final PropertyType PATTERN_TYPE = new PropertyType<>( + createIdentifier("pattern_type"), + PatternTypeSettings::getPatternType, + PatternTypeSettings::getPatternType + ); + + private PatternGridPropertyTypes() { + } +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridScreen.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridScreen.java new file mode 100644 index 000000000..522c1b84c --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridScreen.java @@ -0,0 +1,174 @@ +package com.refinedmods.refinedstorage.common.autocrafting; + +import com.refinedmods.refinedstorage.common.grid.screen.AbstractGridScreen; +import com.refinedmods.refinedstorage.common.support.widget.CustomCheckboxWidget; +import com.refinedmods.refinedstorage.common.support.widget.HoveredImageButton; + +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Nullable; + +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.Button; +import net.minecraft.client.gui.components.ImageButton; +import net.minecraft.client.gui.components.Tooltip; +import net.minecraft.client.gui.components.WidgetSprites; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Inventory; + +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createTranslation; + +public class PatternGridScreen extends AbstractGridScreen { + private static final ResourceLocation TEXTURE = createIdentifier("textures/gui/pattern_grid.png"); + private static final MutableComponent CREATE_PATTERN = createTranslation("gui", "pattern_grid.create_pattern"); + private static final MutableComponent CLEAR = createTranslation("gui", "pattern_grid.clear"); + private static final MutableComponent FUZZY_MODE = createTranslation("gui", "pattern_grid.fuzzy_mode"); + private static final MutableComponent FUZZY_MODE_ON_HELP = + createTranslation("gui", "pattern_grid.fuzzy_mode.on.help"); + private static final MutableComponent FUZZY_MODE_OFF_HELP = + createTranslation("gui", "pattern_grid.fuzzy_mode.off.help"); + private static final int CREATE_PATTERN_BUTTON_SIZE = 16; + + private static final WidgetSprites CREATE_PATTERN_BUTTON_SPRITES = new WidgetSprites( + createIdentifier("widget/create_pattern"), + createIdentifier("widget/create_pattern_disabled"), + createIdentifier("widget/create_pattern_focused"), + createIdentifier("widget/create_pattern_disabled") + ); + private static final WidgetSprites CLEAR_BUTTON_SPRITES = new WidgetSprites( + createIdentifier("widget/clear"), + createIdentifier("widget/clear_disabled"), + createIdentifier("widget/clear_focused"), + createIdentifier("widget/clear_disabled") + ); + private static final ResourceLocation CRAFTING = createIdentifier("pattern_grid/crafting"); + + @Nullable + private Button createPatternButton; + + private final Map patternTypeButtons = new HashMap<>(); + + public PatternGridScreen(final PatternGridContainerMenu menu, final Inventory inventory, final Component title) { + super(menu, inventory, title, 177); + this.inventoryLabelY = 153; + this.imageWidth = 193; + this.imageHeight = 250; + } + + @Override + protected void init() { + super.init(); + createPatternButton = createCreatePatternButton(leftPos + 152, topPos + imageHeight - bottomHeight + 32); + addRenderableWidget(createPatternButton); + final ImageButton clearButton = createClearButton(leftPos + 68, topPos + imageHeight - bottomHeight + 8); + addRenderableWidget(clearButton); + addPatternTypeButtons(getMenu().getPatternType()); + final CustomCheckboxWidget fuzzyMode = createFuzzyModeCheckbox(); + addRenderableWidget(fuzzyMode); + menu.setListener(new PatternGridContainerMenu.PatternGridListener() { + @Override + public void patternTypeChanged(final PatternType value) { + patternTypeButtons.values().forEach(button -> button.setSelected(false)); + patternTypeButtons.get(value).setSelected(true); + fuzzyMode.visible = value == PatternType.CRAFTING; + clearButton.visible = value == PatternType.CRAFTING; + } + + @Override + public void fuzzyModeChanged(final boolean value) { + fuzzyMode.setSelected(value); + fuzzyMode.setTooltip(getFuzzyModeTooltip(value)); + } + }); + } + + private void addPatternTypeButtons(final PatternType currentPatternType) { + final PatternType[] patternTypes = PatternType.values(); + for (int i = 0; i < patternTypes.length; ++i) { + final PatternType patternType = patternTypes[i]; + final PatternTypeButton button = new PatternTypeButton( + leftPos + 172, + topPos + imageHeight - bottomHeight + 4 + (i * (16 + 3)), + btn -> getMenu().setPatternType(patternType), + patternType, + patternType == currentPatternType + ); + patternTypeButtons.put(patternType, button); + addRenderableWidget(button); + } + } + + @Override + protected void containerTick() { + super.containerTick(); + if (createPatternButton != null) { + createPatternButton.active = getMenu().canCreatePattern(); + } + } + + private CustomCheckboxWidget createFuzzyModeCheckbox() { + final CustomCheckboxWidget fuzzyMode = new CustomCheckboxWidget( + leftPos + 11, + topPos + imageHeight - bottomHeight + 65, + FUZZY_MODE, + font, + getMenu().isFuzzyMode(), + CustomCheckboxWidget.Size.SMALL + ); + fuzzyMode.setOnPressed((checkbox, selected) -> getMenu().setFuzzyMode(selected)); + fuzzyMode.setTooltip(getFuzzyModeTooltip(getMenu().isFuzzyMode())); + fuzzyMode.visible = getMenu().getPatternType() == PatternType.CRAFTING; + return fuzzyMode; + } + + private static Tooltip getFuzzyModeTooltip(final boolean fuzzyMode) { + return fuzzyMode ? Tooltip.create(FUZZY_MODE_ON_HELP) : Tooltip.create(FUZZY_MODE_OFF_HELP); + } + + private ImageButton createCreatePatternButton(final int x, final int y) { + final HoveredImageButton button = new HoveredImageButton( + x, + y, + CREATE_PATTERN_BUTTON_SIZE, + CREATE_PATTERN_BUTTON_SIZE, + CREATE_PATTERN_BUTTON_SPRITES, + b -> getMenu().sendCreatePattern(), + CREATE_PATTERN + ); + button.setTooltip(Tooltip.create(CREATE_PATTERN)); + button.active = getMenu().canCreatePattern(); + return button; + } + + private ImageButton createClearButton(final int x, final int y) { + final HoveredImageButton button = new HoveredImageButton( + x, + y, + CLEAR_BUTTON_SIZE, + CLEAR_BUTTON_SIZE, + CLEAR_BUTTON_SPRITES, + b -> getMenu().sendClear(), + CLEAR + ); + button.setTooltip(Tooltip.create(CLEAR)); + button.visible = getMenu().getPatternType() == PatternType.CRAFTING; + return button; + } + + @Override + protected void renderBg(final GuiGraphics graphics, final float delta, final int mouseX, final int mouseY) { + super.renderBg(graphics, delta, mouseX, mouseY); + switch (getMenu().getPatternType()) { + case CRAFTING -> + graphics.blitSprite(CRAFTING, leftPos + 7 + 4, topPos + imageHeight - bottomHeight + 4 + 4, 130, 54); + } + } + + @Override + protected ResourceLocation getTexture() { + return TEXTURE; + } +} 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 new file mode 100644 index 000000000..4fbe8fc75 --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternItem.java @@ -0,0 +1,220 @@ +package com.refinedmods.refinedstorage.common.autocrafting; + +import com.refinedmods.refinedstorage.api.resource.ResourceAmount; +import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.autocrafting.CraftingPattern; +import com.refinedmods.refinedstorage.common.api.autocrafting.Pattern; +import com.refinedmods.refinedstorage.common.api.autocrafting.PatternProviderItem; +import com.refinedmods.refinedstorage.common.api.support.HelpTooltipComponent; +import com.refinedmods.refinedstorage.common.api.support.resource.PlatformResourceKey; +import com.refinedmods.refinedstorage.common.content.DataComponents; +import com.refinedmods.refinedstorage.common.content.Items; +import com.refinedmods.refinedstorage.common.support.CraftingMatrix; +import com.refinedmods.refinedstorage.common.support.resource.ItemResource; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.UUID; +import javax.annotation.Nullable; + +import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.tooltip.TooltipComponent; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.TooltipFlag; +import net.minecraft.world.item.crafting.CraftingInput; +import net.minecraft.world.item.crafting.CraftingRecipe; +import net.minecraft.world.item.crafting.RecipeHolder; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.level.Level; + +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createTranslation; +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createTranslationKey; + +public class PatternItem extends Item implements PatternProviderItem { + private static final Component HELP = createTranslation("item", "pattern.help"); + private static final MutableComponent FUZZY_MODE = createTranslation("item", "pattern.fuzzy_mode") + .withStyle(ChatFormatting.YELLOW); + + public PatternItem() { + super(new Item.Properties()); + } + + @Override + public String getDescriptionId(final ItemStack stack) { + final PatternState state = stack.get(DataComponents.INSTANCE.getPatternState()); + if (state != null) { + return createTranslationKey("misc", "pattern." + state.type().getSerializedName()); + } + return super.getDescriptionId(stack); + } + + @Override + public void appendHoverText(final ItemStack stack, + final TooltipContext context, + final List lines, + final TooltipFlag tooltipFlag) { + super.appendHoverText(stack, context, lines, tooltipFlag); + final PatternState state = stack.get(DataComponents.INSTANCE.getPatternState()); + if (state == null) { + return; + } + final CraftingPatternState craftingState = stack.get(DataComponents.INSTANCE.getCraftingPatternState()); + if (craftingState != null && craftingState.fuzzyMode()) { + lines.add(FUZZY_MODE); + } + } + + boolean hasMapping(final ItemStack stack) { + return stack.has(DataComponents.INSTANCE.getPatternState()); + } + + @Override + public Optional getTooltipImage(final ItemStack stack) { + final PatternState state = stack.get(DataComponents.INSTANCE.getPatternState()); + if (state == null) { + return Optional.of(new HelpTooltipComponent(HELP)); + } + return switch (state.type()) { + case CRAFTING -> { + final CraftingPatternState craftingState = stack.get(DataComponents.INSTANCE.getCraftingPatternState()); + final Level level = Minecraft.getInstance().level; + if (craftingState == null || level == null) { + yield Optional.empty(); + } + yield RefinedStorageApi.INSTANCE.getPattern(stack, level) + .filter(CraftingPattern.class::isInstance) + .map(CraftingPattern.class::cast) + .map(craftingPattern -> new CraftingPatternTooltipComponent( + HELP, + craftingPattern, + craftingState.input().input().width(), + craftingState.input().input().height() + )); + } + default -> Optional.empty(); + }; + } + + @Nullable + @Override + public UUID getId(final ItemStack stack) { + final PatternState state = stack.get(DataComponents.INSTANCE.getPatternState()); + if (state == null) { + return null; + } + return state.id(); + } + + @Override + public Optional getPattern(final ItemStack stack, final Level level) { + final PatternState state = stack.get(DataComponents.INSTANCE.getPatternState()); + if (state == null) { + return Optional.empty(); + } + return switch (state.type()) { + case CRAFTING -> getCraftingPattern(stack, level); + default -> Optional.empty(); + }; + } + + private Optional getCraftingPattern(final ItemStack stack, final Level level) { + final CraftingPatternState craftingState = stack.get(DataComponents.INSTANCE.getCraftingPatternState()); + if (craftingState == null) { + return Optional.empty(); + } + return getCraftingPattern(level, craftingState); + } + + private Optional getCraftingPattern(final Level level, final CraftingPatternState state) { + final CraftingMatrix craftingMatrix = getFilledCraftingMatrix(state); + final CraftingInput.Positioned positionedCraftingInput = craftingMatrix.asPositionedCraftInput(); + final CraftingInput craftingInput = positionedCraftingInput.input(); + return level.getRecipeManager() + .getRecipeFor(RecipeType.CRAFTING, craftingInput, level) + .map(RecipeHolder::value) + .map(recipe -> toCraftingPattern(level, recipe, craftingInput, state)); + } + + private CraftingMatrix getFilledCraftingMatrix(final CraftingPatternState state) { + final CraftingInput.Positioned positionedInput = state.input(); + final CraftingInput input = positionedInput.input(); + final CraftingMatrix craftingMatrix = new CraftingMatrix(null, input.width(), input.height()); + for (int i = 0; i < input.size(); ++i) { + craftingMatrix.setItem(i, input.getItem(i)); + } + return craftingMatrix; + } + + private CraftingPattern toCraftingPattern(final Level level, + final CraftingRecipe recipe, + final CraftingInput craftingInput, + final CraftingPatternState state) { + final List> inputs = getInputs(recipe, state); + final ResourceAmount output = getOutput(level, recipe, craftingInput); + final List byproducts = getByproducts(recipe, craftingInput); + return new CraftingPattern(inputs, output, byproducts); + } + + private List> getInputs(final CraftingRecipe recipe, final CraftingPatternState state) { + final List> inputs = new ArrayList<>(); + for (int i = 0; i < state.input().input().size(); ++i) { + final ItemStack input = state.input().input().getItem(i); + if (input.isEmpty()) { + inputs.add(Collections.emptyList()); + } else if (state.fuzzyMode() && i < recipe.getIngredients().size()) { + final ItemStack[] ingredients = recipe.getIngredients().get(i).getItems(); + inputs.add(Arrays.stream(ingredients) + .map(item -> (PlatformResourceKey) ItemResource.ofItemStack(item)) + .toList()); + } else { + inputs.add(List.of(ItemResource.ofItemStack(input))); + } + } + return inputs; + } + + private ResourceAmount getOutput(final Level level, + final CraftingRecipe recipe, + final CraftingInput craftingInput) { + final ItemStack outputStack = recipe.assemble(craftingInput, level.registryAccess()); + return new ResourceAmount(ItemResource.ofItemStack(outputStack), outputStack.getCount()); + } + + private List getByproducts(final CraftingRecipe recipe, final CraftingInput craftingInput) { + return recipe.getRemainingItems(craftingInput) + .stream() + .filter(byproduct -> !byproduct.isEmpty()) + .map(byproduct -> new ResourceAmount(ItemResource.ofItemStack(byproduct), byproduct.getCount())) + .toList(); + } + + @Override + public InteractionResultHolder use(final Level level, final Player player, final InteractionHand hand) { + final ItemStack stack = player.getItemInHand(hand); + if (!level.isClientSide() && player.isCrouching()) { + return new InteractionResultHolder<>( + InteractionResult.CONSUME, + new ItemStack(Items.INSTANCE.getPattern(), stack.getCount()) + ); + } + return new InteractionResultHolder<>(InteractionResult.PASS, stack); + } + + public record CraftingPatternTooltipComponent(Component helpText, + CraftingPattern craftingPattern, + int width, + int height) + implements TooltipComponent { + } +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternItemColor.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternItemColor.java new file mode 100644 index 000000000..31a82255c --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternItemColor.java @@ -0,0 +1,18 @@ +package com.refinedmods.refinedstorage.common.autocrafting; + +import com.refinedmods.refinedstorage.common.Platform; + +import net.minecraft.client.color.item.ItemColor; +import net.minecraft.world.item.ItemStack; + +public class PatternItemColor implements ItemColor { + @Override + public int getColor(final ItemStack stack, final int tintIndex) { + if (PatternRendering.canDisplayOutput(stack)) { + return PatternRendering.getOutput(stack).map( + output -> Platform.INSTANCE.getItemColor(output, tintIndex) + ).orElse(-1); + } + return -1; + } +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternItemOverrides.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternItemOverrides.java new file mode 100644 index 000000000..faf433d82 --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternItemOverrides.java @@ -0,0 +1,57 @@ +package com.refinedmods.refinedstorage.common.autocrafting; + +import com.refinedmods.refinedstorage.common.content.DataComponents; + +import java.util.List; +import java.util.Optional; +import javax.annotation.Nullable; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.ModelBaker; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.ItemStack; + +public class PatternItemOverrides extends ItemOverrides { + private final BakedModel emptyModel; + private final BakedModel craftingModel; + + @SuppressWarnings({"DataFlowIssue"}) // null is allowed as long as we don't pass overrides + public PatternItemOverrides(final ModelBaker modelBaker, + final BakedModel emptyModel, + final BakedModel craftingModel) { + super(modelBaker, null, List.of()); + this.emptyModel = emptyModel; + this.craftingModel = craftingModel; + } + + @Override + public BakedModel resolve(final BakedModel model, + final ItemStack stack, + @Nullable final ClientLevel level, + @Nullable final LivingEntity entity, + final int seed) { + final PatternState state = stack.get(DataComponents.INSTANCE.getPatternState()); + if (state == null) { + return emptyModel; + } + if (state.type() == PatternType.CRAFTING) { + return getCraftingOutputModel(stack, level, entity, seed).orElse(craftingModel); + } + return emptyModel; + } + + private Optional getCraftingOutputModel(final ItemStack stack, + @Nullable final ClientLevel level, + @Nullable final LivingEntity entity, + final int seed) { + if (PatternRendering.canDisplayOutput(stack)) { + return PatternRendering.getOutput(stack).map( + output -> Minecraft.getInstance().getItemRenderer().getModel(output, level, entity, seed) + ); + } + return Optional.empty(); + } +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternOutputContainer.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternOutputContainer.java new file mode 100644 index 000000000..8a83d878a --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternOutputContainer.java @@ -0,0 +1,21 @@ +package com.refinedmods.refinedstorage.common.autocrafting; + +import com.refinedmods.refinedstorage.common.support.FilteredContainer; + +import net.minecraft.world.item.ItemStack; + +class PatternOutputContainer extends FilteredContainer { + PatternOutputContainer() { + super(1, PatternGridBlockEntity::isValidPattern); + } + + @Override + public int getMaxStackSize() { + return 1; + } + + @Override + public boolean canPlaceItem(final int slot, final ItemStack stack) { + return stack.getItem() instanceof PatternItem patternItem && patternItem.hasMapping(stack); + } +} 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 new file mode 100644 index 000000000..15f287ab8 --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternRendering.java @@ -0,0 +1,38 @@ +package com.refinedmods.refinedstorage.common.autocrafting; + +import com.refinedmods.refinedstorage.api.resource.ResourceAmount; +import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.autocrafting.CraftingPattern; +import com.refinedmods.refinedstorage.common.api.autocrafting.PatternProviderItem; +import com.refinedmods.refinedstorage.common.support.resource.ItemResource; + +import java.util.Optional; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; + +public final class PatternRendering { + private PatternRendering() { + } + + public static boolean canDisplayOutput(final ItemStack stack) { + return stack.getItem() instanceof PatternProviderItem && Screen.hasShiftDown(); + } + + public static Optional getOutput(final ItemStack stack) { + final Level level = Minecraft.getInstance().level; + if (level == null) { + return Optional.empty(); + } + return RefinedStorageApi.INSTANCE.getPattern(stack, level) + .filter(CraftingPattern.class::isInstance) + .map(CraftingPattern.class::cast) + .map(CraftingPattern::output) + .map(ResourceAmount::getResource) + .filter(ItemResource.class::isInstance) + .map(ItemResource.class::cast) + .map(ItemResource::toItemStack); + } +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternState.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternState.java new file mode 100644 index 000000000..1e8a7b3f4 --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternState.java @@ -0,0 +1,25 @@ +package com.refinedmods.refinedstorage.common.autocrafting; + +import com.refinedmods.refinedstorage.common.util.PacketUtil; + +import java.util.UUID; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.core.UUIDUtil; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; + +public record PatternState(UUID id, PatternType type) { + public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( + UUIDUtil.CODEC.fieldOf("id").forGetter(PatternState::id), + PatternType.CODEC.fieldOf("type").forGetter(PatternState::type) + ).apply(instance, PatternState::new)); + + public static final StreamCodec STREAM_CODEC = + StreamCodec.composite( + UUIDUtil.STREAM_CODEC, PatternState::id, + PacketUtil.enumStreamCodec(PatternType.values()), PatternState::type, + PatternState::new + ); +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternType.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternType.java new file mode 100644 index 000000000..6514821b2 --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternType.java @@ -0,0 +1,43 @@ +package com.refinedmods.refinedstorage.common.autocrafting; + +import com.mojang.serialization.Codec; +import net.minecraft.network.chat.Component; +import net.minecraft.util.StringRepresentable; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; + +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createTranslation; + +// TODO: remove widgets.png +// TODO: remove other unused textures, and rename icons.png to side_buttons.png +public enum PatternType implements StringRepresentable { + CRAFTING(Items.CRAFTING_TABLE.getDefaultInstance(), "crafting"), + PROCESSING(Items.FURNACE.getDefaultInstance(), "processing"), + STONECUTTER(Items.STONECUTTER.getDefaultInstance(), "stonecutter"), + SMITHING_TABLE(Items.SMITHING_TABLE.getDefaultInstance(), "smithing_table"); + + public static final Codec CODEC = StringRepresentable.fromValues(PatternType::values); + + private final ItemStack stack; + private final String name; + private final Component translatedName; + + PatternType(final ItemStack stack, final String name) { + this.stack = stack; + this.name = name; + this.translatedName = createTranslation("misc", "pattern." + name); + } + + ItemStack getStack() { + return stack; + } + + Component getTranslatedName() { + return translatedName; + } + + @Override + public String getSerializedName() { + return name; + } +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternTypeButton.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternTypeButton.java new file mode 100644 index 000000000..949c06284 --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternTypeButton.java @@ -0,0 +1,44 @@ +package com.refinedmods.refinedstorage.common.autocrafting; + +import com.refinedmods.refinedstorage.common.support.widget.HoveredImageButton; + +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.Tooltip; +import net.minecraft.client.gui.components.WidgetSprites; +import net.minecraft.resources.ResourceLocation; + +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; + +class PatternTypeButton extends HoveredImageButton { + private static final WidgetSprites SPRITES = new WidgetSprites( + createIdentifier("widget/generic_small_button"), + createIdentifier("widget/generic_small_button_disabled"), + createIdentifier("widget/generic_small_button_focused"), + createIdentifier("widget/generic_small_button_disabled") + ); + + private final PatternType patternType; + private boolean selected; + + PatternTypeButton(final int x, + final int y, + final OnPress onPress, + final PatternType patternType, + final boolean selected) { + super(x, y, 16, 16, SPRITES, onPress, patternType.getTranslatedName()); + this.patternType = patternType; + this.selected = selected; + this.setTooltip(Tooltip.create(patternType.getTranslatedName())); + } + + void setSelected(final boolean selected) { + this.selected = selected; + } + + @Override + public void renderWidget(final GuiGraphics graphics, final int x, final int y, final float partialTicks) { + final ResourceLocation location = sprites.get(isActive(), isHovered() || selected); + graphics.blitSprite(location, getX(), getY(), width, height); + graphics.renderItem(patternType.getStack(), getX(), getY()); + } +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternTypeSettings.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternTypeSettings.java new file mode 100644 index 000000000..3339b0ca4 --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternTypeSettings.java @@ -0,0 +1,29 @@ +package com.refinedmods.refinedstorage.common.autocrafting; + +class PatternTypeSettings { + private static final int CRAFTING = 0; + private static final int PROCESSING = 1; + private static final int STONECUTTER = 2; + private static final int SMITHING_TABLE = 3; + + private PatternTypeSettings() { + } + + public static PatternType getPatternType(final int patternType) { + return switch (patternType) { + case PROCESSING -> PatternType.PROCESSING; + case STONECUTTER -> PatternType.STONECUTTER; + case SMITHING_TABLE -> PatternType.SMITHING_TABLE; + default -> PatternType.CRAFTING; + }; + } + + public static int getPatternType(final PatternType patternType) { + return switch (patternType) { + case CRAFTING -> CRAFTING; + case PROCESSING -> PROCESSING; + case STONECUTTER -> STONECUTTER; + case SMITHING_TABLE -> SMITHING_TABLE; + }; + } +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/package-info.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/package-info.java new file mode 100644 index 000000000..194c7d0ac --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/package-info.java @@ -0,0 +1,7 @@ +@ParametersAreNonnullByDefault +@FieldsAndMethodsAreNonnullByDefault +package com.refinedmods.refinedstorage.common.autocrafting; + +import com.refinedmods.refinedstorage.api.core.FieldsAndMethodsAreNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; 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 35b5a0801..52cbb5070 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 @@ -1,6 +1,7 @@ package com.refinedmods.refinedstorage.common.content; import com.refinedmods.refinedstorage.api.network.impl.node.SimpleNetworkNode; +import com.refinedmods.refinedstorage.common.autocrafting.PatternGridBlockEntity; import com.refinedmods.refinedstorage.common.constructordestructor.ConstructorBlockEntity; import com.refinedmods.refinedstorage.common.constructordestructor.DestructorBlockEntity; import com.refinedmods.refinedstorage.common.controller.ControllerBlockEntity; @@ -47,6 +48,8 @@ public final class BlockEntities { @Nullable private Supplier> craftingGrid; @Nullable + private Supplier> patternGrid; + @Nullable private Supplier> controller; @Nullable private Supplier> creativeController; @@ -124,6 +127,14 @@ public void setCraftingGrid(final Supplier getPatternGrid() { + return requireNonNull(patternGrid).get(); + } + + public void setPatternGrid(final Supplier> supplier) { + this.patternGrid = supplier; + } + public BlockEntityType getController() { return requireNonNull(controller).get(); } 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 1ad8a5c1e..2f9eaf37f 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 @@ -1,5 +1,6 @@ package com.refinedmods.refinedstorage.common.content; +import com.refinedmods.refinedstorage.common.autocrafting.PatternGridBlock; import com.refinedmods.refinedstorage.common.constructordestructor.ConstructorBlock; import com.refinedmods.refinedstorage.common.constructordestructor.DestructorBlock; import com.refinedmods.refinedstorage.common.controller.AbstractControllerBlock; @@ -68,6 +69,12 @@ public final class Blocks { ContentNames.CRAFTING_GRID, COLOR ); + private final BlockColorMap patternGrid = new BlockColorMap<>( + PatternGridBlock::new, + ContentIds.PATTERN_GRID, + ContentNames.PATTERN_GRID, + COLOR + ); private final BlockColorMap detector = new BlockColorMap<>( DetectorBlock::new, ContentIds.DETECTOR, @@ -211,6 +218,10 @@ public BlockColorMap getCraftingGrid() { return craftingGrid; } + public BlockColorMap getPatternGrid() { + return patternGrid; + } + public BlockColorMap, ControllerBlockItem> getController() { return controller; } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/ContentIds.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/ContentIds.java index e49c5a4aa..644e76bb6 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/ContentIds.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/ContentIds.java @@ -24,6 +24,7 @@ public final class ContentIds { public static final ResourceLocation STORAGE_HOUSING = createIdentifier("storage_housing"); public static final ResourceLocation GRID = createIdentifier("grid"); public static final ResourceLocation CRAFTING_GRID = createIdentifier("crafting_grid"); + public static final ResourceLocation PATTERN_GRID = createIdentifier("pattern_grid"); public static final ResourceLocation CONTROLLER = createIdentifier("controller"); public static final ResourceLocation CREATIVE_CONTROLLER = createIdentifier("creative_controller"); public static final ResourceLocation CONSTRUCTION_CORE = createIdentifier("construction_core"); @@ -63,6 +64,7 @@ public final class ContentIds { public static final ResourceLocation SECURITY_MANAGER = createIdentifier("security_manager"); public static final ResourceLocation RELAY = createIdentifier("relay"); public static final ResourceLocation DISK_INTERFACE = createIdentifier("disk_interface"); + public static final ResourceLocation PATTERN = createIdentifier("pattern"); private ContentIds() { } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/ContentNames.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/ContentNames.java index 15dbaf974..8eecbe198 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/ContentNames.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/ContentNames.java @@ -14,6 +14,7 @@ public final class ContentNames { public static final MutableComponent CABLE = name("cable"); public static final MutableComponent GRID = name("grid"); public static final MutableComponent CRAFTING_GRID = name("crafting_grid"); + public static final MutableComponent PATTERN_GRID = name("pattern_grid"); public static final MutableComponent DETECTOR = name("detector"); public static final MutableComponent IMPORTER = name("importer"); public static final MutableComponent EXPORTER = name("exporter"); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/CreativeModeTabItems.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/CreativeModeTabItems.java index 25c381fca..8c2156f1b 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/CreativeModeTabItems.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/CreativeModeTabItems.java @@ -37,6 +37,7 @@ private static void appendBlocks(final Consumer consumer) { itemConsumer.accept(Blocks.INSTANCE.getDiskDrive()); appendBlockColors(consumer, Blocks.INSTANCE.getGrid()); appendBlockColors(consumer, Blocks.INSTANCE.getCraftingGrid()); + appendBlockColors(consumer, Blocks.INSTANCE.getPatternGrid()); itemConsumer.accept(Items.INSTANCE.getPortableGrid()); consumer.accept(Items.INSTANCE.getPortableGrid().createAtEnergyCapacity()); itemConsumer.accept(Items.INSTANCE.getCreativePortableGrid()); @@ -110,5 +111,6 @@ private static void appendItems(final Consumer consumer) { itemConsumer.accept(Items.INSTANCE.getNetworkCard()); itemConsumer.accept(Items.INSTANCE.getSecurityCard()); itemConsumer.accept(Items.INSTANCE.getFallbackSecurityCard()); + itemConsumer.accept(Items.INSTANCE.getPattern()); } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/DataComponents.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/DataComponents.java index 5f8746eb6..47dfd40fd 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/DataComponents.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/DataComponents.java @@ -1,5 +1,7 @@ package com.refinedmods.refinedstorage.common.content; +import com.refinedmods.refinedstorage.common.autocrafting.CraftingPatternState; +import com.refinedmods.refinedstorage.common.autocrafting.PatternState; import com.refinedmods.refinedstorage.common.configurationcard.ConfigurationCardState; import com.refinedmods.refinedstorage.common.security.SecurityCardBoundPlayer; import com.refinedmods.refinedstorage.common.security.SecurityCardPermissions; @@ -31,6 +33,10 @@ public final class DataComponents { private Supplier> securityCardPermissions; @Nullable private Supplier> configurationCardState; + @Nullable + private Supplier> patternState; + @Nullable + private Supplier> craftingPatternState; private DataComponents() { } @@ -96,4 +102,24 @@ public void setConfigurationCardState( ) { this.configurationCardState = supplier; } + + public DataComponentType getPatternState() { + return requireNonNull(patternState).get(); + } + + public void setPatternState( + @Nullable final Supplier> supplier + ) { + this.patternState = supplier; + } + + public DataComponentType getCraftingPatternState() { + return requireNonNull(craftingPatternState).get(); + } + + public void setCraftingPatternState( + @Nullable final Supplier> supplier + ) { + this.craftingPatternState = supplier; + } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/DefaultEnergyUsage.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/DefaultEnergyUsage.java index 01a3e8648..00b51eed3 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/DefaultEnergyUsage.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/DefaultEnergyUsage.java @@ -8,6 +8,7 @@ public final class DefaultEnergyUsage { public static final long EXTERNAL_STORAGE = 6; public static final long DETECTOR = 2; public static final long GRID = 10; + public static final long PATTERN_GRID = 14; public static final long CRAFTING_GRID = 14; public static final long DISK_DRIVE = 10; public static final long DISK_DRIVE_PER_DISK = 4; diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/Items.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/Items.java index 48d1f51f9..ed2b1723e 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/Items.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/Items.java @@ -1,6 +1,7 @@ package com.refinedmods.refinedstorage.common.content; import com.refinedmods.refinedstorage.common.api.upgrade.AbstractUpgradeItem; +import com.refinedmods.refinedstorage.common.autocrafting.PatternItem; import com.refinedmods.refinedstorage.common.controller.ControllerBlockItem; import com.refinedmods.refinedstorage.common.controller.CreativeControllerBlockItem; import com.refinedmods.refinedstorage.common.grid.WirelessGridItem; @@ -103,6 +104,8 @@ public final class Items { private Supplier securityCard; @Nullable private Supplier fallbackSecurityCard; + @Nullable + private Supplier pattern; private Items() { } @@ -474,4 +477,12 @@ public FallbackSecurityCardItem getFallbackSecurityCard() { public void setFallbackSecurityCard(final Supplier fallbackSecurityCard) { this.fallbackSecurityCard = fallbackSecurityCard; } + + public PatternItem getPattern() { + return requireNonNull(pattern).get(); + } + + public void setPattern(final Supplier supplier) { + this.pattern = supplier; + } } 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 e314602ff..b4c7642a2 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 @@ -1,5 +1,6 @@ package com.refinedmods.refinedstorage.common.content; +import com.refinedmods.refinedstorage.common.autocrafting.PatternGridContainerMenu; import com.refinedmods.refinedstorage.common.constructordestructor.ConstructorContainerMenu; import com.refinedmods.refinedstorage.common.constructordestructor.DestructorContainerMenu; import com.refinedmods.refinedstorage.common.controller.ControllerContainerMenu; @@ -43,6 +44,8 @@ public final class Menus { @Nullable private Supplier> craftingGrid; @Nullable + private Supplier> patternGrid; + @Nullable private Supplier> wirelessGrid; @Nullable private Supplier> controller; @@ -106,6 +109,14 @@ public void setCraftingGrid(final Supplier> this.craftingGrid = supplier; } + public MenuType getPatternGrid() { + return requireNonNull(patternGrid).get(); + } + + public void setPatternGrid(final Supplier> supplier) { + this.patternGrid = supplier; + } + public MenuType getWirelessGrid() { return requireNonNull(wirelessGrid).get(); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/Tags.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/Tags.java index ce7b848c9..06509a2ba 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/Tags.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/Tags.java @@ -13,6 +13,7 @@ public final class Tags { public static final TagKey FLUID_STORAGE_DISKS = createTag("fluid_storage_disks"); public static final TagKey GRIDS = createTag("grids"); public static final TagKey CRAFTING_GRIDS = createTag("crafting_grids"); + public static final TagKey PATTERN_GRIDS = createTag("pattern_grids"); public static final TagKey STORAGE_DISKS = createTag("storage_disks"); public static final TagKey IMPORTERS = createTag("importers"); public static final TagKey EXPORTERS = createTag("exporters"); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/AbstractGridBlockEntity.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/AbstractGridBlockEntity.java index dc07da7c7..35872682a 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/AbstractGridBlockEntity.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/AbstractGridBlockEntity.java @@ -17,15 +17,12 @@ import com.refinedmods.refinedstorage.common.api.support.network.InWorldNetworkNodeContainer; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceType; import com.refinedmods.refinedstorage.common.support.AbstractDirectionalBlock; -import com.refinedmods.refinedstorage.common.support.containermenu.NetworkNodeExtendedMenuProvider; import com.refinedmods.refinedstorage.common.support.network.AbstractRedstoneModeNetworkNodeContainerBlockEntity; import com.refinedmods.refinedstorage.common.support.network.ColoredConnectionStrategy; import java.util.List; import net.minecraft.core.BlockPos; -import net.minecraft.network.RegistryFriendlyByteBuf; -import net.minecraft.network.codec.StreamEncoder; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; @@ -34,7 +31,7 @@ public abstract class AbstractGridBlockEntity extends AbstractRedstoneModeNetworkNodeContainerBlockEntity - implements Grid, NetworkNodeExtendedMenuProvider { + implements Grid { protected AbstractGridBlockEntity(final BlockEntityType type, final BlockPos pos, final BlockState state, @@ -50,16 +47,6 @@ protected InWorldNetworkNodeContainer createMainContainer(final GridNetworkNode .build(); } - @Override - public GridData getMenuData() { - return GridData.of(this); - } - - @Override - public StreamEncoder getMenuCodec() { - return GridData.STREAM_CODEC; - } - @Override public List getResources(final Class actorType) { return requireNonNull(mainNetworkNode.getNetwork()) diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/AbstractGridContainerMenu.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/AbstractGridContainerMenu.java index 9ef83b6c6..065c4f96e 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/AbstractGridContainerMenu.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/AbstractGridContainerMenu.java @@ -404,13 +404,15 @@ public boolean onTransfer(final int slotIndex) { @SuppressWarnings("resource") @Override public ItemStack quickMoveStack(final Player playerEntity, final int slotIndex) { - if (!playerEntity.level().isClientSide() && grid != null && grid.isGridActive()) { + if (transferManager.transfer(slotIndex)) { + return ItemStack.EMPTY; + } else if (!playerEntity.level().isClientSide() && grid != null && grid.isGridActive()) { final Slot slot = getSlot(slotIndex); if (slot.hasItem() && insertionStrategy != null && canTransferSlot(slot)) { insertionStrategy.onTransfer(slot.index); } } - return super.quickMoveStack(playerEntity, slotIndex); + return ItemStack.EMPTY; } protected boolean canTransferSlot(final Slot slot) { diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/ClientCraftingGridSource.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/ClientCraftingGridSource.java index 7a773bf5d..b86ac2e3a 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/ClientCraftingGridSource.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/ClientCraftingGridSource.java @@ -1,5 +1,6 @@ package com.refinedmods.refinedstorage.common.grid; +import com.refinedmods.refinedstorage.common.support.CraftingMatrix; import com.refinedmods.refinedstorage.common.support.packet.c2s.C2SPackets; import com.refinedmods.refinedstorage.common.support.resource.ItemResource; @@ -16,7 +17,7 @@ class ClientCraftingGridSource implements CraftingGridSource { private final ResultContainer craftingResult; ClientCraftingGridSource() { - this.craftingMatrix = new CraftingMatrix(null); + this.craftingMatrix = new CraftingMatrix(null, 3, 3); this.craftingResult = new ResultContainer(); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridBlockEntity.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridBlockEntity.java index af272ec47..08c5595c1 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridBlockEntity.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridBlockEntity.java @@ -9,8 +9,9 @@ import com.refinedmods.refinedstorage.common.content.BlockEntities; import com.refinedmods.refinedstorage.common.content.ContentNames; import com.refinedmods.refinedstorage.common.support.BlockEntityWithDrops; +import com.refinedmods.refinedstorage.common.support.CraftingMatrix; +import com.refinedmods.refinedstorage.common.support.containermenu.NetworkNodeExtendedMenuProvider; import com.refinedmods.refinedstorage.common.support.resource.ItemResource; -import com.refinedmods.refinedstorage.common.util.ContainerUtil; import java.util.Optional; import javax.annotation.Nullable; @@ -19,26 +20,20 @@ import net.minecraft.core.HolderLookup; import net.minecraft.core.NonNullList; import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.chat.Component; +import net.minecraft.network.codec.StreamEncoder; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.ResultContainer; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.CraftingInput; -import net.minecraft.world.item.crafting.CraftingRecipe; -import net.minecraft.world.item.crafting.RecipeHolder; -import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; -public class CraftingGridBlockEntity extends AbstractGridBlockEntity implements BlockEntityWithDrops { - private static final String TAG_CRAFTING_MATRIX = "matrix"; - - @Nullable - private CraftingRecipe currentRecipe; - - private final CraftingMatrix craftingMatrix = new CraftingMatrix(this::setOutput); - private final ResultContainer craftingResult = new ResultContainer(); +public class CraftingGridBlockEntity extends AbstractGridBlockEntity implements BlockEntityWithDrops, + NetworkNodeExtendedMenuProvider { + private final CraftingState craftingState = new CraftingState(this::setChanged, this::getLevel); public CraftingGridBlockEntity(final BlockPos pos, final BlockState state) { super( @@ -49,55 +44,26 @@ public CraftingGridBlockEntity(final BlockPos pos, final BlockState state) { ); } - private void setOutput() { - if (level == null) { - return; - } - setOutputSilently(level); - setChanged(); - } - - private void setOutputSilently(final Level level) { - if (level.isClientSide()) { - return; - } - final CraftingInput input = craftingMatrix.asCraftInput(); - if (currentRecipe == null || !currentRecipe.matches(input, level)) { - currentRecipe = loadRecipe(level); - } - if (currentRecipe == null) { - setResult(ItemStack.EMPTY); - } else { - setResult(currentRecipe.assemble(input, level.registryAccess())); - } - } - - private void setResult(final ItemStack result) { - craftingResult.setItem(0, result); + CraftingMatrix getCraftingMatrix() { + return craftingState.getCraftingMatrix(); } - @Nullable - private CraftingRecipe loadRecipe(final Level level) { - return level - .getRecipeManager() - .getRecipeFor(RecipeType.CRAFTING, craftingMatrix.asCraftInput(), level) - .map(RecipeHolder::value) - .orElse(null); + ResultContainer getCraftingResult() { + return craftingState.getCraftingResult(); } - CraftingMatrix getCraftingMatrix() { - return craftingMatrix; + NonNullList getRemainingItems(final Player player, final CraftingInput input) { + return craftingState.getRemainingItems(level, player, input); } - ResultContainer getCraftingResult() { - return craftingResult; + @Override + public GridData getMenuData() { + return GridData.of(this); } - NonNullList getRemainingItems(final Player player, final CraftingInput input) { - if (level == null || currentRecipe == null) { - return NonNullList.create(); - } - return Platform.INSTANCE.getRemainingCraftingItems(player, currentRecipe, input); + @Override + public StreamEncoder getMenuCodec() { + return GridData.STREAM_CODEC; } @Override @@ -114,28 +80,26 @@ public AbstractGridContainerMenu createMenu(final int syncId, final Inventory in @Override public void saveAdditional(final CompoundTag tag, final HolderLookup.Provider provider) { super.saveAdditional(tag, provider); - tag.put(TAG_CRAFTING_MATRIX, ContainerUtil.write(craftingMatrix, provider)); + craftingState.writeToTag(tag, provider); } @Override public void loadAdditional(final CompoundTag tag, final HolderLookup.Provider provider) { super.loadAdditional(tag, provider); - if (tag.contains(TAG_CRAFTING_MATRIX)) { - ContainerUtil.read(tag.getCompound(TAG_CRAFTING_MATRIX), craftingMatrix, provider); - } + craftingState.readFromTag(tag, provider); } @Override public void setLevel(final Level level) { super.setLevel(level); - setOutputSilently(level); + craftingState.updateResult(level); } @Override public NonNullList getDrops() { final NonNullList drops = NonNullList.create(); - for (int i = 0; i < craftingMatrix.getContainerSize(); ++i) { - drops.add(craftingMatrix.getItem(i)); + for (int i = 0; i < craftingState.getCraftingMatrix().getContainerSize(); ++i) { + drops.add(craftingState.getCraftingMatrix().getItem(i)); } return drops; } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridContainerMenu.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridContainerMenu.java index fd072e186..fd65608e6 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridContainerMenu.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridContainerMenu.java @@ -75,7 +75,10 @@ public void onActiveChanged(final boolean newActive) { @Override public boolean canTakeItemForPickAll(final ItemStack stack, final Slot slot) { - return !(slot instanceof CraftingGridResultSlot); + if (slot instanceof CraftingGridResultSlot) { + return false; + } + return super.canTakeItemForPickAll(stack, slot); } @Override diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridResultSlot.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridResultSlot.java index 4887311c1..445c47a28 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridResultSlot.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridResultSlot.java @@ -1,6 +1,7 @@ package com.refinedmods.refinedstorage.common.grid; import com.refinedmods.refinedstorage.common.Platform; +import com.refinedmods.refinedstorage.common.support.CraftingMatrix; import com.refinedmods.refinedstorage.common.support.resource.ItemResource; import java.util.List; @@ -58,7 +59,8 @@ private void doTake(final Player player, final CraftingGridRefillContext refillC for (int x = 0; x < input.width(); ++x) { final int index = x + left + (y + top) * source.getCraftingMatrix().getWidth(); final ItemStack matrixStack = source.getCraftingMatrix().getItem(index); - final ItemStack remainingItem = remainingItems.get(x + y * input.width()); + final int recipeIndex = x + y * input.width(); + final ItemStack remainingItem = remainingItems.get(recipeIndex); if (!remainingItem.isEmpty()) { useIngredientWithRemainingItem(player, index, remainingItem); } else if (!matrixStack.isEmpty()) { diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridSource.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridSource.java index 9ed0828fe..220ce6463 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridSource.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridSource.java @@ -1,5 +1,6 @@ package com.refinedmods.refinedstorage.common.grid; +import com.refinedmods.refinedstorage.common.support.CraftingMatrix; import com.refinedmods.refinedstorage.common.support.resource.ItemResource; import java.util.List; diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridSourceImpl.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridSourceImpl.java index 97632e507..60411e3ca 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridSourceImpl.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridSourceImpl.java @@ -4,6 +4,7 @@ import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.resource.list.ResourceList; import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; +import com.refinedmods.refinedstorage.common.support.CraftingMatrix; import com.refinedmods.refinedstorage.common.support.resource.ItemResource; import java.util.Comparator; diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingState.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingState.java new file mode 100644 index 000000000..a58248ebe --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingState.java @@ -0,0 +1,106 @@ +package com.refinedmods.refinedstorage.common.grid; + +import com.refinedmods.refinedstorage.api.core.NullableType; +import com.refinedmods.refinedstorage.common.Platform; +import com.refinedmods.refinedstorage.common.support.CraftingMatrix; +import com.refinedmods.refinedstorage.common.util.ContainerUtil; + +import java.util.function.Supplier; +import javax.annotation.Nullable; + +import net.minecraft.core.HolderLookup; +import net.minecraft.core.NonNullList; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.ResultContainer; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.CraftingInput; +import net.minecraft.world.item.crafting.CraftingRecipe; +import net.minecraft.world.item.crafting.RecipeHolder; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.level.Level; + +public class CraftingState { + private static final String TAG_CRAFTING_MATRIX = "matrix"; + + private final Runnable listener; + private final Supplier<@NullableType Level> levelSupplier; + private final CraftingMatrix craftingMatrix = new CraftingMatrix(this::craftingMatrixChanged, 3, 3); + private final ResultContainer craftingResult = new ResultContainer(); + + @Nullable + private CraftingRecipe currentRecipe; + + public CraftingState(final Runnable listener, final Supplier<@NullableType Level> levelSupplier) { + this.listener = listener; + this.levelSupplier = levelSupplier; + } + + private void craftingMatrixChanged() { + final Level level = levelSupplier.get(); + if (level == null) { + return; + } + updateResult(level); + listener.run(); + } + + public void updateResult(final Level level) { + if (level.isClientSide()) { + return; + } + final CraftingInput input = craftingMatrix.asCraftInput(); + if (currentRecipe == null || !currentRecipe.matches(input, level)) { + currentRecipe = loadRecipe(level); + } + if (currentRecipe == null) { + setResult(ItemStack.EMPTY); + } else { + setResult(currentRecipe.assemble(input, level.registryAccess())); + } + } + + public CraftingMatrix getCraftingMatrix() { + return craftingMatrix; + } + + public ResultContainer getCraftingResult() { + return craftingResult; + } + + public boolean hasCraftingResult() { + return !craftingResult.getItem(0).isEmpty(); + } + + private void setResult(final ItemStack result) { + craftingResult.setItem(0, result); + } + + @Nullable + private CraftingRecipe loadRecipe(final Level level) { + return level + .getRecipeManager() + .getRecipeFor(RecipeType.CRAFTING, craftingMatrix.asCraftInput(), level) + .map(RecipeHolder::value) + .orElse(null); + } + + NonNullList getRemainingItems(@Nullable final Level level, + final Player player, + final CraftingInput input) { + if (level == null || currentRecipe == null) { + return NonNullList.create(); + } + return Platform.INSTANCE.getRemainingCraftingItems(player, currentRecipe, input); + } + + public void writeToTag(final CompoundTag tag, final HolderLookup.Provider provider) { + tag.put(TAG_CRAFTING_MATRIX, ContainerUtil.write(craftingMatrix, provider)); + } + + public void readFromTag(final CompoundTag tag, final HolderLookup.Provider provider) { + if (tag.contains(TAG_CRAFTING_MATRIX)) { + ContainerUtil.read(tag.getCompound(TAG_CRAFTING_MATRIX), craftingMatrix, provider); + } + } +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/GridBlockEntity.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/GridBlockEntity.java index da2f4aed1..4f20e964f 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/GridBlockEntity.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/GridBlockEntity.java @@ -3,20 +3,33 @@ import com.refinedmods.refinedstorage.common.Platform; import com.refinedmods.refinedstorage.common.content.BlockEntities; import com.refinedmods.refinedstorage.common.content.ContentNames; +import com.refinedmods.refinedstorage.common.support.containermenu.NetworkNodeExtendedMenuProvider; import javax.annotation.Nullable; import net.minecraft.core.BlockPos; +import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.chat.Component; +import net.minecraft.network.codec.StreamEncoder; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.block.state.BlockState; -public class GridBlockEntity extends AbstractGridBlockEntity { +public class GridBlockEntity extends AbstractGridBlockEntity implements NetworkNodeExtendedMenuProvider { public GridBlockEntity(final BlockPos pos, final BlockState state) { super(BlockEntities.INSTANCE.getGrid(), pos, state, Platform.INSTANCE.getConfig().getGrid().getEnergyUsage()); } + @Override + public GridData getMenuData() { + return GridData.of(this); + } + + @Override + public StreamEncoder getMenuCodec() { + return GridData.STREAM_CODEC; + } + @Override public Component getDisplayName() { return ContentNames.GRID; diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/SnapshotCraftingGridRefillContext.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/SnapshotCraftingGridRefillContext.java index 833bfa89c..5dbf3da73 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/SnapshotCraftingGridRefillContext.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/SnapshotCraftingGridRefillContext.java @@ -5,6 +5,7 @@ import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; import com.refinedmods.refinedstorage.api.storage.root.RootStorage; import com.refinedmods.refinedstorage.common.api.storage.PlayerActor; +import com.refinedmods.refinedstorage.common.support.CraftingMatrix; import com.refinedmods.refinedstorage.common.support.resource.ItemResource; import net.minecraft.world.entity.player.Player; diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/AbstractGridScreen.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/AbstractGridScreen.java index 165eda4b4..90a62268e 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/AbstractGridScreen.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/AbstractGridScreen.java @@ -34,6 +34,7 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; @@ -41,12 +42,16 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createTranslation; import static java.util.Objects.requireNonNullElse; public abstract class AbstractGridScreen extends AbstractStretchingScreen { + protected static final int CLEAR_BUTTON_SIZE = 7; + private static final Logger LOGGER = LoggerFactory.getLogger(AbstractGridScreen.class); + private static final ResourceLocation ROW_TEXTURE = createIdentifier("grid_row"); private static final int MODIFIED_JUST_NOW_MAX_SECONDS = 10; private static final int COLUMNS = 9; private static final int DISABLED_SLOT_COLOR = 0xFF5B5B5B; @@ -193,7 +198,7 @@ private void renderRow(final GuiGraphics graphics, final int rowX, final int rowY, final int row) { - graphics.blit(getTexture(), rowX, rowY, 0, 238, 162, ROW_SIZE); + graphics.blitSprite(ROW_TEXTURE, rowX, rowY, 162, ROW_SIZE); for (int column = 0; column < COLUMNS; ++column) { renderCell(graphics, mouseX, mouseY, rowX, rowY, (row * COLUMNS) + column, column); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/CraftingGridScreen.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/CraftingGridScreen.java index fdfb4a045..ba50b5b5a 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/CraftingGridScreen.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/CraftingGridScreen.java @@ -26,7 +26,6 @@ public class CraftingGridScreen extends AbstractGridScreen { private static final ResourceLocation TEXTURE = createIdentifier("textures/gui/crafting_grid.png"); - private static final int CLEAR_BUTTON_SIZE = 7; private static final WidgetSprites CLEAR_BUTTON_TO_PLAYER_INVENTORY_SPRITES = new WidgetSprites( createIdentifier("widget/move_down"), @@ -57,8 +56,8 @@ public CraftingGridScreen(final CraftingGridContainerMenu menu, final Inventory protected void init() { super.init(); - final int clearToNetworkButtonX = leftPos + 82; - final int clearToInventoryButtonX = clearToNetworkButtonX + CLEAR_BUTTON_SIZE + 3; + final int clearToNetworkButtonX = getClearButtonX(0); + final int clearToInventoryButtonX = getClearButtonX(1); final int clearButtonY = topPos + imageHeight - bottomHeight + 4; clearToNetworkButton = createClearButton(clearToNetworkButtonX, clearButtonY, false); @@ -68,6 +67,10 @@ protected void init() { addRenderableWidget(createClearButton(clearToInventoryButtonX, clearButtonY, true)); } + private int getClearButtonX(final int i) { + return leftPos + 82 + ((CLEAR_BUTTON_SIZE + 3) * i); + } + @Override protected void renderBg(final GuiGraphics graphics, final float delta, final int mouseX, final int mouseY) { super.renderBg(graphics, delta, mouseX, mouseY); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/security/AbstractSecurityCardScreen.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/security/AbstractSecurityCardScreen.java index 381c51cff..7d4352bab 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/security/AbstractSecurityCardScreen.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/security/AbstractSecurityCardScreen.java @@ -75,7 +75,8 @@ private CustomCheckboxWidget createPermissionCheckbox( y, getPermissionName(menuPermission), font, - menuPermission.allowed() + menuPermission.allowed(), + CustomCheckboxWidget.Size.REGULAR ); checkbox.visible = visible; checkbox.setTooltip(getPermissionTooltip(menuPermission)); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/AbstractBaseContainerMenu.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/AbstractBaseContainerMenu.java index 857aafcc9..91eb1dea3 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/AbstractBaseContainerMenu.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/AbstractBaseContainerMenu.java @@ -4,6 +4,7 @@ import com.refinedmods.refinedstorage.common.api.support.slotreference.SlotReference; import com.refinedmods.refinedstorage.common.support.containermenu.ClientProperty; import com.refinedmods.refinedstorage.common.support.containermenu.DisabledSlot; +import com.refinedmods.refinedstorage.common.support.containermenu.FilterSlot; import com.refinedmods.refinedstorage.common.support.containermenu.Property; import com.refinedmods.refinedstorage.common.support.containermenu.PropertyType; import com.refinedmods.refinedstorage.common.support.containermenu.ServerProperty; @@ -98,12 +99,29 @@ public void clicked(final int id, final int dragType, final ClickType clickType, if (isSwappingDisabledSlotWithNumberKeys(dragType, clickType)) { return; } + if (slot instanceof FilterSlot) { + final ItemStack carried = player.containerMenu.getCarried(); + if (carried.isEmpty()) { + slot.set(ItemStack.EMPTY); + } else if (slot.mayPlace(carried)) { + slot.set(carried.copy()); + } + return; + } if (slot instanceof DisabledSlot) { return; } super.clicked(id, dragType, clickType, player); } + @Override + public boolean canTakeItemForPickAll(final ItemStack stack, final Slot slot) { + if (slot instanceof FilterSlot || slot instanceof DisabledSlot) { + return false; + } + return super.canTakeItemForPickAll(stack, slot); + } + private boolean isSwappingDisabledSlotWithNumberKeys(final int dragType, final ClickType clickType) { return disabledSlot != null && clickType == ClickType.SWAP diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingMatrix.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/CraftingMatrix.java similarity index 57% rename from refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingMatrix.java rename to refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/CraftingMatrix.java index 805e53372..18db8e3ad 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingMatrix.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/CraftingMatrix.java @@ -1,4 +1,4 @@ -package com.refinedmods.refinedstorage.common.grid; +package com.refinedmods.refinedstorage.common.support; import javax.annotation.Nullable; @@ -8,12 +8,12 @@ public class CraftingMatrix extends TransientCraftingContainer { @Nullable private final Runnable listener; - public CraftingMatrix(@Nullable final Runnable listener) { - super(new CraftingMatrixContainerMenu(listener), 3, 3); + public CraftingMatrix(@Nullable final Runnable listener, final int width, final int height) { + super(new CraftingMatrixContainerMenu(listener), width, height); this.listener = listener; } - void changed() { + public void changed() { if (listener != null) { listener.run(); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingMatrixContainerMenu.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/CraftingMatrixContainerMenu.java similarity index 94% rename from refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingMatrixContainerMenu.java rename to refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/CraftingMatrixContainerMenu.java index 288b9c3e8..406c37706 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingMatrixContainerMenu.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/CraftingMatrixContainerMenu.java @@ -1,4 +1,4 @@ -package com.refinedmods.refinedstorage.common.grid; +package com.refinedmods.refinedstorage.common.support; import javax.annotation.Nullable; diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/containermenu/FilterSlot.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/containermenu/FilterSlot.java new file mode 100644 index 000000000..ff34f8f4f --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/containermenu/FilterSlot.java @@ -0,0 +1,25 @@ +package com.refinedmods.refinedstorage.common.support.containermenu; + +import net.minecraft.world.Container; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; + +public class FilterSlot extends Slot { + public FilterSlot(final Container container, final int index, final int x, final int y) { + super(container, index, x, y); + } + + @Override + public void set(final ItemStack stack) { + if (!stack.isEmpty()) { + stack.setCount(1); + } + super.set(stack); + } + + @Override + public boolean mayPickup(final Player player) { + return false; + } +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/containermenu/TransferManager.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/containermenu/TransferManager.java index 1aece6cbf..098001eab 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/containermenu/TransferManager.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/containermenu/TransferManager.java @@ -46,23 +46,28 @@ public void addBiTransfer(final Container from, final Container to) { addTransfer(to, from); } - public void transfer(final int index) { + public boolean transfer(final int index) { final Slot slot = containerMenu.getSlot(index); if (slot.getItem().isEmpty()) { - return; + return false; } final TransferDestination key = destinationFactory.apply(slot.container); final List destinations = destinationMap.get(key); + boolean success = false; if (destinations != null) { - transfer(slot, destinations); + if (transfer(slot, destinations)) { + success = true; + } } + return success; } - private void transfer(final Slot slot, final List destinations) { + private boolean transfer(final Slot slot, final List destinations) { final ItemStack initial = slot.getItem().copy(); final ItemStack remainder = doTransfer(initial, destinations); slot.set(remainder); slot.setChanged(); + return initial.getCount() != remainder.getCount(); } private ItemStack doTransfer(final ItemStack initial, final List destinations) { @@ -79,4 +84,8 @@ private ItemStack doTransfer(final ItemStack initial, final List> recipe) { Platform.INSTANCE.sendPacketToServer(new CraftingGridRecipeTransferPacket(recipe)); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/packet/c2s/PatternGridClearPacket.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/packet/c2s/PatternGridClearPacket.java new file mode 100644 index 000000000..f4195ef1d --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/packet/c2s/PatternGridClearPacket.java @@ -0,0 +1,28 @@ +package com.refinedmods.refinedstorage.common.support.packet.c2s; + +import com.refinedmods.refinedstorage.common.autocrafting.PatternGridContainerMenu; +import com.refinedmods.refinedstorage.common.support.packet.PacketContext; + +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; + +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; + +public record PatternGridClearPacket() implements CustomPacketPayload { + public static final Type PACKET_TYPE = new Type<>(createIdentifier("pattern_grid_clear")); + public static final PatternGridClearPacket INSTANCE = new PatternGridClearPacket(); + public static final StreamCodec STREAM_CODEC = + StreamCodec.unit(INSTANCE); + + public static void handle(final PacketContext ctx) { + if (ctx.getPlayer().containerMenu instanceof PatternGridContainerMenu patternGridContainerMenu) { + patternGridContainerMenu.clear(); + } + } + + @Override + public Type type() { + return PACKET_TYPE; + } +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/packet/c2s/PatternGridCreatePatternPacket.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/packet/c2s/PatternGridCreatePatternPacket.java new file mode 100644 index 000000000..3225174f6 --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/packet/c2s/PatternGridCreatePatternPacket.java @@ -0,0 +1,29 @@ +package com.refinedmods.refinedstorage.common.support.packet.c2s; + +import com.refinedmods.refinedstorage.common.autocrafting.PatternGridContainerMenu; +import com.refinedmods.refinedstorage.common.support.packet.PacketContext; + +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; + +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; + +public record PatternGridCreatePatternPacket() implements CustomPacketPayload { + public static final Type PACKET_TYPE = + new Type<>(createIdentifier("pattern_grid_create_pattern")); + public static final PatternGridCreatePatternPacket INSTANCE = new PatternGridCreatePatternPacket(); + public static final StreamCodec STREAM_CODEC = + StreamCodec.unit(INSTANCE); + + public static void handle(final PacketContext ctx) { + if (ctx.getPlayer().containerMenu instanceof PatternGridContainerMenu patternGridContainerMenu) { + patternGridContainerMenu.createPattern(); + } + } + + @Override + public Type type() { + return PACKET_TYPE; + } +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/CustomCheckboxWidget.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/CustomCheckboxWidget.java index aca5918a6..af5a8f6c5 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/CustomCheckboxWidget.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/CustomCheckboxWidget.java @@ -25,8 +25,7 @@ public class CustomCheckboxWidget extends AbstractButton { ); private static final ResourceLocation CHECKBOX_SPRITE = ResourceLocation.withDefaultNamespace("widget/checkbox"); - private static final int BOX_SIZE = 9 + 8; - + private final Size size; @Nullable private OnPressed onPressed; private boolean selected; @@ -35,9 +34,11 @@ public CustomCheckboxWidget(final int x, final int y, final Component text, final Font font, - final boolean selected) { - super(x, y, BOX_SIZE + 4 + font.width(text), BOX_SIZE, text); + final boolean selected, + final Size size) { + super(x, y, size.size + 4 + font.width(text), size.size, text); this.selected = selected; + this.size = size; } public void setOnPressed(@Nullable final OnPressed onPressed) { @@ -79,15 +80,26 @@ public void renderWidget(final GuiGraphics graphics, final int mouseX, final int } else { sprite = isFocused() ? CHECKBOX_HIGHLIGHTED_SPRITE : CHECKBOX_SPRITE; } - final int x = getX() + BOX_SIZE + 4; - final int y = (getY() + (height >> 1)) - (9 >> 1); - graphics.blitSprite(sprite, getX(), getY(), BOX_SIZE, BOX_SIZE); + graphics.blitSprite(sprite, getX(), getY(), size.size, size.size); graphics.setColor(1.0F, 1.0F, 1.0F, 1.0F); - graphics.drawString(font, getMessage(), x, y, 4210752, false); + final int textX = getX() + size.size + 4; + final int textY = (getY() + (height >> 1)) - (9 >> 1); + graphics.drawString(font, getMessage(), textX, textY, 4210752, false); } @FunctionalInterface public interface OnPressed { void onPressed(CustomCheckboxWidget checkbox, boolean selected); } + + public enum Size { + REGULAR(9 + 8), + SMALL(9); + + private final int size; + + Size(final int size) { + this.size = size; + } + } } 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 adf9fc563..9ed2a7d7e 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 @@ -6,6 +6,7 @@ "block.refinedstorage.disk_drive": "Disk Drive", "block.refinedstorage.machine_casing": "Machine Casing", "block.refinedstorage.grid": "Grid", + "block.refinedstorage.pattern_grid": "Pattern Grid", "block.refinedstorage.crafting_grid": "Crafting Grid", "block.refinedstorage.controller": "Controller", "block.refinedstorage.creative_controller": "Creative Controller", @@ -61,6 +62,11 @@ "gui.refinedstorage.grid.resource_type.help": "Filter specific resource types.", "gui.refinedstorage.crafting_grid.move.network": "Move items to network", "gui.refinedstorage.crafting_grid.move.inventory": "Move items to inventory", + "gui.refinedstorage.pattern_grid.create_pattern": "Create pattern", + "gui.refinedstorage.pattern_grid.clear": "Clear", + "gui.refinedstorage.pattern_grid.fuzzy_mode": "Fuzzy mode", + "gui.refinedstorage.pattern_grid.fuzzy_mode.on.help": "Match the pattern inputs without comparing NBT tags.", + "gui.refinedstorage.pattern_grid.fuzzy_mode.off.help": "Match the pattern inputs exactly.", "gui.refinedstorage.screen_size": "Screen size", "gui.refinedstorage.screen_size.stretch": "Stretch", "gui.refinedstorage.screen_size.small": "Small", @@ -170,6 +176,7 @@ "item.refinedstorage.disk_interface.help": "Transfers resources between the storage network and provided storage disks.", "item.refinedstorage.grid.help": "Allows for interacting with the storage network.", "item.refinedstorage.crafting_grid.help": "Allows for interacting with the storage network, with crafting abilities.", + "item.refinedstorage.pattern_grid.help": "Allows for the creation of Patterns for use in autocrafting.", "item.refinedstorage.importer.help": "Imports resources from an external source to the storage network.", "item.refinedstorage.exporter.help": "Exports resources from the storage network to an external destination.", "item.refinedstorage.interface.help": "Acts as the combination of an Importer and Exporter.", @@ -271,6 +278,9 @@ "item.refinedstorage.fallback_security_card.help": "Acts as a fallback if no matching Security Card for a player is found. Right click to configure. Use while crouching to clear configuration.", "item.refinedstorage.portable_grid.help": "Allows to interact with a storage disk while not being connected to a storage network. Can be used as a block in world, or from your inventory.", "item.refinedstorage.storage_monitor.help": "A block that displays the current amount of a certain resource in your storage network. SHIFT + right click to configure. Left click to extract a stack, SHIFT + left click to extract a single resource, right click to insert a resource, right click multiple times to insert resources in bulk.", + "item.refinedstorage.pattern": "Pattern", + "item.refinedstorage.pattern.fuzzy_mode": "Fuzzy mode", + "item.refinedstorage.pattern.help": "Used in autocrafting to store the recipe to be crafted. Use while crouching to clear.", "misc.refinedstorage.stored": "Stored: %s", "misc.refinedstorage.stored_with_capacity": "Stored: %s / %s (%d%%)", "misc.refinedstorage.total": "%d total", @@ -298,6 +308,10 @@ "misc.refinedstorage.no_permission.build.break": "You are not allowed to break the %s.", "misc.refinedstorage.no_permission.build.rotate": "You are not allowed to rotate the %s.", "misc.refinedstorage.no_permission.build.dismantle": "You are not allowed to dismantle the %s.", + "misc.refinedstorage.pattern.crafting": "Crafting Pattern", + "misc.refinedstorage.pattern.processing": "Processing Pattern", + "misc.refinedstorage.pattern.stonecutter": "Stonecutter Pattern", + "misc.refinedstorage.pattern.smithing_table": "Smithing Table Pattern", "key.refinedstorage.focus_search_bar": "Focus search bar", "key.refinedstorage.clear_crafting_grid_matrix_to_network": "Clear Crafting Grid matrix to network", "key.refinedstorage.clear_crafting_grid_matrix_to_inventory": "Clear Crafting Grid matrix to inventory", @@ -373,6 +387,10 @@ "text.autoconfig.refinedstorage.option.craftingGrid.energyUsage.tooltip": "The energy used by the Crafting Grid.", "text.autoconfig.refinedstorage.option.craftingGrid.craftingMatrixCloseBehavior": "Crafting matrix close behavior", "text.autoconfig.refinedstorage.option.craftingGrid.craftingMatrixCloseBehavior.tooltip": "What should happen to the crafting matrix slots when closing the Crafting Grid.", + "text.autoconfig.refinedstorage.option.patternGrid": "Pattern Grid", + "text.autoconfig.refinedstorage.option.patternGrid.tooltip": "Configuration for the Pattern Grid.", + "text.autoconfig.refinedstorage.option.patternGrid.energyUsage": "Energy usage", + "text.autoconfig.refinedstorage.option.patternGrid.energyUsage.tooltip": "The energy used by the Pattern Grid.", "text.autoconfig.refinedstorage.option.controller": "Controller", "text.autoconfig.refinedstorage.option.controller.tooltip": "Configuration for the Controller.", "text.autoconfig.refinedstorage.option.controller.energyCapacity": "Energy capacity", diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/models/item/pattern.json b/refinedstorage-common/src/main/resources/assets/refinedstorage/models/item/pattern.json new file mode 100644 index 000000000..9e88470d6 --- /dev/null +++ b/refinedstorage-common/src/main/resources/assets/refinedstorage/models/item/pattern.json @@ -0,0 +1,3 @@ +{ + "loader": "refinedstorage:pattern" +} \ No newline at end of file diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/models/item/pattern/crafting.json b/refinedstorage-common/src/main/resources/assets/refinedstorage/models/item/pattern/crafting.json new file mode 100644 index 000000000..4626053ed --- /dev/null +++ b/refinedstorage-common/src/main/resources/assets/refinedstorage/models/item/pattern/crafting.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "refinedstorage:item/pattern/crafting" + } +} diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/models/item/pattern/empty.json b/refinedstorage-common/src/main/resources/assets/refinedstorage/models/item/pattern/empty.json new file mode 100644 index 000000000..181a096c9 --- /dev/null +++ b/refinedstorage-common/src/main/resources/assets/refinedstorage/models/item/pattern/empty.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "refinedstorage:item/pattern/empty" + } +} diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/back.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/back.png new file mode 100644 index 0000000000000000000000000000000000000000..ffb76f755fa9a787972cd4c17b1c3dca2b1ab4b1 GIT binary patch literal 1415 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+nDa72B1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxOgGuk&``nLQqR!T z!q~`EN5ROz&{W^RQs2-(*TB%q(7?*bKmiJrfVLH-q*(>IxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8E%gnI^o@*kfhu&1EAvVcD|GXUm0>2hq!uR^WfqiV=I1GZOiWD5 zFD#PU%0_}#n6BP2AO_EVu8M)o`HUDF34YC)x{-2sR(CaRb3oXS&*t9 zlv|9-O^tOeQ%y{DEmM*#b&U;;4N_AQ%`FU*4PfSA({E{RVd~;)WME-p4oIBp4nO9trn3tRivpW-LH$<phIbtAf7XZzyuX?y}6TK
    js(5`t?UIDBps zydCLndOza&&3)TX$$#Ntw($~PaQ$RTQ)AU-lRSy4?42*SJ0GsFxmdA9qgk$bnWoZb zMK@VnzIL^xYOW?3hx(5@Uplo(g}2{>{pby*Tuw=v7q4Ll)rDvtlj$EKMOWD+zsT?&%D#q zZSuvzUsL5n%iaGq8`gzspZGIlE89VbhDqlqTc7{@waRx&(7)?D;?{3+O?r`dBOqvk j%+JG(r;1Me=Q3c({@o?*e|U}qsA%+b^>bP0l+XkKE;Id| literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/black.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/black.png new file mode 100644 index 0000000000000000000000000000000000000000..5aa1136ac0b015fc6025141e730120345ac23664 GIT binary patch literal 3047 zcmcImYitx%6kb3GR3ME?K+rgussUwo-m^Oc3$EQ_i*6}pE3N+F&Ye5mp}RBFnd$Bp zV?-qK5MvBtEFg(7F+>d{8WWTsRU#xpqLP>Z5q^mpUu}pI2@&hP`)VsKZBQne*FE1o zkMEvy?%mPS{MekDg*Bm2XiigOq7}bu$vtxhe%|-{5WuflZexcZ3f+Duxu=Bo?q3iJ z)pT2__Mkoaga(~#7#NO@!iB7h(V@`tl?4~TE)-BY>a^?_J$SUArYs{yua}ct(yd2n zt8tTu)@^D|!A)IIHRzQqsO1F>E6Ab%P=##9_O(KcF6!0rHyLJWst5_XVsxAsq}r1$ zRK4RNN(pleh|$>7 zQV3bMs@C?)G-1Nn0&rPA%#o0aKm%5BZjYBK8aE(|GAN7ez{gm=ip4A?lU4YbYO~oY z+7B9X*rRf6W1{_3uZ!4Lg0sv=caf+8Kw0s(2I? zfn|KEw009^YRvC^@@tnp-HAxr+b_~nxoe*k3&2+ph zzzb((K__BeyR&F5nbewWKL9pFO^FzdT@727p(zq4LnI<53Ji%6RVm6uBLZZgE{moN zAwm#V<|iE3Lz0TjFV&afK&+#>8k))Lg1~b!6BR`n7moxPAYtXQtUz59jfg0tincYL zg-aY{MrtKq8Cau`MV3Xm zJlri+3D`Qc`qSOE^g#bx*B7-gu zTVpKnjqg{g87aa^dKjc#c;PW2&OU$VlQC zU6dn?5>=tji2_1=q!Rk|u8SHkX@Xd(p__5NOe;(SyA$C}h^22n7+D9h%0*Nrssf%- zWJzFj6POG%1w}CwBO(c71~XVLF1Va83a8(v>5w|J3QazH4x0ruY=qV%6A zF}aGYO>yJZ#_9!=%|W~qYq+&f(CiIfg^C`L8K5dU!^@;RagH-UGzC#s6d9U;lqb>V z{MTkra;Qkdh;vhA2p`7CXY~|_f2!w5WaGN^@G0>@KJjcQH07SAL_8IJ`S|X~H%^V; z)v#s{{dv#vd+(1qE3Yite(uFf(>|H^LSJ9oo}hotjGbq9n6=ZE9Q^E=Z;tNQ8m8xe zJTPx?@82(NzKUK&Umbc^+L!#aJAXc&aPzIJ-?;nR-=03Qdc!-jx7GiAdEuMQuPms$ zV9$52UR$yIi>-&hJcjB{9XNlXw-CJ}bnqd1OW)~VE_W>b;n&>YnOP@4Fr literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/blue.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/blue.png new file mode 100644 index 0000000000000000000000000000000000000000..397da42e42137d1cb642ccb66d4d0bb90abc7a8a GIT binary patch literal 3070 zcmcImZEO@p7(PS=3MEa^;78PDn;-=Dc4xotc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og-21u}}a2sydSH&Fe63LHLg+qgiGLv_}amq1X!ANTKZn3Ej5h zxROZ33@x2qREG(&`%^w4ao55}%Fl$P0cabeG%(srJ_P(<^f#&ErdAFA_eG+-145<@ zP=Buwng39R$!c$H(i^WlUM*mzs6n(7%c!(ZQtSaEX`<>ENJSD=k`cW0R0N4sIGyDL zQ4};?@f7V@vu?N8dm2j9FzVctYeI)H?=yc2L_hg+Bs5Xp+US(He^$*t44W3N3spn{ z+t0n+yX@JvxhJ;_UwiU{oee&vRNQlB>x#qkAGl}ZwM|21CnCG43$?B7gN4%C>Alm#9N)X)s|N>O z*na+@?iaWA4lE3u8a(~$;=qif7v>cOYM@=v_*VJrHIM&v;FWDh=o5<<43-SnU7hjU zQ?<_=+C1}Y|G@UH9nPI4J5J7CK5+g(LF;ovk&mNWe(Zj}65DlZ==}{F4lQascD;Xw zueg7IbHzaM?;DE)kIl!a?eA2VD3^XN9vB=*4iC@!{{GagV>=Gr;cI>Z9q}=&ZuPp* JdzG8I{{ka63IzZF literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/gray.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/gray.png new file mode 100644 index 0000000000000000000000000000000000000000..eb4885bb5ffcd5e3953d5e4fa4df5717f04aad98 GIT binary patch literal 3057 zcmcgudu-KI7%xT<5X_Vq2b$P*NO-KbJ?(9K+i=0LJGL9WFvp#2im=o6bSt~JEp4~m zEhvP{KO_T<7>zsvQAq$rq69IbkpKxMh8VIe{6R1p{vZnp!&;}N-b8nPnY4q^1hHsI#(`QJ@<|o7m{yb;JpLU;ntGI4B_!B{ zQ-xa1+HM!E>|UPKy4y5arB1iXoQPSe7FtIRwOTSY#_mj^$W}6&S$LKvdYU0wgkjQP`TR8%lj_S>6`@ zi&Cw=?j>ZVu>#}^9p)Iexpdp4l%{3k0v@J5w2vxh? zk5bsvTnK5WsMhlGG-1M+40IR}Vu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main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/inactive.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/inactive.png new file mode 100644 index 0000000000000000000000000000000000000000..1a6fc9e69ab6fabbebe4cc452f5ae0020cc2d8c5 GIT binary patch literal 330 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucLCF%=h?3y^w370~qEv>0#LT=By}Z;C1rt33 zJtM=93Yk-ZigtOrIEGmGFP-Gb*P_7Vy0?XkOG|s=@B8Z?E3drB={7TRkBHX)?IO~G zKf9AQwE@xTV^P}2BowWlAF0;AZ1U7}=f3w#b8r8B(aZQK_x2`@r7E9oz>bZtWacu(WBHzqc!b`C)h+Rv-Q}vNG988WnWpn$H+m%>4c!bE19_R28Z|SWDhK6 zlrR0&^-hpkzwlZNkHnO&eTh5zWj`DXVOZC!$kf~a|De9eWK%GDKk*r};_OV#?_K9S QfxckyboFyt=akR{05*MjqyPW_ literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/light_blue.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/light_blue.png new file mode 100644 index 0000000000000000000000000000000000000000..cb3757fa5d2a2acce93094b4c5873c56ef87f0c7 GIT binary patch literal 551 zcmV+?0@(eDP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02y>eSaefwW^{L9 za%BK;VQFr3E^cLXAT%y8E-^MlX|MGF00EatL_t(IPo<8#OIuL@hy4dCNG#x>ORqd9RfQ%H)(70jp zMpBs4{!%pYOQ$fJyK<1yE41j9rd**Upv>;hUN^nl-R^FC z*Xj=fF{vN?Fp@|Rzak+9QDZbJ7=lQGe;_d=ra>fvXfQ^>ghUAZs5AG~R$AJKY_hYn zGtayq&%EzD^I~Vm>iW7z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@MdXFDe{`y>gK}*Lnio2nToG!`&;3-an*b`CEsE{6tQ$S)g0ZP2g zv3x<=TF1aC4w7S~`c^?KF^)nKuS1REp^T^y6j(}OHNO#|!V4@fYna1Py$x24HWm2!6(-sIV22;7$)4Px%rW?(S-;KCcTO=sI=$XBFvT26`0=7<^|#~F zg$fEOIex~kWPXOKO@@nOt}kC}+EI7Dmo$iMQmR1D zxuE;ei6EIDHYV8M=~0;z+nYd`th+>Q4(3{MuNOF|z6&!vWmeFW8SjGh-A!j@fn`_; zQE`QrC=uZR)p${+q>!R(49_9N$_3Z&G@VyjLFM>D4&96Cd0O=ZFuM>wglO{Ko#7y4 z1)NXV8AYHpQQ&Z+hbV>9H4!O@lK>9gJNIG2g76>;b@k|v83P$Z3FML#`(s8E29bG#@? zq8Tf7D0pW;0dnK*A9d`o=#CzK8ZO6r;;^|8?I zv#$-WZdg|tIsMVd>#KzY1HYFH%!mxP&Y)7a9$7&Q&fgjNT>#A)sFKUS$@a<#M0}V%1&PR{KVw}WqrlbxwBjO*@^A_ z3xz$^3zBO#efshPBg;P9zU`SBEx4)XrENEF)s)t@B!{KW>Z|D6>dIaApKYHU?7sQ_ zgU1{7`Tg(xte!}|`vgDd(7b~~Rr`jy!(X&7q<=hn<-n2k-3N|!UHm50cdlkp`RTP{ zdDysp~|giwSmFm*wB?%OP_kNylU?E2ZpLHFTelm=bN7UjxS{fcbCV@ zUK#wVV(Yd2i$|(f-6+3y{*ApKRIXY)a_I;8`Y&~R>y;OV(tEa*R0(JL%U~q4_RO30 phfiJFICGzT-_6^{m?OvM$D?mI?^-ge#J{RHH?~CHdGgtTzW_~e_CEjs literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/magenta.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/magenta.png new file mode 100644 index 0000000000000000000000000000000000000000..f7c5e1090c7003f2b9ab83b795233f1d7d8f0e61 GIT binary pat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U-Gw@&{m(|>DXPx|JR(^qaT zdv<$$$$}N})Lv$1-SL`%nM+QPXZG||m)6A(4V*saJpW5waAyCPw@N=cd+n*R(rZ0W z&hD-yCeHnW)!+Jh(f8YqURpY<^YXg2Q&;Xupnex)0C&w1L}NnmoBTE?heP z=mS3<`uSw{?!K-=bKf}EIsf9Sqc?UfoYMHnyO(E7n(@l@=k!+(IO)Ik^mo;+`7`$S e?M?e0{;6b<)!RXwPk-Z|&ugpdqi?Q$X4^lgg7y~x literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/orange.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/orange.png new file mode 100644 index 0000000000000000000000000000000000000000..5f15468d0754a298b71ab98fa1e9f4a14fcb0169 GIT binary patch literal 3042 zcmcImTWl0n7~TSDuvkS*J| z)9$u{62K5dLW~a@^Z~^H`aoJPCWLSa7bV05F~r~%6OFzgipY~D^_;zRD=lqMCYjqg z-}(RleCPZBbGEg$K3!WguO<`<)wVRp+wprQxu;j-=VLdAA%5NGHh1}<(2R%4T@~8( z?wnAlW}TJn3_26fs=AX2L&MQfIG1rTIuu&GBN{Dv+t-MPqNCVXE!%g6q$H& z0E)u^#b_cVhKn)+m*jbs1F8rXarlEPKoeM+1`J>&SYbGj1e^+@Du|2%JBDTUPY5-1 z)pWcJ#0zI-U^il2yF2eKkx*M~KY+H5TH-MphZ?plL*h&|BLZ+#8hMC@B1C{7Yna0kzl~1X@e+=K zITvV(thS2H<4_^VuNV!Ajh#fQ>E1%4%yal+0eKetyC&!#>3+esFvUDg5xuB+{~fq= z;Q%C26vSeCo0UW9&bWnH^9zAUl|5afdq^cC8LBp0KGs}+vDS2;b;Yl=Mdg!Hg?eEM zI#DOWlopz;F&21oR2If(QwWoF2h|o}zGDVi=%I#g%eur5w7O(2KO{DQI^iya}=N-A_j2WFUzE zYgm(HMuU+k19?+mcwUxx329g~=2(*%vmo5#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outs/red.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/red.png new file mode 100644 index 0000000000000000000000000000000000000000..6479cd8bcaf4118eaa7c341da0f45b0e79dc48c6 GIT binary patch literal 3054 zcmcImdu$X%7(YM>4|!M&Rw8lP5=80V?(FMsH$4!0K#y{zwr6RHG0yJJwVU4UZg;o6 zD`H~_QH#L{l|S&27!p(xV-O<`4MI>+42i}^NVFPIi7`R(5rffaow-+AX=#J9$-d_M z&G-1t_kA;c^>u4z%~&ua5D3hQ)kGWcdoH=BO~udKejSAPHQlLc@dAOF^T<6Z@bt6g zfxwIoGtulf$JeR4oeo07)=)5;b}%{+s9KSApx%yrN<*!t6`?P_d5oq^BSLSG;#}OR zMr~%zCKokss!Qmb+I7XCS1hNhvMN@PMn0sn>6GQE*$AD}tKx4m%+gd2;|DkrKSL=`R?TXT)1+7Mk`u!a93 zber!xD$8avnP5f;+HNZg6h&bygt#%RgZ8u@tsbcQb7k#665ag+)8%)cvGu|B}@WKQX zg+7YVB#{^{%m`e9=T#1<5?IFJ4=xXl^q$JOF}T z)VAI=af!p!aIM5E18Yp8uq^0?#t23TF=0ali~=Yv^iRFVL#DL8}$vO^BthJ{VpSA&>>0 zkw6F+xrT#*C@Ce$rDNiUV3>1>QAjvqf zlaORI(PsbGW>0b`N5imlQ*j6%#>i*s6o`LH=SXDXx^?j>ao4v!8v}t!6|v~bM0oqV z{YUF2-!pghhn0(${4qJYsQf_R&kHM4>CFr0t36%kc2#bkx}dtU@_DMNxBT3Xo9EB{ z`@qJ>`uYdH?m2ZjqV%`#4Da33|HhzpSN9;lO+R0D^ZCvTfwE=OW0k+$8XJf&X{tF} zcE((*Y&(46x23x~KD#)j{^F%0x7_ekMe9MfP6=zadW zPd|BTeP%(+BfD=L=;(8z&e^j^n&usE*|)W}{7JiNVD_Vj->H4=)Z3}13)F$mx2C~o z9@={RgXcPSz8vfM{6ypHcTPEda87DRg|PTl|GSRmhfYj7wr_B7=IwKSpS*_O+q=E{ SrLE*d9$QrxedX>4w)_L6hVdW( literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/white.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/white.png new file mode 100644 index 0000000000000000000000000000000000000000..358dc332aefec64600e3085dc00ca14662867542 GIT binary patch literal 2978 zcmcImTWl0n7#<*~RA{O^2qeT|Fu^Kk=RP|#VS&;G+r%xkY(pDk^vs+y+mYRwVP@Lh z)))zi36d&_5~GBK#IQaPA@PL=C1QZY2e95C=z|FclRg+F#uzk8>N$JsR$AJiOft9g zf9Jn^=l}n6UhD07YDLSM7KUL~ba$ou$h(c+58OwdkN!3V$!l5AH5f6>gDdI1h&gg} z6~nabb+ZHUK;~)F_6rG!d+`h4Pw{#SgH|P{&1Y) zh^N&M3PD4y7u9GYgz+U9@M1!sAyt6LZs3C9Fkdl_Y#!%v0ef*ouwnyCSjuD?@LAOs z3Jr7=ZyzBZ)nc0!9c4!Y%=h8Q9}aE2eS}zCUw15u`|vb13z$yejmg1~AN$deKL-g7 z@eC?r*O|j0mCS(Rk~;^KN*d6>>cx?hs z!x*PHnn*yWb1YqL zlc*=ILRw!bPOJ?M&{WM2R|k`lKrUXS&zgL29{IGm-*XAY635bfF)Q|Wk=8{V&{S1c zYva9c3FimWE@3UII-)g824_lWC!-Z=cDWJBxzSp$*@gGkzVa?xDM}OC)evl&ofvVo zVRx1VUKo{CwZ$P!$ht$;R$-Cv#6=k5jvQfl-m2i|az271cXnM&Dxx527&wMZatJE| zuw*p}G~KW*L6$HUll9PVcU?9`#gycF4c(3FHCpW<=;bikgm~`mgV8kwLfcS*Ws_ha zR7kbik`9EVBpJFRAV-0-1v6_yxW~cRzBhuyro;+h2+2l@!zjf$p`#;*7H{%x84R0@&d%Q?IJs?!u0RQg}QT zncP9wrn2#xv-N_7<{;ULP14%uY4%7oY|Tol02-PFM3t5&R1E-SN0L=dQ*Eb`(NvrN zUzzVDk_dhOQUcPGEQ zG=91;I{yBNcUBv@OXKd5AInSR^DiAb@a6DxFE2WCbNTsCquhpl2ioilm-IK5>|3>- z`RkMCFFdmE#Md`d%!Cn6=##xy)^zrt{bg(avUMzX{4n$F>7O6_TU*?_wsfPteEHVy z)^K9u#ckgxAN+LiK-;#h{i{Fwb+R>meE;SR<#c;_@v(Iq?k^v1X)hmb{d^n`CYV2` fUim@0w&e1MZ$EqPkF{lbitgUtlRmZWh5i2kAobD( literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/yellow.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/cutouts/yellow.png new file mode 100644 index 0000000000000000000000000000000000000000..277ddfdc81511ba7a2b4609603531b1ff56e5812 GIT binary patch literal 3043 zcmcgudu$X%7(av<-a!aSgAbN%6^!id&hG8*?WQM`9?&XRYN=8pn9l9awQKKomfdad z+L&l)C4!(KD3L0WXpE0UqNLG3loS&nYN}|W5sat^XiK7~V4`4xGxusMEp70z$-ZWO z^L^j^=J$OwTWV`o&X_uHY9J7pQC$_SBkx)Co_sxd&Od({lGhZcYMmDdOq)aR34!kC zN&JboK@b^L3j!q+QiR2fD2M_t$UG1^py)zK2P%`lSmMn!6M9{AMcx#&N43 zVM(O9DWsgDS=-CgL|ffolm&Dh6YGaiM6 zV)rmAd@C`EL)tS8iZa$HP})<3I(nsxppV^pjFScJ)D~i6L=Y62MQbhF#A)w#I`RAf z6oo#DuvAE#5auMIUKDi!=rXuNARj^w8Y9v)p$~_GHBJEaKp>LSfiMh=O)JqpCe$?a z1a?!9ES!~sO^A2wrmVMEOs}>*AKC`0jz(A#YS6MwT{KM?H;~MkvKZzRHH0{*gu|SM zWLY#c(NILOFg}WnRw^nwK9^r6Hi(VlYUl|8gari(oETOWE~JKJVog*z1QMo9$OviS zP{G=2*CHtnlS8f2s7zupfx?Ppm~l=rRm6qO5a2Wrrw`fGq!5tQIN@;6ZzWD*H-=5Z zxx_MbwRK{igbHbXMOct;Y@kw2w&ogDQ6Lu&=riBHZjAoH?t5*EP)w+ydeO7~*O1ah z0#IaGlJo7gRt6;-q84Gz%LSqg?O8XxhgLG0p?a0&5zV#dYt0(8G5?jcm~2w&(8x`} zpz1^>n{T#8Sm5zdnKPSiMue=Zs5S@laKcYR7gaP7hR4hbezf2{*mm{Mff@n=P!N~U zB!!bvNZ{g;!A+iba?6pq@0c0jb zRp#QNDUqxQNnF@SNStgaMASeQG?}RI%5@mAApFOZF|gf++#$kppbN=Hid-+kCS06i zpyMPhBb!}(n{DRzr(!}fK4u2X�uC$hC%OV5pa32+Y6eZ%oCFuNwaEi^S6dLaq$( zf3Fa^|7ecM6?AQ~8?Qc6Ef}u`$xf`3(mqD9H-Tm-aiVCbDRB%_CjC`o%)bi(NLh$?66-N0c=Fq~%V*|fFGVi|kI-fcA_P$kX zU+b-Ywru9Br}qx@3a=#9odZvQwWs62=0Mq`%(kjo%a$%ZclzVD+Z^r3#S5!vcU$wN z7k58U%CyYrzh(O$ANIZV=m!_-W`A~8&U|rVPyZ9^d%7on|M(3rAGma4%GQ#Bo|ViF zw16xf;S)Y zztpxIKeF`VuDyr8J^9P3z~>L1nX{`bzU`(o-niv>`48XyX{nuM$NLv_t>(I9pr1cH z`BK&XCoArW_8sh7wDpAxpKK^Ux_QaNr|{X!_+(?Jdh6zwrq8{5_Xc_luU=jg-M6f9 F(_i@I^UeSO literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/front.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/front.png new file mode 100644 index 0000000000000000000000000000000000000000..d6f059405807c9dfa05e56031611beba088ad926 GIT binary patch literal 554 zcmV+_0@eMAP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02y>eSaefwW^{L9 za%BK;VQFr3E^cLXAT%y8E;2FkAZe8V00EjwL_t(IPnA>Gs=`nZJl|zEHWYioE}~*D zsQ6$7@j>7H;JKL*eFzb*!njFx&t!IXW5VGuEXzV55P;9;QzRmh2tuI{JRXnW^?LRE z9a$R;1|fp$^@{ubj@#{~_9*dL4ehABKO2!{KKI z&1UnZfOF-DepNsMPS9`^o6Sa}au$9=DwWdMKOS&Va=DzHb3fn&x3t}EzxIG0ESF1U zvspXme!vN~K+mLrJH1}7Q7Vmi`i>58Wkv?3h04WnJsV%yWLJ+Y`0rs zHk*lfJRWQB`9YD0_xu(!OiU&d#p!gaUGH|gDx_iTx!>=j*Xv<894f~pH0*;+ sG=zSTkZtjrZ>3CL6RdsL5SC@(55YB7Ik9^q4gdfE07*qoM6N<$f_Sj#zyJUM literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/left.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/left.png new file mode 100644 index 0000000000000000000000000000000000000000..a4a5b2664638ec8d9cb7db5394d541f394fe092c GIT binary patch literal 1445 zcmaJ>du$VR96uh;%7#H)2y6k)8!97f@7?u|6}-d?*uVJi9v?Q2q>8GRvF1~pg3G)B+DiaVNl}qT3Ymv$t8Ec*Z1@JetzG_ zty@qsZ~VBdaR2~}w->QaZJZE)b)&WKd-Xn}HcU|q%hXc2LJf0@05H7l5kR}2TOv3G zj$i)P8KD3G#z>;8Of7S~OnYU&fs5N1BL0Ae27rROkpSmiCa9oCSRzVh==Zkc5Ge9y z$W1yBN5Crh#G zWoGE1s4~X_&?+keNE(cKFN&gIK4m~j6ONI2AcmkMj8HI&=n<4g5gJ3lMApHXZc*apa4@n1Tx znCc$oV_Pj`c3=ih6zHt!p%+1Z(uGkR*^`T%0soKETLulfib_Rg!B{h{Vh zck7-Ud-VMLE+4Ub!>tcX{*lUzRo^%G2)1*3W<&C6Umk?TCe zSEt9m5Hq0mMFXL>s;tSm=dH2X=k7i**Ou(P-6)6+i(gtfX9pMBkPfez`*hm2nv>5R z{PEpFX2aPlN1DDlu(73j>zk)~>bq|CUF+x%^@ZA`+~HVz z51I{}nz+VY>+`KUd>P$Va&r8d{E3H{;_V+U+&W=L&D4SJMXN>uTc&t7?aZ_N7XNYD M3rpDjmc`Zo0Dzqk;s5{u literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/right.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/block/pattern_grid/right.png new file mode 100644 index 0000000000000000000000000000000000000000..eb4e500c5ce553624ae3af919558f6e6a535d46b GIT binary patch literal 1444 zcmaJ>Z%h++7(OXs%pul|FC)&}PGfMhy}Mqo?cG{y+iRgh0SgY$gmLZt3OCxjdcD#@ z7In^zxJ(^r+{BF!+uV$cIt(sTg34Ijgb_FV#~^GfQ$HY*jV**Z;;um1J}@u2`~7>L z=Y4+fpW9trn7d?g_F@Qvmbmj6uQI9=Z+eRIeYdH`pbXE-&T_d#49GE70+5XpeE@cc z*lOSfELXqv5->xMO5jV&<#JB}?H5B@HesWUhr$XPg3Q)A^f<2dLrm8YEECP+013sP$7EVqFKDvjWL8wUrxwGMhc1VDgMX6L2gUKo=t`TK1QX__8hhrw|a84O7aAGX7CXuGu zTQfl7>j3AH#1K3aXPRF?17WvQHoe1U(&NsAew%@`nT!;}7+r*oaFNIymRlfpb6ETT zVo^m5nkbV06isqVsl>!|z6F%Ud=mjd=^ROEkyQu3&W4~x-@6%GX?)P!+#R;PlGa8J2jJaVuXY|OH$nT@IKLt{HvKalC5@o?X(rx8_s z$MA*$X7ZsW!=c{mZ5_#~xO?Wo9ck)!b2~gf`Otj%R(|lpip<6XZ;yQSG_s+jrz~p8 z-gB;7y<_z3$ZrFG=~LU=(ictseZ^F`f7d48<%tW=?_Az9m~~PCwFftf#mC zkDoJC)W@1VXVb<=*BD!kM-Z1n3Cy=9A|kb|I191FRRadAf-wxw3YAZ zR&7Y%E@WpO8WwWXGV|_FKWSaD)H}WHm*@xE&lN!}w_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f(zJo=7a&bt|hqknEbs7uH8$ zomtGu-aW3!*QrvD9T=$b-*C`AhlqFM3=+4M;oX1pi`&mm!RG;bBF~=YY&Lqs?W=EiOht;O#Yc)mxfY#tU9EPiqJ%t zwp31EJV!2Sw6X%KZgQbAhrkV?6Kh>i&m9- zl>DXW<4}J6@#zeUch9Q*=LHMZL-@);b=tNZqD!fU3m^=WFlyv2a*2zpwwLiVUDY`vNaZYIHZESdPOQ7N>ey zmHDQm!m`YzFoIer#ghg8xG(s9EEenQ`UYmRR%ZeQv==2}alRwr7H-W5-Px=lx%uR$wju#CDOjOkfLW7;OZu~rm_bT^Zm+4{y7gOY^7xQaN< l`eXQf=H%RSDY`{}9`d-Mbs$FnwCL>?h6EnQR3C`F@OPN{shI!( diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/grid.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/grid.png index fdb2cc35cf8aaf75a5e1436069682a8dd5c10c85..427fe94861863ec066233b7ce5ff3e3af2144018 100644 GIT binary patch literal 850 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K58911MRQ8&P5D>38$lZxy-8q?;Kn_c~qpu?a z!^VE@KZ&eBzC?geh%1o(|NsB7W5+^6L%X}X&CShk-@XkL?AfqU2uN|11o;I66@UQ4 zz2?1G+w|DOLT{aMDy;u@;;`e^TEjLX* zA3mz_wJ{>S*2(IG_{zN@hKHJTUhnd`^Q-9et{Am8CyE3PS=)n5>sz7UtCM*Vd&_T{jh2iG=4{3}$a_hadHRL}475{n6 zz{C8b@S9w{^qKeD-)S>5*3H|KJN>8d$BVTfuUekC2qdB4NwJ?aggIfeJrhh&!5tKC z5HR7qWiEu}aPA)mOt4vom!W}o!Mp#zdtbfQYiIJ2YIw$Qy^P_ucImzA+zRb=*H=HE z&!><-v3gpvOukjao9YOV)(Ok~1%TA1_lb-g4)@M%DnEVa_j&EB3_H`S$}De#q7MWV ze#?nLSPTpYuGcFTZJV0ZaA)@$(R*)G-qmI=l~TCBCA~HNS+X`%70h@rx76Hnaab2) z(fdu|727B8{JwT-RzuC@d7^bQ``5xu1vvo5zH;|TPn0Ix3}v7|%KgK?m?!MMzW31Y zyJz<1uMJ^-vi$7kL-HBN!(hs9e%}CNGQ7$wc3&&Pd`6IgVK1ZG9zopr0F$3gGXMYp literal 910 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K58911MRQ8&P5D>38$lZxy-8q?;Kn_c~qpu?a z!^VE@KZ&eBzC?geh%1o(|NsB7W5+^6L%X}X&CShk-@XkL?AfqU2uN|11o;I66@UQ4 zz2?1?z`0BYXtAGPT-jfU_4uuAWm^CVlH@5EyWRQD({}R(j#`(MD z4%quO7&Uxf{r%5vh5hl-eq4-ov3p9r|GCs`n*-8v=fp)8pb3l+;z6U|wXx$P&R=^#A_)RqvyxG4ae|ILr9%EyK0&S2b(I z8O;AK-2B~Mh9Q6A?MG&P<}wV`(^VUQb{)9N?g2C{;r%8Sh6eM^Z)|5&|Np7Nd!TsP z+S^zC;7<6a=M8hDz=PlW1$N%@lxTRaSA8(u`pn+xewP?(E^lj!f0nEccMsHjpdXny zCR9%fE)`;Xu=8}>hnsxG@0U(CVYt6#?Stt*Z*)Ta%W>ddDkoSmhMAEmcr-?EyHYfH7cV~WcQEo)d#mH8-I_pO1vBp x{O)OdsCtf+SHqo0WYW7gtoFNMa>?dD+cP=8ms-ApD}i}|!PC{xWt~$(699V6V~PL( diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/pattern_grid.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/pattern_grid.png new file mode 100644 index 0000000000000000000000000000000000000000..93b6d60140357513447d9dd1f43382b3c458cc18 GIT binary patch literal 930 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K58911MRQ8&P5D>38$lZxy-8q?;Kn_c~qpu?a z!^VE@KZ&eBzC?geh%1o(|NsB7W5+^6L%X}X&CShk-@XkL?AfqU2uN|11o;I66@UQ4 zz2?1=FY5(|=DF$B>G+w|4^bZy89mT@1MKnHqu-vOhqf0p-eXANuU&$OO@UsQwP zX3nu=%og8YP2#S}cWCflK5stAC6Y_bfF#3-G+(9(pUv{c8cx5BjcPAyeBaCdVLI~# zo(IQYtbNb+`FnKgQpE%35AL38^j~S+R8gRolnJ*$Iw9bR)nPUWE9ILhRLp^GB`=i8 zz~HdXI0wRUNQ(yrB?y3x*unVackTW#+j*Nb4=e$OwL$sUACp=5{JzAOJ#7q? zTO}9RSGqBQrNFkNF2Bg|Y5t_c1r!Kh%C;c z5H7F4@Ve6IyI8}fUjjfWBad7LHr5Z43$Fv+2=nzRzjk(sm#42>yBN1x7U(exivvFk z80HJ#FV$(_`5XQIoW1OUqVQuY@~s-?>;}a@!-Tu)96-vld@}>X4#p?SC#$F1y!-oj z>OF>^if^uEZUF^42soU(s{>&%Ff<(RKhd-8lBB}-*l$+%Zl8R7&s%#h<0qfnuYRPg ziw1fU44&LM3v?L-yeL;+e$^|z;ZFI@*A@Bd{nh$wzp$M!&RzX@^3FU^`UQar#pc`) z7BD34&z%#dJ(uwr)N%V5ir$y5fBg5Z&AYu@E=en_H;a~yzwjyyrXK8mDCgJRv$_7fY-kZMS;P#dGL(TTo`u`TW%XfDZU-UWA1{*mu hhDw_pcJ>`{^^CO*uXmf3T$%$i&(qbgTe~ HDWM4fYdkH7 literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/large_slot.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/large_slot.png new file mode 100644 index 0000000000000000000000000000000000000000..6c21320cde395209d9857908956c86b4be570287 GIT binary patch literal 154 zcmeAS@N?(olHy`uVBq!ia0vp^QXtI23?!pd0{;Rj#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>0X`wF=H}+z-QEBH|6d&O{W3_fz$3Dlfr0NZ2s0kfUy%Y7l=5_O4AD5B s?7-H;)6>MEU~+2l4D}@}>|S0B2UJA`&z0jgr~boFyt=akR{0AA@TLjV8( literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/light_arrow.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/light_arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..da1309976882f4250f839e6adba86ba5451b8c52 GIT binary patch literal 200 zcmeAS@N?(olHy`uVBq!ia0vp^VnEE#!3-p?Z$2Ldq!^2X+?^QKos)S9vjzBsxc>kDAIJlF_i@Q1^;Jwy4}DF$m1;Vh%9Dc;5!V$jK}j= zqyPnNJzX3_G=h829pqwA;9$P+=l}e5+eDY}-EzEX-Jv{h&aBA21`CarJoJ^-e|*j` oCnNn{1`c>;VwT+PkRySuyp|NjpZ@H_k`1*EPd$S)Wq;-Izi3y{xQ;1OBOz`%DH zgc*T{_#sfCw{=dy zw0%eT&om$Sd7|-vVY>f=k~F^u1t(`6cx;;Nw4Tv1-&dY#`JBJKKa`z**IOAW-%*FV iL2$y&=*zK&`xp=JF-^?a`0F0fYYd*QelF{r5}E)jV~3Xj literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/slot.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/slot.png new file mode 100644 index 0000000000000000000000000000000000000000..cc17511b22da9b05becaee7200e4a83a256d09e0 GIT binary patch literal 153 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh-3?!F4n4AKn7>k44ofy`glX(f`u%tWsIx;Y9 z?C1WI$O`0h2Ka=ynwy(9UeaUQXH<9idRh{4m<&t;ucLK6TkLMZnD literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/clear.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/clear.png new file mode 100644 index 0000000000000000000000000000000000000000..a297d3218b2266ab25bb7602ca110301df6289ef GIT binary patch literal 158 zcmeAS@N?(olHy`uVBq!ia0vp^>>$j-3?$8JydD54#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>0X`wF|NsB*?(Q}>H~)W)`yxoNz$3Dlfr0NZ2s0kfUy%Y7l=F0P43W5; w%)rFR=H}?g%I4-gu;C$`la>k&TQ~e-wY^2dZT7boFyt=akR{0HSj#&j0`b literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/clear_disabled.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/clear_disabled.png new file mode 100644 index 0000000000000000000000000000000000000000..56741f57e7912405051af91f5b47c73c409b9b4e GIT binary patch literal 158 zcmeAS@N?(olHy`uVBq!ia0vp^>>$j-3?$8JydD54#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>0X`wFO-)U1Zf-I%GLtSW02#$u;1OBOz`%DHgc*iofy$RWf+G`njxgN@xNAldL9_ literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/clear_focused.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/clear_focused.png new file mode 100644 index 0000000000000000000000000000000000000000..6c773af481ac18ff137e81bfe0978854ffc1aa09 GIT binary patch literal 158 zcmeAS@N?(olHy`uVBq!ia0vp^>>$j-3?$8JydD54#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>0X`wF|Ns9#a^%RYS+lB=o=1WN3p^r=85sBugD~Uq{1qucK{-zs#}J9j w$qY=4Y;KN@tZZ&>ZVHMF>5WHPrc4oG5ZTB$^+)knexOPQPgg&ebxsLQ01Ch>4gdfE literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/create_pattern.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/create_pattern.png new file mode 100644 index 0000000000000000000000000000000000000000..5f8f20ae9ff984d3b4b982c9b9393c099bb73b28 GIT binary patch literal 363 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%Lh70G|+7NlD37t5z*vzC1raf7!BSd3kw-g@xJK*+D@;IXOAS#l`>s|1T&g zC@n1w4GqoB&CSfr3<(KYy?S*?Nl9d6WO;dcSXfwETAIJVe?&yYiWMsY0s?}AgMEB_ zqN1YW;^JO>tDO(Di?hHZvY3H^?=T269?xHq0u-F$>Ealo5uDn0lkboL56f*mvnLsI z3naK0|NYnBsO;c$ru*s1byFYCzc_Q5o!g8X0zAjAJwGQba=>t@jq-&@N)tr9I4zx4 zb?#NwoXzm*;SKGdPedIKygHO0r6lm=k6@0Im*C5$iT4`x^&aKCuVt^*-gmoq)2tm% zEZ_PYPCS~rA}W8?+HGa|ae`Nm7hhef8+!F9|KSfzF2d|Dr*1Vq0CXRNr>mdKI;Vst E0I21U9smFU literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/create_pattern_disabled.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/create_pattern_disabled.png new file mode 100644 index 0000000000000000000000000000000000000000..02a6f7f2db128274b4b42c4309772609843935d1 GIT binary patch literal 332 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%Lh(0G|+7NlD4Z#>Tq3Iu8#IPft&Oe}7k3S0^VY9UYzS?rwd3{rdWPZ*OmR zcXwS~U1MY8+S*zJ0|Or)A5BfofPer$KR-i5LoF>W6B82)3kxG7qoZ#{vw?X@k4*2C?RC^yVzsP5O#b%SYrAV30yZE2oGNzu|0id!{3!x# Vp&v?Hq=4>W@O1TaS?83{1ON|nalHTl literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/create_pattern_focused.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/create_pattern_focused.png new file mode 100644 index 0000000000000000000000000000000000000000..75dc86a18bae8db49a3dbd4a46dcd77e7d4bbd60 GIT binary patch literal 369 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%Lht0G|+7NlD4Q$Nuj>@qgEm|8*VvcOLp*)3&d%`(Q=Wo`|HGO+5$y|Nq}M z;c#^7oT`>RrS-d_Qf41K^}nU>P<-ZshOPr0la5rk?u|*CTU5IU)Uc##>RVXNQ9v9mQ7P2<3B>*FDakvev+D8f#7!>${W($G5+D ze81}~%i}c#Y}{YuS?^ueic^Vo$y)U_YHgA5PW!Z(uco;0)Lk<1&+_I7l#F-(2Xr5U Mr>mdKI;Vst0BlR0dH?_b literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/generic_small_button.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/generic_small_button.png new file mode 100644 index 0000000000000000000000000000000000000000..e0f684b0fbcdef093e0360fe4a3067ef12208fb7 GIT binary patch literal 356 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%Li60G|+7NlD37t5z*vzC1raf7!BSd3kw-g@xJK*+D@;IXOAS#l-~$1*N5> zp`oFfsDJhAJj4UrN4+{%ROH1?j_m7B(Sg~S7KtMonaIlY$PgGP? zTwL5kjtoe7_94*`DF3^=;tN&ul ztN;IJI!#uUdVjjL-CE+GY1^`uw>j9Yo4Pmh+q*OgS#+Q1aq(_&iSl5XwD9V|i<9lT zXU{peS84hR2Ci)kg_ngp7hLDvz^v=KmAS80{D+vr`P)3d)^*(1Slw(L@;Kiqt=G$J vHUH+Y=<01NR@{8O_tvFpSz-^|4}W0Pwqaj3&(_fw=r#sVS3j3^P6NS%G}N0G|+7NlD4Z#>Tq3Iu8#IPft&Oe}7k3S0^VY9UUEgef|3SdT(!UcXxMP zU0q{iDaISV`@iy0XB z4uLSEsD@VqP_V(%#W6%9IJLiPx#1ZP1_K>z@;j|==^1poj5icm~cMHv|xy~h8)$p5;;|9*(Sxx)W^hQ5J|!FYna zSYnxijKPPI#(jsphLFQsWt@71ymf!NhLFXDkHlJJo59Nedxg4*lgNaQ!e42ifQrC~ zlEj0J!h40iTxOksiobGwxrC0xe1^M8M&uyeB6b1xMfuYTjUCsky{ts_kf2JtJunogFf|}4>)vzs*3y@9C*8%?3)9lI2!O2 z+y!oGeg3U*I5B~$v%&@BK^#1o$to<;UPWRX<1Jd{F7kMurHo}OV(^nBc>!Y53j&y# RA|(I-002ovPDHLkV1ke$xEcTe literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/item/pattern/crafting.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/item/pattern/crafting.png new file mode 100644 index 0000000000000000000000000000000000000000..a23d840a5a5202f168c8397f68787bc135a92414 GIT binary patch literal 489 zcmVblfO#>aTvxQTLg!OXp5R^XvoDe$e|hzJbe#r5o{>h z0%_7OcOdAIQTP|!BsjS!H#9lu6gQaXk0XKxB@kx^!NK0PL(6^%J@fN?cz7RP;6Ft~ zOhmkN*l`^0_xsC1ZqE*xh`7_~aJ$|98|3c%h@T(s`8s~UM8uY5v1M5cA)b%5_f}qU zd=f|Rsf}%a02@1gB+_{ZAut#WP$(2osZ`wD%4}HIb#&e~@zQ<7>e@QCb^}PH^T=c} z==FMNG#U^>V77@1@cDf3dcDvz4W=`~e&iIF>J5^~B!Fa1gfgK1|bBR%_geVDk6~x06^Du1cO10 z$K%D@1m0+6YLjRXdy4@}pi$#t`qs#q6EEZ!~mX{0vR`0;s%8GDAhp_+v01jnXNoGw= f04e|g00;m8000000Mb*F00000NkvXXu0mjf@utkg literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/item/pattern/empty.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/item/pattern/empty.png new file mode 100644 index 0000000000000000000000000000000000000000..5b838ac0ecd3ad21f1d4e1304de5226eb833baa0 GIT binary patch literal 15031 zcmeI3e{2(F7{?EEh$9e*iUbK<%1rpN_U_uXYtOc@t($A4h}#GoM&Z_byIpAS&bu4! zmOyYI5g~+(NYEIT5JC_EBa=)7+?SE^L^g;^Stld`{&lqpZCJp;z`96MU4&C2I}Db3G*|06#Sk#a8H1@$JN>F51ogp@)R)JQjwnGE;9rGH(9ZSO=(K6d#>`m}cAO;M9PQ;?J&L@19q%IGCo6U@c zPIfVt`YaV@Lb@?DpRQ6gKs#+NYnbCWy4+*qoNkBRSxVbk&dIPIhGVTP$8#)iXX*51 z@fX8iUQLYfb%C06I%xSUt%jlU3=@yXZE=T9(OMYJQ@rmoPev>85&#Y~jB(({U`nMAUlW(O%U2|;Bz8_N_562qAowM~mA zhbD#@5Ct(H8#;{R3dX6eilOMO$}lN2?qL(dnuJ1`+y%!Qixo_*8`aAof;7^Ck$OYB z3Ya>eD{WdBR4;>5nO11_h7`#bCr`=r3_Es^kcJ5}J*lwdQb<+E3+KvLX+SU(twB+u z{?sa)KZua7s!FaZdip|17L~X@!^@x{*?MQyKtM2nAFfB2m33QLX9MTvxpLlNx3c9t z%jSrrdLkMjMU*1#`5G=$gLU$3d9FrIPgDc$A5k!b`%=m6o1-I!`G}&$1j8@IgciW4 za*LPAHsGUir=0ohTQD#_M-{oKLh zMrRg16yk%jZU}Jj!9a2>5*!PNM9M|rhKG?o0<3OV8T@jTHCr7HPIP!gHw%C}xf1fj zvm;AO4`xqGo6~#{>74K((l2QeJg$XkPM<-N50avQ%#c*Il3CYw1iV>|dhmLFYqqY* zgH;tY9hk?4&oX#!WKLq(HFJ5B#}6-r%_G?#Hg`1;y-Z$fc35bb^nVMO($5JWK1aM2 z$hcD>C6(+oyojzujJTkIiWazE?&rWtspf~F^0CuWPgu~g%|w)hF3Z?*NuiY;X`xXXlOQafh-w*dpaA^oD*gKeWcE| zdibOR{4S@{;q)?SGa4~pN`Po%K!RtRZmvqsm5xCj1p}Lg3(Rq(15*Xec_vA2sZ=X` z;(-raOy+58$ZpH*g@^egJEMoGifEA}2oStUaN+qNUV;k&f;R~+JRihMa3MhOCc%a0 zgLnxp1PI4T@Fu~9=Yx0&E(8ePB)IT=5HG=n0KuCC z7oHE|CAbhEc$475^Fh1>7Xk!t5?pvbh?n3(fZ$Dn3(p7f5?lxnyh(83`5<0`3ju;R z2`)Sz#7l4?K=3BPh3A8K2`&T(-o)Z6&c440Wcboz9KM~{vGv*p_+}#=uB{7ERL64^ zwQ?0j-Mt6zHz=x&rKq2mP!zv~qMlK@7N4r2s1dcnKt)61()LZhUB~A<^=8ipr6*Q9 zw#@7qbL=?%Sy9pR^)sa1BPVpqb2=@}D`tMIPQAKx>l+*ItXMZj?>`#vf7jDD;{AJp zO)0`e*Z%3EO~nyeSToV^%svC{Er4dzIuGu*?sFv zznrvj-pZ0ut43V@b@Qp_V{-3@2V0tI-rM2aUbHdLw7Is~-`%rl&(2-N!RzhkB0Yk4 zO5dhWC}E;@ZF#rt#Nqw>xHbDqgI%lX(Rco|eY*GN mYT>P)+GoGAx%hmX|Q@;U~lD;&i?>vN`RIC literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/data/refinedstorage/recipe/pattern.json b/refinedstorage-common/src/main/resources/data/refinedstorage/recipe/pattern.json new file mode 100644 index 000000000..0ef8ac15b --- /dev/null +++ b/refinedstorage-common/src/main/resources/data/refinedstorage/recipe/pattern.json @@ -0,0 +1,22 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "GRG", + "RGR", + "EEE" + ], + "key": { + "G": { + "tag": "c:glass_blocks" + }, + "R": { + "tag": "c:dusts/redstone" + }, + "E": { + "item": "refinedstorage:quartz_enriched_iron" + } + }, + "result": { + "id": "refinedstorage:pattern" + } +} \ No newline at end of file diff --git a/refinedstorage-common/src/main/resources/data/refinedstorage/recipe/pattern_grid.json b/refinedstorage-common/src/main/resources/data/refinedstorage/recipe/pattern_grid.json new file mode 100644 index 000000000..dfd7439b2 --- /dev/null +++ b/refinedstorage-common/src/main/resources/data/refinedstorage/recipe/pattern_grid.json @@ -0,0 +1,17 @@ +{ + "type": "minecraft:crafting_shapeless", + "ingredients": [ + { + "item": "refinedstorage:grid" + }, + { + "item": "refinedstorage:advanced_processor" + }, + { + "item": "refinedstorage:pattern" + } + ], + "result": { + "id": "refinedstorage:pattern_grid" + } +} \ No newline at end of file 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 index 1a7fc620a..ac3bdd729 100644 --- a/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/TestPlatform.java +++ b/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/TestPlatform.java @@ -227,4 +227,9 @@ public NetworkNodeContainerProvider getContainerProviderSafely(final Level level @Nullable final Direction direction) { throw new UnsupportedOperationException(); } + + @Override + public int getItemColor(final ItemStack stack, final int tintIndex) { + throw new UnsupportedOperationException(); + } } 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 cb00fd976..e8a6a0a07 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 @@ -4,6 +4,9 @@ import com.refinedmods.refinedstorage.common.AbstractClientModInitializer; import com.refinedmods.refinedstorage.common.api.support.HelpTooltipComponent; import com.refinedmods.refinedstorage.common.api.upgrade.AbstractUpgradeItem; +import com.refinedmods.refinedstorage.common.autocrafting.CraftingPatternClientTooltipComponent; +import com.refinedmods.refinedstorage.common.autocrafting.PatternItem; +import com.refinedmods.refinedstorage.common.autocrafting.PatternItemColor; import com.refinedmods.refinedstorage.common.configurationcard.ConfigurationCardItemPropertyFunction; import com.refinedmods.refinedstorage.common.content.BlockColorMap; import com.refinedmods.refinedstorage.common.content.BlockEntities; @@ -32,6 +35,7 @@ import com.refinedmods.refinedstorage.common.upgrade.RegulatorUpgradeItem; import com.refinedmods.refinedstorage.common.upgrade.UpgradeDestinationClientTooltipComponent; import com.refinedmods.refinedstorage.common.util.IdentifierUtil; +import com.refinedmods.refinedstorage.fabric.autocrafting.PatternUnbakedModel; import com.refinedmods.refinedstorage.fabric.mixin.ItemPropertiesAccessor; import com.refinedmods.refinedstorage.fabric.storage.diskdrive.DiskDriveBlockEntityRendererImpl; import com.refinedmods.refinedstorage.fabric.storage.diskdrive.DiskDriveUnbakedModel; @@ -51,6 +55,7 @@ import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; import net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; +import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; import net.fabricmc.fabric.api.client.rendering.v1.TooltipComponentCallback; import net.minecraft.client.KeyMapping; import net.minecraft.client.gui.screens.MenuScreens; @@ -96,6 +101,7 @@ public > void registerResourceRendering(); registerAlternativeGridHints(); registerItemProperties(); + registerItemColors(); } private void setRenderLayers() { @@ -105,6 +111,7 @@ private void setRenderLayers() { setCutout(Blocks.INSTANCE.getCable()); setCutout(Blocks.INSTANCE.getGrid()); setCutout(Blocks.INSTANCE.getCraftingGrid()); + setCutout(Blocks.INSTANCE.getPatternGrid()); setCutout(Blocks.INSTANCE.getController()); setCutout(Blocks.INSTANCE.getCreativeController()); setCutout(Blocks.INSTANCE.getDetector()); @@ -133,6 +140,7 @@ private void registerEmissiveModels() { registerColoredEmissiveModels(Blocks.INSTANCE.getCreativeController(), "controller"); registerColoredEmissiveModels(Blocks.INSTANCE.getGrid(), "grid"); registerColoredEmissiveModels(Blocks.INSTANCE.getCraftingGrid(), "crafting_grid"); + registerColoredEmissiveModels(Blocks.INSTANCE.getPatternGrid(), "pattern_grid"); registerColoredEmissiveModels(Blocks.INSTANCE.getDetector(), "detector"); registerConstructorDestructorEmissiveModels(Blocks.INSTANCE.getConstructor(), "constructor"); registerConstructorDestructorEmissiveModels(Blocks.INSTANCE.getDestructor(), "destructor"); @@ -299,6 +307,7 @@ private void registerCustomModels() { registerCustomDiskDriveModels(pluginContext, quadRotators); registerCustomDiskInterfaceModels(pluginContext, quadRotators); registerCustomPortableGridModels(pluginContext, quadRotators); + registerCustomPatternModel(pluginContext); }); } @@ -362,14 +371,30 @@ private void registerCustomDiskDriveModels(final ModelLoadingPlugin.Context plug }); } + private void registerCustomPatternModel(final ModelLoadingPlugin.Context pluginContext) { + final ResourceLocation patternIdentifier = createIdentifier(ITEM_PREFIX + "/pattern"); + pluginContext.resolveModel().register(context -> { + if (context.id().equals(patternIdentifier)) { + return new PatternUnbakedModel(); + } + return null; + }); + } + private void registerCustomTooltips() { TooltipComponentCallback.EVENT.register(data -> { if (data instanceof AbstractUpgradeItem.UpgradeDestinationTooltipComponent component) { return new UpgradeDestinationClientTooltipComponent(component.destinations()); } + return null; + }); + TooltipComponentCallback.EVENT.register(data -> { if (data instanceof HelpTooltipComponent component) { return HelpClientTooltipComponent.create(component.text()); } + return null; + }); + TooltipComponentCallback.EVENT.register(data -> { if (data instanceof RegulatorUpgradeItem.RegulatorTooltipComponent component) { final ClientTooltipComponent help = HelpClientTooltipComponent.create(component.helpText()); return component.configuredResource() == null @@ -378,6 +403,20 @@ private void registerCustomTooltips() { } return null; }); + TooltipComponentCallback.EVENT.register(data -> { + if (data instanceof PatternItem.CraftingPatternTooltipComponent component) { + final ClientTooltipComponent help = HelpClientTooltipComponent.create(component.helpText()); + return new CompositeClientTooltipComponent(List.of( + new CraftingPatternClientTooltipComponent( + component.width(), + component.height(), + component.craftingPattern() + ), + help + )); + } + return null; + }); } private CompositeClientTooltipComponent createRegulatorUpgradeClientTooltipComponent( @@ -447,4 +486,8 @@ private void registerItemProperties() { new SecurityCardItemPropertyFunction() ); } + + private void registerItemColors() { + ColorProviderRegistry.ITEM.register(new PatternItemColor(), Items.INSTANCE.getPattern()); + } } diff --git a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/ConfigImpl.java b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/ConfigImpl.java index 440f1fcbf..d9edce291 100644 --- a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/ConfigImpl.java +++ b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/ConfigImpl.java @@ -28,6 +28,9 @@ public class ConfigImpl implements ConfigData, com.refinedmods.refinedstorage.co @ConfigEntry.Gui.CollapsibleObject private GridEntryImpl grid = new GridEntryImpl(); + @ConfigEntry.Gui.CollapsibleObject + private SimpleEnergyUsageEntryImpl patternGrid = new SimpleEnergyUsageEntryImpl(DefaultEnergyUsage.PATTERN_GRID); + @ConfigEntry.Gui.CollapsibleObject private CraftingGridEntryImpl craftingGrid = new CraftingGridEntryImpl(); @@ -145,6 +148,11 @@ public GridEntry getGrid() { return grid; } + @Override + public SimpleEnergyUsageEntry getPatternGrid() { + return patternGrid; + } + @Override public CraftingGridEntry getCraftingGrid() { return craftingGrid; 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 8387e7aef..c26312d02 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 @@ -32,6 +32,8 @@ import com.refinedmods.refinedstorage.common.support.packet.c2s.GridExtractPacket; import com.refinedmods.refinedstorage.common.support.packet.c2s.GridInsertPacket; import com.refinedmods.refinedstorage.common.support.packet.c2s.GridScrollPacket; +import com.refinedmods.refinedstorage.common.support.packet.c2s.PatternGridClearPacket; +import com.refinedmods.refinedstorage.common.support.packet.c2s.PatternGridCreatePatternPacket; import com.refinedmods.refinedstorage.common.support.packet.c2s.PropertyChangePacket; import com.refinedmods.refinedstorage.common.support.packet.c2s.ResourceFilterSlotChangePacket; import com.refinedmods.refinedstorage.common.support.packet.c2s.ResourceSlotAmountChangePacket; @@ -420,6 +422,14 @@ private void registerClientToServerPackets() { CraftingGridClearPacket.PACKET_TYPE, CraftingGridClearPacket.STREAM_CODEC ); + PayloadTypeRegistry.playC2S().register( + PatternGridClearPacket.PACKET_TYPE, + PatternGridClearPacket.STREAM_CODEC + ); + PayloadTypeRegistry.playC2S().register( + PatternGridCreatePatternPacket.PACKET_TYPE, + PatternGridCreatePatternPacket.STREAM_CODEC + ); PayloadTypeRegistry.playC2S().register( CraftingGridRecipeTransferPacket.PACKET_TYPE, CraftingGridRecipeTransferPacket.STREAM_CODEC @@ -487,6 +497,14 @@ private void registerPacketHandlers() { CraftingGridClearPacket.PACKET_TYPE, wrapHandler(CraftingGridClearPacket::handle) ); + ServerPlayNetworking.registerGlobalReceiver( + PatternGridClearPacket.PACKET_TYPE, + wrapHandler((packet, ctx) -> PatternGridClearPacket.handle(ctx)) + ); + ServerPlayNetworking.registerGlobalReceiver( + PatternGridCreatePatternPacket.PACKET_TYPE, + wrapHandler((packet, ctx) -> PatternGridCreatePatternPacket.handle(ctx)) + ); ServerPlayNetworking.registerGlobalReceiver( CraftingGridRecipeTransferPacket.PACKET_TYPE, wrapHandler(CraftingGridRecipeTransferPacket::handle) @@ -540,6 +558,7 @@ private void registerCapabilities() { registerNetworkNodeContainerProvider(BlockEntities.INSTANCE.getConstructor()); registerNetworkNodeContainerProvider(BlockEntities.INSTANCE.getController()); registerNetworkNodeContainerProvider(BlockEntities.INSTANCE.getCraftingGrid()); + registerNetworkNodeContainerProvider(BlockEntities.INSTANCE.getPatternGrid()); registerNetworkNodeContainerProvider(BlockEntities.INSTANCE.getCreativeController()); registerNetworkNodeContainerProvider(BlockEntities.INSTANCE.getDestructor()); registerNetworkNodeContainerProvider(BlockEntities.INSTANCE.getDetector()); diff --git a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/PlatformImpl.java b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/PlatformImpl.java index 169862220..8f5e05b2e 100644 --- a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/PlatformImpl.java +++ b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/PlatformImpl.java @@ -40,6 +40,7 @@ import com.mojang.blaze3d.platform.InputConstants; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; +import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; import net.fabricmc.fabric.api.entity.FakePlayer; import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; @@ -55,6 +56,7 @@ import net.fabricmc.fabric.impl.transfer.context.ConstantContainerItemContext; import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; +import net.minecraft.client.color.item.ItemColor; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.EditBox; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; @@ -474,6 +476,15 @@ public NetworkNodeContainerProvider getContainerProviderSafely(final Level level ); } + @Override + public int getItemColor(final ItemStack stack, final int tintIndex) { + final ItemColor itemColor = ColorProviderRegistry.ITEM.get(stack.getItem()); + if (itemColor == null) { + return -1; + } + return itemColor.getColor(stack, tintIndex); + } + private void doSave(final CompoundTag compoundTag, final Path tempFile, final Path targetPath) throws IOException { // Write to temp file first. NbtIo.writeCompressed(compoundTag, tempFile); diff --git a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/autocrafting/PatternBakedModel.java b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/autocrafting/PatternBakedModel.java new file mode 100644 index 000000000..fc7f3ed44 --- /dev/null +++ b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/autocrafting/PatternBakedModel.java @@ -0,0 +1,24 @@ +package com.refinedmods.refinedstorage.fabric.autocrafting; + +import com.refinedmods.refinedstorage.common.autocrafting.PatternItemOverrides; + +import net.fabricmc.fabric.api.renderer.v1.model.ForwardingBakedModel; +import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.ModelBaker; + +class PatternBakedModel extends ForwardingBakedModel { + private final ItemOverrides itemOverrides; + + PatternBakedModel(final ModelBaker modelBaker, + final BakedModel emptyModel, + final BakedModel craftingModel) { + this.wrapped = emptyModel; + this.itemOverrides = new PatternItemOverrides(modelBaker, emptyModel, craftingModel); + } + + @Override + public ItemOverrides getOverrides() { + return itemOverrides; + } +} diff --git a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/autocrafting/PatternUnbakedModel.java b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/autocrafting/PatternUnbakedModel.java new file mode 100644 index 000000000..08b2f3c8b --- /dev/null +++ b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/autocrafting/PatternUnbakedModel.java @@ -0,0 +1,45 @@ +package com.refinedmods.refinedstorage.fabric.autocrafting; + +import java.util.Collection; +import java.util.Set; +import java.util.function.Function; +import javax.annotation.Nullable; + +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.Material; +import net.minecraft.client.resources.model.ModelBaker; +import net.minecraft.client.resources.model.ModelState; +import net.minecraft.client.resources.model.UnbakedModel; +import net.minecraft.resources.ResourceLocation; + +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; +import static java.util.Objects.requireNonNull; + +public class PatternUnbakedModel implements UnbakedModel { + private static final ResourceLocation EMPTY_MODEL = createIdentifier("item/pattern/empty"); + private static final ResourceLocation CRAFTING_MODEL = createIdentifier("item/pattern/crafting"); + + @Override + public Collection getDependencies() { + return Set.of(EMPTY_MODEL, CRAFTING_MODEL); + } + + @Override + public void resolveParents(final Function resolver) { + resolver.apply(EMPTY_MODEL).resolveParents(resolver); + resolver.apply(CRAFTING_MODEL).resolveParents(resolver); + } + + @Nullable + @Override + public BakedModel bake(final ModelBaker baker, + final Function spriteGetter, + final ModelState state) { + return new PatternBakedModel( + baker, + requireNonNull(baker.bake(EMPTY_MODEL, state)), + requireNonNull(baker.bake(CRAFTING_MODEL, state)) + ); + } +} diff --git a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/autocrafting/package-info.java b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/autocrafting/package-info.java new file mode 100644 index 000000000..e72b75536 --- /dev/null +++ b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/autocrafting/package-info.java @@ -0,0 +1,7 @@ +@ParametersAreNonnullByDefault +@FieldsAndMethodsAreNonnullByDefault +package com.refinedmods.refinedstorage.fabric.autocrafting; + +import com.refinedmods.refinedstorage.api.core.FieldsAndMethodsAreNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/mixin/AbstractBlockEntityWithoutLevelRendererMixin.java b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/mixin/AbstractBlockEntityWithoutLevelRendererMixin.java new file mode 100644 index 000000000..49b593b88 --- /dev/null +++ b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/mixin/AbstractBlockEntityWithoutLevelRendererMixin.java @@ -0,0 +1,34 @@ +package com.refinedmods.refinedstorage.fabric.mixin; + +import com.refinedmods.refinedstorage.common.autocrafting.PatternBlockEntityWithoutLevelRenderer; + +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.world.item.ItemDisplayContext; +import net.minecraft.world.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(BlockEntityWithoutLevelRenderer.class) +public abstract class AbstractBlockEntityWithoutLevelRendererMixin { + @Inject(method = "renderByItem", at = @At("HEAD"), cancellable = true) + public void onRenderByItem(final ItemStack stack, + final ItemDisplayContext displayContext, + final PoseStack poseStack, + final MultiBufferSource buffer, + final int packedLight, + final int packedOverlay, + final CallbackInfo callbackInfo) { + PatternBlockEntityWithoutLevelRenderer.getInstance().renderByItem( + stack, + displayContext, + poseStack, + buffer, + packedLight, + packedOverlay + ); + } +} diff --git a/refinedstorage-fabric/src/main/resources/refinedstorage.accesswidener b/refinedstorage-fabric/src/main/resources/refinedstorage.accesswidener index fbb2da410..f65de0bc5 100644 --- a/refinedstorage-fabric/src/main/resources/refinedstorage.accesswidener +++ b/refinedstorage-fabric/src/main/resources/refinedstorage.accesswidener @@ -5,4 +5,5 @@ accessible method net/minecraft/client/renderer/RenderType create (Ljava/lang/St accessible class net/minecraft/client/resources/model/ModelBakery$BakedCacheKey accessible class net/minecraft/client/resources/model/ModelBakery$ModelBakerImpl accessible method net/minecraft/client/resources/model/ModelBakery$BakedCacheKey (Lnet/minecraft/resources/ResourceLocation;Lcom/mojang/math/Transformation;Z)V -accessible method net/minecraft/client/gui/GuiGraphics renderTooltipInternal (Lnet/minecraft/client/gui/Font;Ljava/util/List;IILnet/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipPositioner;)V \ No newline at end of file +accessible method net/minecraft/client/gui/GuiGraphics renderTooltipInternal (Lnet/minecraft/client/gui/Font;Ljava/util/List;IILnet/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipPositioner;)V +accessible method net/minecraft/client/renderer/block/model/ItemOverrides ()V diff --git a/refinedstorage-fabric/src/main/resources/refinedstorage.mixins.json b/refinedstorage-fabric/src/main/resources/refinedstorage.mixins.json index f92e1683e..0fe893dcb 100644 --- a/refinedstorage-fabric/src/main/resources/refinedstorage.mixins.json +++ b/refinedstorage-fabric/src/main/resources/refinedstorage.mixins.json @@ -8,7 +8,8 @@ "EditBoxAccessor", "ItemPropertiesAccessor", "KeyMappingAccessor", - "ModelBakeryAccessor" + "ModelBakeryAccessor", + "AbstractBlockEntityWithoutLevelRendererMixin" ], "injectors": { "defaultRequire": 1 diff --git a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/ClientModInitializer.java b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/ClientModInitializer.java index bba37a5c7..d91397489 100644 --- a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/ClientModInitializer.java +++ b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/ClientModInitializer.java @@ -4,6 +4,10 @@ import com.refinedmods.refinedstorage.common.AbstractClientModInitializer; import com.refinedmods.refinedstorage.common.api.support.HelpTooltipComponent; import com.refinedmods.refinedstorage.common.api.upgrade.AbstractUpgradeItem; +import com.refinedmods.refinedstorage.common.autocrafting.CraftingPatternClientTooltipComponent; +import com.refinedmods.refinedstorage.common.autocrafting.PatternBlockEntityWithoutLevelRenderer; +import com.refinedmods.refinedstorage.common.autocrafting.PatternItem; +import com.refinedmods.refinedstorage.common.autocrafting.PatternItemColor; import com.refinedmods.refinedstorage.common.configurationcard.ConfigurationCardItemPropertyFunction; import com.refinedmods.refinedstorage.common.content.BlockEntities; import com.refinedmods.refinedstorage.common.content.Blocks; @@ -20,6 +24,7 @@ import com.refinedmods.refinedstorage.common.support.tooltip.ResourceClientTooltipComponent; import com.refinedmods.refinedstorage.common.upgrade.RegulatorUpgradeItem; import com.refinedmods.refinedstorage.common.upgrade.UpgradeDestinationClientTooltipComponent; +import com.refinedmods.refinedstorage.neoforge.autocrafting.PatternGeometryLoader; import com.refinedmods.refinedstorage.neoforge.storage.diskdrive.DiskDriveBlockEntityRendererImpl; import com.refinedmods.refinedstorage.neoforge.storage.diskdrive.DiskDriveGeometryLoader; import com.refinedmods.refinedstorage.neoforge.storage.diskinterface.DiskInterfaceBlockEntityRendererImpl; @@ -34,6 +39,7 @@ import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.MenuAccess; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; +import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; import net.minecraft.client.renderer.item.ItemProperties; import net.minecraft.world.inventory.AbstractContainerMenu; @@ -43,14 +49,18 @@ import net.neoforged.neoforge.client.event.InputEvent; import net.neoforged.neoforge.client.event.ModelEvent; import net.neoforged.neoforge.client.event.RegisterClientTooltipComponentFactoriesEvent; +import net.neoforged.neoforge.client.event.RegisterColorHandlersEvent; import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent; import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent; +import net.neoforged.neoforge.client.extensions.common.IClientItemExtensions; +import net.neoforged.neoforge.client.extensions.common.RegisterClientExtensionsEvent; import net.neoforged.neoforge.client.settings.KeyConflictContext; import net.neoforged.neoforge.client.settings.KeyModifier; import net.neoforged.neoforge.common.NeoForge; import org.lwjgl.glfw.GLFW; import static com.refinedmods.refinedstorage.common.content.ContentIds.DISK_DRIVE; +import static com.refinedmods.refinedstorage.common.content.ContentIds.PATTERN; import static com.refinedmods.refinedstorage.common.content.ContentIds.PORTABLE_GRID; import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; @@ -85,6 +95,7 @@ private static void registerModelPredicates() { @SubscribeEvent public static void onRegisterModelGeometry(final ModelEvent.RegisterGeometryLoaders e) { registerDiskModels(); + e.register(PATTERN, new PatternGeometryLoader()); e.register(DISK_DRIVE, new DiskDriveGeometryLoader()); e.register(PORTABLE_GRID, new PortableGridGeometryLoader()); Blocks.INSTANCE.getDiskInterface().forEach( @@ -177,6 +188,21 @@ private static void registerBlockEntityRenderer() { ); } + @SubscribeEvent + public static void onRegisterItemColors(final RegisterColorHandlersEvent.Item e) { + e.register(new PatternItemColor(), Items.INSTANCE.getPattern()); + } + + @SubscribeEvent + public static void onRegisterClientExtensions(final RegisterClientExtensionsEvent e) { + e.registerItem(new IClientItemExtensions() { + @Override + public BlockEntityWithoutLevelRenderer getCustomRenderer() { + return PatternBlockEntityWithoutLevelRenderer.getInstance(); + } + }, Items.INSTANCE.getPattern()); + } + @SubscribeEvent public static void onRegisterTooltipFactories(final RegisterClientTooltipComponentFactoriesEvent e) { e.register( @@ -196,6 +222,20 @@ public static void onRegisterTooltipFactories(final RegisterClientTooltipCompone : createRegulatorUpgradeClientTooltipComponent(component.configuredResource(), help); } ); + e.register( + PatternItem.CraftingPatternTooltipComponent.class, + component -> { + final ClientTooltipComponent help = HelpClientTooltipComponent.create(component.helpText()); + return new CompositeClientTooltipComponent(List.of( + new CraftingPatternClientTooltipComponent( + component.width(), + component.height(), + component.craftingPattern() + ), + help + )); + } + ); } private static CompositeClientTooltipComponent createRegulatorUpgradeClientTooltipComponent( 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 9a4322505..1fe2b5685 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 @@ -30,6 +30,7 @@ public class ConfigImpl implements Config { private final DiskInterfaceEntry diskInterface; private final GridEntry grid; private final CraftingGridEntry craftingGrid; + private final SimpleEnergyUsageEntry patternGrid; private final StorageBlockEntry storageBlock; private final FluidStorageBlockEntry fluidStorageBlock; private final SimpleEnergyUsageEntry importer; @@ -67,6 +68,7 @@ public ConfigImpl() { diskInterface = new DiskInterfaceEntryImpl(); grid = new GridEntryImpl(); craftingGrid = new CraftingGridEntryImpl(); + patternGrid = new SimpleEnergyUsageEntryImpl("patternGrid", DefaultEnergyUsage.PATTERN_GRID); storageBlock = new StorageBlockEntryImpl(); fluidStorageBlock = new FluidStorageBlockEntryImpl(); importer = new SimpleEnergyUsageEntryImpl("importer", DefaultEnergyUsage.IMPORTER); @@ -125,6 +127,11 @@ public GridEntry getGrid() { return grid; } + @Override + public SimpleEnergyUsageEntry getPatternGrid() { + return patternGrid; + } + @Override public CraftingGridEntry getCraftingGrid() { return craftingGrid; 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 a338ab84a..bde69c78a 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 @@ -32,6 +32,8 @@ import com.refinedmods.refinedstorage.common.support.packet.c2s.GridExtractPacket; import com.refinedmods.refinedstorage.common.support.packet.c2s.GridInsertPacket; import com.refinedmods.refinedstorage.common.support.packet.c2s.GridScrollPacket; +import com.refinedmods.refinedstorage.common.support.packet.c2s.PatternGridClearPacket; +import com.refinedmods.refinedstorage.common.support.packet.c2s.PatternGridCreatePatternPacket; import com.refinedmods.refinedstorage.common.support.packet.c2s.PropertyChangePacket; import com.refinedmods.refinedstorage.common.support.packet.c2s.ResourceFilterSlotChangePacket; import com.refinedmods.refinedstorage.common.support.packet.c2s.ResourceSlotAmountChangePacket; @@ -173,6 +175,8 @@ public ModInitializer(final IEventBus eventBus, final ModContainer modContainer) eventBus.addListener(ClientModInitializer::onRegisterModelGeometry); eventBus.addListener(ClientModInitializer::onRegisterMenuScreens); eventBus.addListener(ClientModInitializer::onRegisterKeyMappings); + eventBus.addListener(ClientModInitializer::onRegisterItemColors); + eventBus.addListener(ClientModInitializer::onRegisterClientExtensions); eventBus.addListener(ClientModInitializer::onRegisterTooltipFactories); modContainer.registerExtensionPoint(IConfigScreenFactory.class, ConfigurationScreen::new); } @@ -379,6 +383,7 @@ private void registerCapabilities(final RegisterCapabilitiesEvent event) { registerNetworkNodeContainerProvider(event, BlockEntities.INSTANCE.getConstructor()); registerNetworkNodeContainerProvider(event, BlockEntities.INSTANCE.getController()); registerNetworkNodeContainerProvider(event, BlockEntities.INSTANCE.getCraftingGrid()); + registerNetworkNodeContainerProvider(event, BlockEntities.INSTANCE.getPatternGrid()); registerNetworkNodeContainerProvider(event, BlockEntities.INSTANCE.getCreativeController()); registerNetworkNodeContainerProvider(event, BlockEntities.INSTANCE.getDestructor()); registerNetworkNodeContainerProvider(event, BlockEntities.INSTANCE.getDetector()); @@ -602,6 +607,16 @@ private static void registerClientToServerPackets(final PayloadRegistrar registr CraftingGridClearPacket.STREAM_CODEC, wrapHandler(CraftingGridClearPacket::handle) ); + registrar.playToServer( + PatternGridClearPacket.PACKET_TYPE, + PatternGridClearPacket.STREAM_CODEC, + wrapHandler((packet, ctx) -> PatternGridClearPacket.handle(ctx)) + ); + registrar.playToServer( + PatternGridCreatePatternPacket.PACKET_TYPE, + PatternGridCreatePatternPacket.STREAM_CODEC, + wrapHandler((packet, ctx) -> PatternGridCreatePatternPacket.handle(ctx)) + ); registrar.playToServer( CraftingGridRecipeTransferPacket.PACKET_TYPE, CraftingGridRecipeTransferPacket.STREAM_CODEC, diff --git a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/PlatformImpl.java b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/PlatformImpl.java index acf8618a4..c660a3a0c 100644 --- a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/PlatformImpl.java +++ b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/PlatformImpl.java @@ -398,4 +398,9 @@ public NetworkNodeContainerProvider getContainerProviderSafely(final Level level direction ); } + + @Override + public int getItemColor(final ItemStack stack, final int tintIndex) { + return Minecraft.getInstance().getItemColors().getColor(stack, tintIndex); + } } diff --git a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/autocrafting/PatternBakedModel.java b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/autocrafting/PatternBakedModel.java new file mode 100644 index 000000000..144b5f4bd --- /dev/null +++ b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/autocrafting/PatternBakedModel.java @@ -0,0 +1,22 @@ +package com.refinedmods.refinedstorage.neoforge.autocrafting; + +import com.refinedmods.refinedstorage.common.autocrafting.PatternItemOverrides; + +import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.ModelBaker; +import net.neoforged.neoforge.client.model.BakedModelWrapper; + +class PatternBakedModel extends BakedModelWrapper { + private final ItemOverrides itemOverrides; + + PatternBakedModel(final ModelBaker modelBaker, final BakedModel emptyModel, final BakedModel craftingModel) { + super(emptyModel); + this.itemOverrides = new PatternItemOverrides(modelBaker, emptyModel, craftingModel); + } + + @Override + public ItemOverrides getOverrides() { + return itemOverrides; + } +} diff --git a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/autocrafting/PatternGeometryLoader.java b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/autocrafting/PatternGeometryLoader.java new file mode 100644 index 000000000..58aef78e1 --- /dev/null +++ b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/autocrafting/PatternGeometryLoader.java @@ -0,0 +1,15 @@ +package com.refinedmods.refinedstorage.neoforge.autocrafting; + +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import net.neoforged.neoforge.client.model.geometry.IGeometryLoader; + +public class PatternGeometryLoader implements IGeometryLoader { + @Override + public PatternUnbakedGeometry read(final JsonObject jsonObject, + final JsonDeserializationContext jsonDeserializationContext) + throws JsonParseException { + return new PatternUnbakedGeometry(); + } +} diff --git a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/autocrafting/PatternUnbakedGeometry.java b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/autocrafting/PatternUnbakedGeometry.java new file mode 100644 index 000000000..dcd6221af --- /dev/null +++ b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/autocrafting/PatternUnbakedGeometry.java @@ -0,0 +1,42 @@ +package com.refinedmods.refinedstorage.neoforge.autocrafting; + +import java.util.function.Function; + +import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.Material; +import net.minecraft.client.resources.model.ModelBaker; +import net.minecraft.client.resources.model.ModelState; +import net.minecraft.client.resources.model.UnbakedModel; +import net.minecraft.resources.ResourceLocation; +import net.neoforged.neoforge.client.model.geometry.IGeometryBakingContext; +import net.neoforged.neoforge.client.model.geometry.IUnbakedGeometry; + +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; +import static java.util.Objects.requireNonNull; + +public class PatternUnbakedGeometry implements IUnbakedGeometry { + private static final ResourceLocation EMPTY_MODEL = createIdentifier("item/pattern/empty"); + private static final ResourceLocation CRAFTING_MODEL = createIdentifier("item/pattern/crafting"); + + @Override + public BakedModel bake(final IGeometryBakingContext ctx, + final ModelBaker modelBaker, + final Function function, + final ModelState modelState, + final ItemOverrides itemOverrides) { + return new PatternBakedModel( + modelBaker, + requireNonNull(modelBaker.bake(EMPTY_MODEL, modelState, function)), + requireNonNull(modelBaker.bake(CRAFTING_MODEL, modelState, function)) + ); + } + + @Override + public void resolveParents(final Function modelGetter, + final IGeometryBakingContext context) { + modelGetter.apply(EMPTY_MODEL).resolveParents(modelGetter); + modelGetter.apply(CRAFTING_MODEL).resolveParents(modelGetter); + } +} diff --git a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/autocrafting/package-info.java b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/autocrafting/package-info.java new file mode 100644 index 000000000..078def6f5 --- /dev/null +++ b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/autocrafting/package-info.java @@ -0,0 +1,7 @@ +@ParametersAreNonnullByDefault +@FieldsAndMethodsAreNonnullByDefault +package com.refinedmods.refinedstorage.neoforge.autocrafting; + +import com.refinedmods.refinedstorage.api.core.FieldsAndMethodsAreNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/datagen/BlockModelProviderImpl.java b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/datagen/BlockModelProviderImpl.java index b605ffb32..aee8cee99 100644 --- a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/datagen/BlockModelProviderImpl.java +++ b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/datagen/BlockModelProviderImpl.java @@ -50,6 +50,7 @@ protected void registerModels() { registerControllers(); registerRightLeftBackFrontTopModel(Blocks.INSTANCE.getGrid(), "grid", ""); registerRightLeftBackFrontTopModel(Blocks.INSTANCE.getCraftingGrid(), "crafting_grid", ""); + registerRightLeftBackFrontTopModel(Blocks.INSTANCE.getPatternGrid(), "pattern_grid", ""); registerDetectors(); registerWirelessTransmitters(); registerNetworkReceivers(); diff --git a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/datagen/BlockStateProviderImpl.java b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/datagen/BlockStateProviderImpl.java index 43071d965..b8f689113 100644 --- a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/datagen/BlockStateProviderImpl.java +++ b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/datagen/BlockStateProviderImpl.java @@ -162,6 +162,11 @@ private void registerGrids() { block, "crafting_grid" )); + Blocks.INSTANCE.getPatternGrid().forEach((color, id, block) -> configureActiveColoredDirectionalBlock( + color, + block, + "pattern_grid" + )); } private void registerControllers() { 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 19f52a8ad..3eb2074d0 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 @@ -41,6 +41,7 @@ protected void registerModels() { registerCreativeControllers(); registerGrids(); registerCraftingGrids(); + registerPatternGrids(); registerDetectors(); registerConstructors(); registerDestructors(); @@ -128,6 +129,14 @@ private void registerCraftingGrids() { )); } + private void registerPatternGrids() { + final var blocks = Blocks.INSTANCE.getPatternGrid(); + blocks.forEach((color, id, block) -> withExistingParent( + id.getPath(), + createIdentifier("block/pattern_grid/" + color.getName()) + )); + } + private void registerDetectors() { final var blocks = Blocks.INSTANCE.getDetector(); blocks.forEach((color, id, block) -> withExistingParent( diff --git a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/datagen/loot/BlockDropProvider.java b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/datagen/loot/BlockDropProvider.java index 0a547cf1a..801c31c73 100644 --- a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/datagen/loot/BlockDropProvider.java +++ b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/datagen/loot/BlockDropProvider.java @@ -22,6 +22,7 @@ protected void generate() { Blocks.INSTANCE.getCable().forEach((color, id, block) -> dropSelf(block.get())); Blocks.INSTANCE.getGrid().forEach((color, id, block) -> dropSelf(block.get())); Blocks.INSTANCE.getCraftingGrid().forEach((color, id, block) -> dropSelf(block.get())); + Blocks.INSTANCE.getPatternGrid().forEach((color, id, block) -> dropSelf(block.get())); Blocks.INSTANCE.getController().forEach((color, id, block) -> add( block.get(), createSingleItemTable(block.get()).apply(EnergyLootItemFunction::new) @@ -44,6 +45,7 @@ protected Iterable getKnownBlocks() { blocks.addAll(Blocks.INSTANCE.getCable().values()); blocks.addAll(Blocks.INSTANCE.getGrid().values()); blocks.addAll(Blocks.INSTANCE.getCraftingGrid().values()); + blocks.addAll(Blocks.INSTANCE.getPatternGrid().values()); blocks.addAll(Blocks.INSTANCE.getController().values()); blocks.addAll(Blocks.INSTANCE.getCreativeController().values()); blocks.addAll(Blocks.INSTANCE.getDetector().values()); diff --git a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/datagen/recipe/RecoloringRecipeProvider.java b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/datagen/recipe/RecoloringRecipeProvider.java index 15672a360..83755c5f3 100644 --- a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/datagen/recipe/RecoloringRecipeProvider.java +++ b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/datagen/recipe/RecoloringRecipeProvider.java @@ -47,6 +47,9 @@ protected void buildRecipes(final RecipeOutput output) { Blocks.INSTANCE.getCraftingGrid().forEach((color, id, block) -> recipe(Tags.CRAFTING_GRIDS, block.get().asItem(), color) .save(output, recipeId(color, "crafting_grid"))); + Blocks.INSTANCE.getPatternGrid().forEach((color, id, block) -> + recipe(Tags.PATTERN_GRIDS, block.get().asItem(), color) + .save(output, recipeId(color, "pattern_grid"))); Blocks.INSTANCE.getDetector().forEach((color, id, block) -> recipe(Tags.DETECTORS, block.get().asItem(), color) .save(output, recipeId(color, "detector"))); diff --git a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/datagen/tag/ItemTagsProviderImpl.java b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/datagen/tag/ItemTagsProviderImpl.java index d9e4687db..fa228fc71 100644 --- a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/datagen/tag/ItemTagsProviderImpl.java +++ b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/datagen/tag/ItemTagsProviderImpl.java @@ -35,6 +35,7 @@ import static com.refinedmods.refinedstorage.common.content.Tags.IMPORTERS; import static com.refinedmods.refinedstorage.common.content.Tags.NETWORK_RECEIVERS; import static com.refinedmods.refinedstorage.common.content.Tags.NETWORK_TRANSMITTERS; +import static com.refinedmods.refinedstorage.common.content.Tags.PATTERN_GRIDS; import static com.refinedmods.refinedstorage.common.content.Tags.RELAYS; import static com.refinedmods.refinedstorage.common.content.Tags.SECURITY_MANAGERS; import static com.refinedmods.refinedstorage.common.content.Tags.STORAGE_DISKS; @@ -71,6 +72,10 @@ protected void addTags(final HolderLookup.Provider provider) { Blocks.INSTANCE.getCraftingGrid().values().stream() .map(block -> (Supplier) block::asItem) .toList()); + addAllToTag(PATTERN_GRIDS, + Blocks.INSTANCE.getPatternGrid().values().stream() + .map(block -> (Supplier) block::asItem) + .toList()); addAllToTag(STORAGE_DISKS, Arrays.stream(ItemStorageVariant.values()) .filter(variant -> variant != ItemStorageVariant.CREATIVE) 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 fee7f5328..b78757abb 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 @@ -168,6 +168,7 @@ private static Runnable resourceContainerContainsExactly(final GameTestHelper he final ResourceContainer container, final ResourceAmount... 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()) From 1d518e456ed0a42c35209ac935eb4539417f345e Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Mon, 29 Jul 2024 20:53:26 +0200 Subject: [PATCH 02/36] fix: remove progress bar from widgets.png Also avoid clicking sound when clicking on a progress bar. --- .../common/support/widget/ProgressWidget.java | 14 +++++++++++--- .../gui/sprites/widget/progress_bar.png | Bin 0 -> 167 bytes .../refinedstorage/textures/gui/widgets.png | Bin 1598 -> 1335 bytes 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/progress_bar.png diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/ProgressWidget.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/ProgressWidget.java index 8cf60a071..59937b74f 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/ProgressWidget.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/ProgressWidget.java @@ -8,13 +8,14 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.narration.NarrationElementOutput; +import net.minecraft.client.sounds.SoundManager; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; public class ProgressWidget extends AbstractWidget { - private static final ResourceLocation TEXTURE = createIdentifier("textures/gui/widgets.png"); + private static final ResourceLocation TEXTURE = createIdentifier("widget/progress_bar"); private final DoubleSupplier progressSupplier; private final Supplier> tooltipSupplier; @@ -30,11 +31,18 @@ public ProgressWidget(final int x, this.tooltipSupplier = tooltipSupplier; } + @Override + public void playDownSound(final SoundManager handler) { + // intentionally empty + } + @Override public void renderWidget(final GuiGraphics graphics, final int mouseX, final int mouseY, final float partialTicks) { final int correctedHeight = (int) (progressSupplier.getAsDouble() * height); - graphics.blit(TEXTURE, getX(), getY() + height - correctedHeight, 179, height - correctedHeight, width, - correctedHeight); + final int correctedY = getY() + height - correctedHeight; + final int u = 0; + final int v = height - correctedHeight; + graphics.blitSprite(TEXTURE, 16, 70, u, v, getX(), correctedY, width, correctedHeight); if (isHovered) { graphics.renderComponentTooltip(Minecraft.getInstance().font, tooltipSupplier.get(), mouseX, mouseY); } diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/progress_bar.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/progress_bar.png new file mode 100644 index 0000000000000000000000000000000000000000..18cf56099e0bf11af7958fa8cf56471731db9af3 GIT binary patch literal 167 zcmeAS@N?(olHy`uVBq!ia0vp^0zmA>!VDzMxj1(KDaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(eheLIFM@t`gfW^32`Fzw$79?^2GsNxc0_S26Va0%bW1JR*x382Ao@Fyrz3 z6)8YLIZqeI5RLQ62?8w)Y^urP1`J&-O$S$;Si#}z5);EvKfCkpnfB;MK$Q%hu6{1- HoD!M<>2EGw literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/widgets.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/widgets.png index fbdd1ff046a6deab31da55773738f250a813b99d..d4b20ba685b0c23b2328f29b859f9721a0abbb24 100644 GIT binary patch literal 1335 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|G!U;i$lZxy-8q?;Kn_c~qpu?a z!^VE@KZ&eBK4*bPWHAE+-vJP2%(~Xe2~=~&)5S5QBJS-SN4@N7nFAlIP8%909xz*T zQ0vI-_)cAk=mt@N&Q3wL9-kuzr1so?erHa#aOPLR_eZ{e_LN%g&TjJW{=cZd<=;Mi zdi2O>=IQe9pUZ2u%iGuSxWE4#pSSN_g}u0?AUhWBA%gf2}rHk#}vu6$`!{i{&182{kEqIpu`t|F2mIr_S)ciPi zd)xNy|2YoS6zXruiJeUthId zoI&j=P%w+7!Beo|>9g#z?CjUUV(SC2{9~lWtjHc zmSOw$?T2q(wXw51H*fy@^m^XwjS7qn282-Oto&bylAD(&jY&Rn-$PpJeG4Qm@D>3+VG4zP7J$ruFe6ZUtF50?t|NeZY2fx8e-n@Ow zdp)eYw$|3#+FBUoFt_)d2M!)QSdeD=SzKWLym^151x~Rr93qHd&biIIWAkR?-Me>7 zpIei+Pdb2Mh6tmCF86_gABs!|mT(++p?z%`C|C@lHktjG+gH~i&Zy|apg|3qztBgW6FRgQzWL_OI)V7#(IX;6~e-j5Y6Z{n_fnAfUz|@Jy3o@}@VM z4g0U3Ph}z;@&u!1h$`5yb^7$_4+T~j;txAK!8(+suH}5==bJv)P-s?Q3$ULT>sD8K9&DYGdsUqb#?XO#ZT>?{bg-f7NgD(|L@c5Hdm-WHR%gYZNhu^+&_&%3NQc8TJZnh-;IMeE~yu!YUkB8PXzHGnFctx0D*Tbm|Us)RRA{Zzl zV|YD+V|XKUc1sli)6VO5s7(#%-8OdOBlu1K}VMPMtmCayX5exwbnO3ATUJ&74 zuz_Jg6KlYECXjCv868-;7tCXI2-ayh#MHng=3vVW3Y1n>22q`cDlrD%o#&Wd^s+Mi zSq`zlywFUSfg=rUP(+E@^{<7S7!+nOI2bTCBrq`?WMOFHWMC0y;80@_@PSC^vo6z& z2H#+;C R8Cd2sc)I$ztaD0e0sz|CCItWh From 5bc65120b6a8976b83309950aaedf71a6bf72cb9 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Mon, 29 Jul 2024 21:04:30 +0200 Subject: [PATCH 03/36] fix: remove scrollbar from widgets.png And now remove widgets.png all together. --- .../widget/AbstractSideButtonWidget.java | 4 +-- .../support/widget/ScrollbarWidget.java | 27 +++++++++++------- .../textures/gui/sprites/widget/scrollbar.png | Bin 0 -> 161 bytes .../gui/sprites/widget/scrollbar_clicked.png | Bin 0 -> 161 bytes .../gui/sprites/widget/scrollbar_disabled.png | Bin 0 -> 157 bytes .../refinedstorage/textures/gui/widgets.png | Bin 1335 -> 0 bytes .../assets/refinedstorage/textures/icons.png | Bin 5773 -> 5611 bytes 7 files changed, 18 insertions(+), 13 deletions(-) create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/scrollbar.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/scrollbar_clicked.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/scrollbar_disabled.png delete mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/widgets.png diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/AbstractSideButtonWidget.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/AbstractSideButtonWidget.java index b91358499..f36448fad 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/AbstractSideButtonWidget.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/AbstractSideButtonWidget.java @@ -51,7 +51,7 @@ public void setWarning(@Nullable final Component text) { @Override public void renderWidget(final GuiGraphics graphics, final int mouseX, final int mouseY, final float partialTicks) { - graphics.blit(getTextureIdentifier(), getX(), getY(), 238, isHovered ? 35 : 16, WIDTH, HEIGHT); + graphics.blit(TextureIds.ICONS, getX(), getY(), 238, isHovered ? 35 : 16, WIDTH, HEIGHT); graphics.blit( getTextureIdentifier(), getX() + 1, @@ -65,7 +65,7 @@ public void renderWidget(final GuiGraphics graphics, final int mouseX, final int RenderSystem.enableBlend(); RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 0.5f); - graphics.blit(getTextureIdentifier(), getX(), getY(), 238, 54, WIDTH, HEIGHT); + graphics.blit(TextureIds.ICONS, getX(), getY(), 238, 54, WIDTH, HEIGHT); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.disableBlend(); final Screen screen = Minecraft.getInstance().screen; diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/ScrollbarWidget.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/ScrollbarWidget.java index 7f0e34a89..6073e437d 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/ScrollbarWidget.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/ScrollbarWidget.java @@ -14,7 +14,11 @@ import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; public class ScrollbarWidget extends AbstractWidget { - private static final ResourceLocation TEXTURE = createIdentifier("textures/gui/widgets.png"); + private static final ResourceLocation TEXTURE = createIdentifier("widget/scrollbar"); + private static final ResourceLocation CLICKED_TEXTURE = createIdentifier("widget/scrollbar_clicked"); + private static final ResourceLocation DISABLED_TEXTURE = createIdentifier("widget/scrollbar_disabled"); + + private static final int SCROLLER_WIDTH = 12; private static final int SCROLLER_HEIGHT = 15; private static final int ANIMATION_SCROLL_DURATION_IN_TICKS = 10; @@ -51,23 +55,24 @@ public void setEnabled(final boolean enabled) { this.enabled = enabled; } + private ResourceLocation getTexture() { + if (!enabled) { + return DISABLED_TEXTURE; + } + return clicked ? CLICKED_TEXTURE : TEXTURE; + } + @Override public void renderWidget(final GuiGraphics graphics, final int mouseX, final int mouseY, final float partialTicks) { if (isAnimatingScroll()) { updateScrollingAnimation(partialTicks); } - - final int enabledU = clicked ? 220 : 232; - final int u = enabled ? enabledU : 244; - - graphics.blit( - TEXTURE, + graphics.blitSprite( + getTexture(), getX(), getY() + (int) ((float) offset / (float) maxOffset * (height - SCROLLER_HEIGHT)), - u, - 0, - 12, - 15 + SCROLLER_WIDTH, + SCROLLER_HEIGHT ); } diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/scrollbar.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/scrollbar.png new file mode 100644 index 0000000000000000000000000000000000000000..38e03a8b439eb4909e61bad6730ba65f9a0a1555 GIT binary patch literal 161 zcmeAS@N?(olHy`uVBq!ia0vp^JV4CP!VDyp&Kp+&DaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(eheJOMr-uK)l4@9yqCcI;SaXy~0STuDH2&H|6fVg?4j!ywFfJby(BP*Bd( y#W6(Uaxw$68=IP{LO@!A5DQc4t4}SxAi!9;jKekGCG9LwC4;A{pUXO@geCx?A1yQh literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/scrollbar_clicked.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/scrollbar_clicked.png new file mode 100644 index 0000000000000000000000000000000000000000..878229c516caa65e29925a712419c4c4087b0e0f GIT binary patch literal 161 zcmeAS@N?(olHy`uVBq!ia0vp^JV4CP!VDyp&Kp+&DaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(eheJOMr-uK)l4@9ys2x^-)4Xy~+G4-$aloCO|{#S9F5he4R}c>anMprD+m yi(`nyy<5J*Z0VPaBz^{J&nMpc!;W*6JR)nDFT1uA6lboFyt=akR{0D8bG;{X5v literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/widgets.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/widgets.png deleted file mode 100644 index d4b20ba685b0c23b2328f29b859f9721a0abbb24..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1335 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|G!U;i$lZxy-8q?;Kn_c~qpu?a z!^VE@KZ&eBK4*bPWHAE+-vJP2%(~Xe2~=~&)5S5QBJS-SN4@N7nFAlIP8%909xz*T zQ0vI-_)cAk=m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+t2)1 zTdd^bWY^=Mz#HG=ZzaTItekdY=KW6cRi;d1B{)c%6LrR7V^`Pl3=4$8O9S&Z(*Zim z`sa)0pP*FRnX~Zo;UX3O@B8+%+RqInI6{7Yeh_HQa)2zm!iVEt^WWckX4(jZE{~rw z=VO_C;3}tcziXLSX~)*)&T3@-x4vlY!7+7SNQH$?O{ySO8+o4V&&JAZ&;{f9;hK}I z%1-zNRnM^0+a!u9cO;8rf4`zJ2r{?ng`aTXeD;Nr zXxW6(`40qUH9MDbWN{lb&VZG4!!pH-p&WIHl=DPy#`R|~?AhhV`;VPXO|NVRVQFID2$g@JfB z>y9&9SKu0H3CFSu3F!_W9Zsi`&v89~NFmQM@!GW({Z;!QgiVSX;bH`ALeQlbB+JO0HRD^kNW!!uLWF5tW| q7(VB;W5W11w`kp{{K(gT_QN`iVd~dmN3Vwf)?;O9XYtkyoA7@Caiu>1 From 32ff668ccc9e62b3c33eb4a9eb84265c7f0dcb96 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Mon, 29 Jul 2024 21:10:04 +0200 Subject: [PATCH 04/36] fix: remove side buttons from icons.png --- .../widget/AbstractSideButtonWidget.java | 10 ++++++++-- .../gui/sprites/widget/side_button.png | Bin 0 -> 165 bytes .../widget/side_button_hover_overlay.png | Bin 0 -> 146 bytes .../sprites/widget/side_button_hovered.png | Bin 0 -> 165 bytes .../assets/refinedstorage/textures/icons.png | Bin 5611 -> 4047 bytes 5 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/side_button.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/side_button_hover_overlay.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/side_button_hovered.png diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/AbstractSideButtonWidget.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/AbstractSideButtonWidget.java index f36448fad..04b3f4379 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/AbstractSideButtonWidget.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/AbstractSideButtonWidget.java @@ -21,7 +21,13 @@ import net.minecraft.resources.ResourceLocation; import org.lwjgl.opengl.GL11; +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; + public abstract class AbstractSideButtonWidget extends Button { + private static final ResourceLocation TEXTURE = createIdentifier("widget/side_button"); + private static final ResourceLocation HOVERED_TEXTURE = createIdentifier("widget/side_button_hovered"); + private static final ResourceLocation HOVER_OVERLAY_TEXTURE = createIdentifier("widget/side_button_hover_overlay"); + private static final int WIDTH = 18; private static final int HEIGHT = 18; private static final int WARNING_SIZE = 10; @@ -51,7 +57,7 @@ public void setWarning(@Nullable final Component text) { @Override public void renderWidget(final GuiGraphics graphics, final int mouseX, final int mouseY, final float partialTicks) { - graphics.blit(TextureIds.ICONS, getX(), getY(), 238, isHovered ? 35 : 16, WIDTH, HEIGHT); + graphics.blitSprite(isHovered ? HOVERED_TEXTURE : TEXTURE, getX(), getY(), WIDTH, HEIGHT); graphics.blit( getTextureIdentifier(), getX() + 1, @@ -65,7 +71,7 @@ public void renderWidget(final GuiGraphics graphics, final int mouseX, final int RenderSystem.enableBlend(); RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 0.5f); - graphics.blit(TextureIds.ICONS, getX(), getY(), 238, 54, WIDTH, HEIGHT); + graphics.blitSprite(HOVER_OVERLAY_TEXTURE, getX(), getY(), WIDTH, HEIGHT); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.disableBlend(); final Screen screen = Minecraft.getInstance().screen; diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/side_button.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/side_button.png new file mode 100644 index 0000000000000000000000000000000000000000..4db677977fd7f08c26b9381a9136c78800e3a4c4 GIT binary patch literal 165 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh-3?!F4n4AKn7>k44ofy`glX(f`u%tWsIx;Y9 z?C1WI$O`212l#}znwgn(cXy|!rza&Pd3t&tX_x&4l;SM#h%9Dc;5!V$jK}j=fDDuO zba4!kxSZ_3;O58?kdR=~#?bC~AgQR4fqjOtqy)o+O_Had_!tEMl`?p``njxgN@xNA Dw?QkO literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/side_button_hover_overlay.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/side_button_hover_overlay.png new file mode 100644 index 0000000000000000000000000000000000000000..23ce7d7108659b1e126bc8832e74bdea007e04de GIT binary patch literal 146 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rf|#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSL74G){)!Z!pt`4vV~B-+@}K|z>zSEF8HA@SljxChLB<>g b1`G^NCd>k44ofy`glX(f`u%tWsIx;Y9 z?C1WI$O`212l#}z*3{HIe*AdHjvYx!Ns}i}UO(}=2~di&z$3Dlfr0NZ2s0kfUjZ^q z-qXb~MB;L?1B06*M?gY?NgG4EFVdQ&MBb@ E0QQV8G5`Po literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/icons.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/icons.png index 513c79e3653d5a686e957431266061559db289e2..5e42fdb3bff1c68e78f364ee12d53f5cdbefc03d 100644 GIT binary patch literal 4047 zcmbVPc{r3^*gwxK7<-f`%g9o_4WmMX!C0#Csz_3{jHQxM={1GOJVTKbUKNvds<$YH zL6(F@k|-)=tTC0cg^|i`z8U@TeSd$?bv@U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L(g!741U_$uB(jkz-@2O}Vy`+m%U-6^+m^ z+g+%(wp8yaeRlW%?LCsl%Q5p;!6a%} z4k$z)L1LyDQZnW8e{EttG!>oqeo1q^?Y&o0-uXn>Pm_9r5*F={{K)&oXR95~iz z6?qUZ(B?ReR?(o#GbGxEs37@#<68zVj|bww)|TJYBNy&GY5Rjm&MTkiKfEGjcm=5B zOdY``VYzSlo+g8CsWx!-fN1f{6yDlipOv!9L{@M()dy6U5KEM4nd?j|;Yjx z6RdI?oj-m<9_L~u^m*t6&&#q`iW^-az*J@ciQ$e(8yYtE%27Km2GX?m78)vhlaJaf zo-s?h;&}?J99|GL{qh8*VA8zs#5q9CXdD_ Date: Mon, 29 Jul 2024 21:13:50 +0200 Subject: [PATCH 05/36] fix: remove light arrow from icons.png There is already a sprite for it. --- ...CraftingPatternClientTooltipComponent.java | 18 +++++++++--------- .../common/support/TextureIds.java | 3 +++ .../tooltip/MouseClientTooltipComponent.java | 6 +++++- .../assets/refinedstorage/textures/icons.png | Bin 4047 -> 4004 bytes 4 files changed, 17 insertions(+), 10 deletions(-) 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 04ea6397e..be13f9548 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 @@ -17,6 +17,9 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; +import static com.refinedmods.refinedstorage.common.support.TextureIds.LIGHT_ARROW; +import static com.refinedmods.refinedstorage.common.support.TextureIds.LIGHT_ARROW_HEIGHT; +import static com.refinedmods.refinedstorage.common.support.TextureIds.LIGHT_ARROW_WIDTH; import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; public class CraftingPatternClientTooltipComponent implements ClientTooltipComponent { @@ -28,9 +31,6 @@ public class CraftingPatternClientTooltipComponent implements ClientTooltipCompo private static final ResourceLocation SLOT = createIdentifier("slot"); private static final ResourceLocation LARGE_SLOT = createIdentifier("large_slot"); - private static final ResourceLocation ARROW = createIdentifier("light_arrow"); - private static final int ARROW_WIDTH = 22; - private static final int ARROW_HEIGHT = 15; private static final int LARGE_SLOT_WIDTH = 26; private static final int LARGE_SLOT_HEIGHT = 26; @@ -53,7 +53,7 @@ public int getHeight() { @Override public int getWidth(final Font font) { - return (width * 18) + ARROW_SPACING + ARROW_WIDTH + ARROW_SPACING + LARGE_SLOT_WIDTH; + return (width * 18) + ARROW_SPACING + LIGHT_ARROW_WIDTH + ARROW_SPACING + LARGE_SLOT_WIDTH; } @Override @@ -108,16 +108,16 @@ private void renderInputSlot(final int x, final int y, final GuiGraphics graphic private void renderArrow(final int x, final int y, final GuiGraphics graphics) { graphics.blitSprite( - ARROW, + LIGHT_ARROW, x + width * 18 + ARROW_SPACING, - y + ((height * 18) / 2) - (ARROW_HEIGHT / 2), - ARROW_WIDTH, - ARROW_HEIGHT + y + ((height * 18) / 2) - (LIGHT_ARROW_HEIGHT / 2), + LIGHT_ARROW_WIDTH, + LIGHT_ARROW_HEIGHT ); } private void renderResultSlot(final Font font, final int x, final int y, final GuiGraphics graphics) { - final int slotX = x + width * 18 + ARROW_SPACING + ARROW_WIDTH + ARROW_SPACING; + final int slotX = x + width * 18 + ARROW_SPACING + LIGHT_ARROW_WIDTH + ARROW_SPACING; final int slotY = y + ((height * 18) / 2) - (LARGE_SLOT_HEIGHT / 2); graphics.blitSprite(LARGE_SLOT, slotX, slotY, LARGE_SLOT_WIDTH, LARGE_SLOT_HEIGHT); final ResourceAmount output = craftingPattern.output(); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/TextureIds.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/TextureIds.java index e4fb3e004..3b6a7e821 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/TextureIds.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/TextureIds.java @@ -6,6 +6,9 @@ public final class TextureIds { public static final ResourceLocation ICONS = createIdentifier("textures/icons.png"); + public static final ResourceLocation LIGHT_ARROW = createIdentifier("light_arrow"); + public static final int LIGHT_ARROW_WIDTH = 22; + public static final int LIGHT_ARROW_HEIGHT = 15; private TextureIds() { } 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 2af039f4f..f09136e14 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 @@ -15,6 +15,10 @@ import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; import net.minecraft.world.item.ItemStack; +import static com.refinedmods.refinedstorage.common.support.TextureIds.LIGHT_ARROW; +import static com.refinedmods.refinedstorage.common.support.TextureIds.LIGHT_ARROW_HEIGHT; +import static com.refinedmods.refinedstorage.common.support.TextureIds.LIGHT_ARROW_WIDTH; + public class MouseClientTooltipComponent implements ClientTooltipComponent { private static final int PADDING = 4; @@ -79,7 +83,7 @@ public static ClientTooltipComponent itemConversion(final Type type, @Override public void render(final GuiGraphics graphics, final int x, final int y) { graphics.renderItem(from, x, y); - graphics.blit(TextureIds.ICONS, x + 16 + 2, y, 234, 133, 22, 15); + graphics.blitSprite(LIGHT_ARROW, x + 16 + 2, y, LIGHT_ARROW_WIDTH, LIGHT_ARROW_HEIGHT); graphics.renderItem(to, x + 16 + 2 + 22 + 2, y); } diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/icons.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/icons.png index 5e42fdb3bff1c68e78f364ee12d53f5cdbefc03d..1b409bbce73426a6c821b2d00b18eafe557a56c7 100644 GIT binary patch delta 3662 zcmXw5c_3748-LHN#=c}rBn?uw3KhkOlI9j|ma$~tLqaa;9Fv=tTjN$A?qr#=-kS+o zvmQ|@+lVY(%UGfsTXZeuns3JazVpv{-}l*nzvn#f>D-#Lwb%iI57=5;o{e#z$sl?U zR>>!-I;XnI=4z*AQp2YDQzjyQ@cB;e%0~K@pp~e5WY*udIaz()PhmnqGv6`)&SH?J zl2+>ycID)YCk}T!pM@uxF=lrye&Ej!db>bc+l#HLw99_EhPw$t)=`PQydHN^)$wuL zR3n5tnLe;8%U^@f7?mHzp^I0(;&+|r@aC=>oZz+^ba~VlwPdR;cY}#t(!rThra0-f z){CD`L7YBC3lDkB%4icA+4`t)&55B6<)ExK||HoLA{5 zi{R^ol~n_d$JIYtV7x7wtZhQxX?l{uKXjt`LwjoE6zu%~Ft1_u55;R*tR~I#Mp)44 ze_VQh&fPpupW0%eXc=cB0BUZyn z{REiqcP(H~i1tl{Vb*@X`0mv0n%0Yl84OWwSfo_))YkcBm<5S4B_8QCUr$@9Qkp2L zfvZ>V&6b@h@7cQ((4d|Oe8x%s_kEjLEIDGE^{YhN!7HB!Vx^LM(?Eb)(kxFxYx~*! zb?p`#TybD1RETTx(Yd?>33cY^iBN(`)M z9WI@_xa-wi9j54!c|wYOhO zLo^ZH+(kzQt4eUg~%Eu@%y=lK%pL|mi#bvhbiXA*Alkh z1)W1P;~19m?mD#m zwH23KSC&L`;kYK4mOboAP`^R9`4^m(=^Mys=Z#Vk9TlG=P2fCl=rXq|T3ktwE*5T;Ql0&5xtlu$Fq308v z`r6OI2GIHB9<7l!p<**9ln{M)rV4yV7QfYR8J;msy`DVhcgiVV~3U4*LeA9FE2=-o7v;nD1pm*sG)pZYR zU#Er8`gw<@zVf^R$oh0T;1FCkNlUHrp^y+*%?ykcKvg)O?%4GJz5nQk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z5e&%xT$OyF;8zA}x>%c4W=C)rPz!NaUW{6QD|KR_dvYz|4We)#9z+#}Q;6iZ)u~IR@|fa{6NQP|ea1 z5;!djquJzB1YglX*zy4h6sS>aEgXG%i0K#3EENV5K=YM=Ze{Nt;>(v(S~Ny(y)OM4 zjz|IDO%78#A>M}gGpGp@D{A+4>WmU%PpBf5~ZnC|dBVVBrHKA4)}ZZ1&(ycaujlzWUf5Ya%Yt@Z1e-5_tNvBq>WSy=#xPDsD z7k6#K(en(5<+jC3New(rcagHk_s{t7g{QZOBp{@ht7U3Uz`3U#ch(peUlg zS%JKY#UX1@bUbu**$T~rH^1j7ajYtg7G8)g`VmY~?}2zn39Pl4b!cNO_CdHJ~KDW-oh0J*BydF_@}3fI2P5 zzGp5wfno>0plhBKLCVl?l07aSPV$2^u_T+oshG|x#CkFuG*&bVHa;cKh=>tS1)4-@ zGh2=|sriq9%^a+g!`(-Y;88MIs$+sR)_X0a#2Wb|^M?mF0qFulFK+smCgv-+7P zc+n#y%hPg#f#8M*u{bZ_Z^XuN`BqvOl1WShh9XsC`~~L>{j!`j(XoUF{=;oP0~>^< zfRU^eBN`|%paGgPIS70dd~;Kexb-Ocy7jN_a$Qj=*y+7{2(7+yY~q_23buC5fb}o3 zAb5{xOv?-x8IaNbOBHuzFtNz+vwSgVO($<;mbo_$Ep05=tkO!G6CJ;X(^uKNHJEr zCC%&WV>>XvGR48*HO%`PLz`!$ynN6;dV*0d4qn?v-moAemX5*;^JOVoo_}>f221+B u3ke^RloI;SDVRkCk+%vj#tt#=Z^7b2o<}dGVDuA!U|H=yVo_*D4gVk3tJU2A From 2763dc43ea3ff4905aec9ae5eec969ccec81d302 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Mon, 29 Jul 2024 21:18:08 +0200 Subject: [PATCH 06/36] fix: remove warning icon from icons.png --- .../networking/NetworkTransmitterScreen.java | 5 +++-- .../common/support/TextureIds.java | 2 ++ .../widget/AbstractSideButtonWidget.java | 9 ++++----- .../textures/gui/sprites/warning.png | Bin 0 -> 154 bytes .../assets/refinedstorage/textures/icons.png | Bin 4004 -> 3971 bytes 5 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/warning.png 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 a7e208be0..cbdcf1a19 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 @@ -1,7 +1,6 @@ package com.refinedmods.refinedstorage.common.networking; import com.refinedmods.refinedstorage.common.support.AbstractBaseScreen; -import com.refinedmods.refinedstorage.common.support.TextureIds; import com.refinedmods.refinedstorage.common.support.containermenu.PropertyTypes; import com.refinedmods.refinedstorage.common.support.widget.RedstoneModeSideButtonWidget; @@ -10,6 +9,8 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; +import static com.refinedmods.refinedstorage.common.support.TextureIds.WARNING; +import static com.refinedmods.refinedstorage.common.support.TextureIds.WARNING_SIZE; import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; public class NetworkTransmitterScreen extends AbstractBaseScreen { @@ -36,7 +37,7 @@ protected void renderLabels(final GuiGraphics graphics, final int mouseX, final final NetworkTransmitterData status = getMenu().getStatus(); final int displayTextX = 51; if (status.error()) { - graphics.blit(TextureIds.ICONS, displayTextX, 23, 246, 148, 10, 10); + graphics.blitSprite(WARNING, displayTextX, 23, WARNING_SIZE, WARNING_SIZE); } graphics.drawString(font, status.message(), displayTextX + (status.error() ? (10 + 4) : 0), 25, 4210752, false); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/TextureIds.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/TextureIds.java index 3b6a7e821..ebe724259 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/TextureIds.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/TextureIds.java @@ -9,6 +9,8 @@ public final class TextureIds { public static final ResourceLocation LIGHT_ARROW = createIdentifier("light_arrow"); public static final int LIGHT_ARROW_WIDTH = 22; public static final int LIGHT_ARROW_HEIGHT = 15; + public static final ResourceLocation WARNING = createIdentifier("warning"); + public static final int WARNING_SIZE = 10; private TextureIds() { } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/AbstractSideButtonWidget.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/AbstractSideButtonWidget.java index 04b3f4379..c34f122a3 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/AbstractSideButtonWidget.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/AbstractSideButtonWidget.java @@ -21,6 +21,8 @@ import net.minecraft.resources.ResourceLocation; import org.lwjgl.opengl.GL11; +import static com.refinedmods.refinedstorage.common.support.TextureIds.WARNING; +import static com.refinedmods.refinedstorage.common.support.TextureIds.WARNING_SIZE; import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; public abstract class AbstractSideButtonWidget extends Button { @@ -30,7 +32,6 @@ public abstract class AbstractSideButtonWidget extends Button { private static final int WIDTH = 18; private static final int HEIGHT = 18; - private static final int WARNING_SIZE = 10; @Nullable private ClientTooltipComponent warning; @@ -87,12 +88,10 @@ public void renderWidget(final GuiGraphics graphics, final int mouseX, final int private void renderWarning(final GuiGraphics graphics) { graphics.pose().pushPose(); graphics.pose().translate(0, 0, 200); - graphics.blit( - TextureIds.ICONS, + graphics.blitSprite( + WARNING, getX() + WIDTH - WARNING_SIZE + 2, getY() + HEIGHT - WARNING_SIZE + 2, - 246, - 148, WARNING_SIZE, WARNING_SIZE ); diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/warning.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/warning.png new file mode 100644 index 0000000000000000000000000000000000000000..411746fe966a3cb7e1f0c04d47b2c75a6d8c04fd GIT binary patch literal 154 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2ZGmxy8xzq=w7>k44ofy`glX(f`u%tWsIx;Y9 z?C1WI$O`0h2Ka=ymT+-hQda)|Kh(`|Pc%rdz$3Dlfr0NZ2s0kfUy%Y7l=5_O43W5; r+`!=G=;+9(u(G9D#3h-Tk(rsnb2d|1$&XL1KvfK$u6{1-oD!M8-LHtFf*31-mzqv%9@C>j~FGlOqNozr0iskNZHOYu24cG%AQKyDA7>X zxuwXGAz3P0F6vq{%AVhu+x_GB-}8B&=lQ?#RcF?eva#hJ_cW=22&m4LCk_CVWb4L zdN+0msA_(3*>j2$#g1ucX_Px**|%q)_1~o1AAesCq7Wq)nl70g zX#V=Gu_Vd9b|rllj!G7#Roa4*+MsdeP2rd|sy6LUxYKX}Ces)nIL+gunGabV%~Z+b zGQ!HV8g~G*C6^QCn@x(KiN&-pBA)tSGEI4FP^p%@p44$sM1j2rG1-jQQ%PK&ee8os z$+qH)A)g%OBBjR*ny0mq>A!Jz2Go$o=(dkG>|uNs%u4o(^V#jMoP?xOJ2J{sCa=`C z1@B8;;v10<6-t|wpYMc=ATRAL`)m^hwY~*wwVV#$JkL=aJX7NPpyUL2in%||XPEbs zb6T5~Y$c&Oi z{B%yRlJ4TZ#6IJxQ;^R_Qd|wV{nO$--+YNLjGbc;NN%(1jBmGkUcxzHira1ykrM-mc=rz@E~gY&SzSVL{JZ!O5|Ga-H?bC5_q#d zZin>u?e!G%>4+_)znvT!6^NO3uocd##no+UKt8ASfXQOr-R8{@26YvdtPHilz-)jvnM&UjS=X;R_Cu# z=Y8pMb4C+4b}QDkvhbrDItQzuyo&Zcz4X-WFNEpl=BjKa&sB1Zwe+ZNB9&tL!egD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FXymID8sU?pF=LFXXHxECGQSmwnnzHI>R;#ZVv|XIJD{6<;M)gM9P4h`io#Ww|h63O|v`zzVU=Q7kNq)hMDMB zyC37O7~AgJjbfT1Cxxh3BC#T5Oj_rBo;Sy92 z9{3ElAx{Vdq@38A5%p-VM+I;tXkGY6bs@YL9x5+SDqk1KmPRIx2!b5Nm~}{{C;DXh zGf+A08chvhdP-0x6#JiAa9pWL77M^K0I#KHvN}&%^uQU#Q!9)$hy{K=H^K41zT=+i z?vDzr?t(J>=t#*XsF*FDK!b09U|^rtjm5S#B1CNH{OP7Q0FmBvW$zX2l`^rXEj5 Date: Mon, 29 Jul 2024 21:22:07 +0200 Subject: [PATCH 07/36] fix: remove help icon from icons.png --- .../tooltip/HelpClientTooltipComponent.java | 7 ++++--- .../textures/gui/sprites/help.png | Bin 0 -> 205 bytes .../assets/refinedstorage/textures/icons.png | Bin 3971 -> 3850 bytes 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/help.png diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/tooltip/HelpClientTooltipComponent.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/tooltip/HelpClientTooltipComponent.java index 23cf658a8..e6f13f107 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/tooltip/HelpClientTooltipComponent.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/tooltip/HelpClientTooltipComponent.java @@ -1,7 +1,5 @@ package com.refinedmods.refinedstorage.common.support.tooltip; -import com.refinedmods.refinedstorage.common.support.TextureIds; - import java.util.List; import net.minecraft.client.Minecraft; @@ -12,13 +10,16 @@ import net.minecraft.locale.Language; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Style; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.FormattedCharSequence; import org.joml.Matrix4f; +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createTranslationAsHeading; import static net.minecraft.client.gui.screens.Screen.hasShiftDown; public class HelpClientTooltipComponent implements ClientTooltipComponent { + private static final ResourceLocation TEXTURE = createIdentifier("help"); private static final ClientTooltipComponent PRESS_SHIFT_FOR_HELP = new SmallTextClientTooltipComponent( createTranslationAsHeading("misc", "press_shift_for_help") ); @@ -76,7 +77,7 @@ public void renderText(final Font font, @Override public void renderImage(final Font font, final int x, final int y, final GuiGraphics graphics) { - graphics.blit(TextureIds.ICONS, x, y + 2, 236, 158, 20, 20); + graphics.blitSprite(TEXTURE, x, y + 2, 20, 20); } public static ClientTooltipComponent create(final Component text) { diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/help.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/help.png new file mode 100644 index 0000000000000000000000000000000000000000..08cf6a985f445bbaf0cd513f3481e853d6d829ce GIT binary patch literal 205 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc3?z4jzqJQajKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$1AIbU|Ns0cH18&mw_sMJ5RhUn3Gxg6|DWOdDPEvj2F?PH$YKTtzQZ8Q zcszea3Q*9_)5S4FBlzmYgS-q1JWdyH{cYdoqU54B;qqy7+sIhMC0}{w$_THR6nM%) t#U{)Ak=1$o&WvZw^XF~#{3&}?`mqF~kj1J`OMxaac)I$ztaD0e0sv+JK;r-a literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/icons.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/icons.png index f168d372f9e11fe4a33e69719785ccfe1728fa1b..4a4d8ed3311b7ef5bf11802fca48e1d878ef10b2 100644 GIT binary patch literal 3850 zcmb7Hc{r5o-@l((Fc`{~ozM^sV=wDi5+T|hA=k@_^GB^c63jpj^RpoLsxm>OW07C#+?K9BP(tHX4d`Nqrs?;z5 z?*S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VFo0H zVFqX3w%SXA>Q$cm!gYFIWLX>}wd*#LASsVWH~`$_L_mv9!0K-Nc%j5g?Q;WMbuwgU ubPSr>wqh>Yh%g(ewh5Sv;o;%yM%Pm>j^Ca0kwJej!J+*YCQtS{(*FnPp~tuY From 6ef5eebf9def1d86b7aeee83c0a97325eca5c030 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Mon, 29 Jul 2024 21:28:39 +0200 Subject: [PATCH 08/36] fix: remove mouse buttons from icons.png --- .../tooltip/MouseClientTooltipComponent.java | 17 ++++++++--------- .../gui/sprites/left_mouse_button.png | Bin 0 -> 222 bytes .../gui/sprites/right_mouse_button.png | Bin 0 -> 222 bytes .../assets/refinedstorage/textures/icons.png | Bin 3850 -> 3561 bytes 4 files changed, 8 insertions(+), 9 deletions(-) create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/left_mouse_button.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/right_mouse_button.png 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 f09136e14..a835b7643 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 @@ -3,7 +3,6 @@ import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.common.Platform; import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; -import com.refinedmods.refinedstorage.common.support.TextureIds; import com.refinedmods.refinedstorage.common.support.resource.FluidResource; import javax.annotation.Nullable; @@ -13,11 +12,13 @@ import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import static com.refinedmods.refinedstorage.common.support.TextureIds.LIGHT_ARROW; import static com.refinedmods.refinedstorage.common.support.TextureIds.LIGHT_ARROW_HEIGHT; import static com.refinedmods.refinedstorage.common.support.TextureIds.LIGHT_ARROW_WIDTH; +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; public class MouseClientTooltipComponent implements ClientTooltipComponent { private static final int PADDING = 4; @@ -119,7 +120,7 @@ public int getWidth(final Font font) { @Override public void renderImage(final Font font, final int x, final int y, final GuiGraphics graphics) { - graphics.blit(TextureIds.ICONS, x + type.leftPad, y, type.x, type.y, type.width, type.height); + graphics.blitSprite(type.texture, x + type.leftPad, y, type.width, type.height); iconRenderer.render(graphics, x + 9 + PADDING, y); if (amount != null) { final PoseStack poseStack = graphics.pose(); @@ -139,19 +140,17 @@ default int getWidth() { } public enum Type { - LEFT(247, 0, 180, 9, 13), - RIGHT(238, 2, 180, 9, 13); + LEFT(createIdentifier("left_mouse_button"), 0, 9, 13), + RIGHT(createIdentifier("right_mouse_button"), 2, 9, 13); - private final int x; + private final ResourceLocation texture; private final int leftPad; - private final int y; private final int width; private final int height; - Type(final int x, final int leftPad, final int y, final int width, final int height) { - this.x = x; + Type(final ResourceLocation texture, final int leftPad, final int width, final int height) { + this.texture = texture; this.leftPad = leftPad; - this.y = y; this.width = width; this.height = height; } diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/left_mouse_button.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/left_mouse_button.png new file mode 100644 index 0000000000000000000000000000000000000000..f04af00db56e49f2871f41bf39c5aacf36e65f46 GIT binary patch literal 222 zcmeAS@N?(olHy`uVBq!ia0vp^oFFy_Gm!MTx5WfVF%}28J29*~C-V}>VM%xNb!1@J z*w6hZkrl`n4e$wZ)d`3b)ihvu`@XWWvg^;^<;#}?Wv03PVFXg_B|(0{|G|Jk%A45@ zD8yOd5n0T@z;_sg8IR|$NC67kd%8G=NQ9SmJMu9&avYMm`0xKo?t9_MmmG98<}Y7S z{@}sI-YKinZ%myl*P?dfdadG?!hJNaAcm_(XpJroBT#o+1c=d#Wz Gp$P!5SxG7Y literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/right_mouse_button.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/right_mouse_button.png new file mode 100644 index 0000000000000000000000000000000000000000..a3a0645704297bb40f6ff3e74010d31078f0268c GIT binary patch literal 222 zcmeAS@N?(olHy`uVBq!ia0vp^oFFy_Gm!MTx5WfVF%}28J29*~C-V}>VM%xNb!1@J z*w6hZkrl`n4e$wZ)d`3b)ikKAtYmome);m{U4Q-pW#pJo8v`l!k|4j}|6sr%<<0B{ z6yhxKh%9Dc;5!V$jK}j=qyPo&JzX3_B*II(J%tz)d6*`;{QI9`ZFOC-y=0??@<+K; z&P~Crr|#a|t+C^=gXAHZ{;K;EB?|Uw7S^}?>oD^wVyL%ceAC|^qYgBR!PC{xWt~$( F69B!8MtJ}L literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/icons.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/icons.png index 4a4d8ed3311b7ef5bf11802fca48e1d878ef10b2..505efb56a3e5696ba99ba4c19bf4d96382f50db7 100644 GIT binary patch literal 3561 zcmbVP2~ZPRx9+A%3`L`@utD1r$JioXhqIK%-$zy;ZaLD?ZRj06xzaBu)o zmQh9=H=^SVsAPeNf;j95C}dHTB}gDF0RrTO#8+=#)vJ1c{aw|4?>YA@-}&yjx2m%b zd+bB28mj^TfZp%!>IDFxYzhJ>NH&DsCwi|)=e+jq1|GJo9+3&k!7hhf0N_!s+F~F= zCQ}X{^mda1{nFGgadB}=0O088Xm4X9?FFQ{01*Ty0l?PEN-8asN~P-ofC~UFJM1xb z8>#>R_Sn3`N}mq^9RPscY?pt|)d{n@69C-zIQa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(iqJnF%V&_2(M&g@=bvSKcldRs!YuwX7a@BmXb;} zM?#7mj4B%c#q$)IMAA^E;rUsS_O;w9jyb})ubTB<%i667+17*&pOiuNllTBUv7XpL z;HkVvLkj}V(OCt+n^03$<4tc2sAyc95@W*(OAYGRT3&skbH@kpXzcs@F z%`)xJB%`G$e;}$)-tYmgeK7OT6Z+8S9;AuTIJ|@86!p+?Eumy-;V@b%ARoKsW_vYR_=7=i?LYjcf zsHZ!T?nbiR;l81sG2Bx#o-`1oz;YH|p7^#C`WME6vaQc=g@4(3BRyQw2pUk-R6&`gQ_4szk2sn?8Hy~ z1hi`297rdFUpDl4HOd{RGhCBz0-t__tRFcLp^vhEBF%yqxi>|QClSeGrW4LHxB-d4 z+Jq?rG?WGmNYm1;cb5qa*290FO_t?O>!FKo+6qF3?4j5vKdH5y?-`cD*jqx267NF` z>>bt};RKO3y#`}|!#({Tz6j8G*Q`iG9F+wmUn6PYhz|cU%WgNkTIn%k?WPCPWp|lK z#n2p|vpgs|8LV)-kL2}%Q?3sylgP3jNcM;vxYSV%doxaN2hXnUUpI|7$v)b8QKF3B zjd+iK>(!X$5{;Qr%E!D_{J`!NshGoXBv>in1kNhJb&VTX)G$(*nY1(y5_TR2;_MJi zSDI)$(qv|fP@q*IQ=r{Y-O>nnljb1Zb4t&B+GByATzPSqPIj4`u}THTw4oo8_;Kj> zXz9)2v6dDbH^ip90l70`7-9E$sdb`P$@?FBZB8Js-uXaP=UCS?a#x>eXPLn6-WqW=u zdkOZu4*&+X53s=Bt4o0%yU(%~aHj+}1B9G30RHp{d-H~On2bINAj5#LmNhhs1K)at zAmlRex4VznE@Cgxr_uv`T5qmL6)?rCr*C%~DiTNh! Q{~zG8d%x3t2YSMP0BU}$tN;K2 From 55f3d39bfc6e8a5b835203b656b1fccff1794ae0 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Mon, 29 Jul 2024 21:29:57 +0200 Subject: [PATCH 09/36] chore: remove guide book texture It was used for Patchouli guide initially. However, Patchouli was too difficult to maintain. Book is no longer needed for now. --- .../common/autocrafting/PatternType.java | 1 - .../assets/refinedstorage/textures/gui/book.png | Bin 19343 -> 0 bytes 2 files changed, 1 deletion(-) delete mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/book.png diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternType.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternType.java index 6514821b2..b622a935a 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternType.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternType.java @@ -8,7 +8,6 @@ import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createTranslation; -// TODO: remove widgets.png // TODO: remove other unused textures, and rename icons.png to side_buttons.png public enum PatternType implements StringRepresentable { CRAFTING(Items.CRAFTING_TABLE.getDefaultInstance(), "crafting"), diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/book.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/book.png deleted file mode 100644 index 0177cc462c3f69f085e3bbbad616bafa8bc3e76a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 19343 zcmbTd1zeO}w%z}Sh{$5%CKN5{d);cuKz~s?C~!)VHw8fYvIZ#z{`KVq`v^It^N(?>gDeE z*W}h#d`L&66Vln!0}CtgZ&+757f%-tJD2|k^}oCS%LG`~YHI#_j{hw!PEP-x!oyS9 z8@r5uG30*>?Vr(oBv?ve;Iw<^Izyf`r7|Dpw~VB z26dHGbVpivy147QxH$eJe(ir40aH}Oid#Sg#%^HmZ0+LX!EsH=zs4YyEIg4iEZBZ= z9szzHK~Y@+2}wbINf8k)egR2-{=Y#rU99bGp8W$VD8R!njQ!OW5Rw$)m%RQe_8*{F zU9`6FwD`XQTU$xmxVSr6U^!{;WMPZsb9J_5f&E)Pl8P>lF7DWgvD69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X2eyQ-lY6-J{65{g*YkuWvmN&oGw1LBC(xwe zaD9g$haxv?`v1D1`P>KQ{tVy5pkn>?&AIeBT03nY+WT~6{;@ajy#F`y`TP6q9~L|O z`oH0C{r~Tc^162nZhuo}`OvxWc(jyW+#Zd0`~TO;x(XgL@Jau6zUDV@Fz)B)8@Fx= zJwHGHy3?BFVT?;fwr!iYk-u#RFsptwRQF!6)O23mvzb3HY~WA~O$1JJ0Xsz-fonN{ zp;9@=$pJW%H5s^6`|Y|G;Odxz%V)o1kmM0%07|A*daN}HVc<|~nebGx_v`{D;OPM= zQWyTeSMR?WFTn!bpuWTm*vI+~obMNKIuTNt^FwWk=L!Y^CytqHpm~{~>pZ~uc>$-a zW<7@gz^UZOj4K)Eu|p4 zukbfB>}>}#eMEutXMA9Vmm7d>7GMaGh+6z@`=hZXo|eNTOK7d@$4FuL1Xg z>KVXg0E#KAfXref$AR@s__dJxKs|(+=>+U}7XX)pfoyMW_|pQM5(TooIbMT(q_u|m zf%+O|pixWeBv@Y9f|)>5IWE9V1%{)H7RbLRJ{`CUTpHCfK^53i00k=7W}s)l%vbG^ z4EGKL7jJ+piDZEI;DpJ8tcJQnU_Dp(V;TM(1~YwxffG~^SIpD`l@Y*oY#{GCMX*D> zDa&A=2o9~UhZP*&Lzuy>uy8qH0-Vu&4i00dY3%FRfYH^Wqj(0mxKF?+bO!4Kbucr? z{tVLxxisK{GLD&A_UsRy&%M9(r{*u6|CZlp->U;IVgpJ5!$248FQHHO8J!XvE51Kp R^qv6-JYD@<);T3K0RZ57`)U9H From 770afb2065cbb1e5468312bb49a4fcc207712c27 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Mon, 29 Jul 2024 21:32:13 +0200 Subject: [PATCH 10/36] chore: rename icons.png to side_button_icons.png --- .../common/autocrafting/PatternType.java | 1 - .../common/grid/AbstractGridSynchronizer.java | 2 +- .../grid/screen/ResourceTypeSideButtonWidget.java | 2 +- .../refinedstorage/common/support/TextureIds.java | 2 +- .../common/support/resource/FluidResourceType.java | 2 +- .../common/support/resource/ItemResourceType.java | 2 +- .../support/widget/AbstractSideButtonWidget.java | 2 +- .../textures/{icons.png => side_button_icons.png} | Bin 8 files changed, 6 insertions(+), 7 deletions(-) rename refinedstorage-common/src/main/resources/assets/refinedstorage/textures/{icons.png => side_button_icons.png} (100%) diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternType.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternType.java index b622a935a..da21cffd7 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternType.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternType.java @@ -8,7 +8,6 @@ import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createTranslation; -// TODO: remove other unused textures, and rename icons.png to side_buttons.png public enum PatternType implements StringRepresentable { CRAFTING(Items.CRAFTING_TABLE.getDefaultInstance(), "crafting"), PROCESSING(Items.FURNACE.getDefaultInstance(), "processing"), diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/AbstractGridSynchronizer.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/AbstractGridSynchronizer.java index 21490821d..92cfb70f8 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/AbstractGridSynchronizer.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/AbstractGridSynchronizer.java @@ -8,7 +8,7 @@ public abstract class AbstractGridSynchronizer implements GridSynchronizer { @Override public ResourceLocation getTextureIdentifier() { - return TextureIds.ICONS; + return TextureIds.SIDE_BUTTON_ICONS; } @Override diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/ResourceTypeSideButtonWidget.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/ResourceTypeSideButtonWidget.java index bb6295282..66740f31d 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/ResourceTypeSideButtonWidget.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/ResourceTypeSideButtonWidget.java @@ -31,7 +31,7 @@ private static OnPress createPressAction(final AbstractGridContainerMenu menu) { protected ResourceLocation getTextureIdentifier() { final ResourceType resourceType = menu.getResourceType(); if (resourceType == null) { - return TextureIds.ICONS; + return TextureIds.SIDE_BUTTON_ICONS; } return resourceType.getTextureIdentifier(); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/TextureIds.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/TextureIds.java index ebe724259..7604a0fb7 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/TextureIds.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/TextureIds.java @@ -5,7 +5,7 @@ import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; public final class TextureIds { - public static final ResourceLocation ICONS = createIdentifier("textures/icons.png"); + public static final ResourceLocation SIDE_BUTTON_ICONS = createIdentifier("textures/side_button_icons.png"); public static final ResourceLocation LIGHT_ARROW = createIdentifier("light_arrow"); public static final int LIGHT_ARROW_WIDTH = 22; public static final int LIGHT_ARROW_HEIGHT = 15; diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/FluidResourceType.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/FluidResourceType.java index 98cddc50f..30e19026d 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/FluidResourceType.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/FluidResourceType.java @@ -25,7 +25,7 @@ class FluidResourceType extends AbstractResourceType { super( "FLUID", createTranslation("misc", "resource_type.fluid"), - TextureIds.ICONS, + TextureIds.SIDE_BUTTON_ICONS, 16, 128 ); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ItemResourceType.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ItemResourceType.java index 0588b9a0b..db994cb0b 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ItemResourceType.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ItemResourceType.java @@ -25,7 +25,7 @@ class ItemResourceType extends AbstractResourceType { super( "ITEM", createTranslation("misc", "resource_type.item"), - TextureIds.ICONS, + TextureIds.SIDE_BUTTON_ICONS, 0, 128 ); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/AbstractSideButtonWidget.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/AbstractSideButtonWidget.java index c34f122a3..4eae21cc4 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/AbstractSideButtonWidget.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/AbstractSideButtonWidget.java @@ -45,7 +45,7 @@ protected AbstractSideButtonWidget(final OnPress pressAction) { protected abstract int getYTexture(); protected ResourceLocation getTextureIdentifier() { - return TextureIds.ICONS; + return TextureIds.SIDE_BUTTON_ICONS; } public void setWarning(@Nullable final Component text) { diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/icons.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/side_button_icons.png similarity index 100% rename from refinedstorage-common/src/main/resources/assets/refinedstorage/textures/icons.png rename to refinedstorage-common/src/main/resources/assets/refinedstorage/textures/side_button_icons.png From d4dfcb2441206abcc3cf68cfeae03fca21fa408a Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Mon, 29 Jul 2024 21:46:08 +0200 Subject: [PATCH 11/36] fix: incorrect and outdated explanations for fuzzy mode Mentioning NBT made it outdated. Incorrect because it was inverted. --- CHANGELOG.md | 11 +++++++++++ .../autocrafting/PatternGridBlockEntity.java | 3 --- .../autocrafting/PatternGridContainerMenu.java | 1 - .../common/autocrafting/PatternItem.java | 4 +++- .../common/autocrafting/PatternRendering.java | 4 ++-- .../common/util/PlatformUtil.java | 16 ++++++++++++++++ .../assets/refinedstorage/lang/en_us.json | 18 +++++++++--------- .../AbstractDiskContainerBakedModel.java | 4 ++-- .../portablegrid/PortableGridBakedModel.java | 6 +++--- 9 files changed, 46 insertions(+), 21 deletions(-) create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/util/PlatformUtil.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 82bfadeec..01f7e9fa4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,17 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Pattern Grid - Pattern +### Changed + +- The Pattern now shows the crafting recipe in the tooltip. +- When a Pattern is created for a crafting recipe, the Pattern will have a different texture and name to differentiate between empty patterns. +- The Pattern Grid now has support for more pattern types. + +### Fixed + +- Clicking on a scrollbar no longer makes a clicking sound. +- Incorrect and outdated (mentioning NBT tags) help explanations for fuzzy mode. + ## [2.0.0-milestone.4.5] - 2024-07-26 ### Added diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridBlockEntity.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridBlockEntity.java index ccbe0ad0d..a9b26747a 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridBlockEntity.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridBlockEntity.java @@ -33,9 +33,6 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; -// TODO: servertest -// TODO: update changelog -// TODO: change "nbt" tooltips (en_us.json) public class PatternGridBlockEntity extends AbstractGridBlockEntity implements BlockEntityWithDrops, NetworkNodeExtendedMenuProvider { private static final String TAG_PATTERN_INPUT = "pattern_input"; diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridContainerMenu.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridContainerMenu.java index 11b4193e5..bbde55ebc 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridContainerMenu.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridContainerMenu.java @@ -179,7 +179,6 @@ public boolean isActive() { }); } } - // TODO: other fuzzy mode tooltips are wrong? addSlot(new DisabledSlot( craftingResult, 0, 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 4fbe8fc75..3542c55b2 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 @@ -1,6 +1,7 @@ package com.refinedmods.refinedstorage.common.autocrafting; import com.refinedmods.refinedstorage.api.resource.ResourceAmount; +import com.refinedmods.refinedstorage.common.PlatformProxy; import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; import com.refinedmods.refinedstorage.common.api.autocrafting.CraftingPattern; import com.refinedmods.refinedstorage.common.api.autocrafting.Pattern; @@ -11,6 +12,7 @@ import com.refinedmods.refinedstorage.common.content.Items; import com.refinedmods.refinedstorage.common.support.CraftingMatrix; import com.refinedmods.refinedstorage.common.support.resource.ItemResource; +import com.refinedmods.refinedstorage.common.util.PlatformUtil; import java.util.ArrayList; import java.util.Arrays; @@ -88,7 +90,7 @@ public Optional getTooltipImage(final ItemStack stack) { return switch (state.type()) { case CRAFTING -> { final CraftingPatternState craftingState = stack.get(DataComponents.INSTANCE.getCraftingPatternState()); - final Level level = Minecraft.getInstance().level; + final Level level = PlatformUtil.getClientLevel(); if (craftingState == null || level == null) { yield Optional.empty(); } 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 15f287ab8..16db1edf6 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 @@ -5,10 +5,10 @@ import com.refinedmods.refinedstorage.common.api.autocrafting.CraftingPattern; import com.refinedmods.refinedstorage.common.api.autocrafting.PatternProviderItem; import com.refinedmods.refinedstorage.common.support.resource.ItemResource; +import com.refinedmods.refinedstorage.common.util.PlatformUtil; import java.util.Optional; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.Screen; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; @@ -22,7 +22,7 @@ public static boolean canDisplayOutput(final ItemStack stack) { } public static Optional getOutput(final ItemStack stack) { - final Level level = Minecraft.getInstance().level; + final Level level = PlatformUtil.getClientLevel(); if (level == null) { return Optional.empty(); } 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 new file mode 100644 index 000000000..24072c78e --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/util/PlatformUtil.java @@ -0,0 +1,16 @@ +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/resources/assets/refinedstorage/lang/en_us.json b/refinedstorage-common/src/main/resources/assets/refinedstorage/lang/en_us.json index 9ed2a7d7e..e4522ab58 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 @@ -65,7 +65,7 @@ "gui.refinedstorage.pattern_grid.create_pattern": "Create pattern", "gui.refinedstorage.pattern_grid.clear": "Clear", "gui.refinedstorage.pattern_grid.fuzzy_mode": "Fuzzy mode", - "gui.refinedstorage.pattern_grid.fuzzy_mode.on.help": "Match the pattern inputs without comparing NBT tags.", + "gui.refinedstorage.pattern_grid.fuzzy_mode.on.help": "Match the pattern inputs, ignoring components.", "gui.refinedstorage.pattern_grid.fuzzy_mode.off.help": "Match the pattern inputs exactly.", "gui.refinedstorage.screen_size": "Screen size", "gui.refinedstorage.screen_size.stretch": "Stretch", @@ -115,15 +115,15 @@ "gui.refinedstorage.filter_mode.block": "Blocklist", "gui.refinedstorage.fuzzy_mode": "Fuzzy mode", "gui.refinedstorage.fuzzy_mode.on": "On", - "gui.refinedstorage.fuzzy_mode.on.storage_help": "Match the filters for the allowlist or blocklist exactly.", - "gui.refinedstorage.fuzzy_mode.on.generic_help": "Match the filter exactly.", - "gui.refinedstorage.fuzzy_mode.on.extracting_storage_network_help": "Match the filters when extracting from the storage network exactly.", - "gui.refinedstorage.fuzzy_mode.on.extracting_source_help": "Match the filters when extracting from the source exactly.", + "gui.refinedstorage.fuzzy_mode.on.storage_help": "Match the filters for the allowlist or blocklist, ignoring components.", + "gui.refinedstorage.fuzzy_mode.on.generic_help": "Match the filter, ignoring components.", + "gui.refinedstorage.fuzzy_mode.on.extracting_storage_network_help": "Match the filters when extracting from the storage network, ignoring components.", + "gui.refinedstorage.fuzzy_mode.on.extracting_source_help": "Match the filters when extracting from the source, ignoring components.", "gui.refinedstorage.fuzzy_mode.off": "Off", - "gui.refinedstorage.fuzzy_mode.off.storage_help": "Match the filters for the allowlist or blocklist without comparing NBT tags.", - "gui.refinedstorage.fuzzy_mode.off.generic_help": "Match the filter without comparing NBT tags.", - "gui.refinedstorage.fuzzy_mode.off.extracting_storage_network_help": "Match the filters when extracting from the storage network without comparing NBT tags.", - "gui.refinedstorage.fuzzy_mode.off.extracting_source_help": "Match the filters when extracting from the source without comparing NBT tags.", + "gui.refinedstorage.fuzzy_mode.off.storage_help": "Match the filters for the allowlist or blocklist exactly.", + "gui.refinedstorage.fuzzy_mode.off.generic_help": "Match the filter exactly.", + "gui.refinedstorage.fuzzy_mode.off.extracting_storage_network_help": "Match the filters when extracting from the storage network exactly.", + "gui.refinedstorage.fuzzy_mode.off.extracting_source_help": "Match the filters when extracting from the source exactly.", "gui.refinedstorage.access_mode": "Access mode", "gui.refinedstorage.access_mode.insert_extract": "Insert and extract", "gui.refinedstorage.access_mode.insert_extract.help": "The storage network will be able to insert or extract from this storage.", 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 eab952169..03d3c9728 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,6 +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.fabric.support.render.QuadTranslator; import java.util.Map; @@ -11,7 +12,6 @@ import net.fabricmc.fabric.api.renderer.v1.model.ForwardingBakedModel; import net.fabricmc.fabric.api.renderer.v1.render.RenderContext; -import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.BlockPos; import net.minecraft.core.component.DataComponents; @@ -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 = Minecraft.getInstance().level; + final Level level = PlatformUtil.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 12f8a67a7..2c490a217 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,6 +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.fabric.support.render.QuadRotators; import com.refinedmods.refinedstorage.fabric.support.render.QuadTranslator; @@ -14,14 +15,13 @@ import net.fabricmc.fabric.api.renderer.v1.model.ForwardingBakedModel; import net.fabricmc.fabric.api.renderer.v1.render.RenderContext; -import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.BlockPos; import net.minecraft.util.RandomSource; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; public class PortableGridBakedModel extends ForwardingBakedModel { @@ -56,7 +56,7 @@ public boolean isVanillaAdapter() { public void emitItemQuads(final ItemStack stack, final Supplier randomSupplier, final RenderContext context) { - final ClientLevel level = Minecraft.getInstance().level; + final Level level = PlatformUtil.getClientLevel(); if (level == null) { return; } From 81e91ac0af76f00e8384049bf362d97293abf5c7 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Mon, 29 Jul 2024 21:58:45 +0200 Subject: [PATCH 12/36] chore: fix sonar issues --- .../common/autocrafting/PatternGridScreen.java | 4 ++-- .../common/autocrafting/PatternItem.java | 2 -- .../support/containermenu/TransferManager.java | 8 +------- .../support/widget/CustomCheckboxWidget.java | 14 +++++++------- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridScreen.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridScreen.java index 522c1b84c..e3ee37662 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridScreen.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridScreen.java @@ -4,7 +4,7 @@ import com.refinedmods.refinedstorage.common.support.widget.CustomCheckboxWidget; import com.refinedmods.refinedstorage.common.support.widget.HoveredImageButton; -import java.util.HashMap; +import java.util.EnumMap; import java.util.Map; import javax.annotation.Nullable; @@ -49,7 +49,7 @@ public class PatternGridScreen extends AbstractGridScreen patternTypeButtons = new HashMap<>(); + private final Map patternTypeButtons = new EnumMap<>(PatternType.class); public PatternGridScreen(final PatternGridContainerMenu menu, final Inventory inventory, final Component title) { super(menu, inventory, title, 177); 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 3542c55b2..1f5faab19 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 @@ -1,7 +1,6 @@ package com.refinedmods.refinedstorage.common.autocrafting; import com.refinedmods.refinedstorage.api.resource.ResourceAmount; -import com.refinedmods.refinedstorage.common.PlatformProxy; import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; import com.refinedmods.refinedstorage.common.api.autocrafting.CraftingPattern; import com.refinedmods.refinedstorage.common.api.autocrafting.Pattern; @@ -23,7 +22,6 @@ import javax.annotation.Nullable; import net.minecraft.ChatFormatting; -import net.minecraft.client.Minecraft; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; import net.minecraft.world.InteractionHand; diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/containermenu/TransferManager.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/containermenu/TransferManager.java index 098001eab..28705c39d 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/containermenu/TransferManager.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/containermenu/TransferManager.java @@ -53,13 +53,7 @@ public boolean transfer(final int index) { } final TransferDestination key = destinationFactory.apply(slot.container); final List destinations = destinationMap.get(key); - boolean success = false; - if (destinations != null) { - if (transfer(slot, destinations)) { - success = true; - } - } - return success; + return destinations != null && transfer(slot, destinations); } private boolean transfer(final Slot slot, final List destinations) { diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/CustomCheckboxWidget.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/CustomCheckboxWidget.java index af5a8f6c5..d7666c620 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/CustomCheckboxWidget.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/CustomCheckboxWidget.java @@ -12,7 +12,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; -// A custom checkbox so that we can change the font color. +// A custom checkbox so that we can change the font color and size. public class CustomCheckboxWidget extends AbstractButton { private static final ResourceLocation CHECKBOX_SELECTED_HIGHLIGHTED_SPRITE = ResourceLocation.withDefaultNamespace( "widget/checkbox_selected_highlighted" @@ -36,7 +36,7 @@ public CustomCheckboxWidget(final int x, final Font font, final boolean selected, final Size size) { - super(x, y, size.size + 4 + font.width(text), size.size, text); + super(x, y, size.widthHeight + 4 + font.width(text), size.widthHeight, text); this.selected = selected; this.size = size; } @@ -80,9 +80,9 @@ public void renderWidget(final GuiGraphics graphics, final int mouseX, final int } else { sprite = isFocused() ? CHECKBOX_HIGHLIGHTED_SPRITE : CHECKBOX_SPRITE; } - graphics.blitSprite(sprite, getX(), getY(), size.size, size.size); + graphics.blitSprite(sprite, getX(), getY(), size.widthHeight, size.widthHeight); graphics.setColor(1.0F, 1.0F, 1.0F, 1.0F); - final int textX = getX() + size.size + 4; + final int textX = getX() + size.widthHeight + 4; final int textY = (getY() + (height >> 1)) - (9 >> 1); graphics.drawString(font, getMessage(), textX, textY, 4210752, false); } @@ -96,10 +96,10 @@ public enum Size { REGULAR(9 + 8), SMALL(9); - private final int size; + private final int widthHeight; - Size(final int size) { - this.size = size; + Size(final int widthHeight) { + this.widthHeight = widthHeight; } } } From 052637c344c073d64d6862a438823eb1552e04ef Mon Sep 17 00:00:00 2001 From: Starforcraft Date: Wed, 31 Jul 2024 13:15:22 +0200 Subject: [PATCH 13/36] feat: silk touch upgrade gametest setup --- .../constructordestructor/DestructorTest.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/refinedstorage-neoforge/src/test/java/com/refinedmods/refinedstorage/common/constructordestructor/DestructorTest.java b/refinedstorage-neoforge/src/test/java/com/refinedmods/refinedstorage/common/constructordestructor/DestructorTest.java index 97420b47f..c8b41ab50 100644 --- a/refinedstorage-neoforge/src/test/java/com/refinedmods/refinedstorage/common/constructordestructor/DestructorTest.java +++ b/refinedstorage-neoforge/src/test/java/com/refinedmods/refinedstorage/common/constructordestructor/DestructorTest.java @@ -14,10 +14,13 @@ import net.neoforged.neoforge.gametest.GameTestHolder; import net.neoforged.neoforge.gametest.PrefixGameTestTemplate; +import static com.refinedmods.refinedstorage.common.GameTestUtil.RSITEMS; import static com.refinedmods.refinedstorage.common.GameTestUtil.asResource; import static com.refinedmods.refinedstorage.common.GameTestUtil.insert; import static com.refinedmods.refinedstorage.common.GameTestUtil.networkIsAvailable; import static com.refinedmods.refinedstorage.common.GameTestUtil.storageContainsExactly; +import static net.minecraft.world.item.Items.DIAMOND; +import static net.minecraft.world.item.Items.DIAMOND_ORE; import static net.minecraft.world.item.Items.DIRT; import static net.minecraft.world.item.Items.STONE; import static net.minecraft.world.level.material.Fluids.LAVA; @@ -50,6 +53,15 @@ public static void shouldBreakBlock(final GameTestHelper helper) { new ResourceAmount(asResource(DIRT), 11), new ResourceAmount(asResource(STONE), 15) )) + .thenExecute(() -> helper.setBlock(pos.east(), Blocks.DIAMOND_ORE)) + .thenWaitUntil(() -> helper.assertBlockNotPresent(Blocks.DIAMOND_ORE, pos.east())) + .thenWaitUntil(storageContainsExactly( + helper, + pos, + new ResourceAmount(asResource(DIRT), 11), + new ResourceAmount(asResource(STONE), 15), + new ResourceAmount(asResource(DIAMOND), 1) + )) .thenSucceed(); }); } @@ -116,6 +128,33 @@ public static void shouldBreakBlockBlocklist(final GameTestHelper helper) { }); } + @GameTest(template = "empty_15x15") + public static void shouldBreakBlockWithSilkTouchUpgrade(final GameTestHelper helper) { + DestructorTestPlots.preparePlot(helper, Direction.EAST, (destructor, pos, sequence) -> { + // Arrange + sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> { + insert(helper, network, DIRT, 10); + insert(helper, network, STONE, 15); + })); + + // Act + helper.setBlock(pos.east(), Blocks.DIAMOND_ORE); + destructor.addUpgradeItem(RSITEMS.getSilkTouchUpgrade()); + + // Assert + sequence + .thenWaitUntil(() -> helper.assertBlockNotPresent(Blocks.DIAMOND_ORE, pos.east())) + .thenWaitUntil(storageContainsExactly( + helper, + pos, + new ResourceAmount(asResource(DIRT), 10), + new ResourceAmount(asResource(STONE), 15), + new ResourceAmount(asResource(DIAMOND_ORE), 1) + )) + .thenSucceed(); + }); + } + @GameTest(template = "empty_15x15") public static void shouldPickupItemAllowlist(final GameTestHelper helper) { DestructorTestPlots.preparePlot(helper, Direction.EAST, (destructor, pos, sequence) -> { From ff8bdd981e1f150a4cb4d0a5fe867059d464853f Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Mon, 29 Jul 2024 22:45:40 +0200 Subject: [PATCH 14/36] feat: processing pattern encoding No alternatives selection yet. --- .../api/autocrafting/CraftingPattern.java | 5 - .../common/api/autocrafting/Pattern.java | 5 - .../api/autocrafting/ProcessingPattern.java | 7 +- .../support/resource/ResourceContainer.java | 11 + .../common/AbstractModInitializer.java | 7 + .../refinedstorage/common/Platform.java | 3 + .../refinedstorage/common/PlatformProxy.java | 6 + ...CraftingPatternClientTooltipComponent.java | 41 +- .../autocrafting/PatternGridBlockEntity.java | 127 ++++- .../PatternGridContainerMenu.java | 54 ++- .../common/autocrafting/PatternGridData.java | 8 +- .../autocrafting/PatternGridScreen.java | 441 +++++++++++++++--- .../common/autocrafting/PatternItem.java | 32 +- .../autocrafting/PatternItemOverrides.java | 18 +- .../common/autocrafting/PatternRendering.java | 22 +- .../autocrafting/PatternTooltipCache.java | 32 ++ .../ProcessingMatrixResourceSlot.java | 57 +++ ...ocessingPatternClientTooltipComponent.java | 137 ++++++ .../autocrafting/ProcessingPatternState.java | 47 ++ .../common/content/DataComponents.java | 13 + .../grid/AbstractGridContainerMenu.java | 6 +- .../common/grid/CraftingGridSourceImpl.java | 2 +- .../SnapshotCraftingGridRefillContext.java | 4 +- .../common/support/AbstractBaseScreen.java | 52 ++- .../common/support/TextureIds.java | 1 + .../support/containermenu/ResourceSlot.java | 2 +- .../PlatformStorageNetworkComponent.java | 2 +- .../support/resource/ResourceCodecs.java | 2 + .../resource/ResourceContainerImpl.java | 8 + .../stretching/AbstractStretchingScreen.java | 7 +- .../support/widget/ScrollbarWidget.java | 50 +- .../assets/refinedstorage/lang/en_us.json | 4 + .../models/item/pattern/processing.json | 6 + .../gui/sprites/pattern_grid/processing.png | Bin 0 -> 256 bytes .../pattern_grid/processing_matrix.png | Bin 0 -> 171 bytes .../gui/sprites/widget/small_scrollbar.png | Bin 0 -> 158 bytes .../widget/small_scrollbar_clicked.png | Bin 0 -> 158 bytes .../widget/small_scrollbar_disabled.png | Bin 0 -> 155 bytes .../textures/item/pattern/processing.png | Bin 0 -> 441 bytes .../refinedstorage/common/TestPlatform.java | 6 + .../list/FuzzyResourceListImplTest.java | 2 +- .../fabric/ClientModInitializerImpl.java | 18 +- .../refinedstorage/fabric/PlatformImpl.java | 6 + .../autocrafting/PatternBakedModel.java | 5 +- .../autocrafting/PatternUnbakedModel.java | 7 +- .../resources/refinedstorage.accesswidener | 1 + .../api/grid/view/GridViewBuilderImpl.java | 2 +- .../api/grid/view/GridViewImpl.java | 2 +- .../neoforge/ClientModInitializer.java | 18 +- .../refinedstorage/neoforge/PlatformImpl.java | 6 + .../autocrafting/PatternBakedModel.java | 7 +- .../autocrafting/PatternUnbakedGeometry.java | 5 +- .../resources/META-INF/accesstransformer.cfg | 1 + .../network/test/NetworkTestFixtures.java | 4 +- .../impl/node/storage/ExposedStorage.java | 2 +- .../StorageTransferNetworkNodeTest.java | 37 +- .../StorageNetworkComponentImplTest.java | 2 +- .../api/resource/ResourceAmount.java | 4 + .../api/resource/list/ResourceListImpl.java | 11 +- .../resource/list/ProxyResourceListTest.java | 2 +- .../resource/list/ResourceListImplTest.java | 2 +- .../ListenableResourceListTest.java | 2 +- .../api/storage/InMemoryStorageImpl.java | 2 +- .../api/storage/external/ExternalStorage.java | 4 +- .../api/storage/root/RootStorageImpl.java | 2 +- .../composite/CompositeStorageImplTest.java | 2 +- .../ExtractCompositeStorageImplTest.java | 2 +- .../InsertCompositeStorageImplTest.java | 2 +- .../SubCompositeCompositeStorageImplTest.java | 10 +- 69 files changed, 1142 insertions(+), 253 deletions(-) create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternTooltipCache.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/ProcessingMatrixResourceSlot.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/ProcessingPatternClientTooltipComponent.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/ProcessingPatternState.java create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/models/item/pattern/processing.json create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/pattern_grid/processing.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/pattern_grid/processing_matrix.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/small_scrollbar.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/small_scrollbar_clicked.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/small_scrollbar_disabled.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/item/pattern/processing.png diff --git a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/CraftingPattern.java b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/CraftingPattern.java index 714a018fa..d047fb081 100644 --- a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/CraftingPattern.java +++ b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/CraftingPattern.java @@ -3,7 +3,6 @@ import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.common.api.support.resource.PlatformResourceKey; -import java.util.Collection; import java.util.List; import org.apiguardian.api.API; @@ -12,8 +11,4 @@ public record CraftingPattern(List> inputs, ResourceAmount output, List byproducts) implements Pattern { - @Override - public Collection getOutputs() { - return List.of(output); - } } diff --git a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/Pattern.java b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/Pattern.java index c055585f4..0bcbc0f31 100644 --- a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/Pattern.java +++ b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/Pattern.java @@ -1,12 +1,7 @@ package com.refinedmods.refinedstorage.common.api.autocrafting; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; - -import java.util.Collection; - import org.apiguardian.api.API; @API(status = API.Status.STABLE, since = "2.0.0-milestone.4.6") public interface Pattern { - Collection getOutputs(); } diff --git a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/ProcessingPattern.java b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/ProcessingPattern.java index ff9d33173..95dd7cf2f 100644 --- a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/ProcessingPattern.java +++ b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/autocrafting/ProcessingPattern.java @@ -2,15 +2,10 @@ import com.refinedmods.refinedstorage.api.resource.ResourceAmount; -import java.util.Collection; import java.util.List; import org.apiguardian.api.API; @API(status = API.Status.STABLE, since = "2.0.0-milestone.4.6") -public record ProcessingPattern(List> inputs, List outputs) implements Pattern { - @Override - public Collection getOutputs() { - return outputs; - } +public record ProcessingPattern(List inputs, List outputs) implements Pattern { } diff --git a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/ResourceContainer.java b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/ResourceContainer.java index cdc582672..c6225cd24 100644 --- a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/ResourceContainer.java +++ b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/ResourceContainer.java @@ -39,8 +39,19 @@ public interface ResourceContainer { void remove(int index); + void clear(); + int size(); + default boolean isEmpty() { + for (int i = 0; i < size(); i++) { + if (!isEmpty(i)) { + return false; + } + } + return true; + } + default boolean isEmpty(int index) { return get(index) == null; } 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 3a2ea3fe5..47989f300 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 @@ -18,6 +18,7 @@ import com.refinedmods.refinedstorage.common.autocrafting.PatternGridData; import com.refinedmods.refinedstorage.common.autocrafting.PatternItem; import com.refinedmods.refinedstorage.common.autocrafting.PatternState; +import com.refinedmods.refinedstorage.common.autocrafting.ProcessingPatternState; import com.refinedmods.refinedstorage.common.configurationcard.ConfigurationCardItem; import com.refinedmods.refinedstorage.common.configurationcard.ConfigurationCardState; import com.refinedmods.refinedstorage.common.constructordestructor.BlockBreakDestructorStrategyFactory; @@ -866,6 +867,12 @@ protected final void registerDataComponents(final RegistryCallback DataComponentType.builder() + .persistent(ProcessingPatternState.CODEC) + .networkSynchronized(ProcessingPatternState.STREAM_CODEC) + .build())); } protected final void registerInventorySlotReference() { diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/Platform.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/Platform.java index 00b0accf0..d7c8baaa7 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/Platform.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/Platform.java @@ -37,6 +37,7 @@ 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; @@ -133,4 +134,6 @@ void saveSavedData(SavedData savedData, NetworkNodeContainerProvider getContainerProviderSafely(Level level, BlockPos pos, @Nullable Direction direction); int getItemColor(ItemStack stack, int tintIndex); + + void setSlotY(Slot slot, int y); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/PlatformProxy.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/PlatformProxy.java index 00ff22c91..51e7a2660 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/PlatformProxy.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/PlatformProxy.java @@ -37,6 +37,7 @@ 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; @@ -259,6 +260,11 @@ public int getItemColor(final ItemStack stack, final int tintIndex) { return ensureLoaded().getItemColor(stack, tintIndex); } + @Override + public void setSlotY(final Slot slot, final int y) { + ensureLoaded().setSlotY(slot, y); + } + private Platform ensureLoaded() { if (platform == null) { throw new IllegalStateException("Platform not loaded yet"); 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 be13f9548..e06c204a1 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/CraftingPatternClientTooltipComponent.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/CraftingPatternClientTooltipComponent.java @@ -1,13 +1,12 @@ package com.refinedmods.refinedstorage.common.autocrafting; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; import com.refinedmods.refinedstorage.common.api.autocrafting.CraftingPattern; import com.refinedmods.refinedstorage.common.api.support.resource.PlatformResourceKey; import com.refinedmods.refinedstorage.common.support.resource.ItemResource; import java.util.List; -import java.util.Objects; +import javax.annotation.Nullable; import net.minecraft.ChatFormatting; import net.minecraft.client.gui.Font; @@ -20,7 +19,9 @@ import static com.refinedmods.refinedstorage.common.support.TextureIds.LIGHT_ARROW; import static com.refinedmods.refinedstorage.common.support.TextureIds.LIGHT_ARROW_HEIGHT; import static com.refinedmods.refinedstorage.common.support.TextureIds.LIGHT_ARROW_WIDTH; +import static com.refinedmods.refinedstorage.common.support.TextureIds.SLOT; import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; +import static java.util.Objects.requireNonNullElse; public class CraftingPatternClientTooltipComponent implements ClientTooltipComponent { private static final long CYCLE_MS = 1000; @@ -29,7 +30,6 @@ public class CraftingPatternClientTooltipComponent implements ClientTooltipCompo private static final int ARROW_SPACING = 8; - private static final ResourceLocation SLOT = createIdentifier("slot"); private static final ResourceLocation LARGE_SLOT = createIdentifier("large_slot"); private static final int LARGE_SLOT_WIDTH = 26; private static final int LARGE_SLOT_HEIGHT = 26; @@ -38,12 +38,27 @@ public class CraftingPatternClientTooltipComponent implements ClientTooltipCompo private final int height; private final CraftingPattern craftingPattern; + @Nullable + private final ItemStack outputStack; + @Nullable + private final Component outputText; + public CraftingPatternClientTooltipComponent(final int width, final int height, final CraftingPattern craftingPattern) { this.width = width; this.height = height; this.craftingPattern = craftingPattern; + final ItemResource outputResource = craftingPattern.output().getResource() instanceof ItemResource itemResource + ? itemResource + : null; + this.outputStack = outputResource != null + ? outputResource.toItemStack(craftingPattern.output().getAmount()) + : null; + this.outputText = outputResource != null + ? Component.literal(String.format("%dx ", craftingPattern.output().getAmount())) + .append(outputResource.toItemStack().getHoverName()) + .withStyle(ChatFormatting.GRAY) : null; } @Override @@ -66,16 +81,8 @@ public void renderImage(final Font font, final int x, final int y, final GuiGrap currentCycle++; cycleStart = now; } - if (craftingPattern.output().getResource() instanceof ItemResource itemResource) { - graphics.drawString( - font, - Component.literal(String.format("%dx ", craftingPattern.output().getAmount())) - .append(itemResource.toItemStack().getHoverName()) - .withStyle(ChatFormatting.GRAY), - x, - y, - Objects.requireNonNullElse(ChatFormatting.GRAY.getColor(), 15) - ); + if (outputText != null) { + graphics.drawString(font, outputText, x, y, requireNonNullElse(ChatFormatting.GRAY.getColor(), 15)); } renderInputSlots(x, y + 9 + 2, graphics); renderArrow(x, y + 9 + 2, graphics); @@ -120,13 +127,11 @@ private void renderResultSlot(final Font font, final int x, final int y, final G final int slotX = x + width * 18 + ARROW_SPACING + LIGHT_ARROW_WIDTH + ARROW_SPACING; final int slotY = y + ((height * 18) / 2) - (LARGE_SLOT_HEIGHT / 2); graphics.blitSprite(LARGE_SLOT, slotX, slotY, LARGE_SLOT_WIDTH, LARGE_SLOT_HEIGHT); - final ResourceAmount output = craftingPattern.output(); - if (output.getResource() instanceof ItemResource itemResource) { - final ItemStack resultItemStack = itemResource.toItemStack(output.getAmount()); + if (outputStack != null) { final int stackX = slotX + 5; final int stackY = slotY + 5; - graphics.renderItem(resultItemStack, stackX, stackY); - graphics.renderItemDecorations(font, resultItemStack, stackX, stackY); + graphics.renderItem(outputStack, stackX, stackY); + graphics.renderItemDecorations(font, outputStack, stackX, stackY); } } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridBlockEntity.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridBlockEntity.java index a9b26747a..cf5e736fc 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridBlockEntity.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridBlockEntity.java @@ -1,6 +1,8 @@ package com.refinedmods.refinedstorage.common.autocrafting; +import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.common.Platform; +import com.refinedmods.refinedstorage.common.api.support.resource.ResourceContainer; import com.refinedmods.refinedstorage.common.content.BlockEntities; import com.refinedmods.refinedstorage.common.content.ContentNames; import com.refinedmods.refinedstorage.common.content.DataComponents; @@ -13,8 +15,13 @@ import com.refinedmods.refinedstorage.common.support.CraftingMatrix; import com.refinedmods.refinedstorage.common.support.FilteredContainer; import com.refinedmods.refinedstorage.common.support.containermenu.NetworkNodeExtendedMenuProvider; +import com.refinedmods.refinedstorage.common.support.resource.ResourceContainerData; +import com.refinedmods.refinedstorage.common.support.resource.ResourceContainerImpl; import com.refinedmods.refinedstorage.common.util.ContainerUtil; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; import java.util.UUID; import javax.annotation.Nullable; @@ -37,10 +44,14 @@ public class PatternGridBlockEntity extends AbstractGridBlockEntity implements B NetworkNodeExtendedMenuProvider { private static final String TAG_PATTERN_INPUT = "pattern_input"; private static final String TAG_PATTERN_OUTPUT = "pattern_output"; + private static final String TAG_PROCESSING_INPUT = "processing_input"; + private static final String TAG_PROCESSING_OUTPUT = "processing_output"; private static final String TAG_FUZZY_MODE = "fuzzy_mode"; private static final String TAG_PATTERN_TYPE = "processing"; private final CraftingState craftingState = new CraftingState(this::setChanged, this::getLevel); + private final ResourceContainer processingInput = ResourceContainerImpl.createForFilter(81); + private final ResourceContainer processingOutput = ResourceContainerImpl.createForFilter(81); private final FilteredContainer patternInput = new FilteredContainer(1, PatternGridBlockEntity::isValidPattern); private final FilteredContainer patternOutput = new PatternOutputContainer(); private boolean fuzzyMode; @@ -55,6 +66,8 @@ public PatternGridBlockEntity(final BlockPos pos, final BlockState state) { ); patternInput.addListener(container -> setChanged()); patternOutput.addListener(container -> setChanged()); + processingInput.setListener(this::setChanged); + processingOutput.setListener(this::setChanged); } CraftingMatrix getCraftingMatrix() { @@ -65,6 +78,14 @@ ResultContainer getCraftingResult() { return craftingState.getCraftingResult(); } + ResourceContainer getProcessingInput() { + return processingInput; + } + + ResourceContainer getProcessingOutput() { + return processingOutput; + } + FilteredContainer getPatternInput() { return patternInput; } @@ -80,6 +101,8 @@ public void saveAdditional(final CompoundTag tag, final HolderLookup.Provider pr tag.put(TAG_PATTERN_OUTPUT, ContainerUtil.write(patternOutput, provider)); tag.putBoolean(TAG_FUZZY_MODE, fuzzyMode); tag.putInt(TAG_PATTERN_TYPE, PatternTypeSettings.getPatternType(patternType)); + tag.put(TAG_PROCESSING_INPUT, processingInput.toTag(provider)); + tag.put(TAG_PROCESSING_OUTPUT, processingOutput.toTag(provider)); craftingState.writeToTag(tag, provider); } @@ -94,6 +117,12 @@ public void loadAdditional(final CompoundTag tag, final HolderLookup.Provider pr } fuzzyMode = tag.getBoolean(TAG_FUZZY_MODE); patternType = PatternTypeSettings.getPatternType(tag.getInt(TAG_PATTERN_TYPE)); + if (tag.contains(TAG_PROCESSING_INPUT)) { + processingInput.fromTag(tag.getCompound(TAG_PROCESSING_INPUT), provider); + } + if (tag.contains(TAG_PROCESSING_OUTPUT)) { + processingOutput.fromTag(tag.getCompound(TAG_PROCESSING_OUTPUT), provider); + } craftingState.readFromTag(tag, provider); } @@ -134,7 +163,12 @@ public AbstractGridContainerMenu createMenu(final int syncId, final Inventory in @Override public PatternGridData getMenuData() { - return new PatternGridData(GridData.of(this), patternType); + return new PatternGridData( + GridData.of(this), + patternType, + ResourceContainerData.of(processingInput), + ResourceContainerData.of(processingOutput) + ); } @Override @@ -157,8 +191,17 @@ void clear() { if (level == null) { return; } - craftingState.getCraftingMatrix().clearContent(); - craftingState.updateResult(level); + switch (patternType) { + case CRAFTING -> { + craftingState.getCraftingMatrix().clearContent(); + craftingState.updateResult(level); + } + case PROCESSING -> { + processingInput.clear(); + processingOutput.clear(); + } + } + setChanged(); } void createPattern() { @@ -167,6 +210,7 @@ void createPattern() { } final ItemStack result = switch (patternType) { case CRAFTING -> createCraftingPattern(); + case PROCESSING -> createProcessingPattern(); default -> null; }; if (result != null) { @@ -178,6 +222,49 @@ void createPattern() { } } + @Nullable + private ItemStack createCraftingPattern() { + if (!craftingState.hasCraftingResult()) { + return null; + } + final ItemStack result = createPatternStack(PatternType.CRAFTING); + final CraftingPatternState state = new CraftingPatternState( + fuzzyMode, + getCraftingMatrix().asPositionedCraftInput() + ); + result.set(DataComponents.INSTANCE.getCraftingPatternState(), state); + return result; + } + + @Nullable + private ItemStack createProcessingPattern() { + if (processingInput.isEmpty() || processingOutput.isEmpty()) { + return null; + } + final ItemStack result = createPatternStack(PatternType.PROCESSING); + final List> inputs = new ArrayList<>(); + for (int i = 0; i < processingInput.size(); ++i) { + inputs.add(Optional.ofNullable(processingInput.get(i)).map(ResourceAmount::copy)); + } + final List> outputs = new ArrayList<>(); + for (int i = 0; i < processingOutput.size(); ++i) { + outputs.add(Optional.ofNullable(processingOutput.get(i)).map(ResourceAmount::copy)); + } + final ProcessingPatternState patternProcessingState = new ProcessingPatternState( + inputs, + outputs + ); + result.set(DataComponents.INSTANCE.getProcessingPatternState(), patternProcessingState); + return result; + } + + private static ItemStack createPatternStack(final PatternType patternType) { + final ItemStack result = new ItemStack(Items.INSTANCE.getPattern()); + final PatternState patternState = new PatternState(UUID.randomUUID(), patternType); + result.set(DataComponents.INSTANCE.getPatternState(), patternState); + return result; + } + void copyPattern(final ItemStack stack) { final PatternState state = stack.get(DataComponents.INSTANCE.getPatternState()); if (state == null) { @@ -194,6 +281,15 @@ void copyPattern(final ItemStack stack) { } copyCraftingPattern(patternCraftingState); } + case PROCESSING -> { + final ProcessingPatternState patternProcessingState = stack.get( + DataComponents.INSTANCE.getProcessingPatternState() + ); + if (patternProcessingState == null) { + return; + } + copyProcessingPattern(patternProcessingState); + } } setChanged(); } @@ -218,24 +314,17 @@ private void copyCraftingPattern(final CraftingPatternState state) { } } - @Nullable - private ItemStack createCraftingPattern() { - if (!craftingState.hasCraftingResult()) { - return null; + private void copyProcessingPattern(final ProcessingPatternState state) { + processingInput.clear(); + processingOutput.clear(); + for (int i = 0; i < state.inputs().size(); ++i) { + final int ii = i; + state.inputs().get(i).ifPresent(amount -> processingInput.set(ii, amount)); } - final boolean shouldExtractInputPattern = patternOutput.getItem(0).isEmpty(); - if (shouldExtractInputPattern) { - patternInput.removeItem(0, 1); + for (int i = 0; i < state.outputs().size(); ++i) { + final int ii = i; + state.outputs().get(i).ifPresent(amount -> processingOutput.set(ii, amount)); } - final ItemStack result = new ItemStack(Items.INSTANCE.getPattern()); - final PatternState patternState = new PatternState(UUID.randomUUID(), PatternType.CRAFTING); - result.set(DataComponents.INSTANCE.getPatternState(), patternState); - final CraftingPatternState patternCraftingState = new CraftingPatternState( - fuzzyMode, - getCraftingMatrix().asPositionedCraftInput() - ); - result.set(DataComponents.INSTANCE.getCraftingPatternState(), patternCraftingState); - return result; } private boolean isPatternAvailable() { diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridContainerMenu.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridContainerMenu.java index bbde55ebc..b06323c5d 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridContainerMenu.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridContainerMenu.java @@ -1,5 +1,6 @@ package com.refinedmods.refinedstorage.common.autocrafting; +import com.refinedmods.refinedstorage.common.api.support.resource.ResourceContainer; import com.refinedmods.refinedstorage.common.content.Menus; import com.refinedmods.refinedstorage.common.grid.AbstractGridContainerMenu; import com.refinedmods.refinedstorage.common.support.CraftingMatrix; @@ -12,6 +13,7 @@ import com.refinedmods.refinedstorage.common.support.containermenu.ServerProperty; import com.refinedmods.refinedstorage.common.support.containermenu.ValidatedSlot; import com.refinedmods.refinedstorage.common.support.packet.c2s.C2SPackets; +import com.refinedmods.refinedstorage.common.support.resource.ResourceContainerImpl; import javax.annotation.Nullable; @@ -23,12 +25,16 @@ public class PatternGridContainerMenu extends AbstractGridContainerMenu { private static final int Y_OFFSET_BETWEEN_PLAYER_INVENTORY_AND_PATTERN_INPUT_SLOT = 81; private static final int SPACING_BETWEEN_PATTERN_INPUT_AND_PATTERN_OUTPUT_SLOTS = 36; - private static final int Y_OFFSET_BETWEEN_PLAYER_INVENTORY_AND_FIRST_CRAFTING_MATRIX_SLOT = 86; + private static final int Y_OFFSET_BETWEEN_PLAYER_INVENTORY_AND_FIRST_CRAFTING_MATRIX_SLOT = 85; + private static final int Y_OFFSET_BETWEEN_PLAYER_INVENTORY_AND_FIRST_PROCESSING_MATRIX_SLOT = 76; + private static final int INDIVIDUAL_PROCESSING_MATRIX_SIZE = 54; private final Container patternInput; private final Container patternOutput; private final Container craftingMatrix; private final Container craftingResult; + private final ResourceContainer processingInput; + private final ResourceContainer processingOutput; @Nullable private PatternGridListener listener; @@ -41,6 +47,8 @@ public PatternGridContainerMenu(final int syncId, super(Menus.INSTANCE.getPatternGrid(), syncId, playerInventory, patternGridData.gridData()); this.patternInput = new FilteredContainer(1, PatternGridBlockEntity::isValidPattern); this.patternOutput = new PatternOutputContainer(); + this.processingInput = ResourceContainerImpl.createForFilter(patternGridData.processingInputData()); + this.processingOutput = ResourceContainerImpl.createForFilter(patternGridData.processingOutputData()); this.craftingMatrix = new CraftingMatrix(null, 3, 3); this.craftingResult = new ResultContainer(); onScreenReady(0); @@ -73,6 +81,8 @@ protected void onChangedOnClient(final Boolean newValue) { this.patternOutput = grid.getPatternOutput(); this.craftingMatrix = grid.getCraftingMatrix(); this.craftingResult = grid.getCraftingResult(); + this.processingInput = grid.getProcessingInput(); + this.processingOutput = grid.getProcessingOutput(); this.patternGrid = grid; onScreenReady(0); registerProperty(new ServerProperty<>( @@ -118,6 +128,7 @@ boolean canCreatePattern() { } return switch (getPatternType()) { case CRAFTING -> !craftingResult.getItem(0).isEmpty(); + case PROCESSING -> !processingInput.isEmpty() && !processingOutput.isEmpty(); default -> false; }; } @@ -128,6 +139,7 @@ public void onScreenReady(final int playerInventoryY) { transferManager.clear(); addPatternSlots(playerInventoryY); addCraftingMatrixSlots(playerInventoryY); + addProcessingMatrixSlots(playerInventoryY); } private void addPatternSlots(final int playerInventoryY) { @@ -167,7 +179,7 @@ public void set(final ItemStack stack) { private void addCraftingMatrixSlots(final int playerInventoryY) { for (int y = 0; y < 3; ++y) { for (int x = 0; x < 3; ++x) { - final int slotX = 12 + ((x % 3) * 18); + final int slotX = 13 + ((x % 3) * 18); final int slotY = playerInventoryY - Y_OFFSET_BETWEEN_PLAYER_INVENTORY_AND_FIRST_CRAFTING_MATRIX_SLOT + ((y % 3) * 18); @@ -182,7 +194,7 @@ public boolean isActive() { addSlot(new DisabledSlot( craftingResult, 0, - 116 + 4, + 117 + 4, playerInventoryY - Y_OFFSET_BETWEEN_PLAYER_INVENTORY_AND_FIRST_CRAFTING_MATRIX_SLOT + 18 ) { @Override @@ -192,6 +204,42 @@ public boolean isActive() { }); } + private void addProcessingMatrixSlots(final int playerInventoryY) { + final int y = playerInventoryY - Y_OFFSET_BETWEEN_PLAYER_INVENTORY_AND_FIRST_PROCESSING_MATRIX_SLOT; + final int startY = y - 18; + final int endY = y + INDIVIDUAL_PROCESSING_MATRIX_SIZE; + addProcessingMatrixSlots(13, y, startY, endY, processingInput, true); + addProcessingMatrixSlots(13 + INDIVIDUAL_PROCESSING_MATRIX_SIZE + 2, y, startY, endY, processingOutput, false); + } + + private void addProcessingMatrixSlots(final int x, + final int y, + final int startY, + final int endY, + final ResourceContainer resourceContainer, + final boolean input) { + int slotX = x; + int slotY = y; + for (int i = 0; i < resourceContainer.size(); ++i) { + addSlot(new ProcessingMatrixResourceSlot( + resourceContainer, + i, + slotX, + slotY, + input, + this::getPatternType, + startY, + endY + )); + if ((i + 1) % 3 == 0) { + slotX = x; + slotY += 18; + } else { + slotX += 18; + } + } + } + public void clear() { if (patternGrid != null) { patternGrid.clear(); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridData.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridData.java index a04c8c6e7..47f22df67 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridData.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridData.java @@ -1,15 +1,21 @@ package com.refinedmods.refinedstorage.common.autocrafting; import com.refinedmods.refinedstorage.common.grid.GridData; +import com.refinedmods.refinedstorage.common.support.resource.ResourceContainerData; import com.refinedmods.refinedstorage.common.util.PacketUtil; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; -public record PatternGridData(GridData gridData, PatternType patternType) { +public record PatternGridData(GridData gridData, + PatternType patternType, + ResourceContainerData processingInputData, + ResourceContainerData processingOutputData) { public static final StreamCodec STREAM_CODEC = StreamCodec.composite( GridData.STREAM_CODEC, PatternGridData::gridData, PacketUtil.enumStreamCodec(PatternType.values()), PatternGridData::patternType, + ResourceContainerData.STREAM_CODEC, PatternGridData::processingInputData, + ResourceContainerData.STREAM_CODEC, PatternGridData::processingOutputData, PatternGridData::new ); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridScreen.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridScreen.java index e3ee37662..30589cd96 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridScreen.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridScreen.java @@ -1,8 +1,11 @@ package com.refinedmods.refinedstorage.common.autocrafting; +import com.refinedmods.refinedstorage.common.Platform; import com.refinedmods.refinedstorage.common.grid.screen.AbstractGridScreen; +import com.refinedmods.refinedstorage.common.support.containermenu.ResourceSlot; import com.refinedmods.refinedstorage.common.support.widget.CustomCheckboxWidget; import com.refinedmods.refinedstorage.common.support.widget.HoveredImageButton; +import com.refinedmods.refinedstorage.common.support.widget.ScrollbarWidget; import java.util.EnumMap; import java.util.Map; @@ -20,8 +23,10 @@ import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createTranslation; +import static java.util.Objects.requireNonNull; -public class PatternGridScreen extends AbstractGridScreen { +public class PatternGridScreen extends AbstractGridScreen implements + PatternGridContainerMenu.PatternGridListener { private static final ResourceLocation TEXTURE = createIdentifier("textures/gui/pattern_grid.png"); private static final MutableComponent CREATE_PATTERN = createTranslation("gui", "pattern_grid.create_pattern"); private static final MutableComponent CLEAR = createTranslation("gui", "pattern_grid.clear"); @@ -30,8 +35,15 @@ public class PatternGridScreen extends AbstractGridScreen patternTypeButtons = new EnumMap<>(PatternType.class); @@ -55,34 +77,38 @@ public PatternGridScreen(final PatternGridContainerMenu menu, final Inventory in super(menu, inventory, title, 177); this.inventoryLabelY = 153; this.imageWidth = 193; - this.imageHeight = 250; + this.imageHeight = 249; } @Override protected void init() { super.init(); - createPatternButton = createCreatePatternButton(leftPos + 152, topPos + imageHeight - bottomHeight + 32); + this.createPatternButton = createCreatePatternButton(leftPos + 152, topPos + imageHeight - bottomHeight + 32); addRenderableWidget(createPatternButton); - final ImageButton clearButton = createClearButton(leftPos + 68, topPos + imageHeight - bottomHeight + 8); - addRenderableWidget(clearButton); addPatternTypeButtons(getMenu().getPatternType()); - final CustomCheckboxWidget fuzzyMode = createFuzzyModeCheckbox(); - addRenderableWidget(fuzzyMode); - menu.setListener(new PatternGridContainerMenu.PatternGridListener() { - @Override - public void patternTypeChanged(final PatternType value) { - patternTypeButtons.values().forEach(button -> button.setSelected(false)); - patternTypeButtons.get(value).setSelected(true); - fuzzyMode.visible = value == PatternType.CRAFTING; - clearButton.visible = value == PatternType.CRAFTING; - } + this.clearButton = createClearButton(getMenu().getPatternType()); + addRenderableWidget(clearButton); + this.fuzzyModeCheckbox = createFuzzyModeCheckbox(); + addRenderableWidget(fuzzyModeCheckbox); + this.processingScrollbar = createProcessingScrollbar(); + updateMaxProcessingScrollbarOffset(); + addWidget(processingScrollbar); + menu.setListener(this); + } - @Override - public void fuzzyModeChanged(final boolean value) { - fuzzyMode.setSelected(value); - fuzzyMode.setTooltip(getFuzzyModeTooltip(value)); - } - }); + private ImageButton createCreatePatternButton(final int x, final int y) { + final HoveredImageButton button = new HoveredImageButton( + x, + y, + CREATE_PATTERN_BUTTON_SIZE, + CREATE_PATTERN_BUTTON_SIZE, + CREATE_PATTERN_BUTTON_SPRITES, + b -> getMenu().sendCreatePattern(), + CREATE_PATTERN + ); + button.setTooltip(Tooltip.create(CREATE_PATTERN)); + button.active = getMenu().canCreatePattern(); + return button; } private void addPatternTypeButtons(final PatternType currentPatternType) { @@ -101,74 +127,369 @@ private void addPatternTypeButtons(final PatternType currentPatternType) { } } - @Override - protected void containerTick() { - super.containerTick(); - if (createPatternButton != null) { - createPatternButton.active = getMenu().canCreatePattern(); - } + private ImageButton createClearButton(final PatternType patternType) { + final HoveredImageButton button = new HoveredImageButton( + getClearButtonX(patternType), + getClearButtonY(patternType), + CLEAR_BUTTON_SIZE, + CLEAR_BUTTON_SIZE, + CLEAR_BUTTON_SPRITES, + b -> getMenu().sendClear(), + CLEAR + ); + button.setTooltip(Tooltip.create(CLEAR)); + button.visible = isClearButtonVisible(); + return button; } private CustomCheckboxWidget createFuzzyModeCheckbox() { - final CustomCheckboxWidget fuzzyMode = new CustomCheckboxWidget( - leftPos + 11, + final CustomCheckboxWidget checkbox = new CustomCheckboxWidget( + getInsetContentX(), topPos + imageHeight - bottomHeight + 65, FUZZY_MODE, font, getMenu().isFuzzyMode(), CustomCheckboxWidget.Size.SMALL ); - fuzzyMode.setOnPressed((checkbox, selected) -> getMenu().setFuzzyMode(selected)); - fuzzyMode.setTooltip(getFuzzyModeTooltip(getMenu().isFuzzyMode())); - fuzzyMode.visible = getMenu().getPatternType() == PatternType.CRAFTING; - return fuzzyMode; + checkbox.setOnPressed((c, selected) -> getMenu().setFuzzyMode(selected)); + checkbox.setTooltip(getFuzzyModeTooltip(getMenu().isFuzzyMode())); + checkbox.visible = isFuzzyModeCheckboxVisible(); + return checkbox; } private static Tooltip getFuzzyModeTooltip(final boolean fuzzyMode) { return fuzzyMode ? Tooltip.create(FUZZY_MODE_ON_HELP) : Tooltip.create(FUZZY_MODE_OFF_HELP); } - private ImageButton createCreatePatternButton(final int x, final int y) { - final HoveredImageButton button = new HoveredImageButton( - x, - y, - CREATE_PATTERN_BUTTON_SIZE, - CREATE_PATTERN_BUTTON_SIZE, - CREATE_PATTERN_BUTTON_SPRITES, - b -> getMenu().sendCreatePattern(), - CREATE_PATTERN + private ScrollbarWidget createProcessingScrollbar() { + final ScrollbarWidget scrollbar = new ScrollbarWidget( + getInsetX() + 126, + getInsetY() + 14, + ScrollbarWidget.Type.SMALL, + 52 ); - button.setTooltip(Tooltip.create(CREATE_PATTERN)); - button.active = getMenu().canCreatePattern(); - return button; + scrollbar.visible = isProcessingScrollbarVisible(); + scrollbar.setListener(offset -> onScrollbarChanged((int) offset)); + return scrollbar; } - private ImageButton createClearButton(final int x, final int y) { - final HoveredImageButton button = new HoveredImageButton( - x, - y, - CLEAR_BUTTON_SIZE, - CLEAR_BUTTON_SIZE, - CLEAR_BUTTON_SPRITES, - b -> getMenu().sendClear(), - CLEAR - ); - button.setTooltip(Tooltip.create(CLEAR)); - button.visible = getMenu().getPatternType() == PatternType.CRAFTING; - return button; + private void onScrollbarChanged(final int offset) { + int inputRow = 0; + int outputRow = 0; + final int scrollbarOffset = (processingScrollbar != null && processingScrollbar.isSmoothScrolling()) + ? offset + : offset * PROCESSING_MATRIX_SLOT_SIZE; + for (int i = 0; i < getMenu().getResourceSlots().size(); ++i) { + final ResourceSlot slot = getMenu().getResourceSlots().get(i); + if (!(slot instanceof ProcessingMatrixResourceSlot matrixSlot)) { + continue; + } + final int row = matrixSlot.isInput() ? inputRow : outputRow; + final int slotY = getInsetContentY() + + PROCESSING_INSET_Y_PADDING + 1 + + (row * PROCESSING_MATRIX_SLOT_SIZE) + - scrollbarOffset + - topPos; + Platform.INSTANCE.setSlotY(getMenu().getResourceSlots().get(i), slotY); + if ((i + 1) % 3 == 0) { + if (matrixSlot.isInput()) { + inputRow++; + } else { + outputRow++; + } + } + } + } + + @Override + protected void containerTick() { + super.containerTick(); + if (createPatternButton != null) { + createPatternButton.active = getMenu().canCreatePattern(); + } + updateMaxProcessingScrollbarOffset(); + } + + private void updateMaxProcessingScrollbarOffset() { + if (processingScrollbar == null || getMenu().getPatternType() != PatternType.PROCESSING) { + return; + } + + int filledInputSlots = 0; + int filledOutputSlots = 0; + int lastFilledInputSlot = 0; + int lastFilledOutputSlot = 0; + + for (int i = 0; i < getMenu().getResourceSlots().size(); ++i) { + final ResourceSlot resourceSlot = getMenu().getResourceSlots().get(i); + if (resourceSlot.isEmpty() || !(resourceSlot instanceof ProcessingMatrixResourceSlot matrixSlot)) { + continue; + } + if (matrixSlot.isInput()) { + filledInputSlots++; + lastFilledInputSlot = i; + } else { + filledOutputSlots++; + lastFilledOutputSlot = i - 81; + } + } + + final int maxFilledSlots = Math.max(filledInputSlots, filledOutputSlots); + final int maxFilledRows = Math.floorDiv(maxFilledSlots - 1, 3); + + final int maxLastFilledSlot = Math.max(lastFilledInputSlot, lastFilledOutputSlot); + final int maxLastFilledRow = Math.floorDiv(maxLastFilledSlot, 3) - 2; + + final int maxOffset = Math.max(maxFilledRows, maxLastFilledRow); + final int maxOffsetCorrected = processingScrollbar.isSmoothScrolling() + ? maxOffset * PROCESSING_MATRIX_SLOT_SIZE + : maxOffset; + processingScrollbar.setMaxOffset(maxOffsetCorrected); + processingScrollbar.setEnabled(maxOffsetCorrected > 0); + } + + @Override + public void render(final GuiGraphics graphics, final int mouseX, final int mouseY, final float partialTicks) { + super.render(graphics, mouseX, mouseY, partialTicks); + if (processingScrollbar != null) { + processingScrollbar.render(graphics, mouseX, mouseY, partialTicks); + } } @Override protected void renderBg(final GuiGraphics graphics, final float delta, final int mouseX, final int mouseY) { super.renderBg(graphics, delta, mouseX, mouseY); + final int insetContentX = getInsetContentX(); + final int insetContentY = getInsetContentY(); switch (getMenu().getPatternType()) { - case CRAFTING -> - graphics.blitSprite(CRAFTING, leftPos + 7 + 4, topPos + imageHeight - bottomHeight + 4 + 4, 130, 54); + case CRAFTING -> graphics.blitSprite(CRAFTING, insetContentX, insetContentY, 130, 54); + case PROCESSING -> renderProcessingBackground(graphics, mouseX, mouseY, insetContentX, insetContentY); + } + } + + private void renderProcessingBackground(final GuiGraphics graphics, + final int mouseX, + final int mouseY, + final int insetContentX, + final int insetContentY) { + graphics.blitSprite(PROCESSING, insetContentX, insetContentY + PROCESSING_INSET_Y_PADDING, 130, 54); + renderProcessingMatrix( + graphics, + getInsetContentX() + 1, + getInsetY() + 14, + getInsetContentX() + 1 + 52 + 1, // include the edge so we get the item counts properly + getInsetY() + 14 + 52 + 1, // include the edge so we get the item counts properly + mouseX, + mouseY, + true + ); + renderProcessingMatrix( + graphics, + getInsetContentX() + INDIVIDUAL_PROCESSING_MATRIX_SIZE + 2 + 1, + getInsetY() + 14, + getInsetContentX() + INDIVIDUAL_PROCESSING_MATRIX_SIZE + 2 + 1 + 52 + 1, + getInsetY() + 14 + 52 + 1, + mouseX, + mouseY, + false + ); + } + + private void renderProcessingMatrix(final GuiGraphics graphics, + final int startX, + final int startY, + final int endX, + final int endY, + final int mouseX, + final int mouseY, + final boolean input) { + graphics.enableScissor(startX, startY, endX, endY); + renderProcessingMatrixSlotBackground(graphics, input); + renderProcessingMatrixSlots(graphics, mouseX, mouseY, input); + graphics.disableScissor(); + } + + private void renderProcessingMatrixSlotBackground(final GuiGraphics graphics, final boolean input) { + final int x = getInsetContentX() + (!input ? INDIVIDUAL_PROCESSING_MATRIX_SIZE + 2 : 0); + final int startY = getInsetY() + PROCESSING_INSET_Y_PADDING - INDIVIDUAL_PROCESSING_MATRIX_SIZE; + final int endY = getInsetY() + PROCESSING_INSET_Y_PADDING + INDIVIDUAL_PROCESSING_MATRIX_SIZE; + final int scrollbarOffset = processingScrollbar != null ? (int) processingScrollbar.getOffset() : 0; + final int scrollbarOffsetCorrected = processingScrollbar != null && processingScrollbar.isSmoothScrolling() + ? scrollbarOffset + : scrollbarOffset * PROCESSING_MATRIX_SLOT_SIZE; + for (int i = 0; i < 9; ++i) { + final int y = (getInsetY() + 13) + + (i * INDIVIDUAL_PROCESSING_MATRIX_SIZE) + - scrollbarOffsetCorrected; + if (y < startY || y > endY) { + continue; + } + graphics.blitSprite( + PROCESSING_MATRIX, + x, + y, + INDIVIDUAL_PROCESSING_MATRIX_SIZE, + INDIVIDUAL_PROCESSING_MATRIX_SIZE + ); } } + private void renderProcessingMatrixSlots(final GuiGraphics graphics, + final int mouseX, + final int mouseY, + final boolean input) { + for (final ResourceSlot resourceSlot : getMenu().getResourceSlots()) { + if (resourceSlot.isActive() + && resourceSlot instanceof ProcessingMatrixResourceSlot matrixSlot + && matrixSlot.isInput() == input) { + tryRenderResourceSlot(graphics, resourceSlot); + if (isHovering(resourceSlot.x, resourceSlot.y, 16, 16, mouseX, mouseY) + && canInteractWithResourceSlot(resourceSlot, mouseX, mouseY)) { + renderSlotHighlight(graphics, leftPos + resourceSlot.x, topPos + resourceSlot.y, 0); + } + } + } + } + + @Override + protected void renderResourceSlots(final GuiGraphics graphics) { + // no op, we render them in the scissor rendering + } + + @Override + protected boolean canInteractWithResourceSlot(final ResourceSlot resourceSlot, + final double mouseX, + final double mouseY) { + // Ensure that we can't interact with the resource slot, when the resource slot is on the + // edge of the scissoring area and still technically visible and active, + // but we're no longer hovering over the processing matrix. + final int insetContentX = getInsetContentX() + ( + resourceSlot instanceof ProcessingMatrixResourceSlot matrixSlot && !matrixSlot.isInput() + ? INDIVIDUAL_PROCESSING_MATRIX_SIZE + 2 + : 0); + final int insetContentY = getInsetContentY(); + return mouseX >= insetContentX + && mouseX < insetContentX + INDIVIDUAL_PROCESSING_MATRIX_SIZE + && mouseY >= insetContentY + PROCESSING_INSET_Y_PADDING + && mouseY < insetContentY + PROCESSING_INSET_Y_PADDING + INDIVIDUAL_PROCESSING_MATRIX_SIZE; + } + + @Override + protected void renderLabels(final GuiGraphics graphics, final int mouseX, final int mouseY) { + super.renderLabels(graphics, mouseX, mouseY); + if (getMenu().getPatternType() == PatternType.PROCESSING) { + final int x = getInsetContentX() - leftPos; + final int y = getInsetContentY() - topPos; + graphics.drawString(font, INPUTS, x, y, 4210752, false); + graphics.drawString(font, OUTPUTS, x + 56, y, 4210752, false); + } + } + + @Override + public boolean mouseClicked(final double mouseX, final double mouseY, final int clickedButton) { + if (processingScrollbar != null && processingScrollbar.mouseClicked(mouseX, mouseY, clickedButton)) { + return true; + } + return super.mouseClicked(mouseX, mouseY, clickedButton); + } + + @Override + public void mouseMoved(final double mx, final double my) { + if (processingScrollbar != null) { + processingScrollbar.mouseMoved(mx, my); + } + super.mouseMoved(mx, my); + } + + @Override + public boolean mouseReleased(final double mx, final double my, final int button) { + return (processingScrollbar != null && processingScrollbar.mouseReleased(mx, my, button)) + || super.mouseReleased(mx, my, button); + } + + @Override + public boolean mouseScrolled(final double x, final double y, final double z, final double delta) { + final boolean isOverProcessingArea = x >= getInsetX() + && (x < getInsetX() + INSET_WIDTH) + && y > getInsetY() + && (y < getInsetY() + INSET_HEIGHT); + final boolean didScrollbar = processingScrollbar != null + && processingScrollbar.isActive() + && isOverProcessingArea + && processingScrollbar.mouseScrolled(x, y, z, delta); + return didScrollbar || super.mouseScrolled(x, y, z, delta); + } + @Override protected ResourceLocation getTexture() { return TEXTURE; } + + @Override + public void patternTypeChanged(final PatternType value) { + patternTypeButtons.values().forEach(button -> button.setSelected(false)); + patternTypeButtons.get(value).setSelected(true); + if (fuzzyModeCheckbox != null) { + fuzzyModeCheckbox.visible = isFuzzyModeCheckboxVisible(); + } + if (clearButton != null) { + clearButton.visible = isClearButtonVisible(); + if (clearButton.visible) { + clearButton.setX(getClearButtonX(value)); + requireNonNull(clearButton).setY(getClearButtonY(value)); + } + } + if (processingScrollbar != null) { + processingScrollbar.visible = isProcessingScrollbarVisible(); + } + } + + @Override + public void fuzzyModeChanged(final boolean value) { + if (fuzzyModeCheckbox == null) { + return; + } + fuzzyModeCheckbox.setSelected(value); + fuzzyModeCheckbox.setTooltip(getFuzzyModeTooltip(value)); + } + + private int getClearButtonX(final PatternType patternType) { + return patternType == PatternType.CRAFTING ? leftPos + 69 : leftPos + 124; + } + + private int getClearButtonY(final PatternType patternType) { + if (patternType == PatternType.PROCESSING) { + return getInsetContentY() + PROCESSING_INSET_Y_PADDING; + } + return getInsetContentY(); + } + + private boolean isClearButtonVisible() { + return getMenu().getPatternType() == PatternType.CRAFTING + || getMenu().getPatternType() == PatternType.PROCESSING; + } + + private boolean isFuzzyModeCheckboxVisible() { + return getMenu().getPatternType() == PatternType.CRAFTING; + } + + private boolean isProcessingScrollbarVisible() { + return getMenu().getPatternType() == PatternType.PROCESSING; + } + + private int getInsetX() { + return leftPos + 8; + } + + private int getInsetY() { + return topPos + imageHeight - bottomHeight + 5; + } + + private int getInsetContentX() { + return getInsetX() + INSET_PADDING; + } + + private int getInsetContentY() { + return getInsetY() + INSET_PADDING; + } } 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 1f5faab19..72faa2e61 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 @@ -5,6 +5,7 @@ import com.refinedmods.refinedstorage.common.api.autocrafting.CraftingPattern; import com.refinedmods.refinedstorage.common.api.autocrafting.Pattern; import com.refinedmods.refinedstorage.common.api.autocrafting.PatternProviderItem; +import com.refinedmods.refinedstorage.common.api.autocrafting.ProcessingPattern; import com.refinedmods.refinedstorage.common.api.support.HelpTooltipComponent; import com.refinedmods.refinedstorage.common.api.support.resource.PlatformResourceKey; import com.refinedmods.refinedstorage.common.content.DataComponents; @@ -96,12 +97,21 @@ public Optional getTooltipImage(final ItemStack stack) { .filter(CraftingPattern.class::isInstance) .map(CraftingPattern.class::cast) .map(craftingPattern -> new CraftingPatternTooltipComponent( - HELP, + state.id(), craftingPattern, craftingState.input().input().width(), craftingState.input().input().height() )); } + case PROCESSING -> { + final ProcessingPatternState processingState = stack.get( + DataComponents.INSTANCE.getProcessingPatternState() + ); + if (processingState == null) { + yield Optional.empty(); + } + yield Optional.of(new ProcessingPatternTooltipComponent(state.id(), processingState)); + } default -> Optional.empty(); }; } @@ -124,6 +134,7 @@ public Optional getPattern(final ItemStack stack, final Level level) { } return switch (state.type()) { case CRAFTING -> getCraftingPattern(stack, level); + case PROCESSING -> getProcessingPattern(stack); default -> Optional.empty(); }; } @@ -199,6 +210,16 @@ private List getByproducts(final CraftingRecipe recipe, final Cr .toList(); } + private Optional getProcessingPattern(final ItemStack stack) { + final ProcessingPatternState state = stack.get( + DataComponents.INSTANCE.getProcessingPatternState() + ); + if (state == null) { + return Optional.empty(); + } + return Optional.of(new ProcessingPattern(state.getFlatInputs(), state.getFlatOutputs())); + } + @Override public InteractionResultHolder use(final Level level, final Player player, final InteractionHand hand) { final ItemStack stack = player.getItemInHand(hand); @@ -211,10 +232,11 @@ public InteractionResultHolder use(final Level level, final Player pl return new InteractionResultHolder<>(InteractionResult.PASS, stack); } - public record CraftingPatternTooltipComponent(Component helpText, - CraftingPattern craftingPattern, - int width, - int height) + public record CraftingPatternTooltipComponent(UUID id, CraftingPattern craftingPattern, int width, int height) + implements TooltipComponent { + } + + public record ProcessingPatternTooltipComponent(UUID id, ProcessingPatternState state) implements TooltipComponent { } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternItemOverrides.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternItemOverrides.java index faf433d82..3a6aa09fb 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternItemOverrides.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternItemOverrides.java @@ -17,14 +17,17 @@ public class PatternItemOverrides extends ItemOverrides { private final BakedModel emptyModel; private final BakedModel craftingModel; + private final BakedModel processingModel; @SuppressWarnings({"DataFlowIssue"}) // null is allowed as long as we don't pass overrides public PatternItemOverrides(final ModelBaker modelBaker, final BakedModel emptyModel, - final BakedModel craftingModel) { + final BakedModel craftingModel, + final BakedModel processingModel) { super(modelBaker, null, List.of()); this.emptyModel = emptyModel; this.craftingModel = craftingModel; + this.processingModel = processingModel; } @Override @@ -38,15 +41,18 @@ public BakedModel resolve(final BakedModel model, return emptyModel; } if (state.type() == PatternType.CRAFTING) { - return getCraftingOutputModel(stack, level, entity, seed).orElse(craftingModel); + return getOutputModel(stack, level, entity, seed).orElse(craftingModel); + } + if (state.type() == PatternType.PROCESSING) { + return getOutputModel(stack, level, entity, seed).orElse(processingModel); } return emptyModel; } - private Optional getCraftingOutputModel(final ItemStack stack, - @Nullable final ClientLevel level, - @Nullable final LivingEntity entity, - final int seed) { + private Optional getOutputModel(final ItemStack stack, + @Nullable final ClientLevel level, + @Nullable final LivingEntity entity, + final int seed) { if (PatternRendering.canDisplayOutput(stack)) { return PatternRendering.getOutput(stack).map( output -> Minecraft.getInstance().getItemRenderer().getModel(output, level, entity, seed) 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 16db1edf6..165abc671 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 @@ -1,9 +1,9 @@ package com.refinedmods.refinedstorage.common.autocrafting; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; import com.refinedmods.refinedstorage.common.api.autocrafting.CraftingPattern; import com.refinedmods.refinedstorage.common.api.autocrafting.PatternProviderItem; +import com.refinedmods.refinedstorage.common.api.autocrafting.ProcessingPattern; import com.refinedmods.refinedstorage.common.support.resource.ItemResource; import com.refinedmods.refinedstorage.common.util.PlatformUtil; @@ -26,13 +26,17 @@ public static Optional getOutput(final ItemStack stack) { if (level == null) { return Optional.empty(); } - return RefinedStorageApi.INSTANCE.getPattern(stack, level) - .filter(CraftingPattern.class::isInstance) - .map(CraftingPattern.class::cast) - .map(CraftingPattern::output) - .map(ResourceAmount::getResource) - .filter(ItemResource.class::isInstance) - .map(ItemResource.class::cast) - .map(ItemResource::toItemStack); + return RefinedStorageApi.INSTANCE.getPattern(stack, level).map(pattern -> { + if (pattern instanceof CraftingPattern craftingPattern + && craftingPattern.output().getResource() instanceof ItemResource itemResource) { + return itemResource.toItemStack(); + } + if (pattern instanceof ProcessingPattern processingPattern + && processingPattern.outputs().size() == 1 + && processingPattern.outputs().getFirst().getResource() instanceof ItemResource itemResource) { + return itemResource.toItemStack(); + } + return null; + }); } } 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 new file mode 100644 index 000000000..cd7b91269 --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternTooltipCache.java @@ -0,0 +1,32 @@ +package com.refinedmods.refinedstorage.common.autocrafting; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; + +public final class PatternTooltipCache { + private static final Map CACHE = new HashMap<>(); + + private PatternTooltipCache() { + } + + public static ClientTooltipComponent getComponent(final PatternItem.CraftingPatternTooltipComponent key) { + if (CACHE.size() > 1000) { + CACHE.clear(); + } + return CACHE.computeIfAbsent(key.id(), id -> new CraftingPatternClientTooltipComponent( + key.width(), + key.height(), + key.craftingPattern() + )); + } + + public static ClientTooltipComponent getComponent(final PatternItem.ProcessingPatternTooltipComponent key) { + if (CACHE.size() > 1000) { + CACHE.clear(); + } + return CACHE.computeIfAbsent(key.id(), id -> new ProcessingPatternClientTooltipComponent(key.state())); + } +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/ProcessingMatrixResourceSlot.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/ProcessingMatrixResourceSlot.java new file mode 100644 index 000000000..a397e7baf --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/ProcessingMatrixResourceSlot.java @@ -0,0 +1,57 @@ +package com.refinedmods.refinedstorage.common.autocrafting; + +import com.refinedmods.refinedstorage.common.api.support.resource.ResourceContainer; +import com.refinedmods.refinedstorage.common.support.containermenu.ResourceSlot; +import com.refinedmods.refinedstorage.common.support.containermenu.ResourceSlotType; + +import java.util.function.Supplier; + +import net.minecraft.network.chat.MutableComponent; + +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createTranslation; + +class ProcessingMatrixResourceSlot extends ResourceSlot { + private static final MutableComponent INPUT_HELP = createTranslation( + "gui", + "pattern_grid.processing.input_slots_help" + ); + private static final MutableComponent OUTPUT_HELP = createTranslation( + "gui", + "pattern_grid.processing.output_slots_help" + ); + + private final Supplier patternTypeSupplier; + private final boolean input; + private final int startY; + private final int endY; + + ProcessingMatrixResourceSlot(final ResourceContainer resourceContainer, + final int index, + final int x, + final int y, + final boolean input, + final Supplier patternTypeSupplier, + final int startY, + final int endY) { + super(resourceContainer, index, input ? INPUT_HELP : OUTPUT_HELP, x, y, ResourceSlotType.FILTER_WITH_AMOUNT); + this.patternTypeSupplier = patternTypeSupplier; + this.input = input; + this.startY = startY; + this.endY = endY; + } + + boolean isInput() { + return input; + } + + @Override + public boolean isActive() { + final PatternType patternType = patternTypeSupplier.get(); + return patternType == PatternType.PROCESSING && y >= startY && y < endY; + } + + @Override + public boolean isHighlightable() { + return false; // we render the highlight in the scissor render + } +} 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 new file mode 100644 index 000000000..5131a51a2 --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/ProcessingPatternClientTooltipComponent.java @@ -0,0 +1,137 @@ +package com.refinedmods.refinedstorage.common.autocrafting; + +import com.refinedmods.refinedstorage.api.resource.ResourceAmount; +import com.refinedmods.refinedstorage.common.api.RefinedStorageApi; +import com.refinedmods.refinedstorage.common.api.support.resource.ResourceRendering; +import com.refinedmods.refinedstorage.common.support.AbstractBaseScreen; + +import java.util.List; +import java.util.Optional; + +import net.minecraft.ChatFormatting; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; +import net.minecraft.network.chat.Component; + +import static com.refinedmods.refinedstorage.common.support.TextureIds.LIGHT_ARROW; +import static com.refinedmods.refinedstorage.common.support.TextureIds.LIGHT_ARROW_HEIGHT; +import static com.refinedmods.refinedstorage.common.support.TextureIds.LIGHT_ARROW_WIDTH; +import static com.refinedmods.refinedstorage.common.support.TextureIds.SLOT; +import static java.util.Objects.requireNonNullElse; + +public class ProcessingPatternClientTooltipComponent implements ClientTooltipComponent { + private static final int ARROW_SPACING = 8; + + private final ProcessingPatternState state; + private final int rows; + private final List outputs; + + public ProcessingPatternClientTooltipComponent(final ProcessingPatternState state) { + this.state = state; + this.rows = calculateMaxRows(state); + this.outputs = getOutputText(state); + } + + private static int calculateMaxRows(final ProcessingPatternState state) { + int lastFilledInputIndex = 0; + for (int i = 0; i < state.inputs().size(); i++) { + if (state.inputs().get(i).isPresent()) { + lastFilledInputIndex = i; + } + } + int lastFilledOutputIndex = 0; + for (int i = 0; i < state.outputs().size(); i++) { + if (state.outputs().get(i).isPresent()) { + lastFilledOutputIndex = i; + } + } + final int lastFilledInputRow = Math.ceilDiv(lastFilledInputIndex + 1, 3); + final int lastFilledOutputRow = Math.ceilDiv(lastFilledOutputIndex + 1, 3); + return Math.max(lastFilledInputRow, lastFilledOutputRow); + } + + private static List getOutputText(final ProcessingPatternState state) { + return state.getFlatOutputs() + .stream() + .map(ProcessingPatternClientTooltipComponent::getOutputText) + .toList(); + } + + private static Component getOutputText(final ResourceAmount resourceAmount) { + final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering( + resourceAmount.getResource() + ); + final String displayAmount = rendering.getDisplayedAmount( + resourceAmount.getAmount(), + false + ); + return Component.literal(String.format("%sx ", displayAmount)) + .append(rendering.getDisplayName(resourceAmount.getResource())) + .withStyle(ChatFormatting.GRAY); + } + + @Override + public int getHeight() { + return (outputs.size() * 9) + 2 + (rows * 18) + 3; + } + + @Override + public int getWidth(final Font font) { + return (18 * 3) + ARROW_SPACING + LIGHT_ARROW_WIDTH + ARROW_SPACING + (18 * 3); + } + + @Override + public void renderImage(final Font font, final int x, final int y, final GuiGraphics graphics) { + renderOutputText(font, x, y, graphics); + final int matrixSlotsY = y + (outputs.size() * 9) + 2; + renderMatrixSlots(x, matrixSlotsY, true, graphics); + graphics.blitSprite( + LIGHT_ARROW, + x + (18 * 3) + ARROW_SPACING, + y + (outputs.size() * 9) + 2 + ((rows * 18) / 2) - (LIGHT_ARROW_HEIGHT / 2), + LIGHT_ARROW_WIDTH, + LIGHT_ARROW_HEIGHT + ); + renderMatrixSlots(x, matrixSlotsY, false, graphics); + } + + private void renderMatrixSlots(final int x, + final int y, + final boolean input, + final GuiGraphics graphics) { + final List> slots = input ? state.inputs() : state.outputs(); + for (int row = 0; row < rows; ++row) { + for (int column = 0; column < 3; ++column) { + final int slotXOffset = !input ? ((18 * 3) + ARROW_SPACING + LIGHT_ARROW_WIDTH + ARROW_SPACING) : 0; + final int slotX = x + slotXOffset + column * 18; + final int slotY = y + row * 18; + final int idx = row * 3 + column; + if (idx >= slots.size()) { + break; + } + graphics.blitSprite(SLOT, slotX, slotY, 18, 18); + slots.get(idx).ifPresent(resourceAmount -> { + final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering( + resourceAmount.getResource() + ); + rendering.render(resourceAmount.getResource(), graphics, slotX + 1, slotY + 1); + AbstractBaseScreen.renderResourceAmount(graphics, slotX + 1, slotY + 1, resourceAmount.getAmount(), + rendering); + }); + } + } + } + + private void renderOutputText(final Font font, final int x, final int y, final GuiGraphics graphics) { + for (int i = 0; i < outputs.size(); ++i) { + graphics.drawString( + font, + outputs.get(i), + x, + y + (i * 9), + requireNonNullElse(ChatFormatting.GRAY.getColor(), 15) + ); + } + } +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/ProcessingPatternState.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/ProcessingPatternState.java new file mode 100644 index 000000000..afa7d0f76 --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/ProcessingPatternState.java @@ -0,0 +1,47 @@ +package com.refinedmods.refinedstorage.common.autocrafting; + +import com.refinedmods.refinedstorage.api.resource.ResourceAmount; +import com.refinedmods.refinedstorage.api.resource.list.ResourceList; +import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; +import com.refinedmods.refinedstorage.common.support.resource.ResourceCodecs; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; + +public record ProcessingPatternState( + List> inputs, + List> outputs +) { + public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( + Codec.list(ResourceCodecs.AMOUNT_OPTIONAL_CODEC).fieldOf("inputs").forGetter(ProcessingPatternState::inputs), + Codec.list(ResourceCodecs.AMOUNT_OPTIONAL_CODEC).fieldOf("outputs").forGetter(ProcessingPatternState::outputs) + ).apply(instance, ProcessingPatternState::new)); + + public static final StreamCodec STREAM_CODEC = + StreamCodec.composite( + ByteBufCodecs.collection(ArrayList::new, ResourceCodecs.AMOUNT_STREAM_OPTIONAL_CODEC), + ProcessingPatternState::inputs, + ByteBufCodecs.collection(ArrayList::new, ResourceCodecs.AMOUNT_STREAM_OPTIONAL_CODEC), + ProcessingPatternState::outputs, + ProcessingPatternState::new + ); + + List getFlatInputs() { + final ResourceList list = ResourceListImpl.orderPreserving(); + inputs.forEach(input -> input.ifPresent(list::add)); + return new ArrayList<>(list.getAll()); + } + + List getFlatOutputs() { + final ResourceList list = ResourceListImpl.orderPreserving(); + outputs.forEach(output -> output.ifPresent(list::add)); + return new ArrayList<>(list.getAll()); + } +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/DataComponents.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/DataComponents.java index 47dfd40fd..4b9d7ad45 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/DataComponents.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/content/DataComponents.java @@ -2,6 +2,7 @@ import com.refinedmods.refinedstorage.common.autocrafting.CraftingPatternState; import com.refinedmods.refinedstorage.common.autocrafting.PatternState; +import com.refinedmods.refinedstorage.common.autocrafting.ProcessingPatternState; import com.refinedmods.refinedstorage.common.configurationcard.ConfigurationCardState; import com.refinedmods.refinedstorage.common.security.SecurityCardBoundPlayer; import com.refinedmods.refinedstorage.common.security.SecurityCardPermissions; @@ -37,6 +38,8 @@ public final class DataComponents { private Supplier> patternState; @Nullable private Supplier> craftingPatternState; + @Nullable + private Supplier> processingPatternState; private DataComponents() { } @@ -122,4 +125,14 @@ public void setCraftingPatternState( ) { this.craftingPatternState = supplier; } + + public DataComponentType getProcessingPatternState() { + return requireNonNull(processingPatternState).get(); + } + + public void setProcessingPatternState( + @Nullable final Supplier> supplier + ) { + this.processingPatternState = supplier; + } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/AbstractGridContainerMenu.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/AbstractGridContainerMenu.java index 065c4f96e..51d45f07c 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/AbstractGridContainerMenu.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/AbstractGridContainerMenu.java @@ -30,7 +30,7 @@ import com.refinedmods.refinedstorage.common.grid.strategy.ClientGridInsertionStrategy; import com.refinedmods.refinedstorage.common.grid.strategy.ClientGridScrollingStrategy; import com.refinedmods.refinedstorage.common.grid.view.CompositeGridResourceFactory; -import com.refinedmods.refinedstorage.common.support.AbstractBaseContainerMenu; +import com.refinedmods.refinedstorage.common.support.containermenu.AbstractResourceContainerMenu; import com.refinedmods.refinedstorage.common.support.packet.s2c.S2CPackets; import com.refinedmods.refinedstorage.common.support.resource.ResourceTypes; import com.refinedmods.refinedstorage.common.support.stretching.ScreenSizeListener; @@ -53,7 +53,7 @@ import static java.util.Objects.requireNonNull; -public abstract class AbstractGridContainerMenu extends AbstractBaseContainerMenu +public abstract class AbstractGridContainerMenu extends AbstractResourceContainerMenu implements GridWatcher, GridInsertionStrategy, GridExtractionStrategy, GridScrollingStrategy, ScreenSizeListener { private static final Logger LOGGER = LoggerFactory.getLogger(AbstractGridContainerMenu.class); private static final GridQueryParserImpl QUERY_PARSER = new GridQueryParserImpl( @@ -125,7 +125,7 @@ protected AbstractGridContainerMenu( final Inventory playerInventory, final Grid grid ) { - super(menuType, syncId); + super(menuType, syncId, playerInventory.player); this.view = createViewBuilder().build(); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridSourceImpl.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridSourceImpl.java index 60411e3ca..08f3ade93 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridSourceImpl.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridSourceImpl.java @@ -128,7 +128,7 @@ private boolean extractFromPlayerInventory(final Player player, final ItemResour } private ResourceList createCombinedPlayerInventoryAndNetworkList(final Player player) { - final ResourceList list = new ResourceListImpl(); + final ResourceList list = ResourceListImpl.create(); addNetworkItemsIntoList(list); addPlayerInventoryItemsIntoList(player, list); return list; diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/SnapshotCraftingGridRefillContext.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/SnapshotCraftingGridRefillContext.java index 5dbf3da73..2aae5c9e4 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/SnapshotCraftingGridRefillContext.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/SnapshotCraftingGridRefillContext.java @@ -14,8 +14,8 @@ class SnapshotCraftingGridRefillContext implements CraftingGridRefillContext { private final PlayerActor playerActor; private final CraftingGridBlockEntity blockEntity; - private final ResourceList available = new ResourceListImpl(); - private final ResourceList used = new ResourceListImpl(); + private final ResourceList available = ResourceListImpl.create(); + private final ResourceList used = ResourceListImpl.create(); SnapshotCraftingGridRefillContext( final Player player, 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 6c642ed05..713e825c2 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 @@ -25,6 +25,8 @@ import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; @@ -95,7 +97,7 @@ public void render(final GuiGraphics graphics, final int mouseX, final int mouse renderTooltip(graphics, mouseX, mouseY); } - protected final void renderResourceSlots(final GuiGraphics graphics) { + protected void renderResourceSlots(final GuiGraphics graphics) { if (!(menu instanceof AbstractResourceContainerMenu resourceContainerMenu)) { return; } @@ -104,7 +106,7 @@ protected final void renderResourceSlots(final GuiGraphics graphics) { } } - private void tryRenderResourceSlot(final GuiGraphics graphics, final ResourceSlot slot) { + protected final void tryRenderResourceSlot(final GuiGraphics graphics, final ResourceSlot slot) { final ResourceKey resource = slot.getResource(); if (resource == null) { return; @@ -128,15 +130,15 @@ private void renderResourceSlot(final GuiGraphics graphics, final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering(resource); rendering.render(resource, graphics, x, y); if (renderAmount) { - renderResourceSlotAmount(graphics, x, y, amount, rendering); + renderResourceAmount(graphics, x, y, amount, rendering); } } - private void renderResourceSlotAmount(final GuiGraphics graphics, - final int x, - final int y, - final long amount, - final ResourceRendering rendering) { + public static void renderResourceAmount(final GuiGraphics graphics, + final int x, + final int y, + final long amount, + final ResourceRendering rendering) { renderAmount( graphics, x, @@ -147,12 +149,13 @@ private void renderResourceSlotAmount(final GuiGraphics graphics, ); } - protected void renderAmount(final GuiGraphics graphics, - final int x, - final int y, - final String amount, - final int color, - final boolean large) { + protected static void renderAmount(final GuiGraphics graphics, + final int x, + final int y, + final String amount, + final int color, + final boolean large) { + final Font font = Minecraft.getInstance().font; final PoseStack poseStack = graphics.pose(); poseStack.pushPose(); // Large amounts overlap with the slot lines (see Minecraft behavior) @@ -186,7 +189,7 @@ protected void renderTooltip(final GuiGraphics graphics, final int x, final int return; } } - if (hoveredSlot instanceof ResourceSlot resourceSlot) { + if (hoveredSlot instanceof ResourceSlot resourceSlot && canInteractWithResourceSlot(resourceSlot, x, y)) { final List tooltip = getResourceTooltip(menu.getCarried(), resourceSlot); if (!tooltip.isEmpty()) { Platform.INSTANCE.renderTooltip(graphics, tooltip, x, y); @@ -294,9 +297,10 @@ public boolean mouseClicked(final double mouseX, final double mouseY, final int if (hoveredSlot instanceof ResourceSlot resourceSlot && !resourceSlot.supportsItemSlotInteractions() && !resourceSlot.isDisabled() - && getMenu() instanceof AbstractResourceContainerMenu containerMenu) { - if (!tryOpenResourceAmountScreen(resourceSlot)) { - containerMenu.sendResourceSlotChange(hoveredSlot.index, clickedButton == 1); + && canInteractWithResourceSlot(resourceSlot, mouseX, mouseY)) { + if (!tryOpenResourceAmountScreen(resourceSlot) + && getMenu() instanceof AbstractResourceContainerMenu resourceMenu) { + resourceMenu.sendResourceSlotChange(hoveredSlot.index, clickedButton == 1); } return true; } @@ -308,14 +312,22 @@ private boolean tryOpenResourceAmountScreen(final ResourceSlot slot) { final boolean canModifyAmount = isFilterSlot && slot.canModifyAmount(); final boolean isNotTryingToRemoveFilter = !hasShiftDown(); final boolean isNotCarryingItem = getMenu().getCarried().isEmpty(); - final boolean canOpen = - isFilterSlot && canModifyAmount && isNotTryingToRemoveFilter && isNotCarryingItem; + final boolean canOpen = isFilterSlot + && canModifyAmount + && isNotTryingToRemoveFilter + && isNotCarryingItem; if (canOpen && minecraft != null) { minecraft.setScreen(new ResourceAmountScreen(this, playerInventory, slot)); } return canOpen; } + protected boolean canInteractWithResourceSlot(final ResourceSlot resourceSlot, + final double mouseX, + final double mouseY) { + return true; + } + @Nullable @API(status = API.Status.INTERNAL) public PlatformResourceKey getHoveredResource() { diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/TextureIds.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/TextureIds.java index 7604a0fb7..57e62faf0 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/TextureIds.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/TextureIds.java @@ -7,6 +7,7 @@ public final class TextureIds { public static final ResourceLocation SIDE_BUTTON_ICONS = createIdentifier("textures/side_button_icons.png"); public static final ResourceLocation LIGHT_ARROW = createIdentifier("light_arrow"); + public static final ResourceLocation SLOT = createIdentifier("slot"); public static final int LIGHT_ARROW_WIDTH = 22; public static final int LIGHT_ARROW_HEIGHT = 15; public static final ResourceLocation WARNING = createIdentifier("warning"); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/containermenu/ResourceSlot.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/containermenu/ResourceSlot.java index 41ca7769d..b7d4e4b8b 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/containermenu/ResourceSlot.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/containermenu/ResourceSlot.java @@ -56,7 +56,7 @@ public ResourceSlot(final ResourceContainer resourceContainer, } public ResourceSlot forAmountScreen(final int newX, final int newY) { - return new ResourceSlot(resourceContainer, container, index, helpText, newX, newY, type) { + return new ResourceSlot(resourceContainer, container, getContainerSlot(), helpText, newX, newY, type) { @Override public boolean canModifyAmount() { return false; diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/network/component/PlatformStorageNetworkComponent.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/network/component/PlatformStorageNetworkComponent.java index 0302c6dad..0ed1f5fd8 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/network/component/PlatformStorageNetworkComponent.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/network/component/PlatformStorageNetworkComponent.java @@ -14,7 +14,7 @@ public class PlatformStorageNetworkComponent extends StorageNetworkComponentImpl private final FuzzyResourceList fuzzyResourceList; public PlatformStorageNetworkComponent() { - this(new FuzzyResourceListImpl(new ResourceListImpl())); + this(new FuzzyResourceListImpl(ResourceListImpl.create())); } private PlatformStorageNetworkComponent(final FuzzyResourceList fuzzyResourceList) { diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceCodecs.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceCodecs.java index 9f44cb67b..2c1e07eaa 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceCodecs.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceCodecs.java @@ -40,6 +40,8 @@ public final class ResourceCodecs { CODEC.fieldOf("resource").forGetter(resourceAmount -> (PlatformResourceKey) resourceAmount.getResource()), Codec.LONG.fieldOf("amount").forGetter(ResourceAmount::getAmount) ).apply(instance, ResourceAmount::new)); + public static final Codec> AMOUNT_OPTIONAL_CODEC = AMOUNT_CODEC.optionalFieldOf("resource") + .codec(); public static final StreamCodec STREAM_CODEC = new StreamCodec<>() { @Override diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceContainerImpl.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceContainerImpl.java index f41dcc314..8e62a7724 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceContainerImpl.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceContainerImpl.java @@ -136,6 +136,14 @@ public void remove(final int index) { changed(); } + @Override + public void clear() { + for (int i = 0; i < size(); ++i) { + removeSilently(i); + } + changed(); + } + private void removeSilently(final int index) { slots[index] = null; } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/stretching/AbstractStretchingScreen.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/stretching/AbstractStretchingScreen.java index d1a71632a..ecf213992 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/stretching/AbstractStretchingScreen.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/stretching/AbstractStretchingScreen.java @@ -41,7 +41,12 @@ protected void init() { super.init(); - this.scrollbar = new ScrollbarWidget(leftPos + 174, topPos + 20, 12, (visibleRows * ROW_SIZE) - 2); + this.scrollbar = new ScrollbarWidget( + leftPos + 174, + topPos + 20, + ScrollbarWidget.Type.NORMAL, + (visibleRows * ROW_SIZE) - 2 + ); this.scrollbar.setListener(offset -> scrollbarChanged(visibleRows)); addWidget(scrollbar); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/ScrollbarWidget.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/ScrollbarWidget.java index 6073e437d..2b167e2c3 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/ScrollbarWidget.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/ScrollbarWidget.java @@ -14,17 +14,13 @@ import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; public class ScrollbarWidget extends AbstractWidget { - private static final ResourceLocation TEXTURE = createIdentifier("widget/scrollbar"); - private static final ResourceLocation CLICKED_TEXTURE = createIdentifier("widget/scrollbar_clicked"); - private static final ResourceLocation DISABLED_TEXTURE = createIdentifier("widget/scrollbar_disabled"); - - private static final int SCROLLER_WIDTH = 12; private static final int SCROLLER_HEIGHT = 15; private static final int ANIMATION_SCROLL_DURATION_IN_TICKS = 10; private static final double ANIMATION_SCROLL_HEIGHT_IN_PIXELS = 30; private final boolean smoothScrolling; + private final Type type; private double offset; private double maxOffset; @@ -38,9 +34,10 @@ public class ScrollbarWidget extends AbstractWidget { @Nullable private DoubleConsumer listener; - public ScrollbarWidget(final int x, final int y, final int width, final int height) { - super(x, y, width, height, Component.empty()); + public ScrollbarWidget(final int x, final int y, final Type type, final int height) { + super(x, y, type.width, height, Component.empty()); this.smoothScrolling = Platform.INSTANCE.getConfig().isSmoothScrolling(); + this.type = type; } public void setListener(@Nullable final DoubleConsumer listener) { @@ -57,9 +54,9 @@ public void setEnabled(final boolean enabled) { private ResourceLocation getTexture() { if (!enabled) { - return DISABLED_TEXTURE; + return type.disabledTexture; } - return clicked ? CLICKED_TEXTURE : TEXTURE; + return clicked ? type.clickedTexture : type.texture; } @Override @@ -71,7 +68,7 @@ public void renderWidget(final GuiGraphics graphics, final int mouseX, final int getTexture(), getX(), getY() + (int) ((float) offset / (float) maxOffset * (height - SCROLLER_HEIGHT)), - SCROLLER_WIDTH, + type.width, SCROLLER_HEIGHT ); } @@ -166,6 +163,9 @@ public void setMaxOffset(final double maxOffset) { this.maxOffset = Math.max(0, maxOffset); if (this.offset > this.maxOffset) { this.offset = this.maxOffset; + if (listener != null) { + listener.accept(this.offset); + } } } @@ -188,4 +188,34 @@ private void updateOffset(final double mouseY) { protected void updateWidgetNarration(final NarrationElementOutput narrationElementOutput) { // intentionally empty } + + public enum Type { + NORMAL( + createIdentifier("widget/scrollbar"), + createIdentifier("widget/scrollbar_clicked"), + createIdentifier("widget/scrollbar_disabled"), + 12 + ), + SMALL( + createIdentifier("widget/small_scrollbar"), + createIdentifier("widget/small_scrollbar_clicked"), + createIdentifier("widget/small_scrollbar_disabled"), + 7 + ); + + private final ResourceLocation texture; + private final ResourceLocation clickedTexture; + private final ResourceLocation disabledTexture; + private final int width; + + Type(final ResourceLocation texture, + final ResourceLocation clickedTexture, + final ResourceLocation disabledTexture, + final int width) { + this.texture = texture; + this.clickedTexture = clickedTexture; + this.disabledTexture = disabledTexture; + this.width = width; + } + } } 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 e4522ab58..486c24929 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 @@ -67,6 +67,10 @@ "gui.refinedstorage.pattern_grid.fuzzy_mode": "Fuzzy mode", "gui.refinedstorage.pattern_grid.fuzzy_mode.on.help": "Match the pattern inputs, ignoring components.", "gui.refinedstorage.pattern_grid.fuzzy_mode.off.help": "Match the pattern inputs exactly.", + "gui.refinedstorage.pattern_grid.processing.inputs": "Inputs", + "gui.refinedstorage.pattern_grid.processing.outputs": "Outputs", + "gui.refinedstorage.pattern_grid.processing.input_slots_help": "The resources that will be extracted from the storage network and will be inserted into the target inventory.", + "gui.refinedstorage.pattern_grid.processing.output_slots_help": "The resources that are expected to be returned to the storage network to deem the crafting task successful.", "gui.refinedstorage.screen_size": "Screen size", "gui.refinedstorage.screen_size.stretch": "Stretch", "gui.refinedstorage.screen_size.small": "Small", diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/models/item/pattern/processing.json b/refinedstorage-common/src/main/resources/assets/refinedstorage/models/item/pattern/processing.json new file mode 100644 index 000000000..0a09e5b10 --- /dev/null +++ b/refinedstorage-common/src/main/resources/assets/refinedstorage/models/item/pattern/processing.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "refinedstorage:item/pattern/processing" + } +} diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/pattern_grid/processing.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/pattern_grid/processing.png new file mode 100644 index 0000000000000000000000000000000000000000..07750be3c6d516a702fe8307b4c02f8523ea8669 GIT binary patch literal 256 zcmeAS@N?(olHy`uVBq!ia0vp^O+akM!3-pA+BU8MQjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1``2&1HT+PkRySuw@-@g6-|9_xZa<9J{kYX(f@(Tuv{Ac*RjV~A|z**oC zS`O%y!e8YQ1*v+3Qo6aF(3nmD^T4H(r9u*_f(PGItBz|Q%wx@C>@-RmdKI;Vst0ESOh@Bjb+ literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/pattern_grid/processing_matrix.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/pattern_grid/processing_matrix.png new file mode 100644 index 0000000000000000000000000000000000000000..6bcd16977f63859f2f8d79eacc392d3b8c6b87b0 GIT binary patch literal 171 zcmeAS@N?(olHy`uVBq!ia0vp^W+2SM3?%Ea%ijSh#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>0X`wF=H}+z-QEBH|6d&O{W3_fz$3Dlfr0NZ2s0kfUy%Y7)b@0746!(! z+`#Cj!{g@2A#f_E)V!VDyD>7VEYQjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`c>;VwT>t<7-`(AP?AWo;(9kanMprEv; yi(`ny_E)V!VDyD>7VEYQjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`c>;VwT>t<7-`(B4b?es9(9mhW9wY$8ISV`@iy0XB4ude`@%$AjKtX9w y7sn8Z%gGE(jBIMEs?2O^j*84hk%x{QV`Dg$#`;OgQ_2OXjKR~@&t;ucLK6UClq%!^ literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/small_scrollbar_disabled.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/small_scrollbar_disabled.png new file mode 100644 index 0000000000000000000000000000000000000000..c28213ac9befe0ef07d07c1e2567320e5723da0f GIT binary patch literal 155 zcmeAS@N?(olHy`uVBq!ia0vp^>_E)V!VDyD>7VEYQjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`IRkt`T>t<7-`(9E8XD^GN%kB_u)rg-n1O-sFbFdq&tH)O6qNRKaSV~T toXo()$mZtg$jauX>dIOa>Ez|b#jt>zWy^-C1^z%~44$rjF6*2UngBWPCz=2N literal 0 HcmV?d00001 diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/item/pattern/processing.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/item/pattern/processing.png new file mode 100644 index 0000000000000000000000000000000000000000..7e6f13658cb8a53aabdf11bd65de8e18357e2fd1 GIT binary patch literal 441 zcmV;q0Y?6bP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0ZvIoK~y+TwUIw- zgJ2NGAG-+oMBOq6lBkd=d$%r~qUaVO-8y#28YsyUaLy3hrA|hTA3*3JbaN0ggtzZq zqO{~sn?N5p&eMB--n}pWRl2SVihX&R$e5<7$g=E8$g^N$k|ZLI;|n3uj8_>?J4g@& z9KS-ify}0immMUF-fGBvK0ghi59{@M*C78)fRFT@Yg%DCoeIZs4ko$TXEYiOsHzIt z1l>3Ad7I+ie#BrfK%VDVtybuCI(2WQ8lWf&Ow+`6yM<+0xO;Fg91c+w1(wStO~`$t z(TH=U8nD@HVB2=xK#(vDu~;miX&S$CT^G$}6J=R)eIVLRjw%ep-~+36uJ#^}$D-YC zpT7w*M^VIv%G~XC+5G+RDk=N?Lj-BHTJU|JYkHo|X7D`kX#Y_WgsycmnTTGmcYf?s j>i7FXUfp%(zX|vPQ~ls*8%1sR00000NkvXXu0mjf*LA%| literal 0 HcmV?d00001 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 index ac3bdd729..e15c86a2f 100644 --- a/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/TestPlatform.java +++ b/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/TestPlatform.java @@ -37,6 +37,7 @@ 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; @@ -232,4 +233,9 @@ public NetworkNodeContainerProvider getContainerProviderSafely(final Level level 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/support/resource/list/FuzzyResourceListImplTest.java b/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImplTest.java index dfc5dfcc3..d067faa78 100644 --- a/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImplTest.java +++ b/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImplTest.java @@ -33,7 +33,7 @@ class FuzzyResourceListImplTest { @BeforeEach void setUp() { - sut = new FuzzyResourceListImpl(new ResourceListImpl()); + sut = new FuzzyResourceListImpl(ResourceListImpl.create()); } @Test 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 e8a6a0a07..b175fd745 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 @@ -4,9 +4,9 @@ import com.refinedmods.refinedstorage.common.AbstractClientModInitializer; import com.refinedmods.refinedstorage.common.api.support.HelpTooltipComponent; import com.refinedmods.refinedstorage.common.api.upgrade.AbstractUpgradeItem; -import com.refinedmods.refinedstorage.common.autocrafting.CraftingPatternClientTooltipComponent; import com.refinedmods.refinedstorage.common.autocrafting.PatternItem; import com.refinedmods.refinedstorage.common.autocrafting.PatternItemColor; +import com.refinedmods.refinedstorage.common.autocrafting.PatternTooltipCache; import com.refinedmods.refinedstorage.common.configurationcard.ConfigurationCardItemPropertyFunction; import com.refinedmods.refinedstorage.common.content.BlockColorMap; import com.refinedmods.refinedstorage.common.content.BlockEntities; @@ -405,15 +405,13 @@ private void registerCustomTooltips() { }); TooltipComponentCallback.EVENT.register(data -> { if (data instanceof PatternItem.CraftingPatternTooltipComponent component) { - final ClientTooltipComponent help = HelpClientTooltipComponent.create(component.helpText()); - return new CompositeClientTooltipComponent(List.of( - new CraftingPatternClientTooltipComponent( - component.width(), - component.height(), - component.craftingPattern() - ), - help - )); + return PatternTooltipCache.getComponent(component); + } + return null; + }); + TooltipComponentCallback.EVENT.register(data -> { + if (data instanceof PatternItem.ProcessingPatternTooltipComponent component) { + return PatternTooltipCache.getComponent(component); } return null; }); diff --git a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/PlatformImpl.java b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/PlatformImpl.java index 8f5e05b2e..6cdaf7999 100644 --- a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/PlatformImpl.java +++ b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/PlatformImpl.java @@ -82,6 +82,7 @@ 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.context.BlockPlaceContext; @@ -485,6 +486,11 @@ public int getItemColor(final ItemStack stack, final int tintIndex) { return itemColor.getColor(stack, tintIndex); } + @Override + public void setSlotY(final Slot slot, final int y) { + slot.y = y; + } + private void doSave(final CompoundTag compoundTag, final Path tempFile, final Path targetPath) throws IOException { // Write to temp file first. NbtIo.writeCompressed(compoundTag, tempFile); diff --git a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/autocrafting/PatternBakedModel.java b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/autocrafting/PatternBakedModel.java index fc7f3ed44..afe70ec19 100644 --- a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/autocrafting/PatternBakedModel.java +++ b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/autocrafting/PatternBakedModel.java @@ -12,9 +12,10 @@ class PatternBakedModel extends ForwardingBakedModel { PatternBakedModel(final ModelBaker modelBaker, final BakedModel emptyModel, - final BakedModel craftingModel) { + final BakedModel craftingModel, + final BakedModel processingModel) { this.wrapped = emptyModel; - this.itemOverrides = new PatternItemOverrides(modelBaker, emptyModel, craftingModel); + this.itemOverrides = new PatternItemOverrides(modelBaker, emptyModel, craftingModel, processingModel); } @Override diff --git a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/autocrafting/PatternUnbakedModel.java b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/autocrafting/PatternUnbakedModel.java index 08b2f3c8b..a81382ba8 100644 --- a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/autocrafting/PatternUnbakedModel.java +++ b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/autocrafting/PatternUnbakedModel.java @@ -19,16 +19,18 @@ public class PatternUnbakedModel implements UnbakedModel { private static final ResourceLocation EMPTY_MODEL = createIdentifier("item/pattern/empty"); private static final ResourceLocation CRAFTING_MODEL = createIdentifier("item/pattern/crafting"); + private static final ResourceLocation PROCESSING_MODEL = createIdentifier("item/pattern/processing"); @Override public Collection getDependencies() { - return Set.of(EMPTY_MODEL, CRAFTING_MODEL); + return Set.of(EMPTY_MODEL, CRAFTING_MODEL, PROCESSING_MODEL); } @Override public void resolveParents(final Function resolver) { resolver.apply(EMPTY_MODEL).resolveParents(resolver); resolver.apply(CRAFTING_MODEL).resolveParents(resolver); + resolver.apply(PROCESSING_MODEL).resolveParents(resolver); } @Nullable @@ -39,7 +41,8 @@ public BakedModel bake(final ModelBaker baker, return new PatternBakedModel( baker, requireNonNull(baker.bake(EMPTY_MODEL, state)), - requireNonNull(baker.bake(CRAFTING_MODEL, state)) + requireNonNull(baker.bake(CRAFTING_MODEL, state)), + requireNonNull(baker.bake(PROCESSING_MODEL, state)) ); } } diff --git a/refinedstorage-fabric/src/main/resources/refinedstorage.accesswidener b/refinedstorage-fabric/src/main/resources/refinedstorage.accesswidener index f65de0bc5..3e09e10d3 100644 --- a/refinedstorage-fabric/src/main/resources/refinedstorage.accesswidener +++ b/refinedstorage-fabric/src/main/resources/refinedstorage.accesswidener @@ -7,3 +7,4 @@ accessible class net/minecraft/client/resources/model/ModelBakery$ModelBakerImpl accessible method net/minecraft/client/resources/model/ModelBakery$BakedCacheKey (Lnet/minecraft/resources/ResourceLocation;Lcom/mojang/math/Transformation;Z)V accessible method net/minecraft/client/gui/GuiGraphics renderTooltipInternal (Lnet/minecraft/client/gui/Font;Ljava/util/List;IILnet/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipPositioner;)V accessible method net/minecraft/client/renderer/block/model/ItemOverrides ()V +mutable field net/minecraft/world/inventory/Slot y I diff --git a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewBuilderImpl.java b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewBuilderImpl.java index e38890ba5..a1fb8af66 100644 --- a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewBuilderImpl.java +++ b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewBuilderImpl.java @@ -14,7 +14,7 @@ @API(status = API.Status.STABLE, since = "2.0.0-milestone.2.4") public class GridViewBuilderImpl implements GridViewBuilder { private final GridResourceFactory resourceFactory; - private final ResourceList backingList = new ResourceListImpl(); + private final ResourceList backingList = ResourceListImpl.create(); private final Map trackedResources = new HashMap<>(); private final GridSortingType identitySortingType; private final GridSortingType defaultSortingType; diff --git a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java index 49394645e..9c0eed56f 100644 --- a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java +++ b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java @@ -249,7 +249,7 @@ public List getViewList() { @Override public ResourceList copyBackingList() { - final ResourceList copy = new ResourceListImpl(); + final ResourceList copy = ResourceListImpl.create(); backingList.getAll().forEach(copy::add); return copy; } diff --git a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/ClientModInitializer.java b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/ClientModInitializer.java index d91397489..825d9d852 100644 --- a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/ClientModInitializer.java +++ b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/ClientModInitializer.java @@ -4,10 +4,10 @@ import com.refinedmods.refinedstorage.common.AbstractClientModInitializer; import com.refinedmods.refinedstorage.common.api.support.HelpTooltipComponent; import com.refinedmods.refinedstorage.common.api.upgrade.AbstractUpgradeItem; -import com.refinedmods.refinedstorage.common.autocrafting.CraftingPatternClientTooltipComponent; import com.refinedmods.refinedstorage.common.autocrafting.PatternBlockEntityWithoutLevelRenderer; import com.refinedmods.refinedstorage.common.autocrafting.PatternItem; import com.refinedmods.refinedstorage.common.autocrafting.PatternItemColor; +import com.refinedmods.refinedstorage.common.autocrafting.PatternTooltipCache; import com.refinedmods.refinedstorage.common.configurationcard.ConfigurationCardItemPropertyFunction; import com.refinedmods.refinedstorage.common.content.BlockEntities; import com.refinedmods.refinedstorage.common.content.Blocks; @@ -222,20 +222,8 @@ public static void onRegisterTooltipFactories(final RegisterClientTooltipCompone : createRegulatorUpgradeClientTooltipComponent(component.configuredResource(), help); } ); - e.register( - PatternItem.CraftingPatternTooltipComponent.class, - component -> { - final ClientTooltipComponent help = HelpClientTooltipComponent.create(component.helpText()); - return new CompositeClientTooltipComponent(List.of( - new CraftingPatternClientTooltipComponent( - component.width(), - component.height(), - component.craftingPattern() - ), - help - )); - } - ); + e.register(PatternItem.CraftingPatternTooltipComponent.class, PatternTooltipCache::getComponent); + e.register(PatternItem.ProcessingPatternTooltipComponent.class, PatternTooltipCache::getComponent); } private static CompositeClientTooltipComponent createRegulatorUpgradeClientTooltipComponent( diff --git a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/PlatformImpl.java b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/PlatformImpl.java index c660a3a0c..8c8cf08ab 100644 --- a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/PlatformImpl.java +++ b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/PlatformImpl.java @@ -51,6 +51,7 @@ 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.Items; @@ -403,4 +404,9 @@ public NetworkNodeContainerProvider getContainerProviderSafely(final Level level public int getItemColor(final ItemStack stack, final int tintIndex) { return Minecraft.getInstance().getItemColors().getColor(stack, tintIndex); } + + @Override + public void setSlotY(final Slot slot, final int y) { + slot.y = y; + } } diff --git a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/autocrafting/PatternBakedModel.java b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/autocrafting/PatternBakedModel.java index 144b5f4bd..f3f939298 100644 --- a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/autocrafting/PatternBakedModel.java +++ b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/autocrafting/PatternBakedModel.java @@ -10,9 +10,12 @@ class PatternBakedModel extends BakedModelWrapper { private final ItemOverrides itemOverrides; - PatternBakedModel(final ModelBaker modelBaker, final BakedModel emptyModel, final BakedModel craftingModel) { + PatternBakedModel(final ModelBaker modelBaker, + final BakedModel emptyModel, + final BakedModel craftingModel, + final BakedModel processingModel) { super(emptyModel); - this.itemOverrides = new PatternItemOverrides(modelBaker, emptyModel, craftingModel); + this.itemOverrides = new PatternItemOverrides(modelBaker, emptyModel, craftingModel, processingModel); } @Override diff --git a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/autocrafting/PatternUnbakedGeometry.java b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/autocrafting/PatternUnbakedGeometry.java index dcd6221af..017d33f17 100644 --- a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/autocrafting/PatternUnbakedGeometry.java +++ b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/autocrafting/PatternUnbakedGeometry.java @@ -19,6 +19,7 @@ public class PatternUnbakedGeometry implements IUnbakedGeometry { private static final ResourceLocation EMPTY_MODEL = createIdentifier("item/pattern/empty"); private static final ResourceLocation CRAFTING_MODEL = createIdentifier("item/pattern/crafting"); + private static final ResourceLocation PROCESSING_MODEL = createIdentifier("item/pattern/processing"); @Override public BakedModel bake(final IGeometryBakingContext ctx, @@ -29,7 +30,8 @@ public BakedModel bake(final IGeometryBakingContext ctx, return new PatternBakedModel( modelBaker, requireNonNull(modelBaker.bake(EMPTY_MODEL, modelState, function)), - requireNonNull(modelBaker.bake(CRAFTING_MODEL, modelState, function)) + requireNonNull(modelBaker.bake(CRAFTING_MODEL, modelState, function)), + requireNonNull(modelBaker.bake(PROCESSING_MODEL, modelState, function)) ); } @@ -38,5 +40,6 @@ public void resolveParents(final Function modelG final IGeometryBakingContext context) { modelGetter.apply(EMPTY_MODEL).resolveParents(modelGetter); modelGetter.apply(CRAFTING_MODEL).resolveParents(modelGetter); + modelGetter.apply(PROCESSING_MODEL).resolveParents(modelGetter); } } diff --git a/refinedstorage-neoforge/src/main/resources/META-INF/accesstransformer.cfg b/refinedstorage-neoforge/src/main/resources/META-INF/accesstransformer.cfg index 7b36b1489..3f2063b65 100644 --- a/refinedstorage-neoforge/src/main/resources/META-INF/accesstransformer.cfg +++ b/refinedstorage-neoforge/src/main/resources/META-INF/accesstransformer.cfg @@ -1,2 +1,3 @@ public net.minecraft.client.gui.components.EditBox canLoseFocus public net.minecraft.client.gui.GuiGraphics renderTooltipInternal(Lnet/minecraft/client/gui/Font;Ljava/util/List;IILnet/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipPositioner;)V +public-f net.minecraft.world.inventory.Slot y \ No newline at end of file diff --git a/refinedstorage-network-test/src/main/java/com/refinedmods/refinedstorage/network/test/NetworkTestFixtures.java b/refinedstorage-network-test/src/main/java/com/refinedmods/refinedstorage/network/test/NetworkTestFixtures.java index ba433377d..37328b2c8 100644 --- a/refinedstorage-network-test/src/main/java/com/refinedmods/refinedstorage/network/test/NetworkTestFixtures.java +++ b/refinedstorage-network-test/src/main/java/com/refinedmods/refinedstorage/network/test/NetworkTestFixtures.java @@ -15,8 +15,6 @@ import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; import com.refinedmods.refinedstorage.network.test.fake.FakePermissions; -import java.util.LinkedHashMap; - public final class NetworkTestFixtures { public static final ComponentMapFactory NETWORK_COMPONENT_MAP_FACTORY = new ComponentMapFactory<>(); @@ -32,7 +30,7 @@ public final class NetworkTestFixtures { ); NETWORK_COMPONENT_MAP_FACTORY.addFactory( StorageNetworkComponent.class, - network -> new StorageNetworkComponentImpl(new ResourceListImpl(new LinkedHashMap<>())) + network -> new StorageNetworkComponentImpl(ResourceListImpl.orderPreserving()) ); NETWORK_COMPONENT_MAP_FACTORY.addFactory( SecurityNetworkComponent.class, diff --git a/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/storage/ExposedStorage.java b/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/storage/ExposedStorage.java index 403db7e6f..0d9987cbb 100644 --- a/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/storage/ExposedStorage.java +++ b/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/storage/ExposedStorage.java @@ -17,7 +17,7 @@ class ExposedStorage extends AbstractImmutableConfiguredProxyStorage implements CompositeStorage { protected ExposedStorage(final StorageConfiguration config) { - super(config, new CompositeStorageImpl(new ResourceListImpl())); + super(config, new CompositeStorageImpl(ResourceListImpl.create())); } long getCapacity() { 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 9a0763f5a..9ee64fdf1 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 @@ -17,7 +17,6 @@ import com.refinedmods.refinedstorage.network.test.NetworkTest; import com.refinedmods.refinedstorage.network.test.SetupNetwork; -import java.util.LinkedHashMap; import java.util.Set; import org.junit.jupiter.api.BeforeEach; @@ -57,7 +56,7 @@ void shouldNotTransferWithoutNetwork(@InjectNetworkStorageComponent final Storag // Arrange networkStorage.addSource(new InMemoryStorageImpl()); - final Storage source = new InMemoryStorageImpl(new ResourceListImpl(new LinkedHashMap<>())); + final Storage source = new InMemoryStorageImpl(ResourceListImpl.orderPreserving()); source.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(0, source); @@ -78,7 +77,7 @@ void shouldNotTransferWhenInactive(@InjectNetworkStorageComponent final StorageN // Arrange networkStorage.addSource(new InMemoryStorageImpl()); - final Storage source = new InMemoryStorageImpl(new ResourceListImpl(new LinkedHashMap<>())); + final Storage source = new InMemoryStorageImpl(ResourceListImpl.orderPreserving()); source.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(0, source); @@ -140,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(new ResourceListImpl(new LinkedHashMap<>())); + final Storage source1 = new InMemoryStorageImpl(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(new ResourceListImpl(new LinkedHashMap<>())); + final Storage source2 = new InMemoryStorageImpl(ResourceListImpl.orderPreserving()); source2.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(2, source2); @@ -181,14 +180,14 @@ void shouldInsertAllowlist(@InjectNetworkStorageComponent final StorageNetworkCo // Arrange networkStorage.addSource(new InMemoryStorageImpl()); - final Storage source1 = new InMemoryStorageImpl(new ResourceListImpl(new LinkedHashMap<>())); + final Storage source1 = new InMemoryStorageImpl(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(new ResourceListImpl(new LinkedHashMap<>())); + final Storage source2 = new InMemoryStorageImpl(ResourceListImpl.orderPreserving()); source2.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set((sut.getSize() / 2) - 1, source2); @@ -220,14 +219,14 @@ void shouldInsertBlocklist(@InjectNetworkStorageComponent final StorageNetworkCo // Arrange networkStorage.addSource(new InMemoryStorageImpl()); - final Storage source1 = new InMemoryStorageImpl(new ResourceListImpl(new LinkedHashMap<>())); + final Storage source1 = new InMemoryStorageImpl(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(new ResourceListImpl(new LinkedHashMap<>())); + final Storage source2 = new InMemoryStorageImpl(ResourceListImpl.orderPreserving()); source2.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(1, source2); @@ -278,7 +277,7 @@ void shouldNotifyListenerWhenReadyInsertingAllResources( // Arrange networkStorage.addSource(new InMemoryStorageImpl()); - final Storage source = new InMemoryStorageImpl(new ResourceListImpl(new LinkedHashMap<>())); + final Storage source = new InMemoryStorageImpl(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); @@ -298,12 +297,12 @@ void shouldNotifyListenerWhenReadyInsertingAllResources( @Test void shouldNotifyListenerWhenReadyInsertingAllResourcesAndUsingFilterButInsertedNothing() { // Arrange - final Storage source1 = new InMemoryStorageImpl(new ResourceListImpl(new LinkedHashMap<>())); + final Storage source1 = new InMemoryStorageImpl(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(new ResourceListImpl(new LinkedHashMap<>())); + final Storage source2 = new InMemoryStorageImpl(ResourceListImpl.orderPreserving()); source2.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(1, source2); @@ -333,13 +332,13 @@ void shouldNotifyListenerWhenReadyInsertingAllResourcesAndUsingFilterButStillIns // Arrange networkStorage.addSource(new InMemoryStorageImpl()); - final Storage source1 = new InMemoryStorageImpl(new ResourceListImpl(new LinkedHashMap<>())); + final Storage source1 = new InMemoryStorageImpl(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(new ResourceListImpl(new LinkedHashMap<>())); + final Storage source2 = new InMemoryStorageImpl(ResourceListImpl.orderPreserving()); source2.insert(D, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(1, source2); @@ -369,14 +368,14 @@ void shouldNotNotifyListenerWhenReadyInsertingAllResourcesAndNetworkIsFull( // Arrange networkStorage.addSource(new LimitedStorageImpl(15)); - final Storage source1 = new InMemoryStorageImpl(new ResourceListImpl(new LinkedHashMap<>())); + final Storage source1 = new InMemoryStorageImpl(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(new ResourceListImpl(new LinkedHashMap<>())); + final Storage source2 = new InMemoryStorageImpl(ResourceListImpl.orderPreserving()); source2.insert(A, 5, Action.EXECUTE, EmptyActor.INSTANCE); provider.set(1, source2); @@ -597,12 +596,12 @@ void shouldNotifyListenerWhenReadyExtractingAllResourcesAndUsingFilterButStillEx @InjectNetworkStorageComponent final StorageNetworkComponent networkStorage ) { // Arrange - networkStorage.addSource(new InMemoryStorageImpl(new ResourceListImpl(new LinkedHashMap<>()))); + networkStorage.addSource(new InMemoryStorageImpl(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(new ResourceListImpl(new LinkedHashMap<>())); + final Storage source = new InMemoryStorageImpl(ResourceListImpl.orderPreserving()); provider.set(0, source); sut.setProvider(provider); @@ -663,7 +662,7 @@ void shouldRespectNormalizer( // Arrange networkStorage.addSource(new InMemoryStorageImpl()); - final Storage source = new InMemoryStorageImpl(new ResourceListImpl(new LinkedHashMap<>())); + final Storage source = new InMemoryStorageImpl(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); diff --git a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/storage/StorageNetworkComponentImplTest.java b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/storage/StorageNetworkComponentImplTest.java index b7beebb1d..c79cc9c67 100644 --- a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/storage/StorageNetworkComponentImplTest.java +++ b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/storage/StorageNetworkComponentImplTest.java @@ -37,7 +37,7 @@ class StorageNetworkComponentImplTest { @BeforeEach void setUp() { - sut = new StorageNetworkComponentImpl(new ResourceListImpl()); + sut = new StorageNetworkComponentImpl(ResourceListImpl.create()); storage1 = new StorageNetworkNode(0, 0, 1); storage1.setNetwork(new NetworkImpl(NetworkTestFixtures.NETWORK_COMPONENT_MAP_FACTORY)); diff --git a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/ResourceAmount.java b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/ResourceAmount.java index 5c6398c89..b9f697637 100644 --- a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/ResourceAmount.java +++ b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/ResourceAmount.java @@ -31,6 +31,10 @@ public long getAmount() { return amount; } + public ResourceAmount copy() { + return new ResourceAmount(resource, amount); + } + /** * Increments with the given amount. * diff --git a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java index f26778ec8..42aaae19a 100644 --- a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java +++ b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java @@ -5,6 +5,7 @@ import java.util.Collection; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; import java.util.Optional; @@ -17,12 +18,16 @@ public class ResourceListImpl implements ResourceList { private final Map entries; - public ResourceListImpl(final Map entries) { + private ResourceListImpl(final Map entries) { this.entries = entries; } - public ResourceListImpl() { - this(new HashMap<>()); + public static ResourceListImpl create() { + return new ResourceListImpl(new HashMap<>()); + } + + public static ResourceListImpl orderPreserving() { + return new ResourceListImpl(new LinkedHashMap<>()); } @Override diff --git a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/ProxyResourceListTest.java b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/ProxyResourceListTest.java index 326fb994f..fb0f9aa52 100644 --- a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/ProxyResourceListTest.java +++ b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/ProxyResourceListTest.java @@ -3,7 +3,7 @@ class ProxyResourceListTest extends AbstractResourceListTest { @Override protected ResourceList createList() { - return new AbstractProxyResourceList(new ResourceListImpl()) { + return new AbstractProxyResourceList(ResourceListImpl.create()) { }; } } diff --git a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImplTest.java b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImplTest.java index 7cf73397e..f8c1259ca 100644 --- a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImplTest.java +++ b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImplTest.java @@ -3,6 +3,6 @@ class ResourceListImplTest extends AbstractResourceListTest { @Override protected ResourceList createList() { - return new ResourceListImpl(); + return ResourceListImpl.create(); } } diff --git a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/listenable/ListenableResourceListTest.java b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/listenable/ListenableResourceListTest.java index d23729ea9..24aa02530 100644 --- a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/listenable/ListenableResourceListTest.java +++ b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/listenable/ListenableResourceListTest.java @@ -21,7 +21,7 @@ class ListenableResourceListTest { @BeforeEach void setUp() { listener = new FakeResourceListListener(); - list = new ResourceListImpl(); + list = ResourceListImpl.create(); sut = new ListenableResourceList(list); } 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/InMemoryStorageImpl.java index 6a558c8c3..0d7a9ad77 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/InMemoryStorageImpl.java @@ -23,7 +23,7 @@ public InMemoryStorageImpl(final ResourceList list) { } public InMemoryStorageImpl() { - this(new ResourceListImpl()); + this(ResourceListImpl.create()); } @Override diff --git a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/external/ExternalStorage.java b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/external/ExternalStorage.java index 15e519539..96694ff2f 100644 --- a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/external/ExternalStorage.java +++ b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/external/ExternalStorage.java @@ -20,7 +20,7 @@ public class ExternalStorage implements CompositeAwareChild { private final ExternalStorageProvider provider; private final Set parents = new HashSet<>(); - private final ResourceList cache = new ResourceListImpl(); + private final ResourceList cache = ResourceListImpl.create(); private final ExternalStorageListener listener; public ExternalStorage(final ExternalStorageProvider provider, final ExternalStorageListener listener) { @@ -111,7 +111,7 @@ private void removeFromCache(final ResourceKey resource, final long amount) { } private ResourceList buildCache() { - final ResourceList list = new ResourceListImpl(); + final ResourceList list = ResourceListImpl.create(); provider.iterator().forEachRemaining(list::add); return list; } diff --git a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImpl.java b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImpl.java index 92735fd32..c38172f67 100644 --- a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImpl.java +++ b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImpl.java @@ -24,7 +24,7 @@ public class RootStorageImpl implements RootStorage { private final ListenableResourceList list; public RootStorageImpl() { - this(new ResourceListImpl()); + this(ResourceListImpl.create()); } public RootStorageImpl(final ResourceList list) { 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 db2dcbfc4..f956e531d 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 @@ -27,7 +27,7 @@ class CompositeStorageImplTest { @BeforeEach void setUp() { - sut = new CompositeStorageImpl(new ResourceListImpl()); + sut = new CompositeStorageImpl(ResourceListImpl.create()); } @Test diff --git a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/ExtractCompositeStorageImplTest.java b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/ExtractCompositeStorageImplTest.java index 576a54b49..b5d12bf59 100644 --- a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/ExtractCompositeStorageImplTest.java +++ b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/ExtractCompositeStorageImplTest.java @@ -23,7 +23,7 @@ class ExtractCompositeStorageImplTest { @BeforeEach void setUp() { - sut = new CompositeStorageImpl(new ResourceListImpl()); + sut = new CompositeStorageImpl(ResourceListImpl.create()); } @ParameterizedTest diff --git a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/InsertCompositeStorageImplTest.java b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/InsertCompositeStorageImplTest.java index a71b35f5d..6dab1918f 100644 --- a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/InsertCompositeStorageImplTest.java +++ b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/composite/InsertCompositeStorageImplTest.java @@ -22,7 +22,7 @@ class InsertCompositeStorageImplTest { @BeforeEach void setUp() { - sut = new CompositeStorageImpl(new ResourceListImpl()); + sut = new CompositeStorageImpl(ResourceListImpl.create()); } @ParameterizedTest 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 6bfff4f0c..9e3cd603d 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 @@ -19,13 +19,13 @@ class SubCompositeCompositeStorageImplTest { @BeforeEach void setUp() { - sut = new CompositeStorageImpl(new ResourceListImpl()); + sut = new CompositeStorageImpl(ResourceListImpl.create()); } @Test void testAddingSubCompositeShouldAddAllResourcesToParent() { // Arrange - final CompositeStorage subComposite = new CompositeStorageImpl(new ResourceListImpl()); + final CompositeStorage subComposite = new CompositeStorageImpl(ResourceListImpl.create()); subComposite.addSource(new InMemoryStorageImpl()); subComposite.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); @@ -41,7 +41,7 @@ void testAddingSubCompositeShouldAddAllResourcesToParent() { @Test void testRemovingSubCompositeShouldRemoveAllResourcesFromParent() { // Arrange - final CompositeStorage subComposite = new CompositeStorageImpl(new ResourceListImpl()); + final CompositeStorage subComposite = new CompositeStorageImpl(ResourceListImpl.create()); subComposite.addSource(new InMemoryStorageImpl()); subComposite.insert(A, 10, Action.EXECUTE, EmptyActor.INSTANCE); @@ -62,7 +62,7 @@ void testRemovingSubCompositeShouldRemoveAllResourcesFromParent() { @Test void testAddingSourceToSubCompositeShouldNotifyParent() { // Arrange - final CompositeStorage subComposite = new CompositeStorageImpl(new ResourceListImpl()); + final CompositeStorage subComposite = new CompositeStorageImpl(ResourceListImpl.create()); final Storage subStorage = new InMemoryStorageImpl(); subStorage.insert(B, 10, Action.EXECUTE, EmptyActor.INSTANCE); @@ -89,7 +89,7 @@ void testAddingSourceToSubCompositeShouldNotifyParent() { @Test void testRemovingSourceFromSubCompositeShouldNotifyParent() { // Arrange - final CompositeStorage subComposite = new CompositeStorageImpl(new ResourceListImpl()); + final CompositeStorage subComposite = new CompositeStorageImpl(ResourceListImpl.create()); final Storage subStorage = new InMemoryStorageImpl(); subStorage.insert(B, 10, Action.EXECUTE, EmptyActor.INSTANCE); From b9f384b413e54eb441ecd2e85468c6df3b4193e1 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Sat, 3 Aug 2024 09:54:26 +0200 Subject: [PATCH 15/36] refactor: grid resources no longer store amount This relied on having a mutable ResourceAmount by-reference, which is unstable. --- .../view/AbstractPlatformGridResource.java | 25 ++- .../api/grid/view/PlatformGridResource.java | 12 +- .../api/support/resource/ResourceType.java | 6 +- .../grid/AbstractGridContainerMenu.java | 12 +- .../grid/CraftingGridContainerMenu.java | 10 +- .../common/grid/GridSortingTypes.java | 2 +- .../grid/screen/AbstractGridScreen.java | 8 +- .../AbstractFluidGridResourceFactory.java | 8 +- .../view/AbstractItemGridResourceFactory.java | 8 +- .../view/CompositeGridResourceFactory.java | 6 +- .../common/grid/view/FluidGridResource.java | 45 ++--- .../common/grid/view/ItemGridResource.java | 44 ++--- .../support/resource/FluidResourceType.java | 12 +- .../support/resource/ItemResourceType.java | 12 +- .../common/grid/GridSortingTypesTest.java | 2 +- .../api/grid/query/GridQueryParser.java | 5 +- .../api/grid/query/GridQueryParserImpl.java | 61 +++--- .../api/grid/view/GridResource.java | 2 +- .../api/grid/view/GridResourceFactory.java | 10 +- .../api/grid/view/GridView.java | 10 +- .../api/grid/view/GridViewImpl.java | 25 ++- .../grid/query/GridQueryParserImplTest.java | 152 ++++++++------- .../api/grid/view/GridResourceImpl.java | 27 ++- .../api/grid/view/GridViewImplTest.java | 182 ++++++++++-------- 24 files changed, 368 insertions(+), 318 deletions(-) diff --git a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/grid/view/AbstractPlatformGridResource.java b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/grid/view/AbstractPlatformGridResource.java index f633c8021..01ebaa119 100644 --- a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/grid/view/AbstractPlatformGridResource.java +++ b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/grid/view/AbstractPlatformGridResource.java @@ -2,39 +2,40 @@ import com.refinedmods.refinedstorage.api.grid.view.GridResourceAttributeKey; import com.refinedmods.refinedstorage.api.grid.view.GridView; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.storage.tracked.TrackedResource; +import com.refinedmods.refinedstorage.common.api.support.resource.PlatformResourceKey; import java.util.Collections; import java.util.Map; import java.util.Optional; import java.util.Set; +import javax.annotation.Nullable; import org.apiguardian.api.API; @API(status = API.Status.STABLE, since = "2.0.0-milestone.3.0") -public abstract class AbstractPlatformGridResource implements PlatformGridResource { - protected final ResourceAmount resourceAmount; +public abstract class AbstractPlatformGridResource implements PlatformGridResource { + protected final T resource; private final String name; private final Map> attributes; private boolean zeroed; - protected AbstractPlatformGridResource(final ResourceAmount resourceAmount, + protected AbstractPlatformGridResource(final T resource, final String name, final Map> attributes) { - this.resourceAmount = resourceAmount; + this.resource = resource; this.name = name; this.attributes = attributes; } @Override public Optional getTrackedResource(final GridView view) { - return view.getTrackedResource(resourceAmount.getResource()); + return view.getTrackedResource(resource); } @Override - public long getAmount() { - return resourceAmount.getAmount(); + public long getAmount(final GridView view) { + return view.getAmount(resource); } @Override @@ -57,10 +58,16 @@ public void setZeroed(final boolean zeroed) { this.zeroed = zeroed; } + @Nullable + @Override + public PlatformResourceKey getResourceForRecipeMods() { + return resource; + } + @Override public String toString() { return "AbstractPlatformGridResource{" - + "resourceAmount=" + resourceAmount + + "resource=" + resource + ", name='" + name + '\'' + ", attributes=" + attributes + ", zeroed=" + zeroed diff --git a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/grid/view/PlatformGridResource.java b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/grid/view/PlatformGridResource.java index 9436be8f2..40e9a03cd 100644 --- a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/grid/view/PlatformGridResource.java +++ b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/grid/view/PlatformGridResource.java @@ -2,10 +2,12 @@ import com.refinedmods.refinedstorage.api.grid.operations.GridExtractMode; import com.refinedmods.refinedstorage.api.grid.view.GridResource; +import com.refinedmods.refinedstorage.api.grid.view.GridView; 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.support.resource.PlatformResourceKey; +import com.refinedmods.refinedstorage.common.api.support.resource.ResourceType; import java.util.List; import java.util.Optional; @@ -28,9 +30,11 @@ void onScroll(GridScrollMode scrollMode, void render(GuiGraphics graphics, int x, int y); - String getDisplayedAmount(); + String getDisplayedAmount(GridView view); - String getAmountInTooltip(); + String getAmountInTooltip(GridView view); + + boolean belongsToResourceType(ResourceType resourceType); List getTooltip(); @@ -38,9 +42,9 @@ void onScroll(GridScrollMode scrollMode, int getRegistryId(); - List getExtractionHints(); + List getExtractionHints(GridView view); @Nullable @API(status = API.Status.INTERNAL) - PlatformResourceKey getUnderlyingResource(); + PlatformResourceKey getResourceForRecipeMods(); } diff --git a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/ResourceType.java b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/ResourceType.java index ad0d97054..1e8d34bfa 100644 --- a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/ResourceType.java +++ b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/ResourceType.java @@ -2,7 +2,7 @@ import com.refinedmods.refinedstorage.api.grid.operations.GridOperations; import com.refinedmods.refinedstorage.api.grid.view.GridResource; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; +import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.api.storage.Actor; import com.refinedmods.refinedstorage.api.storage.root.RootStorage; @@ -33,9 +33,7 @@ public interface ResourceType { double getDisplayAmount(long amount); - Optional toGridResource(ResourceAmount resourceAmount); - - boolean isGridResourceBelonging(GridResource gridResource); + Optional toGridResource(ResourceKey resource); long getInterfaceExportLimit(); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/AbstractGridContainerMenu.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/AbstractGridContainerMenu.java index 51d45f07c..678bf3ca6 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/AbstractGridContainerMenu.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/AbstractGridContainerMenu.java @@ -22,6 +22,7 @@ import com.refinedmods.refinedstorage.common.api.grid.strategy.GridExtractionStrategy; import com.refinedmods.refinedstorage.common.api.grid.strategy.GridInsertionStrategy; import com.refinedmods.refinedstorage.common.api.grid.strategy.GridScrollingStrategy; +import com.refinedmods.refinedstorage.common.api.grid.view.PlatformGridResource; import com.refinedmods.refinedstorage.common.api.storage.PlayerActor; import com.refinedmods.refinedstorage.common.api.support.registry.PlatformRegistry; import com.refinedmods.refinedstorage.common.api.support.resource.PlatformResourceKey; @@ -39,7 +40,7 @@ import java.util.Map; import java.util.Set; -import java.util.function.Predicate; +import java.util.function.BiPredicate; import javax.annotation.Nullable; import net.minecraft.server.level.ServerPlayer; @@ -137,12 +138,13 @@ protected AbstractGridContainerMenu( initStrategies((ServerPlayer) playerInventory.player); } - private Predicate filterResourceType() { - return gridResource -> Platform.INSTANCE.getConfig().getGrid().getResourceType().flatMap(resourceTypeId -> + private BiPredicate filterResourceType() { + return (v, resource) -> resource instanceof PlatformGridResource platformResource + && Platform.INSTANCE.getConfig().getGrid().getResourceType().flatMap(resourceTypeId -> RefinedStorageApi.INSTANCE .getResourceTypeRegistry() .get(resourceTypeId) - .map(type -> type.isGridResourceBelonging(gridResource)) + .map(platformResource::belongsToResourceType) ).orElse(true); } @@ -199,7 +201,7 @@ private boolean onSearchTextChanged(final String text) { view.setFilterAndSort(QUERY_PARSER.parse(text).and(filterResourceType())); return true; } catch (GridQueryParserException e) { - view.setFilterAndSort(resource -> false); + view.setFilterAndSort((v, resource) -> false); return false; } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridContainerMenu.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridContainerMenu.java index fd65608e6..3835530bb 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridContainerMenu.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridContainerMenu.java @@ -1,6 +1,7 @@ package com.refinedmods.refinedstorage.common.grid; import com.refinedmods.refinedstorage.api.grid.view.GridResource; +import com.refinedmods.refinedstorage.api.grid.view.GridView; import com.refinedmods.refinedstorage.api.resource.list.ResourceList; import com.refinedmods.refinedstorage.common.content.Menus; import com.refinedmods.refinedstorage.common.grid.view.ItemGridResource; @@ -14,6 +15,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.function.BiPredicate; import java.util.function.Consumer; import java.util.function.Predicate; import javax.annotation.Nullable; @@ -35,7 +37,7 @@ public class CraftingGridContainerMenu extends AbstractGridContainerMenu { @Nullable private Consumer activenessListener; @Nullable - private Predicate filterBeforeFilteringBasedOnCraftingMatrixItems; + private BiPredicate filterBeforeFilteringBasedOnCraftingMatrixItems; public CraftingGridContainerMenu(final int syncId, final Inventory playerInventory, @@ -149,9 +151,9 @@ public void transferRecipe(final List> recipe) { public void filterBasedOnCraftingMatrixItems() { final Set craftingMatrixItems = getCraftingMatrixItems(); filterBeforeFilteringBasedOnCraftingMatrixItems = getView().setFilterAndSort( - gridResource -> gridResource instanceof ItemGridResource itemGridResource - && itemGridResource.getUnderlyingResource() != null - && craftingMatrixItems.contains((ItemResource) itemGridResource.getUnderlyingResource()) + (view, gridResource) -> gridResource instanceof ItemGridResource itemGridResource + && itemGridResource.getResourceForRecipeMods() != null + && craftingMatrixItems.contains((ItemResource) itemGridResource.getResourceForRecipeMods()) ); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/GridSortingTypes.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/GridSortingTypes.java index 9d38f3f33..29f2d5e4f 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/GridSortingTypes.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/GridSortingTypes.java @@ -10,7 +10,7 @@ import java.util.function.Function; public enum GridSortingTypes implements GridSortingType { - QUANTITY(view -> Comparator.comparingLong(GridResource::getAmount)), + QUANTITY(view -> Comparator.comparingLong(value -> value.getAmount(view))), NAME(view -> Comparator.comparing(GridResource::getName)), ID(view -> (a, b) -> { if (a instanceof PlatformGridResource aa && b instanceof PlatformGridResource bb) { diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/AbstractGridScreen.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/AbstractGridScreen.java index 90a62268e..811da35ec 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/AbstractGridScreen.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/screen/AbstractGridScreen.java @@ -262,7 +262,7 @@ private void renderAmount(final GuiGraphics graphics, if (!(resource instanceof PlatformGridResource platformResource)) { return; } - final String text = resource.isZeroed() ? "0" : platformResource.getDisplayedAmount(); + final String text = resource.isZeroed() ? "0" : platformResource.getDisplayedAmount(getMenu().getView()); final int color = resource.isZeroed() ? requireNonNullElse(ChatFormatting.RED.getColor(), 15) : requireNonNullElse(ChatFormatting.WHITE.getColor(), 15); @@ -319,7 +319,7 @@ private void renderHoveredResourceTooltip(final GuiGraphics graphics, addDetailedTooltip(view, platformResource, processedLines); } if (!platformResource.isZeroed()) { - processedLines.addAll(platformResource.getExtractionHints()); + processedLines.addAll(platformResource.getExtractionHints(getMenu().getView())); } Platform.INSTANCE.renderTooltip(graphics, processedLines, mouseX, mouseY); } @@ -327,7 +327,9 @@ private void renderHoveredResourceTooltip(final GuiGraphics graphics, private void addDetailedTooltip(final GridView view, final PlatformGridResource platformResource, final List lines) { - final String amountInTooltip = platformResource.isZeroed() ? "0" : platformResource.getAmountInTooltip(); + final String amountInTooltip = platformResource.isZeroed() + ? "0" + : platformResource.getAmountInTooltip(getMenu().getView()); lines.add(new SmallTextClientTooltipComponent( createTranslation("misc", "total", amountInTooltip).withStyle(ChatFormatting.GRAY) )); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/view/AbstractFluidGridResourceFactory.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/view/AbstractFluidGridResourceFactory.java index 76083fcfe..27fa5fb16 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/view/AbstractFluidGridResourceFactory.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/view/AbstractFluidGridResourceFactory.java @@ -2,7 +2,7 @@ import com.refinedmods.refinedstorage.api.grid.view.GridResource; import com.refinedmods.refinedstorage.api.grid.view.GridResourceFactory; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; +import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.common.support.resource.FluidResource; import java.util.Optional; @@ -15,8 +15,8 @@ public abstract class AbstractFluidGridResourceFactory implements GridResourceFactory { @Override - public Optional apply(final ResourceAmount resourceAmount) { - if (!(resourceAmount.getResource() instanceof FluidResource fluidResource)) { + public Optional apply(final ResourceKey resource) { + if (!(resource instanceof FluidResource fluidResource)) { return Optional.empty(); } final String name = getName(fluidResource); @@ -25,7 +25,7 @@ public Optional apply(final ResourceAmount resourceAmount) { final Set tags = getTags(fluidResource.fluid()); final String tooltip = getTooltip(fluidResource); return Optional.of(new FluidGridResource( - resourceAmount, + fluidResource, name, modId, modName, diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/view/AbstractItemGridResourceFactory.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/view/AbstractItemGridResourceFactory.java index ad6b897bd..fe3af6975 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/view/AbstractItemGridResourceFactory.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/view/AbstractItemGridResourceFactory.java @@ -2,7 +2,7 @@ import com.refinedmods.refinedstorage.api.grid.view.GridResource; import com.refinedmods.refinedstorage.api.grid.view.GridResourceFactory; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; +import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.common.support.resource.ItemResource; import java.util.Optional; @@ -18,8 +18,8 @@ public abstract class AbstractItemGridResourceFactory implements GridResourceFactory { @Override - public Optional apply(final ResourceAmount resourceAmount) { - if (!(resourceAmount.getResource() instanceof ItemResource itemResource)) { + public Optional apply(final ResourceKey resource) { + if (!(resource instanceof ItemResource itemResource)) { return Optional.empty(); } final Item item = itemResource.item(); @@ -30,7 +30,7 @@ public Optional apply(final ResourceAmount resourceAmount) { final Set tags = getTags(item); final String tooltip = getTooltip(itemStack); return Optional.of(new ItemGridResource( - resourceAmount, + itemResource, itemStack, name, modId, diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/view/CompositeGridResourceFactory.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/view/CompositeGridResourceFactory.java index fe82452de..fad231cfa 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/view/CompositeGridResourceFactory.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/view/CompositeGridResourceFactory.java @@ -2,7 +2,7 @@ import com.refinedmods.refinedstorage.api.grid.view.GridResource; import com.refinedmods.refinedstorage.api.grid.view.GridResourceFactory; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; +import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.common.api.support.registry.PlatformRegistry; import com.refinedmods.refinedstorage.common.api.support.resource.ResourceType; @@ -16,10 +16,10 @@ public CompositeGridResourceFactory(final PlatformRegistry resourc } @Override - public Optional apply(final ResourceAmount resourceAmount) { + public Optional apply(final ResourceKey resource) { return resourceTypeRegistry.getAll() .stream() - .flatMap(type -> type.toGridResource(resourceAmount).stream()) + .flatMap(type -> type.toGridResource(resource).stream()) .findFirst(); } } 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 bd042f156..9571ec6dc 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 @@ -1,23 +1,23 @@ package com.refinedmods.refinedstorage.common.grid.view; import com.refinedmods.refinedstorage.api.grid.operations.GridExtractMode; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; +import com.refinedmods.refinedstorage.api.grid.view.GridView; import com.refinedmods.refinedstorage.common.Platform; 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.PlatformResourceKey; +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; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; -import javax.annotation.Nullable; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; @@ -25,24 +25,22 @@ import net.minecraft.network.chat.Component; import net.minecraft.world.inventory.tooltip.TooltipComponent; -public class FluidGridResource extends AbstractPlatformGridResource { - private final FluidResource fluidResource; +public class FluidGridResource extends AbstractPlatformGridResource { private final int id; - public FluidGridResource(final ResourceAmount resourceAmount, + public FluidGridResource(final FluidResource resource, final String name, final String modId, final String modName, final Set tags, final String tooltip) { - super(resourceAmount, name, Map.of( + super(resource, name, Map.of( GridResourceAttributeKeys.MOD_ID, Set.of(modId), GridResourceAttributeKeys.MOD_NAME, Set.of(modName), GridResourceAttributeKeys.TAGS, tags, GridResourceAttributeKeys.TOOLTIP, Set.of(tooltip) )); - this.fluidResource = (FluidResource) resourceAmount.getResource(); - this.id = BuiltInRegistries.FLUID.getId(fluidResource.fluid()); + this.id = BuiltInRegistries.FLUID.getId(resource.fluid()); } @Override @@ -51,25 +49,19 @@ public int getRegistryId() { } @Override - public List getExtractionHints() { - return Platform.INSTANCE.getFilledBucket(fluidResource).map(bucket -> MouseClientTooltipComponent.item( + public List getExtractionHints(final GridView view) { + return Platform.INSTANCE.getFilledBucket(resource).map(bucket -> MouseClientTooltipComponent.item( MouseClientTooltipComponent.Type.LEFT, bucket, null )).stream().toList(); } - @Nullable - @Override - public PlatformResourceKey getUnderlyingResource() { - return fluidResource; - } - @Override public void onExtract(final GridExtractMode extractMode, final boolean cursor, final GridExtractionStrategy extractionStrategy) { - extractionStrategy.onExtract(fluidResource, extractMode, cursor); + extractionStrategy.onExtract(resource, extractMode, cursor); } @Override @@ -79,22 +71,27 @@ public void onScroll(final GridScrollMode scrollMode, final GridScrollingStrateg @Override public void render(final GuiGraphics graphics, final int x, final int y) { - Platform.INSTANCE.getFluidRenderer().render(graphics.pose(), x, y, fluidResource); + Platform.INSTANCE.getFluidRenderer().render(graphics.pose(), x, y, resource); + } + + @Override + public String getDisplayedAmount(final GridView view) { + return FluidResourceRendering.formatWithUnits(getAmount(view)); } @Override - public String getDisplayedAmount() { - return FluidResourceRendering.formatWithUnits(getAmount()); + public String getAmountInTooltip(final GridView view) { + return FluidResourceRendering.format(getAmount(view)); } @Override - public String getAmountInTooltip() { - return FluidResourceRendering.format(getAmount()); + public boolean belongsToResourceType(final ResourceType resourceType) { + return resourceType == ResourceTypes.FLUID; } @Override public List getTooltip() { - return Platform.INSTANCE.getFluidRenderer().getTooltip(fluidResource); + return Platform.INSTANCE.getFluidRenderer().getTooltip(resource); } @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 da0b5d98c..c5497557e 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 @@ -1,22 +1,22 @@ package com.refinedmods.refinedstorage.common.grid.view; import com.refinedmods.refinedstorage.api.grid.operations.GridExtractMode; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; +import com.refinedmods.refinedstorage.api.grid.view.GridView; 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.AmountFormatting; -import com.refinedmods.refinedstorage.common.api.support.resource.PlatformResourceKey; +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; import com.refinedmods.refinedstorage.common.support.tooltip.MouseClientTooltipComponent; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; -import javax.annotation.Nullable; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; @@ -28,26 +28,24 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -public class ItemGridResource extends AbstractPlatformGridResource { +public class ItemGridResource extends AbstractPlatformGridResource { private final int id; private final ItemStack itemStack; - private final ItemResource itemResource; - public ItemGridResource(final ResourceAmount resourceAmount, + public ItemGridResource(final ItemResource resource, final ItemStack itemStack, final String name, final String modId, final String modName, final Set tags, final String tooltip) { - super(resourceAmount, name, Map.of( + super(resource, name, Map.of( GridResourceAttributeKeys.MOD_ID, Set.of(modId), GridResourceAttributeKeys.MOD_NAME, Set.of(modName), GridResourceAttributeKeys.TAGS, tags, GridResourceAttributeKeys.TOOLTIP, Set.of(tooltip) )); - this.itemResource = (ItemResource) resourceAmount.getResource(); - this.id = Item.getId(itemResource.item()); + this.id = Item.getId(resource.item()); this.itemStack = itemStack; } @@ -55,20 +53,15 @@ public ItemStack getItemStack() { return itemStack; } - @Nullable - @Override - public PlatformResourceKey getUnderlyingResource() { - return itemResource; - } - @Override public int getRegistryId() { return id; } @Override - public List getExtractionHints() { - final long extractableAmount = Math.min(getAmount(), itemStack.getMaxStackSize()); + public List getExtractionHints(final GridView view) { + final long amount = getAmount(view); + final long extractableAmount = Math.min(amount, itemStack.getMaxStackSize()); final long halfExtractionAmount = extractableAmount == 1 ? 1 : extractableAmount / 2; return List.of( MouseClientTooltipComponent.itemWithDecorations( @@ -88,12 +81,12 @@ public List getExtractionHints() { public void onExtract(final GridExtractMode extractMode, final boolean cursor, final GridExtractionStrategy extractionStrategy) { - extractionStrategy.onExtract(itemResource, extractMode, cursor); + extractionStrategy.onExtract(resource, extractMode, cursor); } @Override public void onScroll(final GridScrollMode scrollMode, final GridScrollingStrategy scrollingStrategy) { - scrollingStrategy.onScroll(itemResource, scrollMode, -1); + scrollingStrategy.onScroll(resource, scrollMode, -1); } @Override @@ -104,13 +97,18 @@ public void render(final GuiGraphics graphics, final int x, final int y) { } @Override - public String getDisplayedAmount() { - return AmountFormatting.formatWithUnits(getAmount()); + public String getDisplayedAmount(final GridView view) { + return AmountFormatting.formatWithUnits(getAmount(view)); + } + + @Override + public String getAmountInTooltip(final GridView view) { + return AmountFormatting.format(getAmount(view)); } @Override - public String getAmountInTooltip() { - return AmountFormatting.format(getAmount()); + public boolean belongsToResourceType(final ResourceType resourceType) { + return resourceType == ResourceTypes.ITEM; } @Override diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/FluidResourceType.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/FluidResourceType.java index 30e19026d..acfbf46b4 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/FluidResourceType.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/FluidResourceType.java @@ -3,13 +3,12 @@ import com.refinedmods.refinedstorage.api.grid.operations.GridOperations; import com.refinedmods.refinedstorage.api.grid.operations.GridOperationsImpl; import com.refinedmods.refinedstorage.api.grid.view.GridResource; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; +import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.api.storage.Actor; import com.refinedmods.refinedstorage.api.storage.root.RootStorage; import com.refinedmods.refinedstorage.common.Platform; import com.refinedmods.refinedstorage.common.api.support.resource.AbstractResourceType; import com.refinedmods.refinedstorage.common.api.support.resource.PlatformResourceKey; -import com.refinedmods.refinedstorage.common.grid.view.FluidGridResource; import com.refinedmods.refinedstorage.common.support.TextureIds; import java.util.Optional; @@ -32,13 +31,8 @@ class FluidResourceType extends AbstractResourceType { } @Override - public Optional toGridResource(final ResourceAmount resourceAmount) { - return Platform.INSTANCE.getFluidGridResourceFactory().apply(resourceAmount); - } - - @Override - public boolean isGridResourceBelonging(final GridResource gridResource) { - return gridResource instanceof FluidGridResource; + public Optional toGridResource(final ResourceKey resource) { + return Platform.INSTANCE.getFluidGridResourceFactory().apply(resource); } @Override diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ItemResourceType.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ItemResourceType.java index db994cb0b..be6006f86 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ItemResourceType.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ItemResourceType.java @@ -3,13 +3,12 @@ import com.refinedmods.refinedstorage.api.grid.operations.GridOperations; import com.refinedmods.refinedstorage.api.grid.operations.GridOperationsImpl; import com.refinedmods.refinedstorage.api.grid.view.GridResource; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; +import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.api.storage.Actor; import com.refinedmods.refinedstorage.api.storage.root.RootStorage; import com.refinedmods.refinedstorage.common.Platform; import com.refinedmods.refinedstorage.common.api.support.resource.AbstractResourceType; import com.refinedmods.refinedstorage.common.api.support.resource.PlatformResourceKey; -import com.refinedmods.refinedstorage.common.grid.view.ItemGridResource; import com.refinedmods.refinedstorage.common.support.TextureIds; import java.util.Optional; @@ -32,13 +31,8 @@ class ItemResourceType extends AbstractResourceType { } @Override - public Optional toGridResource(final ResourceAmount resourceAmount) { - return Platform.INSTANCE.getItemGridResourceFactory().apply(resourceAmount); - } - - @Override - public boolean isGridResourceBelonging(final GridResource gridResource) { - return gridResource instanceof ItemGridResource; + public Optional toGridResource(final ResourceKey resource) { + return Platform.INSTANCE.getItemGridResourceFactory().apply(resource); } @Override diff --git a/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/grid/GridSortingTypesTest.java b/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/grid/GridSortingTypesTest.java index 3d22021ab..76a93c453 100644 --- a/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/grid/GridSortingTypesTest.java +++ b/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/grid/GridSortingTypesTest.java @@ -49,7 +49,7 @@ void setUp() { viewBuilder = new GridViewBuilderImpl( FACTORY, view -> Comparator.comparing(GridResource::getName), - view -> Comparator.comparing(GridResource::getAmount) + view -> Comparator.comparingLong(resource -> resource.getAmount(view)) ); dirt = new ItemResource(Items.DIRT, DataComponentPatch.EMPTY); stone = new ItemResource(Items.STONE, DataComponentPatch.EMPTY); diff --git a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/query/GridQueryParser.java b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/query/GridQueryParser.java index d188611e1..cb8396fd2 100644 --- a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/query/GridQueryParser.java +++ b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/query/GridQueryParser.java @@ -1,12 +1,13 @@ package com.refinedmods.refinedstorage.api.grid.query; import com.refinedmods.refinedstorage.api.grid.view.GridResource; +import com.refinedmods.refinedstorage.api.grid.view.GridView; -import java.util.function.Predicate; +import java.util.function.BiPredicate; import org.apiguardian.api.API; @API(status = API.Status.STABLE, since = "2.0.0-milestone.1.0") public interface GridQueryParser { - Predicate parse(String query) throws GridQueryParserException; + BiPredicate parse(String query) throws GridQueryParserException; } diff --git a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/query/GridQueryParserImpl.java b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/query/GridQueryParserImpl.java index a7a3e6ea0..4e957a183 100644 --- a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/query/GridQueryParserImpl.java +++ b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/query/GridQueryParserImpl.java @@ -2,6 +2,7 @@ import com.refinedmods.refinedstorage.api.grid.view.GridResource; import com.refinedmods.refinedstorage.api.grid.view.GridResourceAttributeKey; +import com.refinedmods.refinedstorage.api.grid.view.GridView; import com.refinedmods.refinedstorage.query.lexer.Lexer; import com.refinedmods.refinedstorage.query.lexer.LexerException; import com.refinedmods.refinedstorage.query.lexer.LexerTokenMappings; @@ -25,7 +26,6 @@ import java.util.Map; import java.util.Set; import java.util.function.BiPredicate; -import java.util.function.Predicate; import org.apiguardian.api.API; @@ -44,9 +44,9 @@ public GridQueryParserImpl(final LexerTokenMappings tokenMappings, } @Override - public Predicate parse(final String query) throws GridQueryParserException { + public BiPredicate parse(final String query) throws GridQueryParserException { if (query.trim().isEmpty()) { - return resource -> true; + return (view, resource) -> true; } final List tokens = getTokens(query); final List nodes = getNodes(tokens); @@ -73,15 +73,15 @@ private List getNodes(final List tokens) throws GridQueryParserExce } } - private Predicate implicitAnd(final List nodes) throws GridQueryParserException { - final List> conditions = new ArrayList<>(); + private BiPredicate implicitAnd(final List nodes) throws GridQueryParserException { + final List> conditions = new ArrayList<>(); for (final Node node : nodes) { conditions.add(parseNode(node)); } return and(conditions); } - private Predicate parseNode(final Node node) throws GridQueryParserException { + private BiPredicate parseNode(final Node node) throws GridQueryParserException { return switch (node) { case LiteralNode literalNode -> parseLiteral(literalNode); case UnaryOpNode unaryOpNode -> parseUnaryOp(unaryOpNode); @@ -91,7 +91,7 @@ private Predicate parseNode(final Node node) throws GridQueryParse }; } - private Predicate parseBinOp(final BinOpNode node) throws GridQueryParserException { + private BiPredicate parseBinOp(final BinOpNode node) throws GridQueryParserException { final String operator = node.binOp().content(); if ("&&".equals(operator)) { return parseAndBinOpNode(node); @@ -102,24 +102,26 @@ private Predicate parseBinOp(final BinOpNode node) throws GridQuer } } - private Predicate parseAndBinOpNode(final BinOpNode node) throws GridQueryParserException { + private BiPredicate parseAndBinOpNode(final BinOpNode node) + throws GridQueryParserException { return and(Arrays.asList( parseNode(node.left()), parseNode(node.right()) )); } - private Predicate parseOrBinOpNode(final BinOpNode node) throws GridQueryParserException { + private BiPredicate parseOrBinOpNode(final BinOpNode node) + throws GridQueryParserException { return or(Arrays.asList( parseNode(node.left()), parseNode(node.right()) )); } - private Predicate parseUnaryOp(final UnaryOpNode node) throws GridQueryParserException { + private BiPredicate parseUnaryOp(final UnaryOpNode node) throws GridQueryParserException { final String operator = node.operator().content(); final Node content = node.node(); - final Predicate predicate; + final BiPredicate predicate; if ("!".equals(operator)) { predicate = not(parseNode(content)); @@ -146,8 +148,7 @@ private Predicate parseUnaryOp(final UnaryOpNode node) throws Grid return predicate; } - private static Predicate count(final Node node, - final BiPredicate predicate) + private static BiPredicate count(final Node node, final BiPredicate predicate) throws GridQueryParserException { if (!(node instanceof LiteralNode)) { throw new GridQueryParserException("Count filtering expects a literal", null); @@ -159,12 +160,14 @@ private static Predicate count(final Node node, final long wantedCount = Long.parseLong(((LiteralNode) node).token().content()); - return resource -> predicate.test(resource.getAmount(), wantedCount); + return (view, resource) -> predicate.test(resource.getAmount(view), wantedCount); } - private static Predicate attributeMatch(final Set keys, - final String query) { - return resource -> keys + private static BiPredicate attributeMatch( + final Set keys, + final String query + ) { + return (view, resource) -> keys .stream() .map(resource::getAttribute) .flatMap(Collection::stream) @@ -175,14 +178,14 @@ private static String normalize(final String value) { return value.trim().toLowerCase(Locale.ROOT); } - private static Predicate parseLiteral(final LiteralNode node) { - return resource -> normalize(resource.getName()).contains(normalize(node.token().content())); + private static BiPredicate parseLiteral(final LiteralNode node) { + return (view, resource) -> normalize(resource.getName()).contains(normalize(node.token().content())); } - private static Predicate and(final List> chain) { - return resource -> { - for (final Predicate predicate : chain) { - if (!predicate.test(resource)) { + private static BiPredicate and(final List> chain) { + return (view, resource) -> { + for (final BiPredicate predicate : chain) { + if (!predicate.test(view, resource)) { return false; } } @@ -190,10 +193,10 @@ private static Predicate and(final List> c }; } - private static Predicate or(final List> chain) { - return resource -> { - for (final Predicate predicate : chain) { - if (predicate.test(resource)) { + private static BiPredicate or(final List> chain) { + return (view, resource) -> { + for (final BiPredicate predicate : chain) { + if (predicate.test(view, resource)) { return true; } } @@ -201,7 +204,7 @@ private static Predicate or(final List> ch }; } - private static Predicate not(final Predicate predicate) { - return resource -> !predicate.test(resource); + private static BiPredicate not(final BiPredicate predicate) { + return (view, resource) -> !predicate.test(view, resource); } } diff --git a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridResource.java b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridResource.java index 2407f4987..20b613552 100644 --- a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridResource.java +++ b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridResource.java @@ -14,7 +14,7 @@ public interface GridResource { Optional getTrackedResource(GridView view); - long getAmount(); + long getAmount(GridView view); String getName(); diff --git a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridResourceFactory.java b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridResourceFactory.java index 14bde3f3b..64289636b 100644 --- a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridResourceFactory.java +++ b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridResourceFactory.java @@ -1,6 +1,6 @@ package com.refinedmods.refinedstorage.api.grid.view; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; +import com.refinedmods.refinedstorage.api.resource.ResourceKey; import java.util.Optional; @@ -13,12 +13,10 @@ @API(status = API.Status.STABLE, since = "2.0.0-milestone.2.6") public interface GridResourceFactory { /** - * Transforms a {@link ResourceAmount} into a {@link GridResource}. - * It's important to keep the {@link ResourceAmount} instance around to - * get updated resource amounts from the {@link GridView} backing list. + * Transforms a {@link com.refinedmods.refinedstorage.api.resource.ResourceKey} into a {@link GridResource}. * - * @param resourceAmount the resource amount from the backing list + * @param resource the resource * @return the grid resource, if applicable */ - Optional apply(ResourceAmount resourceAmount); + Optional apply(ResourceKey resource); } diff --git a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridView.java b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridView.java index 9f25238cc..df1f422c9 100644 --- a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridView.java +++ b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridView.java @@ -6,7 +6,7 @@ import java.util.List; import java.util.Optional; -import java.util.function.Predicate; +import java.util.function.BiPredicate; import javax.annotation.Nullable; import org.apiguardian.api.API; @@ -38,7 +38,7 @@ public interface GridView { * @param predicate the filter * @return the previous filtering predicate */ - Predicate setFilterAndSort(Predicate predicate); + BiPredicate setFilterAndSort(BiPredicate predicate); /** * Preventing sorting means that the changes will still arrive at the backing list and view list, but, @@ -64,6 +64,12 @@ public interface GridView { */ Optional getTrackedResource(ResourceKey resource); + /** + * @param resource the resource + * @return the amount in the view, or zero if not present + */ + long getAmount(ResourceKey resource); + /** * Sorts the view list. * Applies sorting and filtering rules. diff --git a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java index 9c0eed56f..b401cf0da 100644 --- a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java +++ b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java @@ -14,7 +14,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.function.Predicate; +import java.util.function.BiPredicate; import javax.annotation.Nullable; import org.apiguardian.api.API; @@ -35,7 +35,7 @@ public class GridViewImpl implements GridView { private GridSortingType sortingType; private GridSortingDirection sortingDirection = GridSortingDirection.ASCENDING; - private Predicate filter = resource -> true; + private BiPredicate filter = (view, resource) -> true; @Nullable private Runnable listener; private boolean preventSorting; @@ -70,8 +70,8 @@ public void setSortingType(final GridSortingType sortingType) { } @Override - public Predicate setFilterAndSort(final Predicate predicate) { - final Predicate previousPredicate = filter; + public BiPredicate setFilterAndSort(final BiPredicate predicate) { + final BiPredicate previousPredicate = filter; this.filter = predicate; sort(); return previousPredicate; @@ -94,6 +94,11 @@ public Optional getTrackedResource(final ResourceKey resource) return Optional.ofNullable(trackedResources.get(resource)); } + @Override + public long getAmount(final ResourceKey resource) { + return backingList.get(resource).map(ResourceAmount::getAmount).orElse(0L); + } + @Override public void sort() { LOGGER.info("Sorting grid view"); @@ -102,8 +107,8 @@ public void sort() { final List newViewList = new ArrayList<>(); for (final ResourceAmount backingListItem : backingList.getAll()) { - resourceFactory.apply(backingListItem).ifPresent(gridResource -> { - if (filter.test(gridResource)) { + resourceFactory.apply(backingListItem.getResource()).ifPresent(gridResource -> { + if (filter.test(this, gridResource)) { newViewList.add(gridResource); viewListIndex.put(backingListItem.getResource(), gridResource); } @@ -158,7 +163,8 @@ private void reinsertZeroedResourceIntoViewList(final ResourceKey resource, final ResourceList.OperationResult operationResult, final GridResource oldGridResource) { LOGGER.debug("{} was zeroed, unzeroing", resource); - final GridResource newResource = resourceFactory.apply(operationResult.resourceAmount()).orElseThrow(); + final GridResource newResource = resourceFactory.apply(operationResult.resourceAmount().getResource()) + .orElseThrow(); viewListIndex.put(resource, newResource); final int index = CoreValidations.validateNotNegative( viewList.indexOf(oldGridResource), @@ -198,8 +204,9 @@ private void updateExistingResourceInViewList(final ResourceKey resource, private void handleChangeForNewResource(final ResourceKey resource, final ResourceList.OperationResult operationResult) { - final GridResource gridResource = resourceFactory.apply(operationResult.resourceAmount()).orElseThrow(); - if (filter.test(gridResource)) { + final GridResource gridResource = resourceFactory.apply(operationResult.resourceAmount().getResource()) + .orElseThrow(); + if (filter.test(this, gridResource)) { LOGGER.debug("Filter allowed, actually adding {}", resource); viewListIndex.put(resource, gridResource); addIntoView(gridResource); diff --git a/refinedstorage-grid-api/src/test/java/com/refinedmods/refinedstorage/api/grid/query/GridQueryParserImplTest.java b/refinedstorage-grid-api/src/test/java/com/refinedmods/refinedstorage/api/grid/query/GridQueryParserImplTest.java index 21879ac19..8d69ad560 100644 --- a/refinedstorage-grid-api/src/test/java/com/refinedmods/refinedstorage/api/grid/query/GridQueryParserImplTest.java +++ b/refinedstorage-grid-api/src/test/java/com/refinedmods/refinedstorage/api/grid/query/GridQueryParserImplTest.java @@ -3,15 +3,19 @@ import com.refinedmods.refinedstorage.api.grid.view.FakeGridResourceAttributeKeys; import com.refinedmods.refinedstorage.api.grid.view.GridResource; import com.refinedmods.refinedstorage.api.grid.view.GridResourceAttributeKey; +import com.refinedmods.refinedstorage.api.grid.view.GridResourceImpl; import com.refinedmods.refinedstorage.api.grid.view.GridView; +import com.refinedmods.refinedstorage.api.grid.view.GridViewImpl; +import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; import com.refinedmods.refinedstorage.api.storage.tracked.TrackedResource; import com.refinedmods.refinedstorage.query.lexer.LexerTokenMappings; import com.refinedmods.refinedstorage.query.parser.ParserOperatorMappings; +import java.util.Comparator; +import java.util.HashMap; import java.util.Map; import java.util.Optional; import java.util.Set; -import java.util.function.Predicate; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; @@ -28,49 +32,57 @@ class GridQueryParserImplTest { FakeGridResourceAttributeKeys.UNARY_OPERATOR_TO_ATTRIBUTE_KEY_MAPPING ); + private final GridView view = new GridViewImpl( + resource -> Optional.of(new GridResourceImpl(resource)), + ResourceListImpl.create(), + new HashMap<>(), + v -> Comparator.comparing(GridResource::getName), + v -> Comparator.comparingLong(resource -> resource.getAmount(v)) + ); + @ParameterizedTest @ValueSource(strings = {"", " "}) void testEmptyQuery(final String query) throws GridQueryParserException { // Act - final Predicate predicate = queryParser.parse(query); + final var predicate = queryParser.parse(query); // Assert - assertThat(predicate.test(new R("Dirt"))).isTrue(); - assertThat(predicate.test(new R("Glass"))).isTrue(); + assertThat(predicate.test(view, new R("Dirt"))).isTrue(); + assertThat(predicate.test(view, new R("Glass"))).isTrue(); } @ParameterizedTest @ValueSource(strings = {"dirt", "Dirt", "DiRt", "Di", "irt"}) void testNameQuery(final String query) throws GridQueryParserException { // Act - final Predicate predicate = queryParser.parse(query); + final var predicate = queryParser.parse(query); // Assert - assertThat(predicate.test(new R("Dirt"))).isTrue(); - assertThat(predicate.test(new R("Glass"))).isFalse(); + assertThat(predicate.test(view, new R("Dirt"))).isTrue(); + assertThat(predicate.test(view, new R("Glass"))).isFalse(); } @ParameterizedTest @ValueSource(strings = {"@refined", "@\"Refined Storage\"", "@ReFiNe", "@Storage", "@rs", "@RS"}) void testModQuery(final String query) throws GridQueryParserException { // Act - final Predicate predicate = queryParser.parse(query); + final var predicate = queryParser.parse(query); // Assert - assertThat(predicate.test(new R("Sponge", 1, "rs", "Refined Storage", Set.of()))).isTrue(); - assertThat(predicate.test(new R("Glass"))).isFalse(); + assertThat(predicate.test(view, new R("Sponge", 1, "rs", "Refined Storage", Set.of()))).isTrue(); + assertThat(predicate.test(view, new R("Glass"))).isFalse(); } @ParameterizedTest @ValueSource(strings = {"$underwater", "$UnDerWate", "$water", "$unrelated", "$UNREL", "$laTed"}) void testTagQuery(final String query) throws GridQueryParserException { // Act - final Predicate predicate = queryParser.parse(query); + final var predicate = queryParser.parse(query); // Assert - assertThat(predicate.test( + assertThat(predicate.test(view, new R("Sponge", 1, "mc", "Minecraft", Set.of("underwater", "unrelated")))).isTrue(); - assertThat(predicate.test(new R("Dirt", 1, "mc", "Minecraft", Set.of("transparent")))).isFalse(); + assertThat(predicate.test(view, new R("Dirt", 1, "mc", "Minecraft", Set.of("transparent")))).isFalse(); } @Test @@ -86,154 +98,154 @@ void testAttributeQueryWithInvalidNode() { @Test void testImplicitAndQuery() throws GridQueryParserException { // Act - final Predicate predicate = queryParser.parse("DirT di RT"); + final var predicate = queryParser.parse("DirT di RT"); // Assert - assertThat(predicate.test(new R("Dirt"))).isTrue(); - assertThat(predicate.test(new R("Glass"))).isFalse(); + assertThat(predicate.test(view, new R("Dirt"))).isTrue(); + assertThat(predicate.test(view, new R("Glass"))).isFalse(); } @Test void testImplicitAndQueryInParenthesis() throws GridQueryParserException { // Act - final Predicate predicate = queryParser.parse("(DirT di RT) || (sto stone)"); + final var predicate = queryParser.parse("(DirT di RT) || (sto stone)"); // Assert - assertThat(predicate.test(new R("Dirt"))).isTrue(); - assertThat(predicate.test(new R("Glass"))).isFalse(); - assertThat(predicate.test(new R("Stone"))).isTrue(); + assertThat(predicate.test(view, new R("Dirt"))).isTrue(); + assertThat(predicate.test(view, new R("Glass"))).isFalse(); + assertThat(predicate.test(view, new R("Stone"))).isTrue(); } @Test void testImplicitAndQueryWithUnaryOperator() throws GridQueryParserException { // Act - final Predicate predicate = queryParser.parse("@minecraft >5"); + final var predicate = queryParser.parse("@minecraft >5"); // Assert - assertThat(predicate.test(new R("Dirt", 6, "minecraft", "Minecraft", Set.of()))).isTrue(); - assertThat(predicate.test(new R("Glass", 5, "minecraft", "Minecraft", Set.of()))).isFalse(); - assertThat(predicate.test(new R("Sponge", 5, "rs", "Refined Storage", Set.of()))).isFalse(); - assertThat(predicate.test(new R("Cobblestone", 6, "rs", "Refined Storage", Set.of()))).isFalse(); + assertThat(predicate.test(view, new R("Dirt", 6, "minecraft", "Minecraft", Set.of()))).isTrue(); + assertThat(predicate.test(view, new R("Glass", 5, "minecraft", "Minecraft", Set.of()))).isFalse(); + assertThat(predicate.test(view, new R("Sponge", 5, "rs", "Refined Storage", Set.of()))).isFalse(); + assertThat(predicate.test(view, new R("Cobblestone", 6, "rs", "Refined Storage", Set.of()))).isFalse(); } @Test void testAndQuery() throws GridQueryParserException { // Act - final Predicate predicate = queryParser.parse("DirT && di && RT"); + final var predicate = queryParser.parse("DirT && di && RT"); // Assert - assertThat(predicate.test(new R("Dirt"))).isTrue(); - assertThat(predicate.test(new R("Glass"))).isFalse(); + assertThat(predicate.test(view, new R("Dirt"))).isTrue(); + assertThat(predicate.test(view, new R("Glass"))).isFalse(); } @Test void testOrQuery() throws GridQueryParserException { // Act - final Predicate predicate = queryParser.parse("dir || glass || StoNe"); + final var predicate = queryParser.parse("dir || glass || StoNe"); // Assert - assertThat(predicate.test(new R("Dirt"))).isTrue(); - assertThat(predicate.test(new R("Glass"))).isTrue(); - assertThat(predicate.test(new R("Stone"))).isTrue(); - assertThat(predicate.test(new R("Cobblestone"))).isTrue(); + assertThat(predicate.test(view, new R("Dirt"))).isTrue(); + assertThat(predicate.test(view, new R("Glass"))).isTrue(); + assertThat(predicate.test(view, new R("Stone"))).isTrue(); + assertThat(predicate.test(view, new R("Cobblestone"))).isTrue(); - assertThat(predicate.test(new R("Sponge"))).isFalse(); - assertThat(predicate.test(new R("Furnace"))).isFalse(); + assertThat(predicate.test(view, new R("Sponge"))).isFalse(); + assertThat(predicate.test(view, new R("Furnace"))).isFalse(); } @Test void testSimpleNotQuery() throws GridQueryParserException { // Act - final Predicate predicate = queryParser.parse("!stone"); + final var predicate = queryParser.parse("!stone"); // Assert - assertThat(predicate.test(new R("Dirt"))).isTrue(); - assertThat(predicate.test(new R("Glass"))).isTrue(); + assertThat(predicate.test(view, new R("Dirt"))).isTrue(); + assertThat(predicate.test(view, new R("Glass"))).isTrue(); - assertThat(predicate.test(new R("Stone"))).isFalse(); - assertThat(predicate.test(new R("Cobblestone"))).isFalse(); + assertThat(predicate.test(view, new R("Stone"))).isFalse(); + assertThat(predicate.test(view, new R("Cobblestone"))).isFalse(); } @Test void testNotQueryWithMultipleOrParts() throws GridQueryParserException { // Act - final Predicate predicate = queryParser.parse("!(stone || dirt)"); + final var predicate = queryParser.parse("!(stone || dirt)"); // Assert - assertThat(predicate.test(new R("Sponge"))).isTrue(); - assertThat(predicate.test(new R("Glass"))).isTrue(); + assertThat(predicate.test(view, new R("Sponge"))).isTrue(); + assertThat(predicate.test(view, new R("Glass"))).isTrue(); - assertThat(predicate.test(new R("Stone"))).isFalse(); - assertThat(predicate.test(new R("Dirt"))).isFalse(); + assertThat(predicate.test(view, new R("Stone"))).isFalse(); + assertThat(predicate.test(view, new R("Dirt"))).isFalse(); } @Test void testComplexModQuery() throws GridQueryParserException { // Act - final Predicate predicate = queryParser.parse( + final var predicate = queryParser.parse( "((spo || buck) && @refined) || (glass && @mine)" ); // Assert - assertThat(predicate.test(new R("Sponge", 1, "rs", "Refined Storage", Set.of()))).isTrue(); - assertThat(predicate.test(new R("Bucket", 1, "rs", "Refined Storage", Set.of()))).isTrue(); - assertThat(predicate.test(new R("Saddle", 1, "rs", "Refined Storage", Set.of()))).isFalse(); + assertThat(predicate.test(view, new R("Sponge", 1, "rs", "Refined Storage", Set.of()))).isTrue(); + assertThat(predicate.test(view, new R("Bucket", 1, "rs", "Refined Storage", Set.of()))).isTrue(); + assertThat(predicate.test(view, new R("Saddle", 1, "rs", "Refined Storage", Set.of()))).isFalse(); - assertThat(predicate.test(new R("Glass", 1, "mc", "Minecraft", Set.of()))).isTrue(); - assertThat(predicate.test(new R("Furnace", 1, "mc", "Minecraft", Set.of()))).isFalse(); + assertThat(predicate.test(view, new R("Glass", 1, "mc", "Minecraft", Set.of()))).isTrue(); + assertThat(predicate.test(view, new R("Furnace", 1, "mc", "Minecraft", Set.of()))).isFalse(); } @Test void testLessThanUnaryCountQuery() throws GridQueryParserException { // Act - final Predicate predicate = queryParser.parse("<5"); + final var predicate = queryParser.parse("<5"); // Assert - assertThat(predicate.test(new R("Glass", 5))).isFalse(); - assertThat(predicate.test(new R("Glass", 4))).isTrue(); + assertThat(predicate.test(view, new R("Glass", 5))).isFalse(); + assertThat(predicate.test(view, new R("Glass", 4))).isTrue(); } @Test void testLessThanEqualsUnaryCountQuery() throws GridQueryParserException { // Act - final Predicate predicate = queryParser.parse("<=5"); + final var predicate = queryParser.parse("<=5"); // Assert - assertThat(predicate.test(new R("Glass", 6))).isFalse(); - assertThat(predicate.test(new R("Glass", 5))).isTrue(); - assertThat(predicate.test(new R("Glass", 4))).isTrue(); + assertThat(predicate.test(view, new R("Glass", 6))).isFalse(); + assertThat(predicate.test(view, new R("Glass", 5))).isTrue(); + assertThat(predicate.test(view, new R("Glass", 4))).isTrue(); } @Test void testGreaterThanUnaryCountQuery() throws GridQueryParserException { // Act - final Predicate predicate = queryParser.parse(">5"); + final var predicate = queryParser.parse(">5"); // Assert - assertThat(predicate.test(new R("Glass", 5))).isFalse(); - assertThat(predicate.test(new R("Glass", 6))).isTrue(); + assertThat(predicate.test(view, new R("Glass", 5))).isFalse(); + assertThat(predicate.test(view, new R("Glass", 6))).isTrue(); } @Test void testGreaterThanEqualsUnaryCountQuery() throws GridQueryParserException { // Act - final Predicate predicate = queryParser.parse(">=5"); + final var predicate = queryParser.parse(">=5"); // Assert - assertThat(predicate.test(new R("Glass", 4))).isFalse(); - assertThat(predicate.test(new R("Glass", 5))).isTrue(); - assertThat(predicate.test(new R("Glass", 6))).isTrue(); + assertThat(predicate.test(view, new R("Glass", 4))).isFalse(); + assertThat(predicate.test(view, new R("Glass", 5))).isTrue(); + assertThat(predicate.test(view, new R("Glass", 6))).isTrue(); } @Test void testEqualsUnaryCountQuery() throws GridQueryParserException { // Act - final Predicate predicate = queryParser.parse("=5"); + final var predicate = queryParser.parse("=5"); // Assert - assertThat(predicate.test(new R("Glass", 4))).isFalse(); - assertThat(predicate.test(new R("Glass", 5))).isTrue(); - assertThat(predicate.test(new R("Glass", 6))).isFalse(); + assertThat(predicate.test(view, new R("Glass", 4))).isFalse(); + assertThat(predicate.test(view, new R("Glass", 5))).isTrue(); + assertThat(predicate.test(view, new R("Glass", 6))).isFalse(); } @ParameterizedTest @@ -295,7 +307,7 @@ public Optional getTrackedResource(final GridView view) { } @Override - public long getAmount() { + public long getAmount(final GridView view) { return amount; } diff --git a/refinedstorage-grid-api/src/test/java/com/refinedmods/refinedstorage/api/grid/view/GridResourceImpl.java b/refinedstorage-grid-api/src/test/java/com/refinedmods/refinedstorage/api/grid/view/GridResourceImpl.java index 28ef989e6..ae11dd59e 100644 --- a/refinedstorage-grid-api/src/test/java/com/refinedmods/refinedstorage/api/grid/view/GridResourceImpl.java +++ b/refinedstorage-grid-api/src/test/java/com/refinedmods/refinedstorage/api/grid/view/GridResourceImpl.java @@ -1,6 +1,5 @@ package com.refinedmods.refinedstorage.api.grid.view; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.api.storage.tracked.TrackedResource; @@ -9,20 +8,16 @@ import java.util.Optional; import java.util.Set; -class GridResourceImpl implements GridResource { - private final ResourceAmount resourceAmountRef; +public class GridResourceImpl implements GridResource { + private final ResourceKey resource; private final Map> attributes; private boolean zeroed; - GridResourceImpl(final ResourceKey resource, final long amount) { - this(new ResourceAmount(resource, amount)); - } - - GridResourceImpl(final ResourceAmount resourceAmountRef) { - this.resourceAmountRef = resourceAmountRef; + public GridResourceImpl(final ResourceKey resource) { + this.resource = resource; this.attributes = Map.of( - FakeGridResourceAttributeKeys.MOD_ID, Set.of(resourceAmountRef.getResource().toString()), - FakeGridResourceAttributeKeys.MOD_NAME, Set.of(resourceAmountRef.getResource().toString()) + FakeGridResourceAttributeKeys.MOD_ID, Set.of(resource.toString()), + FakeGridResourceAttributeKeys.MOD_NAME, Set.of(resource.toString()) ); } @@ -33,17 +28,17 @@ public GridResourceImpl zeroed() { @Override public Optional getTrackedResource(final GridView view) { - return view.getTrackedResource(resourceAmountRef.getResource()); + return view.getTrackedResource(resource); } @Override - public long getAmount() { - return resourceAmountRef.getAmount(); + public long getAmount(final GridView view) { + return view.getAmount(resource); } @Override public String getName() { - return resourceAmountRef.getResource().toString(); + return resource.toString(); } @Override @@ -63,6 +58,6 @@ public void setZeroed(final boolean zeroed) { @Override public String toString() { - return resourceAmountRef.getResource().toString(); + return resource.toString(); } } diff --git a/refinedstorage-grid-api/src/test/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImplTest.java b/refinedstorage-grid-api/src/test/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImplTest.java index 2837dd328..5dd5cc47b 100644 --- a/refinedstorage-grid-api/src/test/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImplTest.java +++ b/refinedstorage-grid-api/src/test/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImplTest.java @@ -7,7 +7,7 @@ import java.util.Comparator; import java.util.Optional; -import java.util.function.Predicate; +import java.util.function.BiPredicate; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -28,14 +28,14 @@ class GridViewImplTest { @BeforeEach void setUp() { - viewBuilder = getViewBuilder(resourceAmount -> Optional.of(new GridResourceImpl(resourceAmount))); + viewBuilder = getViewBuilder(resource -> Optional.of(new GridResourceImpl(resource))); } private static GridViewBuilderImpl getViewBuilder(final GridResourceFactory resourceFactory) { return new GridViewBuilderImpl( resourceFactory, view -> Comparator.comparing(GridResource::getName), - view -> Comparator.comparing(GridResource::getAmount) + view -> Comparator.comparingLong(resource -> resource.getAmount(view)) ); } @@ -57,8 +57,8 @@ void shouldAddResourcesWithSameNameButDifferentIdentity() { // Assert assertThat(view.getViewList()).usingRecursiveFieldByFieldElementComparator().containsExactly( - new GridResourceWithMetadata(new ResourceAmount(new ResourceWithMetadata(A, 1), 1)), - new GridResourceWithMetadata(new ResourceAmount(new ResourceWithMetadata(A, 2), 1)) + new GridResourceWithMetadata(new ResourceWithMetadata(A, 1)), + new GridResourceWithMetadata(new ResourceWithMetadata(A, 2)) ); } @@ -75,9 +75,9 @@ void shouldPreserveOrderWhenSortingAndTwoResourcesHaveTheSameQuantity() { view.onChange(C, 2, null); assertThat(view.getViewList()).usingRecursiveFieldByFieldElementComparator().containsExactly( - new GridResourceImpl(B, 15), - new GridResourceImpl(A, 15), - new GridResourceImpl(C, 2) + new GridResourceImpl(B), + new GridResourceImpl(A), + new GridResourceImpl(C) ); view.onChange(A, -15, null); @@ -87,9 +87,9 @@ void shouldPreserveOrderWhenSortingAndTwoResourcesHaveTheSameQuantity() { view.onChange(B, 15, null); assertThat(view.getViewList()).usingRecursiveFieldByFieldElementComparator().containsExactly( - new GridResourceImpl(B, 15), - new GridResourceImpl(A, 15), - new GridResourceImpl(C, 2) + new GridResourceImpl(B), + new GridResourceImpl(A), + new GridResourceImpl(C) ); } @@ -120,6 +120,10 @@ void shouldLoadResourcesAndRetrieveTrackedResourcesProperly() { new ResourceAmount(B, 2), new ResourceAmount(D, 1) ); + assertThat(view.getAmount(A)).isEqualTo(2); + assertThat(view.getAmount(B)).isEqualTo(2); + assertThat(view.getAmount(C)).isZero(); + assertThat(view.getAmount(D)).isEqualTo(1); } @Test @@ -140,9 +144,9 @@ void shouldInsertNewResource() { // Assert assertThat(view.getViewList()).usingRecursiveFieldByFieldElementComparator().containsExactly( - new GridResourceImpl(D, 10), - new GridResourceImpl(A, 12), - new GridResourceImpl(B, 15) + new GridResourceImpl(D), + new GridResourceImpl(A), + new GridResourceImpl(B) ); assertThat(view.copyBackingList().getAll()) .usingRecursiveFieldByFieldElementComparator() @@ -152,6 +156,9 @@ void shouldInsertNewResource() { new ResourceAmount(B, 15) ); verify(listener, times(1)).run(); + assertThat(view.getAmount(A)).isEqualTo(12); + assertThat(view.getAmount(B)).isEqualTo(15); + assertThat(view.getAmount(D)).isEqualTo(10); } @Test @@ -162,19 +169,21 @@ void shouldSetFilterAndSort() { .withResource(B, 10, null) .build(); - final Predicate filterA = resource -> resource.getName().equals(A.name()); - final Predicate filterB = resource -> resource.getName().equals(B.name()); + final BiPredicate filterA = (v, resource) -> resource.getName().equals(A.name()); + final BiPredicate filterB = (v, resource) -> resource.getName().equals(B.name()); // Act - final Predicate previousFilter1 = view.setFilterAndSort(filterA); - final Predicate previousFilter2 = view.setFilterAndSort(filterB); + final BiPredicate previousFilter1 = view.setFilterAndSort(filterA); + final BiPredicate previousFilter2 = view.setFilterAndSort(filterB); // Assert assertThat(previousFilter1).isNotNull(); assertThat(previousFilter2).isEqualTo(filterA); assertThat(view.getViewList()).usingRecursiveFieldByFieldElementComparator().containsExactly( - new GridResourceImpl(B, 10) + new GridResourceImpl(B) ); + assertThat(view.getAmount(A)).isEqualTo(10); + assertThat(view.getAmount(B)).isEqualTo(10); } @Test @@ -185,7 +194,7 @@ void shouldNotInsertNewResourceWhenFilteringProhibitsIt() { .withResource(D, 10, null) .build(); - view.setFilterAndSort(resource -> !resource.getName().equals(A.name())); + view.setFilterAndSort((v, resource) -> !resource.getName().equals(A.name())); final Runnable listener = mock(Runnable.class); view.setListener(listener); @@ -195,10 +204,13 @@ void shouldNotInsertNewResourceWhenFilteringProhibitsIt() { // Assert assertThat(view.getViewList()).usingRecursiveFieldByFieldElementComparator().containsExactly( - new GridResourceImpl(D, 10), - new GridResourceImpl(B, 15) + new GridResourceImpl(D), + new GridResourceImpl(B) ); verify(listener, never()).run(); + assertThat(view.getAmount(A)).isEqualTo(12); + assertThat(view.getAmount(B)).isEqualTo(15); + assertThat(view.getAmount(D)).isEqualTo(10); } @Test @@ -240,9 +252,9 @@ void shouldUpdateExistingResource() { // Assert assertThat(view.getViewList()).usingRecursiveFieldByFieldElementComparator().containsExactly( - new GridResourceImpl(D, 10), - new GridResourceImpl(B, 11), - new GridResourceImpl(A, 15) + new GridResourceImpl(D), + new GridResourceImpl(B), + new GridResourceImpl(A) ); assertThat(view.copyBackingList().getAll()) .usingRecursiveFieldByFieldElementComparator() @@ -252,6 +264,9 @@ void shouldUpdateExistingResource() { new ResourceAmount(A, 15) ); verify(listener, times(1)).run(); + assertThat(view.getAmount(A)).isEqualTo(15); + assertThat(view.getAmount(B)).isEqualTo(11); + assertThat(view.getAmount(D)).isEqualTo(10); } @Test @@ -263,7 +278,7 @@ void shouldNotUpdateExistingResourceWhenFilteringProhibitsIt() { .withResource(D, 10, null) .build(); - view.setFilterAndSort(resource -> !resource.getName().equals(B.name())); + view.setFilterAndSort((v, resource) -> !resource.getName().equals(B.name())); final Runnable listener = mock(Runnable.class); view.setListener(listener); @@ -273,8 +288,8 @@ void shouldNotUpdateExistingResourceWhenFilteringProhibitsIt() { // Assert assertThat(view.getViewList()).usingRecursiveFieldByFieldElementComparator().containsExactly( - new GridResourceImpl(D, 10), - new GridResourceImpl(A, 15) + new GridResourceImpl(D), + new GridResourceImpl(A) ); assertThat(view.copyBackingList().getAll()) .usingRecursiveFieldByFieldElementComparator() @@ -284,6 +299,9 @@ void shouldNotUpdateExistingResourceWhenFilteringProhibitsIt() { new ResourceAmount(A, 15) ); verify(listener, never()).run(); + assertThat(view.getAmount(A)).isEqualTo(15); + assertThat(view.getAmount(B)).isEqualTo(11); + assertThat(view.getAmount(D)).isEqualTo(10); } @Test @@ -302,9 +320,9 @@ void shouldNotReorderExistingResourceWhenPreventingSorting() { // Act & assert assertThat(view.getViewList()).usingRecursiveFieldByFieldElementComparator().containsExactly( - new GridResourceImpl(B, 6), - new GridResourceImpl(D, 10), - new GridResourceImpl(A, 15) + new GridResourceImpl(B), + new GridResourceImpl(D), + new GridResourceImpl(A) ); final boolean changed = view.setPreventSorting(true); @@ -316,9 +334,9 @@ void shouldNotReorderExistingResourceWhenPreventingSorting() { verify(listener, never()).run(); assertThat(view.getViewList()).usingRecursiveFieldByFieldElementComparator().containsExactly( - new GridResourceImpl(B, 11), - new GridResourceImpl(D, 10), - new GridResourceImpl(A, 15) + new GridResourceImpl(B), + new GridResourceImpl(D), + new GridResourceImpl(A) ); assertThat(view.copyBackingList().getAll()) .usingRecursiveFieldByFieldElementComparator() @@ -333,9 +351,9 @@ void shouldNotReorderExistingResourceWhenPreventingSorting() { view.sort(); assertThat(view.getViewList()).usingRecursiveFieldByFieldElementComparator().containsExactly( - new GridResourceImpl(D, 10), - new GridResourceImpl(B, 11), - new GridResourceImpl(A, 15) + new GridResourceImpl(D), + new GridResourceImpl(B), + new GridResourceImpl(A) ); assertThat(view.copyBackingList().getAll()) .usingRecursiveFieldByFieldElementComparator() @@ -389,9 +407,9 @@ void shouldUpdateExistingResourceWhenPerformingPartialRemoval() { // Assert assertThat(view.getViewList()).usingRecursiveFieldByFieldElementComparator().containsExactly( - new GridResourceImpl(D, 10), - new GridResourceImpl(B, 13), - new GridResourceImpl(A, 15) + new GridResourceImpl(D), + new GridResourceImpl(B), + new GridResourceImpl(A) ); assertThat(view.copyBackingList().getAll()) .usingRecursiveFieldByFieldElementComparator() @@ -401,6 +419,9 @@ void shouldUpdateExistingResourceWhenPerformingPartialRemoval() { new ResourceAmount(A, 15) ); verify(listener, times(1)).run(); + assertThat(view.getAmount(A)).isEqualTo(15); + assertThat(view.getAmount(B)).isEqualTo(13); + assertThat(view.getAmount(D)).isEqualTo(10); } @Test @@ -412,7 +433,7 @@ void shouldNotUpdateExistingResourceWhenPerformingPartialRemovalAndFilteringProh .withResource(D, 10, null) .build(); - view.setFilterAndSort(resource -> !resource.getName().equals(B.name())); + view.setFilterAndSort((v, resource) -> !resource.getName().equals(B.name())); final Runnable listener = mock(Runnable.class); view.setListener(listener); @@ -422,10 +443,13 @@ void shouldNotUpdateExistingResourceWhenPerformingPartialRemovalAndFilteringProh // Assert assertThat(view.getViewList()).usingRecursiveFieldByFieldElementComparator().containsExactly( - new GridResourceImpl(D, 10), - new GridResourceImpl(A, 15) + new GridResourceImpl(D), + new GridResourceImpl(A) ); verify(listener, never()).run(); + assertThat(view.getAmount(A)).isEqualTo(15); + assertThat(view.getAmount(B)).isEqualTo(13); + assertThat(view.getAmount(D)).isEqualTo(10); } @Test @@ -444,9 +468,9 @@ void shouldNotReorderExistingResourceWhenPerformingPartialRemovalAndPreventingSo // Act & assert assertThat(view.getViewList()).usingRecursiveFieldByFieldElementComparator().containsExactly( - new GridResourceImpl(D, 10), - new GridResourceImpl(A, 15), - new GridResourceImpl(B, 20) + new GridResourceImpl(D), + new GridResourceImpl(A), + new GridResourceImpl(B) ); view.setPreventSorting(true); @@ -455,18 +479,18 @@ void shouldNotReorderExistingResourceWhenPerformingPartialRemovalAndPreventingSo verify(listener, never()).run(); assertThat(view.getViewList()).usingRecursiveFieldByFieldElementComparator().containsExactly( - new GridResourceImpl(D, 10), - new GridResourceImpl(A, 15), - new GridResourceImpl(B, 13) + new GridResourceImpl(D), + new GridResourceImpl(A), + new GridResourceImpl(B) ); view.setPreventSorting(false); view.sort(); assertThat(view.getViewList()).usingRecursiveFieldByFieldElementComparator().containsExactly( - new GridResourceImpl(D, 10), - new GridResourceImpl(B, 13), - new GridResourceImpl(A, 15) + new GridResourceImpl(D), + new GridResourceImpl(B), + new GridResourceImpl(A) ); } @@ -489,8 +513,8 @@ void shouldRemoveExistingResourceCompletely() { // Assert assertThat(view.getViewList()).usingRecursiveFieldByFieldElementComparator().containsExactly( - new GridResourceImpl(D, 10), - new GridResourceImpl(A, 15) + new GridResourceImpl(D), + new GridResourceImpl(A) ); assertThat(view.copyBackingList().getAll()) .usingRecursiveFieldByFieldElementComparator() @@ -499,6 +523,9 @@ void shouldRemoveExistingResourceCompletely() { new ResourceAmount(A, 15) ); verify(listener, times(1)).run(); + assertThat(view.getAmount(A)).isEqualTo(15); + assertThat(view.getAmount(B)).isZero(); + assertThat(view.getAmount(D)).isEqualTo(10); } @Test @@ -517,9 +544,9 @@ void shouldNotReorderWhenRemovingExistingResourceCompletelyAndPreventingSorting( // Act & assert assertThat(view.getViewList()).usingRecursiveFieldByFieldElementComparator().containsExactly( - new GridResourceImpl(D, 10), - new GridResourceImpl(A, 15), - new GridResourceImpl(B, 20) + new GridResourceImpl(D), + new GridResourceImpl(A), + new GridResourceImpl(B) ); view.setPreventSorting(true); @@ -527,9 +554,9 @@ void shouldNotReorderWhenRemovingExistingResourceCompletelyAndPreventingSorting( verify(listener, never()).run(); assertThat(view.getViewList()).usingRecursiveFieldByFieldElementComparator().containsExactly( - new GridResourceImpl(D, 10), - new GridResourceImpl(A, 15), - new GridResourceImpl(B, 20).zeroed() + new GridResourceImpl(D), + new GridResourceImpl(A), + new GridResourceImpl(B).zeroed() ); assertThat(view.copyBackingList().getAll()) .usingRecursiveFieldByFieldElementComparator() @@ -542,8 +569,8 @@ void shouldNotReorderWhenRemovingExistingResourceCompletelyAndPreventingSorting( view.sort(); assertThat(view.getViewList()).usingRecursiveFieldByFieldElementComparator().containsExactly( - new GridResourceImpl(D, 10), - new GridResourceImpl(A, 15) + new GridResourceImpl(D), + new GridResourceImpl(A) ); assertThat(view.copyBackingList().getAll()) .usingRecursiveFieldByFieldElementComparator() @@ -569,9 +596,9 @@ void shouldReuseExistingResourceWhenPreventingSortingAndRemovingExistingResource // Act & assert assertThat(view.getViewList()).usingRecursiveFieldByFieldElementComparator().containsExactly( - new GridResourceImpl(D, 10), - new GridResourceImpl(A, 15), - new GridResourceImpl(B, 20) + new GridResourceImpl(D), + new GridResourceImpl(A), + new GridResourceImpl(B) ); // Delete the item @@ -580,9 +607,9 @@ void shouldReuseExistingResourceWhenPreventingSortingAndRemovingExistingResource verify(listener, never()).run(); assertThat(view.getViewList()).usingRecursiveFieldByFieldElementComparator().containsExactly( - new GridResourceImpl(D, 10), - new GridResourceImpl(A, 15), - new GridResourceImpl(B, 20).zeroed() + new GridResourceImpl(D), + new GridResourceImpl(A), + new GridResourceImpl(B).zeroed() ); // Re-insert the item @@ -590,9 +617,9 @@ void shouldReuseExistingResourceWhenPreventingSortingAndRemovingExistingResource verify(listener, never()).run(); assertThat(view.getViewList()).usingRecursiveFieldByFieldElementComparator().containsExactly( - new GridResourceImpl(D, 10), - new GridResourceImpl(A, 15), - new GridResourceImpl(B, 5) + new GridResourceImpl(D), + new GridResourceImpl(A), + new GridResourceImpl(B) ); // Re-insert the item again @@ -600,9 +627,9 @@ void shouldReuseExistingResourceWhenPreventingSortingAndRemovingExistingResource verify(listener, never()).run(); assertThat(view.getViewList()).usingRecursiveFieldByFieldElementComparator().containsExactly( - new GridResourceImpl(D, 10), - new GridResourceImpl(A, 15), - new GridResourceImpl(B, 8) + new GridResourceImpl(D), + new GridResourceImpl(A), + new GridResourceImpl(B) ); } @@ -624,14 +651,17 @@ void shouldClear() { assertThat(view.getTrackedResource(A)).isEmpty(); assertThat(view.getTrackedResource(B)).isEmpty(); assertThat(view.getTrackedResource(D)).isEmpty(); + assertThat(view.getAmount(A)).isZero(); + assertThat(view.getAmount(B)).isZero(); + assertThat(view.getAmount(D)).isZero(); } private record ResourceWithMetadata(ResourceKey resource, int metadata) implements ResourceKey { } private static class GridResourceWithMetadata extends GridResourceImpl { - GridResourceWithMetadata(final ResourceAmount resourceAmount) { - super(resourceAmount); + GridResourceWithMetadata(final ResourceKey resource) { + super(resource); } } } From 890903bc81856bd915f841cc346f4a6b49301d2c Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Sat, 3 Aug 2024 12:04:11 +0200 Subject: [PATCH 16/36] refactor: fuzzy resource list no longer stores ResourceAmount references --- .../api/storage/root/FuzzyRootStorage.java | 3 +- .../resource/list/FuzzyResourceList.java | 2 +- .../detector/FuzzyDetectorAmountStrategy.java | 1 + .../FuzzyExporterTransferStrategy.java | 8 +- .../iface/ExportedResourcesContainer.java | 7 +- .../StorageMonitorBlockEntity.java | 6 +- .../PlatformStorageNetworkComponent.java | 3 +- .../resource/list/FuzzyResourceListImpl.java | 19 +++-- .../list/FuzzyResourceListImplTest.java | 73 +++++++++---------- 9 files changed, 56 insertions(+), 66 deletions(-) diff --git a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/storage/root/FuzzyRootStorage.java b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/storage/root/FuzzyRootStorage.java index 9f6f516b3..74ad368b4 100644 --- a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/storage/root/FuzzyRootStorage.java +++ b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/storage/root/FuzzyRootStorage.java @@ -1,6 +1,5 @@ package com.refinedmods.refinedstorage.common.api.storage.root; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.api.storage.root.RootStorage; @@ -10,5 +9,5 @@ @API(status = API.Status.STABLE, since = "2.0.0-milestone.2.4") public interface FuzzyRootStorage extends RootStorage { - Collection getFuzzy(ResourceKey resource); + Collection getFuzzy(ResourceKey resource); } diff --git a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/list/FuzzyResourceList.java b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/list/FuzzyResourceList.java index 0842d3181..f88a252b2 100644 --- a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/list/FuzzyResourceList.java +++ b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/list/FuzzyResourceList.java @@ -17,5 +17,5 @@ public interface FuzzyResourceList extends ResourceList { * @param resource the resource, doesn't matter if it's normalized or not * @return a list of fuzzy matched variants, or empty list if none found */ - Collection getFuzzy(ResourceKey resource); + Collection getFuzzy(ResourceKey resource); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/detector/FuzzyDetectorAmountStrategy.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/detector/FuzzyDetectorAmountStrategy.java index f6745d320..4eeab01b6 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/detector/FuzzyDetectorAmountStrategy.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/detector/FuzzyDetectorAmountStrategy.java @@ -23,6 +23,7 @@ public long getAmount(final Network network, final ResourceKey configuredResourc } return fuzzyRootStorage.getFuzzy(configuredResource) .stream() + .flatMap(resource -> rootStorage.get(resource).stream()) .mapToLong(ResourceAmount::getAmount) .sum(); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/exporter/FuzzyExporterTransferStrategy.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/exporter/FuzzyExporterTransferStrategy.java index 0c9d5db4c..1b160d739 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/exporter/FuzzyExporterTransferStrategy.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/exporter/FuzzyExporterTransferStrategy.java @@ -1,14 +1,12 @@ package com.refinedmods.refinedstorage.common.exporter; import com.refinedmods.refinedstorage.api.network.impl.node.exporter.ExporterTransferStrategyImpl; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.api.storage.InsertableStorage; import com.refinedmods.refinedstorage.api.storage.root.RootStorage; import com.refinedmods.refinedstorage.common.api.storage.root.FuzzyRootStorage; import java.util.Collection; -import java.util.stream.Collectors; public class FuzzyExporterTransferStrategy extends ExporterTransferStrategyImpl { public FuzzyExporterTransferStrategy(final InsertableStorage destination, final long transferQuota) { @@ -18,11 +16,7 @@ public FuzzyExporterTransferStrategy(final InsertableStorage destination, final @Override protected Collection expand(final ResourceKey resource, final RootStorage rootStorage) { if (rootStorage instanceof FuzzyRootStorage fuzzyRootStorage) { - return fuzzyRootStorage - .getFuzzy(resource) - .stream() - .map(ResourceAmount::getResource) - .collect(Collectors.toSet()); + return fuzzyRootStorage.getFuzzy(resource); } return super.expand(resource, rootStorage); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/iface/ExportedResourcesContainer.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/iface/ExportedResourcesContainer.java index afff56c66..b1df46029 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/iface/ExportedResourcesContainer.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/iface/ExportedResourcesContainer.java @@ -12,7 +12,6 @@ import java.util.Collection; import java.util.Collections; -import java.util.stream.Collectors; import javax.annotation.Nullable; public class ExportedResourcesContainer extends ResourceContainerImpl implements InterfaceExportState { @@ -42,11 +41,7 @@ public Collection expandExportCandidates(final RootStorage rootStor if (!(rootStorage instanceof FuzzyRootStorage fuzzyRootStorage)) { return Collections.singletonList(resource); } - return fuzzyRootStorage - .getFuzzy(resource) - .stream() - .map(ResourceAmount::getResource) - .collect(Collectors.toSet()); + return fuzzyRootStorage.getFuzzy(resource); } @Override diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storagemonitor/StorageMonitorBlockEntity.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storagemonitor/StorageMonitorBlockEntity.java index 443fd19d2..5a07d4a1f 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storagemonitor/StorageMonitorBlockEntity.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storagemonitor/StorageMonitorBlockEntity.java @@ -104,7 +104,11 @@ private long getAmount(final Network network, final ResourceKey configuredResour if (!filter.isFuzzyMode() || !(rootStorage instanceof FuzzyRootStorage fuzzyRootStorage)) { return rootStorage.get(configuredResource).map(ResourceAmount::getAmount).orElse(0L); } - return fuzzyRootStorage.getFuzzy(configuredResource).stream().mapToLong(ResourceAmount::getAmount).sum(); + return fuzzyRootStorage.getFuzzy(configuredResource) + .stream() + .flatMap(resource -> rootStorage.get(resource).stream()) + .mapToLong(ResourceAmount::getAmount) + .sum(); } public void extract(final Player player) { diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/network/component/PlatformStorageNetworkComponent.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/network/component/PlatformStorageNetworkComponent.java index 0ed1f5fd8..fffbad02c 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/network/component/PlatformStorageNetworkComponent.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/network/component/PlatformStorageNetworkComponent.java @@ -1,7 +1,6 @@ package com.refinedmods.refinedstorage.common.support.network.component; import com.refinedmods.refinedstorage.api.network.impl.storage.StorageNetworkComponentImpl; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; import com.refinedmods.refinedstorage.common.api.storage.root.FuzzyRootStorage; @@ -23,7 +22,7 @@ private PlatformStorageNetworkComponent(final FuzzyResourceList fuzzyResourceLis } @Override - public Collection getFuzzy(final ResourceKey resource) { + public Collection getFuzzy(final ResourceKey resource) { return fuzzyResourceList.getFuzzy(resource); } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImpl.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImpl.java index ad6eb1bff..2df754611 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImpl.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImpl.java @@ -1,6 +1,5 @@ package com.refinedmods.refinedstorage.common.support.resource.list; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.api.resource.list.AbstractProxyResourceList; import com.refinedmods.refinedstorage.api.resource.list.ResourceList; @@ -16,7 +15,7 @@ import java.util.Set; public class FuzzyResourceListImpl extends AbstractProxyResourceList implements FuzzyResourceList { - private final Map> normalizedFuzzyMap = new HashMap<>(); + private final Map> normalizedFuzzyMap = new HashMap<>(); public FuzzyResourceListImpl(final ResourceList delegate) { super(delegate); @@ -32,7 +31,7 @@ public OperationResult add(final ResourceKey resource, final long amount) { private void addToIndex(final ResourceKey resource, final OperationResult result) { if (resource instanceof FuzzyModeNormalizer normalizer) { normalizedFuzzyMap.computeIfAbsent(normalizer.normalize(), k -> new HashSet<>()) - .add(result.resourceAmount()); + .add(result.resourceAmount().getResource()); } } @@ -51,21 +50,25 @@ private void removeFromIndex(final ResourceKey resource, final OperationResult r return; } final ResourceKey normalized = normalizer.normalize(); - final Collection index = normalizedFuzzyMap.get(normalized); + final Collection index = normalizedFuzzyMap.get(normalized); if (index == null) { return; } - index.remove(result.resourceAmount()); + index.remove(result.resourceAmount().getResource()); if (index.isEmpty()) { normalizedFuzzyMap.remove(normalized); } } @Override - public Collection getFuzzy(final ResourceKey resource) { + public Collection getFuzzy(final ResourceKey resource) { if (resource instanceof FuzzyModeNormalizer normalizer) { - return normalizedFuzzyMap.getOrDefault(normalizer.normalize(), Collections.emptySet()); + return Collections.unmodifiableCollection( + normalizedFuzzyMap.getOrDefault(normalizer.normalize(), Collections.emptySet()) + ); } - return normalizedFuzzyMap.getOrDefault(resource, Collections.emptySet()); + return Collections.unmodifiableCollection( + normalizedFuzzyMap.getOrDefault(resource, Collections.emptySet()) + ); } } diff --git a/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImplTest.java b/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImplTest.java index d067faa78..ac3a1d064 100644 --- a/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImplTest.java +++ b/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImplTest.java @@ -1,6 +1,7 @@ package com.refinedmods.refinedstorage.common.support.resource.list; import com.refinedmods.refinedstorage.api.resource.ResourceAmount; +import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; import com.refinedmods.refinedstorage.common.SetupMinecraft; import com.refinedmods.refinedstorage.common.api.support.resource.list.FuzzyResourceList; @@ -58,11 +59,11 @@ void testRetrievingFuzzy() { final Optional strictD = sut.get(DUMMY_D); final Optional strictE = sut.get(DUMMY_E); - final Collection fuzzyA = sut.getFuzzy(DUMMY_A); - final Collection fuzzyB = sut.getFuzzy(DUMMY_B); - final Collection fuzzyC = sut.getFuzzy(DUMMY_C); - final Collection fuzzyD = sut.getFuzzy(DUMMY_D); - final Collection fuzzyE = sut.getFuzzy(DUMMY_E); + final Collection fuzzyA = sut.getFuzzy(DUMMY_A); + final Collection fuzzyB = sut.getFuzzy(DUMMY_B); + final Collection fuzzyC = sut.getFuzzy(DUMMY_C); + final Collection fuzzyD = sut.getFuzzy(DUMMY_D); + final Collection fuzzyE = sut.getFuzzy(DUMMY_E); // Assert assertThat(strictA).get().usingRecursiveComparison().isEqualTo(new ResourceAmount(DUMMY_A, 1)); @@ -72,23 +73,21 @@ void testRetrievingFuzzy() { assertThat(strictE).isNotPresent(); assertThat(fuzzyA).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( - new ResourceAmount(DUMMY_A, 1), - new ResourceAmount(DUMMY_B, 15), - new ResourceAmount(DUMMY_C, 20) + DUMMY_A, + DUMMY_B, + DUMMY_C ); assertThat(fuzzyB).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( - new ResourceAmount(DUMMY_A, 1), - new ResourceAmount(DUMMY_B, 15), - new ResourceAmount(DUMMY_C, 20) + DUMMY_A, + DUMMY_B, + DUMMY_C ); assertThat(fuzzyC).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( - new ResourceAmount(DUMMY_A, 1), - new ResourceAmount(DUMMY_B, 15), - new ResourceAmount(DUMMY_C, 20) - ); - assertThat(fuzzyD).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( - new ResourceAmount(DUMMY_D, 25) + DUMMY_A, + DUMMY_B, + DUMMY_C ); + assertThat(fuzzyD).usingRecursiveFieldByFieldElementComparator().containsExactly(DUMMY_D); assertThat(fuzzyE).isEmpty(); } @@ -116,11 +115,11 @@ void shouldRemoveEntireResourceFromFuzzyIndexAfterRemoval() { final Optional strictD = sut.get(DUMMY_D); final Optional strictE = sut.get(DUMMY_E); - final Collection fuzzyA = sut.getFuzzy(DUMMY_A); - final Collection fuzzyB = sut.getFuzzy(DUMMY_B); - final Collection fuzzyC = sut.getFuzzy(DUMMY_C); - final Collection fuzzyD = sut.getFuzzy(DUMMY_D); - final Collection fuzzyE = sut.getFuzzy(DUMMY_E); + final Collection fuzzyA = sut.getFuzzy(DUMMY_A); + final Collection fuzzyB = sut.getFuzzy(DUMMY_B); + final Collection fuzzyC = sut.getFuzzy(DUMMY_C); + final Collection fuzzyD = sut.getFuzzy(DUMMY_D); + final Collection fuzzyE = sut.getFuzzy(DUMMY_E); // Assert assertThat(strictA).isNotPresent(); @@ -132,9 +131,7 @@ void shouldRemoveEntireResourceFromFuzzyIndexAfterRemoval() { assertThat(fuzzyA).isEmpty(); assertThat(fuzzyB).isEmpty(); assertThat(fuzzyC).isEmpty(); - assertThat(fuzzyD).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( - new ResourceAmount(DUMMY_D, 25) - ); + assertThat(fuzzyD).usingRecursiveFieldByFieldElementComparator().containsExactly(DUMMY_D); assertThat(fuzzyE).isEmpty(); } @@ -160,11 +157,11 @@ void shouldRemoveSingleResourceFromFuzzyIndexAfterRemoval() { final Optional strictD = sut.get(DUMMY_D); final Optional strictE = sut.get(DUMMY_E); - final Collection fuzzyA = sut.getFuzzy(DUMMY_A); - final Collection fuzzyB = sut.getFuzzy(DUMMY_B); - final Collection fuzzyC = sut.getFuzzy(DUMMY_C); - final Collection fuzzyD = sut.getFuzzy(DUMMY_D); - final Collection fuzzyE = sut.getFuzzy(DUMMY_E); + final Collection fuzzyA = sut.getFuzzy(DUMMY_A); + final Collection fuzzyB = sut.getFuzzy(DUMMY_B); + final Collection fuzzyC = sut.getFuzzy(DUMMY_C); + final Collection fuzzyD = sut.getFuzzy(DUMMY_D); + final Collection fuzzyE = sut.getFuzzy(DUMMY_E); // Assert assertThat(strictA).isNotPresent(); @@ -174,20 +171,18 @@ void shouldRemoveSingleResourceFromFuzzyIndexAfterRemoval() { assertThat(strictE).isNotPresent(); assertThat(fuzzyA).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( - new ResourceAmount(DUMMY_B, 15), - new ResourceAmount(DUMMY_C, 20) + DUMMY_B, + DUMMY_C ); assertThat(fuzzyB).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( - new ResourceAmount(DUMMY_B, 15), - new ResourceAmount(DUMMY_C, 20) + DUMMY_B, + DUMMY_C ); assertThat(fuzzyC).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( - new ResourceAmount(DUMMY_B, 15), - new ResourceAmount(DUMMY_C, 20) - ); - assertThat(fuzzyD).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( - new ResourceAmount(DUMMY_D, 25) + DUMMY_B, + DUMMY_C ); + assertThat(fuzzyD).usingRecursiveFieldByFieldElementComparator().containsExactly(DUMMY_D); assertThat(fuzzyE).isEmpty(); } } From b21b7cd2d82d488ef8b9817fb392efc798871133 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Sat, 3 Aug 2024 12:15:39 +0200 Subject: [PATCH 17/36] feat: add ability to retrieve amount of a resource In ResourceList and RootStorage. --- .../list/AbstractProxyResourceList.java | 5 ++++ .../api/resource/list/ResourceList.java | 6 +++++ .../api/resource/list/ResourceListImpl.java | 6 +++++ .../list/AbstractResourceListTest.java | 23 +++++++++++++++++++ .../api/storage/root/RootStorage.java | 6 +++++ .../api/storage/root/RootStorageImpl.java | 5 ++++ .../api/storage/root/RootStorageImplTest.java | 20 +++++++++++++--- 7 files changed, 68 insertions(+), 3 deletions(-) diff --git a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/AbstractProxyResourceList.java b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/AbstractProxyResourceList.java index c7c6cd581..88d78a884 100644 --- a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/AbstractProxyResourceList.java +++ b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/AbstractProxyResourceList.java @@ -39,6 +39,11 @@ public Collection getAll() { return delegate.getAll(); } + @Override + public long getAmount(final ResourceKey resource) { + return delegate.getAmount(resource); + } + @Override public void clear() { delegate.clear(); diff --git a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java index 7249e2a40..2c616efed 100644 --- a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java +++ b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java @@ -71,6 +71,12 @@ default Optional remove(ResourceAmount resourceAmount) { */ Collection getAll(); + /** + * @param resource the resource + * @return the amount stored, or zero if not stored + */ + long getAmount(ResourceKey resource); + /** * Clears the list. */ diff --git a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java index 42aaae19a..d41ef83c2 100644 --- a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java +++ b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java @@ -95,6 +95,12 @@ public Collection getAll() { return entries.values(); } + @Override + public long getAmount(final ResourceKey resource) { + final ResourceAmount entry = entries.get(resource); + return entry != null ? entry.getAmount() : 0; + } + @Override public void clear() { entries.clear(); diff --git a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractResourceListTest.java b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractResourceListTest.java index 78e10ca3e..8b9a31d8e 100644 --- a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractResourceListTest.java +++ b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractResourceListTest.java @@ -38,6 +38,7 @@ void shouldAddNewResource() { assertThat(list.getAll()).usingRecursiveFieldByFieldElementComparator().containsExactly( new ResourceAmount(TestResource.A, 10) ); + assertThat(list.getAmount(TestResource.A)).isEqualTo(10); } @Test @@ -54,6 +55,7 @@ void shouldAddNewResourceWithResourceAmountDirectly() { assertThat(list.getAll()).usingRecursiveFieldByFieldElementComparator().containsExactly( new ResourceAmount(TestResource.A, 10) ); + assertThat(list.getAmount(TestResource.A)).isEqualTo(10); } @Test @@ -76,6 +78,7 @@ void shouldAddMultipleOfSameResource() { assertThat(list.getAll()).usingRecursiveFieldByFieldElementComparator().containsExactly( new ResourceAmount(TestResource.A, 15) ); + assertThat(list.getAmount(TestResource.A)).isEqualTo(15); } @Test @@ -105,6 +108,8 @@ void shouldAddMultipleOfDifferentResources() { new ResourceAmount(TestResource.A, 15), new ResourceAmount(TestResource.B, 3) ); + assertThat(list.getAmount(TestResource.A)).isEqualTo(15); + assertThat(list.getAmount(TestResource.B)).isEqualTo(3); } @Test @@ -150,6 +155,9 @@ void shouldRemoveResourcePartly() { new ResourceAmount(TestResource.A, 15), new ResourceAmount(TestResource.B, 6) ); + + assertThat(list.getAmount(TestResource.A)).isEqualTo(15); + assertThat(list.getAmount(TestResource.B)).isEqualTo(6); } @Test @@ -175,6 +183,9 @@ void shouldRemoveResourcePartlyWithResourceAmountDirectly() { new ResourceAmount(TestResource.A, 15), new ResourceAmount(TestResource.B, 6) ); + + assertThat(list.getAmount(TestResource.A)).isEqualTo(15); + assertThat(list.getAmount(TestResource.B)).isEqualTo(6); } @Test @@ -196,6 +207,9 @@ void shouldRemoveResourceCompletely() { assertThat(list.getAll()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( new ResourceAmount(TestResource.B, 6) ); + + assertThat(list.getAmount(TestResource.A)).isEqualTo(0); + assertThat(list.getAmount(TestResource.B)).isEqualTo(6); } @Test @@ -220,6 +234,9 @@ void shouldRemoveResourceCompletelyWithResourceAmountDirectly() { assertThat(list.getAll()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( new ResourceAmount(TestResource.B, 6) ); + + assertThat(list.getAmount(TestResource.A)).isEqualTo(0); + assertThat(list.getAmount(TestResource.B)).isEqualTo(6); } @Test @@ -241,6 +258,9 @@ void shouldNotRemoveResourceWithMoreThanIsAvailable() { assertThat(list.getAll()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( new ResourceAmount(TestResource.B, 6) ); + + assertThat(list.getAmount(TestResource.A)).isZero(); + assertThat(list.getAmount(TestResource.B)).isEqualTo(6); } @Test @@ -315,5 +335,8 @@ void shouldClearList() { assertThat(contentsBeforeClear).hasSize(2); assertThat(contentsAfterClear).isEmpty(); + + assertThat(list.getAmount(TestResource.A)).isZero(); + assertThat(list.getAmount(TestResource.B)).isZero(); } } diff --git a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorage.java b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorage.java index 7a5920523..70be790a6 100644 --- a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorage.java +++ b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorage.java @@ -38,6 +38,12 @@ public interface RootStorage extends Storage, TrackedStorage { */ Optional get(ResourceKey resource); + /** + * @param resource the resource + * @return the amount stored, or zero if not stored + */ + long getAmount(ResourceKey resource); + /** * Sorts the sources in the backing storage. */ diff --git a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImpl.java b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImpl.java index c38172f67..187381bc1 100644 --- a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImpl.java +++ b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImpl.java @@ -67,6 +67,11 @@ public Optional get(final ResourceKey resource) { return list.get(resource); } + @Override + public long getAmount(final ResourceKey resource) { + return list.getAmount(resource); + } + @Override public long extract(final ResourceKey resource, final long amount, final Action action, final Actor actor) { return storage.extract(resource, amount, action, actor); diff --git a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImplTest.java b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImplTest.java index 67896ab94..5f8a39c6b 100644 --- a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImplTest.java +++ b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImplTest.java @@ -211,7 +211,7 @@ void shouldExtract() { } @Test - void shouldBeAbleToRetrieveResource() { + void shouldRetrieveResource() { // Arrange final Storage storage = new LimitedStorageImpl(100); storage.insert(A, 50, Action.EXECUTE, EmptyActor.INSTANCE); @@ -227,9 +227,23 @@ void shouldBeAbleToRetrieveResource() { assertThat(sut.findTrackedResourceByActorType(A, EmptyActor.class)).isEmpty(); } + @Test + void shouldRetrieveResourceAmount() { + // Arrange + final Storage storage = new LimitedStorageImpl(100); + storage.insert(A, 50, Action.EXECUTE, EmptyActor.INSTANCE); + storage.extract(A, 25, Action.EXECUTE, EmptyActor.INSTANCE); + + sut.addSource(storage); + + // Act & assert + assertThat(sut.getAmount(A)).isEqualTo(25); + assertThat(sut.getAmount(B)).isZero(); + } + @Test @SuppressWarnings("AssertBetweenInconvertibleTypes") - void shouldBeAbleToRetrieveTrackedResource() { + void shouldRetrieveTrackedResource() { // Arrange final Storage storage = new TrackedStorageImpl( new LimitedStorageImpl(100), @@ -253,7 +267,7 @@ void shouldBeAbleToRetrieveTrackedResource() { } @Test - void shouldNotBeAbleToRetrieveNonExistentResource() { + void shouldNotRetrieveNonExistentResource() { // Arrange sut.addSource(new LimitedStorageImpl(100)); From db62e7b9340b2fbb9165804310f420f61aa43fa0 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Sat, 3 Aug 2024 12:49:25 +0200 Subject: [PATCH 18/36] refactor: add ability to check if a resource exists in storage In RootStorage and ResourceList. Thanks to this we can remove #get in RootStorage and ResourceList. --- .../resource/list/FuzzyResourceList.java | 1 - .../detector/FuzzyDetectorAmountStrategy.java | 4 +- .../grid/CraftingGridContainerMenu.java | 1 - .../common/grid/CraftingGridSourceImpl.java | 7 +- .../SnapshotCraftingGridRefillContext.java | 9 ++- .../StorageMonitorBlockEntity.java | 6 +- .../list/FuzzyResourceListImplTest.java | 65 +++++++++---------- .../grid/operations/GridOperationsImpl.java | 3 +- .../api/grid/view/GridViewImpl.java | 2 +- .../detector/DetectorAmountStrategyImpl.java | 6 +- .../node/iface/InterfaceExportStateImpl.java | 4 +- .../list/AbstractProxyResourceList.java | 10 +-- .../api/resource/list/ResourceList.java | 14 ++-- .../api/resource/list/ResourceListImpl.java | 10 +-- .../list/AbstractResourceListTest.java | 61 +++++------------ .../api/storage/InMemoryStorageImpl.java | 14 ++-- .../api/storage/external/ExternalStorage.java | 14 ++-- .../api/storage/root/RootStorage.java | 12 ++-- .../api/storage/root/RootStorageImpl.java | 8 +-- .../api/storage/root/RootStorageImplTest.java | 31 ++------- 20 files changed, 104 insertions(+), 178 deletions(-) diff --git a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/list/FuzzyResourceList.java b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/list/FuzzyResourceList.java index f88a252b2..082e82808 100644 --- a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/list/FuzzyResourceList.java +++ b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/list/FuzzyResourceList.java @@ -1,6 +1,5 @@ package com.refinedmods.refinedstorage.common.api.support.resource.list; -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.common.api.support.resource.FuzzyModeNormalizer; diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/detector/FuzzyDetectorAmountStrategy.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/detector/FuzzyDetectorAmountStrategy.java index 4eeab01b6..4ce64d0b4 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/detector/FuzzyDetectorAmountStrategy.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/detector/FuzzyDetectorAmountStrategy.java @@ -3,7 +3,6 @@ import com.refinedmods.refinedstorage.api.network.Network; import com.refinedmods.refinedstorage.api.network.impl.node.detector.AbstractDetectorAmountStrategy; import com.refinedmods.refinedstorage.api.network.impl.node.detector.DetectorAmountStrategy; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.api.storage.root.RootStorage; import com.refinedmods.refinedstorage.common.api.storage.root.FuzzyRootStorage; @@ -23,8 +22,7 @@ public long getAmount(final Network network, final ResourceKey configuredResourc } return fuzzyRootStorage.getFuzzy(configuredResource) .stream() - .flatMap(resource -> rootStorage.get(resource).stream()) - .mapToLong(ResourceAmount::getAmount) + .mapToLong(rootStorage::getAmount) .sum(); } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridContainerMenu.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridContainerMenu.java index 3835530bb..5155a8448 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridContainerMenu.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridContainerMenu.java @@ -17,7 +17,6 @@ import java.util.Set; import java.util.function.BiPredicate; import java.util.function.Consumer; -import java.util.function.Predicate; import javax.annotation.Nullable; import net.minecraft.world.Container; diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridSourceImpl.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridSourceImpl.java index 08f3ade93..f3ff2e2b8 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridSourceImpl.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridSourceImpl.java @@ -1,7 +1,6 @@ package com.refinedmods.refinedstorage.common.grid; import com.refinedmods.refinedstorage.api.network.storage.StorageNetworkComponent; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.resource.list.ResourceList; import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; import com.refinedmods.refinedstorage.common.support.CraftingMatrix; @@ -151,10 +150,6 @@ private void addPlayerInventoryItemsIntoList(final Player player, final Resource } private Comparator sortByHighestAvailableFirst(final ResourceList available) { - return Comparator.comparingLong(resource -> getAvailableAmount(available, resource)).reversed(); - } - - private long getAvailableAmount(final ResourceList available, final ItemResource resource) { - return available.get(resource).map(ResourceAmount::getAmount).orElse(0L); + return Comparator.comparingLong(available::getAmount).reversed(); } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/SnapshotCraftingGridRefillContext.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/SnapshotCraftingGridRefillContext.java index 2aae5c9e4..eabaa86c6 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/SnapshotCraftingGridRefillContext.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/SnapshotCraftingGridRefillContext.java @@ -49,15 +49,18 @@ private void addAvailableItem(final RootStorage rootStorage, final ItemStack craftingMatrixStack) { final ItemResource craftingMatrixResource = ItemResource.ofItemStack(craftingMatrixStack); // a single resource can occur multiple times in a recipe, only add it once - if (available.get(craftingMatrixResource).isEmpty()) { - rootStorage.get(craftingMatrixResource).ifPresent(available::add); + if (!available.contains(craftingMatrixResource)) { + final long amount = rootStorage.getAmount(craftingMatrixResource); + if (amount > 0) { + available.add(craftingMatrixResource, amount); + } } } @Override public boolean extract(final ItemResource resource, final Player player) { return blockEntity.getNetwork().map(network -> { - final boolean isAvailable = available.get(resource).isPresent(); + final boolean isAvailable = available.contains(resource); if (isAvailable) { available.remove(resource, 1); used.add(resource, 1); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storagemonitor/StorageMonitorBlockEntity.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storagemonitor/StorageMonitorBlockEntity.java index 5a07d4a1f..afcd1e870 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storagemonitor/StorageMonitorBlockEntity.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storagemonitor/StorageMonitorBlockEntity.java @@ -3,7 +3,6 @@ import com.refinedmods.refinedstorage.api.network.Network; import com.refinedmods.refinedstorage.api.network.impl.node.SimpleNetworkNode; 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.storage.root.RootStorage; import com.refinedmods.refinedstorage.common.Platform; @@ -102,12 +101,11 @@ private long getAmount() { private long getAmount(final Network network, final ResourceKey configuredResource) { final RootStorage rootStorage = network.getComponent(StorageNetworkComponent.class); if (!filter.isFuzzyMode() || !(rootStorage instanceof FuzzyRootStorage fuzzyRootStorage)) { - return rootStorage.get(configuredResource).map(ResourceAmount::getAmount).orElse(0L); + return rootStorage.getAmount(configuredResource); } return fuzzyRootStorage.getFuzzy(configuredResource) .stream() - .flatMap(resource -> rootStorage.get(resource).stream()) - .mapToLong(ResourceAmount::getAmount) + .mapToLong(rootStorage::getAmount) .sum(); } diff --git a/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImplTest.java b/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImplTest.java index ac3a1d064..88e28b72a 100644 --- a/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImplTest.java +++ b/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImplTest.java @@ -1,6 +1,5 @@ package com.refinedmods.refinedstorage.common.support.resource.list; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.api.resource.list.ResourceListImpl; import com.refinedmods.refinedstorage.common.SetupMinecraft; @@ -8,7 +7,6 @@ import com.refinedmods.refinedstorage.common.support.resource.ItemResource; import java.util.Collection; -import java.util.Optional; import net.minecraft.core.component.DataComponentPatch; import net.minecraft.core.component.DataComponents; @@ -38,7 +36,6 @@ void setUp() { } @Test - @SuppressWarnings("AssertBetweenInconvertibleTypes") void testRetrievingFuzzy() { // Arrange sut.add(DUMMY_A, 5); @@ -53,11 +50,11 @@ void testRetrievingFuzzy() { sut.add(DUMMY_D, 15); // Act - final Optional strictA = sut.get(DUMMY_A); - final Optional strictB = sut.get(DUMMY_B); - final Optional strictC = sut.get(DUMMY_C); - final Optional strictD = sut.get(DUMMY_D); - final Optional strictE = sut.get(DUMMY_E); + final long strictA = sut.getAmount(DUMMY_A); + final long strictB = sut.getAmount(DUMMY_B); + final long strictC = sut.getAmount(DUMMY_C); + final long strictD = sut.getAmount(DUMMY_D); + final long strictE = sut.getAmount(DUMMY_E); final Collection fuzzyA = sut.getFuzzy(DUMMY_A); final Collection fuzzyB = sut.getFuzzy(DUMMY_B); @@ -66,11 +63,11 @@ void testRetrievingFuzzy() { final Collection fuzzyE = sut.getFuzzy(DUMMY_E); // Assert - assertThat(strictA).get().usingRecursiveComparison().isEqualTo(new ResourceAmount(DUMMY_A, 1)); - assertThat(strictB).get().usingRecursiveComparison().isEqualTo(new ResourceAmount(DUMMY_B, 15)); - assertThat(strictC).get().usingRecursiveComparison().isEqualTo(new ResourceAmount(DUMMY_C, 20)); - assertThat(strictD).get().usingRecursiveComparison().isEqualTo(new ResourceAmount(DUMMY_D, 25)); - assertThat(strictE).isNotPresent(); + assertThat(strictA).isEqualTo(1); + assertThat(strictB).isEqualTo(15); + assertThat(strictC).isEqualTo(20); + assertThat(strictD).isEqualTo(25); + assertThat(strictE).isZero(); assertThat(fuzzyA).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( DUMMY_A, @@ -92,7 +89,6 @@ void testRetrievingFuzzy() { } @Test - @SuppressWarnings("AssertBetweenInconvertibleTypes") void shouldRemoveEntireResourceFromFuzzyIndexAfterRemoval() { // Arrange sut.add(DUMMY_A, 5); @@ -109,11 +105,11 @@ void shouldRemoveEntireResourceFromFuzzyIndexAfterRemoval() { sut.add(DUMMY_D, 15); // Act - final Optional strictA = sut.get(DUMMY_A); - final Optional strictB = sut.get(DUMMY_B); - final Optional strictC = sut.get(DUMMY_C); - final Optional strictD = sut.get(DUMMY_D); - final Optional strictE = sut.get(DUMMY_E); + final long strictA = sut.getAmount(DUMMY_A); + final long strictB = sut.getAmount(DUMMY_B); + final long strictC = sut.getAmount(DUMMY_C); + final long strictD = sut.getAmount(DUMMY_D); + final long strictE = sut.getAmount(DUMMY_E); final Collection fuzzyA = sut.getFuzzy(DUMMY_A); final Collection fuzzyB = sut.getFuzzy(DUMMY_B); @@ -122,11 +118,11 @@ void shouldRemoveEntireResourceFromFuzzyIndexAfterRemoval() { final Collection fuzzyE = sut.getFuzzy(DUMMY_E); // Assert - assertThat(strictA).isNotPresent(); - assertThat(strictB).isNotPresent(); - assertThat(strictC).isNotPresent(); - assertThat(strictD).get().usingRecursiveComparison().isEqualTo(new ResourceAmount(DUMMY_D, 25)); - assertThat(strictE).isNotPresent(); + assertThat(strictA).isZero(); + assertThat(strictB).isZero(); + assertThat(strictC).isZero(); + assertThat(strictD).isEqualTo(25); + assertThat(strictE).isZero(); assertThat(fuzzyA).isEmpty(); assertThat(fuzzyB).isEmpty(); @@ -136,7 +132,6 @@ void shouldRemoveEntireResourceFromFuzzyIndexAfterRemoval() { } @Test - @SuppressWarnings("AssertBetweenInconvertibleTypes") void shouldRemoveSingleResourceFromFuzzyIndexAfterRemoval() { // Arrange sut.add(DUMMY_A, 5); @@ -151,11 +146,11 @@ void shouldRemoveSingleResourceFromFuzzyIndexAfterRemoval() { sut.add(DUMMY_D, 15); // Act - final Optional strictA = sut.get(DUMMY_A); - final Optional strictB = sut.get(DUMMY_B); - final Optional strictC = sut.get(DUMMY_C); - final Optional strictD = sut.get(DUMMY_D); - final Optional strictE = sut.get(DUMMY_E); + final long strictA = sut.getAmount(DUMMY_A); + final long strictB = sut.getAmount(DUMMY_B); + final long strictC = sut.getAmount(DUMMY_C); + final long strictD = sut.getAmount(DUMMY_D); + final long strictE = sut.getAmount(DUMMY_E); final Collection fuzzyA = sut.getFuzzy(DUMMY_A); final Collection fuzzyB = sut.getFuzzy(DUMMY_B); @@ -164,11 +159,11 @@ void shouldRemoveSingleResourceFromFuzzyIndexAfterRemoval() { final Collection fuzzyE = sut.getFuzzy(DUMMY_E); // Assert - assertThat(strictA).isNotPresent(); - assertThat(strictB).get().usingRecursiveComparison().isEqualTo(new ResourceAmount(DUMMY_B, 15)); - assertThat(strictC).get().usingRecursiveComparison().isEqualTo(new ResourceAmount(DUMMY_C, 20)); - assertThat(strictD).get().usingRecursiveComparison().isEqualTo(new ResourceAmount(DUMMY_D, 25)); - assertThat(strictE).isNotPresent(); + assertThat(strictA).isZero(); + assertThat(strictB).isEqualTo(15); + assertThat(strictC).isEqualTo(20); + assertThat(strictD).isEqualTo(25); + assertThat(strictE).isZero(); assertThat(fuzzyA).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( DUMMY_B, diff --git a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/operations/GridOperationsImpl.java b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/operations/GridOperationsImpl.java index d4b1d3476..f79f4e947 100644 --- a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/operations/GridOperationsImpl.java +++ b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/operations/GridOperationsImpl.java @@ -1,6 +1,5 @@ package com.refinedmods.refinedstorage.api.grid.operations; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.api.storage.Actor; import com.refinedmods.refinedstorage.api.storage.ExtractableStorage; @@ -53,7 +52,7 @@ private long getExtractableAmount(final ResourceKey resource, final GridExtractM } private long getExtractableAmount(final ResourceKey resource) { - final long totalSize = rootStorage.get(resource).map(ResourceAmount::getAmount).orElse(0L); + final long totalSize = rootStorage.getAmount(resource); final long maxAmount = maxAmountProvider.applyAsLong(resource); return Math.min(totalSize, maxAmount); } diff --git a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java index b401cf0da..654baa738 100644 --- a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java +++ b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java @@ -96,7 +96,7 @@ public Optional getTrackedResource(final ResourceKey resource) @Override public long getAmount(final ResourceKey resource) { - return backingList.get(resource).map(ResourceAmount::getAmount).orElse(0L); + return backingList.getAmount(resource); } @Override diff --git a/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/detector/DetectorAmountStrategyImpl.java b/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/detector/DetectorAmountStrategyImpl.java index d07e877fe..8f5f5d4c0 100644 --- a/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/detector/DetectorAmountStrategyImpl.java +++ b/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/detector/DetectorAmountStrategyImpl.java @@ -1,15 +1,11 @@ package com.refinedmods.refinedstorage.api.network.impl.node.detector; import com.refinedmods.refinedstorage.api.network.Network; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.resource.ResourceKey; public class DetectorAmountStrategyImpl extends AbstractDetectorAmountStrategy { @Override public long getAmount(final Network network, final ResourceKey configuredResource) { - return getRootStorage(network) - .get(configuredResource) - .map(ResourceAmount::getAmount) - .orElse(0L); + return getRootStorage(network).getAmount(configuredResource); } } diff --git a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/InterfaceExportStateImpl.java b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/InterfaceExportStateImpl.java index 3cdcf0350..7b4843241 100644 --- a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/InterfaceExportStateImpl.java +++ b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/InterfaceExportStateImpl.java @@ -52,10 +52,10 @@ private Collection expandExportCandidates(final RootStorage rootSto final List candidates = new ArrayList<>(); candidates.add(A); // Simulate the behavior from FuzzyRootStorage - if (rootStorage.get(A_ALTERNATIVE).isPresent()) { + if (rootStorage.contains(A_ALTERNATIVE)) { candidates.add(A_ALTERNATIVE); } - if (rootStorage.get(A_ALTERNATIVE2).isPresent()) { + if (rootStorage.contains(A_ALTERNATIVE2)) { candidates.add(A_ALTERNATIVE2); } return candidates; diff --git a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/AbstractProxyResourceList.java b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/AbstractProxyResourceList.java index 88d78a884..dd598776c 100644 --- a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/AbstractProxyResourceList.java +++ b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/AbstractProxyResourceList.java @@ -29,11 +29,6 @@ public Optional remove(final ResourceKey resource, final long a return delegate.remove(resource, amount); } - @Override - public Optional get(final ResourceKey resource) { - return delegate.get(resource); - } - @Override public Collection getAll() { return delegate.getAll(); @@ -44,6 +39,11 @@ public long getAmount(final ResourceKey resource) { return delegate.getAmount(resource); } + @Override + public boolean contains(final ResourceKey resource) { + return delegate.contains(resource); + } + @Override public void clear() { delegate.clear(); diff --git a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java index 2c616efed..5958497f0 100644 --- a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java +++ b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java @@ -56,14 +56,6 @@ default Optional remove(ResourceAmount resourceAmount) { return remove(resourceAmount.getResource(), resourceAmount.getAmount()); } - /** - * Retrieves the resource and its amount from the list, identified by resource. - * - * @param resource the resource - * @return the resource amount if it's present in the list, otherwise an empty {@link Optional} - */ - Optional get(ResourceKey resource); - /** * Retrieves all resources and their amounts from the list. * @@ -77,6 +69,12 @@ default Optional remove(ResourceAmount resourceAmount) { */ long getAmount(ResourceKey resource); + /** + * @param resource the resource + * @return whether the list contains this resource + */ + boolean contains(ResourceKey resource); + /** * Clears the list. */ diff --git a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java index d41ef83c2..55b7ff4c7 100644 --- a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java +++ b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java @@ -85,11 +85,6 @@ private Optional removeCompletely(final ResourceAmount resource )); } - @Override - public Optional get(final ResourceKey resource) { - return Optional.ofNullable(entries.get(resource)); - } - @Override public Collection getAll() { return entries.values(); @@ -101,6 +96,11 @@ public long getAmount(final ResourceKey resource) { return entry != null ? entry.getAmount() : 0; } + @Override + public boolean contains(final ResourceKey resource) { + return entries.containsKey(resource); + } + @Override public void clear() { entries.clear(); diff --git a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractResourceListTest.java b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractResourceListTest.java index 8b9a31d8e..24850fab8 100644 --- a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractResourceListTest.java +++ b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractResourceListTest.java @@ -39,6 +39,7 @@ void shouldAddNewResource() { new ResourceAmount(TestResource.A, 10) ); assertThat(list.getAmount(TestResource.A)).isEqualTo(10); + assertThat(list.contains(TestResource.A)).isTrue(); } @Test @@ -56,6 +57,7 @@ void shouldAddNewResourceWithResourceAmountDirectly() { new ResourceAmount(TestResource.A, 10) ); assertThat(list.getAmount(TestResource.A)).isEqualTo(10); + assertThat(list.contains(TestResource.A)).isTrue(); } @Test @@ -79,6 +81,7 @@ void shouldAddMultipleOfSameResource() { new ResourceAmount(TestResource.A, 15) ); assertThat(list.getAmount(TestResource.A)).isEqualTo(15); + assertThat(list.contains(TestResource.A)).isTrue(); } @Test @@ -109,7 +112,9 @@ void shouldAddMultipleOfDifferentResources() { new ResourceAmount(TestResource.B, 3) ); assertThat(list.getAmount(TestResource.A)).isEqualTo(15); + assertThat(list.contains(TestResource.A)).isTrue(); assertThat(list.getAmount(TestResource.B)).isEqualTo(3); + assertThat(list.contains(TestResource.B)).isTrue(); } @Test @@ -157,7 +162,9 @@ void shouldRemoveResourcePartly() { ); assertThat(list.getAmount(TestResource.A)).isEqualTo(15); + assertThat(list.contains(TestResource.A)).isTrue(); assertThat(list.getAmount(TestResource.B)).isEqualTo(6); + assertThat(list.contains(TestResource.B)).isTrue(); } @Test @@ -185,7 +192,9 @@ void shouldRemoveResourcePartlyWithResourceAmountDirectly() { ); assertThat(list.getAmount(TestResource.A)).isEqualTo(15); + assertThat(list.contains(TestResource.A)).isTrue(); assertThat(list.getAmount(TestResource.B)).isEqualTo(6); + assertThat(list.contains(TestResource.B)).isTrue(); } @Test @@ -208,8 +217,10 @@ void shouldRemoveResourceCompletely() { new ResourceAmount(TestResource.B, 6) ); - assertThat(list.getAmount(TestResource.A)).isEqualTo(0); + assertThat(list.getAmount(TestResource.A)).isZero(); + assertThat(list.contains(TestResource.A)).isFalse(); assertThat(list.getAmount(TestResource.B)).isEqualTo(6); + assertThat(list.contains(TestResource.B)).isTrue(); } @Test @@ -235,8 +246,10 @@ void shouldRemoveResourceCompletelyWithResourceAmountDirectly() { new ResourceAmount(TestResource.B, 6) ); - assertThat(list.getAmount(TestResource.A)).isEqualTo(0); + assertThat(list.getAmount(TestResource.A)).isZero(); + assertThat(list.contains(TestResource.A)).isFalse(); assertThat(list.getAmount(TestResource.B)).isEqualTo(6); + assertThat(list.contains(TestResource.B)).isTrue(); } @Test @@ -260,7 +273,9 @@ void shouldNotRemoveResourceWithMoreThanIsAvailable() { ); assertThat(list.getAmount(TestResource.A)).isZero(); + assertThat(list.contains(TestResource.A)).isFalse(); assertThat(list.getAmount(TestResource.B)).isEqualTo(6); + assertThat(list.contains(TestResource.B)).isTrue(); } @Test @@ -277,48 +292,6 @@ void shouldNotRemoveInvalidResourceOrAmount() { assertThrows(NullPointerException.class, action3); } - @Test - void shouldBeAbleToRetrieveByResourceAfterAdding() { - // Arrange - list.add(TestResource.A, 6); - - // Act - final Optional resourceAmount = list.get(TestResource.A); - - // Assert - assertThat(resourceAmount).isPresent(); - assertThat(resourceAmount.get().getResource()).isEqualTo(TestResource.A); - assertThat(resourceAmount.get().getAmount()).isEqualTo(6); - } - - @Test - void shouldStillBeAbleToRetrieveByResourceWhenRemovingPartly() { - // Arrange - list.add(TestResource.A, 10); - list.remove(TestResource.A, 3); - - // Act - final Optional resourceAmount = list.get(TestResource.A); - - // Assert - assertThat(resourceAmount).isPresent(); - assertThat(resourceAmount.get().getResource()).isEqualTo(TestResource.A); - assertThat(resourceAmount.get().getAmount()).isEqualTo(7); - } - - @Test - void shouldNotBeAbleToRetrieveByResourceWhenRemovingCompletely() { - // Arrange - list.add(TestResource.A, 10); - list.remove(TestResource.A, 10); - - // Act - final Optional resourceAmount = list.get(TestResource.A); - - // Assert - assertThat(resourceAmount).isNotPresent(); - } - @Test void shouldClearList() { // Arrange 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/InMemoryStorageImpl.java index 0d7a9ad77..d2236684b 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/InMemoryStorageImpl.java @@ -29,14 +29,12 @@ public InMemoryStorageImpl() { @Override public long extract(final ResourceKey resource, final long amount, final Action action, final Actor actor) { ResourceAmount.validate(resource, amount); - - return list.get(resource).map(resourceAmount -> { - final long maxExtract = Math.min( - resourceAmount.getAmount(), - amount - ); - return doExtract(resource, maxExtract, action); - }).orElse(0L); + final long availableAmount = list.getAmount(resource); + if (availableAmount == 0) { + return 0; + } + final long maxExtract = Math.min(availableAmount, amount); + return doExtract(resource, maxExtract, action); } private long doExtract(final ResourceKey resource, final long amount, final Action action) { diff --git a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/external/ExternalStorage.java b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/external/ExternalStorage.java index 96694ff2f..df3989a3f 100644 --- a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/external/ExternalStorage.java +++ b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/external/ExternalStorage.java @@ -11,7 +11,6 @@ import java.util.Collection; import java.util.HashSet; -import java.util.Optional; import java.util.Set; import org.apiguardian.api.API; @@ -62,8 +61,7 @@ public boolean detectChanges() { private boolean detectCompleteRemovals(final ResourceList updatedCache) { final Set removedInUpdatedCache = new HashSet<>(); for (final ResourceAmount inOldCache : cache.getAll()) { - final Optional inUpdatedCache = updatedCache.get(inOldCache.getResource()); - if (inUpdatedCache.isEmpty()) { + if (!updatedCache.contains(inOldCache.getResource())) { removedInUpdatedCache.add(inOldCache); } } @@ -74,22 +72,22 @@ private boolean detectCompleteRemovals(final ResourceList updatedCache) { private boolean detectAdditionsAndPartialRemovals(final ResourceList updatedCache) { boolean hasChanges = false; for (final ResourceAmount inUpdatedCache : updatedCache.getAll()) { - final Optional inOldCache = cache.get(inUpdatedCache.getResource()); - final boolean doesNotExistInOldCache = inOldCache.isEmpty(); + final long amountInOldCache = cache.getAmount(inUpdatedCache.getResource()); + final boolean doesNotExistInOldCache = amountInOldCache == 0; if (doesNotExistInOldCache) { addToCache(inUpdatedCache.getResource(), inUpdatedCache.getAmount()); hasChanges = true; } else { - hasChanges |= detectPotentialDifference(inUpdatedCache, inOldCache.get()); + hasChanges |= detectPotentialDifference(inUpdatedCache, amountInOldCache); } } return hasChanges; } private boolean detectPotentialDifference(final ResourceAmount inUpdatedCache, - final ResourceAmount inOldCache) { + final long amountInOldCache) { final ResourceKey resource = inUpdatedCache.getResource(); - final long diff = inUpdatedCache.getAmount() - inOldCache.getAmount(); + final long diff = inUpdatedCache.getAmount() - amountInOldCache; if (diff > 0) { addToCache(resource, diff); return true; diff --git a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorage.java b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorage.java index 70be790a6..1770c1cb2 100644 --- a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorage.java +++ b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorage.java @@ -1,12 +1,10 @@ package com.refinedmods.refinedstorage.api.storage.root; -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.api.resource.list.listenable.ResourceListListener; import com.refinedmods.refinedstorage.api.storage.Storage; import com.refinedmods.refinedstorage.api.storage.tracked.TrackedStorage; -import java.util.Optional; import java.util.function.Predicate; import org.apiguardian.api.API; @@ -33,16 +31,16 @@ public interface RootStorage extends Storage, TrackedStorage { void removeListener(ResourceListListener listener); /** - * @param resource the resource to retrieve - * @return the resource amount for the given resource, if present + * @param resource the resource + * @return the amount stored, or zero if not stored */ - Optional get(ResourceKey resource); + long getAmount(ResourceKey resource); /** * @param resource the resource - * @return the amount stored, or zero if not stored + * @return whether the storage contains the resource */ - long getAmount(ResourceKey resource); + boolean contains(ResourceKey resource); /** * Sorts the sources in the backing storage. diff --git a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImpl.java b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImpl.java index 187381bc1..ec3a2ac0d 100644 --- a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImpl.java +++ b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImpl.java @@ -63,13 +63,13 @@ public void removeListener(final ResourceListListener listener) { } @Override - public Optional get(final ResourceKey resource) { - return list.get(resource); + public long getAmount(final ResourceKey resource) { + return list.getAmount(resource); } @Override - public long getAmount(final ResourceKey resource) { - return list.getAmount(resource); + public boolean contains(final ResourceKey resource) { + return list.contains(resource); } @Override diff --git a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImplTest.java b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImplTest.java index 5f8a39c6b..1d6aca0f7 100644 --- a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImplTest.java +++ b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImplTest.java @@ -11,8 +11,6 @@ import com.refinedmods.refinedstorage.api.storage.tracked.TrackedResource; import com.refinedmods.refinedstorage.api.storage.tracked.TrackedStorageImpl; -import java.util.Optional; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; @@ -211,20 +209,16 @@ void shouldExtract() { } @Test - void shouldRetrieveResource() { + void shouldRetrieveIfResourceIsContained() { // Arrange final Storage storage = new LimitedStorageImpl(100); storage.insert(A, 50, Action.EXECUTE, EmptyActor.INSTANCE); sut.addSource(storage); - // Act - final Optional resource = sut.get(A); - - // Assert - assertThat(resource).isPresent(); - assertThat(resource.get()).usingRecursiveComparison().isEqualTo(new ResourceAmount(A, 50)); - assertThat(sut.findTrackedResourceByActorType(A, EmptyActor.class)).isEmpty(); + // Act & assert + assertThat(sut.contains(A)).isTrue(); + assertThat(sut.contains(B)).isFalse(); } @Test @@ -256,28 +250,13 @@ void shouldRetrieveTrackedResource() { sut.insert(A, 50, Action.EXECUTE, EmptyActor.INSTANCE); // Assert - final Optional value = sut.get(A); - assertThat(value).isPresent(); - assertThat(value.get()).usingRecursiveComparison().isEqualTo(new ResourceAmount(A, 50)); - + assertThat(sut.contains(A)).isTrue(); assertThat(sut.findTrackedResourceByActorType(A, EmptyActor.class)) .get() .usingRecursiveComparison() .isEqualTo(new TrackedResource("Empty", 0)); } - @Test - void shouldNotRetrieveNonExistentResource() { - // Arrange - sut.addSource(new LimitedStorageImpl(100)); - - // Act - final Optional resource = sut.get(A); - - // Assert - assertThat(resource).isEmpty(); - } - @Test void shouldSortSources() { // Arrange From 47549ab3ee76632f18caaeb58b179243a2671830 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Sat, 3 Aug 2024 12:58:32 +0200 Subject: [PATCH 19/36] feat: add ability to retrieve unique resources within a ResourceList --- .../SnapshotCraftingGridRefillContext.java | 6 +++- .../api/grid/view/GridViewImpl.java | 6 ++-- .../api/resource/list/ResourceList.java | 6 ++++ .../api/resource/list/ResourceListImpl.java | 6 ++++ .../list/AbstractResourceListTest.java | 20 ++++++++++++ .../api/storage/external/ExternalStorage.java | 31 ++++++++++++------- 6 files changed, 59 insertions(+), 16 deletions(-) diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/SnapshotCraftingGridRefillContext.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/SnapshotCraftingGridRefillContext.java index eabaa86c6..d3d4236b7 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/SnapshotCraftingGridRefillContext.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/SnapshotCraftingGridRefillContext.java @@ -1,6 +1,7 @@ package com.refinedmods.refinedstorage.common.grid; import com.refinedmods.refinedstorage.api.core.Action; +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.root.RootStorage; @@ -75,6 +76,9 @@ public void close() { } private void extractUsedItems(final RootStorage rootStorage) { - used.getAll().forEach(u -> rootStorage.extract(u.getResource(), u.getAmount(), Action.EXECUTE, playerActor)); + for (final ResourceKey usedResource : used.getResources()) { + final long amountUsed = used.getAmount(usedResource); + rootStorage.extract(usedResource, amountUsed, Action.EXECUTE, playerActor); + } } } diff --git a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java index 654baa738..7f6e66170 100644 --- a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java +++ b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java @@ -106,11 +106,11 @@ public void sort() { viewListIndex.clear(); final List newViewList = new ArrayList<>(); - for (final ResourceAmount backingListItem : backingList.getAll()) { - resourceFactory.apply(backingListItem.getResource()).ifPresent(gridResource -> { + for (final ResourceKey resource : backingList.getResources()) { + resourceFactory.apply(resource).ifPresent(gridResource -> { if (filter.test(this, gridResource)) { newViewList.add(gridResource); - viewListIndex.put(backingListItem.getResource(), gridResource); + viewListIndex.put(resource, gridResource); } }); } diff --git a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java index 5958497f0..7490d3e76 100644 --- a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java +++ b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java @@ -5,6 +5,7 @@ import java.util.Collection; import java.util.Optional; +import java.util.Set; import org.apiguardian.api.API; @@ -63,6 +64,11 @@ default Optional remove(ResourceAmount resourceAmount) { */ Collection getAll(); + /** + * @return set of resources contained in this list + */ + Set getResources(); + /** * @param resource the resource * @return the amount stored, or zero if not stored diff --git a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java index 55b7ff4c7..0f14c7f9b 100644 --- a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java +++ b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java @@ -8,6 +8,7 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.Optional; +import java.util.Set; import org.apiguardian.api.API; @@ -90,6 +91,11 @@ public Collection getAll() { return entries.values(); } + @Override + public Set getResources() { + return entries.keySet(); + } + @Override public long getAmount(final ResourceKey resource) { final ResourceAmount entry = entries.get(resource); diff --git a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractResourceListTest.java b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractResourceListTest.java index 24850fab8..c2a09399f 100644 --- a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractResourceListTest.java +++ b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractResourceListTest.java @@ -40,6 +40,8 @@ void shouldAddNewResource() { ); assertThat(list.getAmount(TestResource.A)).isEqualTo(10); assertThat(list.contains(TestResource.A)).isTrue(); + + assertThat(list.getResources()).containsExactly(TestResource.A); } @Test @@ -58,6 +60,8 @@ void shouldAddNewResourceWithResourceAmountDirectly() { ); assertThat(list.getAmount(TestResource.A)).isEqualTo(10); assertThat(list.contains(TestResource.A)).isTrue(); + + assertThat(list.getResources()).containsExactly(TestResource.A); } @Test @@ -82,6 +86,8 @@ void shouldAddMultipleOfSameResource() { ); assertThat(list.getAmount(TestResource.A)).isEqualTo(15); assertThat(list.contains(TestResource.A)).isTrue(); + + assertThat(list.getResources()).containsExactly(TestResource.A); } @Test @@ -115,6 +121,8 @@ void shouldAddMultipleOfDifferentResources() { assertThat(list.contains(TestResource.A)).isTrue(); assertThat(list.getAmount(TestResource.B)).isEqualTo(3); assertThat(list.contains(TestResource.B)).isTrue(); + + assertThat(list.getResources()).containsExactlyInAnyOrder(TestResource.A, TestResource.B); } @Test @@ -165,6 +173,8 @@ void shouldRemoveResourcePartly() { assertThat(list.contains(TestResource.A)).isTrue(); assertThat(list.getAmount(TestResource.B)).isEqualTo(6); assertThat(list.contains(TestResource.B)).isTrue(); + + assertThat(list.getResources()).containsExactlyInAnyOrder(TestResource.A, TestResource.B); } @Test @@ -195,6 +205,8 @@ void shouldRemoveResourcePartlyWithResourceAmountDirectly() { assertThat(list.contains(TestResource.A)).isTrue(); assertThat(list.getAmount(TestResource.B)).isEqualTo(6); assertThat(list.contains(TestResource.B)).isTrue(); + + assertThat(list.getResources()).containsExactlyInAnyOrder(TestResource.A, TestResource.B); } @Test @@ -221,6 +233,8 @@ void shouldRemoveResourceCompletely() { assertThat(list.contains(TestResource.A)).isFalse(); assertThat(list.getAmount(TestResource.B)).isEqualTo(6); assertThat(list.contains(TestResource.B)).isTrue(); + + assertThat(list.getResources()).containsExactly(TestResource.B); } @Test @@ -250,6 +264,8 @@ void shouldRemoveResourceCompletelyWithResourceAmountDirectly() { assertThat(list.contains(TestResource.A)).isFalse(); assertThat(list.getAmount(TestResource.B)).isEqualTo(6); assertThat(list.contains(TestResource.B)).isTrue(); + + assertThat(list.getResources()).containsExactly(TestResource.B); } @Test @@ -276,6 +292,8 @@ void shouldNotRemoveResourceWithMoreThanIsAvailable() { assertThat(list.contains(TestResource.A)).isFalse(); assertThat(list.getAmount(TestResource.B)).isEqualTo(6); assertThat(list.contains(TestResource.B)).isTrue(); + + assertThat(list.getResources()).containsExactly(TestResource.B); } @Test @@ -311,5 +329,7 @@ void shouldClearList() { assertThat(list.getAmount(TestResource.A)).isZero(); assertThat(list.getAmount(TestResource.B)).isZero(); + + assertThat(list.getResources()).isEmpty(); } } diff --git a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/external/ExternalStorage.java b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/external/ExternalStorage.java index df3989a3f..5c3c24310 100644 --- a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/external/ExternalStorage.java +++ b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/external/ExternalStorage.java @@ -59,35 +59,38 @@ public boolean detectChanges() { } private boolean detectCompleteRemovals(final ResourceList updatedCache) { - final Set removedInUpdatedCache = new HashSet<>(); - for (final ResourceAmount inOldCache : cache.getAll()) { - if (!updatedCache.contains(inOldCache.getResource())) { + final Set removedInUpdatedCache = new HashSet<>(); + for (final ResourceKey inOldCache : cache.getResources()) { + if (!updatedCache.contains(inOldCache)) { removedInUpdatedCache.add(inOldCache); } } - removedInUpdatedCache.forEach(removed -> removeFromCache(removed.getResource(), removed.getAmount())); + removedInUpdatedCache.forEach(this::removeFromCache); return !removedInUpdatedCache.isEmpty(); } private boolean detectAdditionsAndPartialRemovals(final ResourceList updatedCache) { boolean hasChanges = false; - for (final ResourceAmount inUpdatedCache : updatedCache.getAll()) { - final long amountInOldCache = cache.getAmount(inUpdatedCache.getResource()); + for (final ResourceKey resource : updatedCache.getResources()) { + final long amountInUpdatedCache = updatedCache.getAmount(resource); + final long amountInOldCache = cache.getAmount(resource); final boolean doesNotExistInOldCache = amountInOldCache == 0; if (doesNotExistInOldCache) { - addToCache(inUpdatedCache.getResource(), inUpdatedCache.getAmount()); + addToCache(resource, amountInUpdatedCache); hasChanges = true; } else { - hasChanges |= detectPotentialDifference(inUpdatedCache, amountInOldCache); + hasChanges |= detectPotentialDifference(resource, amountInUpdatedCache, amountInOldCache); } } return hasChanges; } - private boolean detectPotentialDifference(final ResourceAmount inUpdatedCache, - final long amountInOldCache) { - final ResourceKey resource = inUpdatedCache.getResource(); - final long diff = inUpdatedCache.getAmount() - amountInOldCache; + private boolean detectPotentialDifference( + final ResourceKey resource, + final long amountInUpdatedCache, + final long amountInOldCache + ) { + final long diff = amountInUpdatedCache - amountInOldCache; if (diff > 0) { addToCache(resource, diff); return true; @@ -103,6 +106,10 @@ private void addToCache(final ResourceKey resource, final long amount) { parents.forEach(parent -> parent.addToCache(resource, amount)); } + private void removeFromCache(final ResourceKey resource) { + removeFromCache(resource, cache.getAmount(resource)); + } + private void removeFromCache(final ResourceKey resource, final long amount) { cache.remove(resource, amount); parents.forEach(parent -> parent.removeFromCache(resource, amount)); From 9380e40f38848f6927f05b0b4cd84e07f8208b54 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Sat, 3 Aug 2024 13:10:42 +0200 Subject: [PATCH 20/36] feat: add ability to copy resource list --- .../api/grid/view/GridViewImpl.java | 6 +--- .../list/AbstractProxyResourceList.java | 11 ++++++++ .../api/resource/list/ResourceList.java | 5 ++++ .../api/resource/list/ResourceListImpl.java | 7 +++++ .../api/resource/TestResource.java | 3 +- .../list/AbstractResourceListTest.java | 28 +++++++++++++++++++ 6 files changed, 54 insertions(+), 6 deletions(-) diff --git a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java index 7f6e66170..4b61f7e33 100644 --- a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java +++ b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java @@ -1,10 +1,8 @@ package com.refinedmods.refinedstorage.api.grid.view; import com.refinedmods.refinedstorage.api.core.CoreValidations; -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.tracked.TrackedResource; import java.util.ArrayList; @@ -256,9 +254,7 @@ public List getViewList() { @Override public ResourceList copyBackingList() { - final ResourceList copy = ResourceListImpl.create(); - backingList.getAll().forEach(copy::add); - return copy; + return backingList.copy(); } @Override diff --git a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/AbstractProxyResourceList.java b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/AbstractProxyResourceList.java index dd598776c..a19a328c0 100644 --- a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/AbstractProxyResourceList.java +++ b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/AbstractProxyResourceList.java @@ -5,6 +5,7 @@ import java.util.Collection; import java.util.Optional; +import java.util.Set; import org.apiguardian.api.API; @@ -44,6 +45,16 @@ public boolean contains(final ResourceKey resource) { return delegate.contains(resource); } + @Override + public Set getResources() { + return delegate.getResources(); + } + + @Override + public ResourceList copy() { + return delegate.copy(); + } + @Override public void clear() { delegate.clear(); diff --git a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java index 7490d3e76..1f0269a6d 100644 --- a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java +++ b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java @@ -86,6 +86,11 @@ default Optional remove(ResourceAmount resourceAmount) { */ void clear(); + /** + * Copies the list. + */ + ResourceList copy(); + /** * Represents the result of an operation in a {@link ResourceList}. * diff --git a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java index 0f14c7f9b..89790746e 100644 --- a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java +++ b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java @@ -111,4 +111,11 @@ public boolean contains(final ResourceKey resource) { public void clear() { entries.clear(); } + + @Override + public ResourceList copy() { + final ResourceList copy = ResourceListImpl.create(); + entries.forEach((key, value) -> copy.add(key, value.getAmount())); + return copy; + } } diff --git a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/TestResource.java b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/TestResource.java index 996358103..b677a0a2a 100644 --- a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/TestResource.java +++ b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/TestResource.java @@ -3,5 +3,6 @@ public enum TestResource implements ResourceKey { A, B, - C + C, + D } diff --git a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractResourceListTest.java b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractResourceListTest.java index c2a09399f..588f86820 100644 --- a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractResourceListTest.java +++ b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractResourceListTest.java @@ -332,4 +332,32 @@ void shouldClearList() { assertThat(list.getResources()).isEmpty(); } + + @Test + void shouldCopyList() { + // Arrange + list.add(TestResource.A, 10); + list.add(TestResource.B, 5); + + // Act + final ResourceList copy = list.copy(); + + list.add(TestResource.A, 1); + list.add(TestResource.C, 3); + + copy.add(TestResource.A, 2); + copy.add(TestResource.D, 3); + + // Assert + assertThat(list.getAll()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( + new ResourceAmount(TestResource.A, 11), + new ResourceAmount(TestResource.B, 5), + new ResourceAmount(TestResource.C, 3) + ); + assertThat(copy.getAll()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( + new ResourceAmount(TestResource.A, 12), + new ResourceAmount(TestResource.B, 5), + new ResourceAmount(TestResource.D, 3) + ); + } } From cfa6ea2b9652db443528bdb608a2ba2152cc7ed3 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Sat, 3 Aug 2024 13:14:29 +0200 Subject: [PATCH 21/36] refactor: rename #getAll to #copyState And rename #getResources to #getAll --- .../autocrafting/ProcessingPatternState.java | 4 +- .../detector/FuzzyDetectorAmountStrategy.java | 2 +- .../common/grid/CraftingGridSourceImpl.java | 2 +- .../SnapshotCraftingGridRefillContext.java | 6 +- .../StorageMonitorBlockEntity.java | 4 +- .../list/FuzzyResourceListImplTest.java | 30 +++---- .../grid/operations/GridOperationsImpl.java | 2 +- .../api/grid/view/GridViewImpl.java | 4 +- .../api/grid/view/GridViewImplTest.java | 22 ++--- .../detector/DetectorAmountStrategyImpl.java | 2 +- .../list/AbstractProxyResourceList.java | 12 +-- .../api/resource/list/ResourceList.java | 6 +- .../api/resource/list/ResourceListImpl.java | 6 +- .../list/AbstractResourceListTest.java | 80 +++++++++---------- .../api/storage/InMemoryStorageImpl.java | 4 +- .../composite/CompositeStorageImpl.java | 2 +- .../api/storage/external/ExternalStorage.java | 12 +-- .../api/storage/root/RootStorage.java | 2 +- .../api/storage/root/RootStorageImpl.java | 4 +- .../api/storage/root/RootStorageImplTest.java | 4 +- 20 files changed, 105 insertions(+), 105 deletions(-) diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/ProcessingPatternState.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/ProcessingPatternState.java index afa7d0f76..d006c71b4 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/ProcessingPatternState.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/ProcessingPatternState.java @@ -36,12 +36,12 @@ public record ProcessingPatternState( List getFlatInputs() { final ResourceList list = ResourceListImpl.orderPreserving(); inputs.forEach(input -> input.ifPresent(list::add)); - return new ArrayList<>(list.getAll()); + return new ArrayList<>(list.copyState()); } List getFlatOutputs() { final ResourceList list = ResourceListImpl.orderPreserving(); outputs.forEach(output -> output.ifPresent(list::add)); - return new ArrayList<>(list.getAll()); + return new ArrayList<>(list.copyState()); } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/detector/FuzzyDetectorAmountStrategy.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/detector/FuzzyDetectorAmountStrategy.java index 4ce64d0b4..d5ef6830a 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/detector/FuzzyDetectorAmountStrategy.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/detector/FuzzyDetectorAmountStrategy.java @@ -22,7 +22,7 @@ public long getAmount(final Network network, final ResourceKey configuredResourc } return fuzzyRootStorage.getFuzzy(configuredResource) .stream() - .mapToLong(rootStorage::getAmount) + .mapToLong(rootStorage::get) .sum(); } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridSourceImpl.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridSourceImpl.java index f3ff2e2b8..483dc69a3 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridSourceImpl.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridSourceImpl.java @@ -150,6 +150,6 @@ private void addPlayerInventoryItemsIntoList(final Player player, final Resource } private Comparator sortByHighestAvailableFirst(final ResourceList available) { - return Comparator.comparingLong(available::getAmount).reversed(); + return Comparator.comparingLong(available::get).reversed(); } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/SnapshotCraftingGridRefillContext.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/SnapshotCraftingGridRefillContext.java index d3d4236b7..cd22c8832 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/SnapshotCraftingGridRefillContext.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/SnapshotCraftingGridRefillContext.java @@ -51,7 +51,7 @@ private void addAvailableItem(final RootStorage rootStorage, final ItemResource craftingMatrixResource = ItemResource.ofItemStack(craftingMatrixStack); // a single resource can occur multiple times in a recipe, only add it once if (!available.contains(craftingMatrixResource)) { - final long amount = rootStorage.getAmount(craftingMatrixResource); + final long amount = rootStorage.get(craftingMatrixResource); if (amount > 0) { available.add(craftingMatrixResource, amount); } @@ -76,8 +76,8 @@ public void close() { } private void extractUsedItems(final RootStorage rootStorage) { - for (final ResourceKey usedResource : used.getResources()) { - final long amountUsed = used.getAmount(usedResource); + for (final ResourceKey usedResource : used.getAll()) { + final long amountUsed = used.get(usedResource); rootStorage.extract(usedResource, amountUsed, Action.EXECUTE, playerActor); } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storagemonitor/StorageMonitorBlockEntity.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storagemonitor/StorageMonitorBlockEntity.java index afcd1e870..052685ee9 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storagemonitor/StorageMonitorBlockEntity.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storagemonitor/StorageMonitorBlockEntity.java @@ -101,11 +101,11 @@ private long getAmount() { private long getAmount(final Network network, final ResourceKey configuredResource) { final RootStorage rootStorage = network.getComponent(StorageNetworkComponent.class); if (!filter.isFuzzyMode() || !(rootStorage instanceof FuzzyRootStorage fuzzyRootStorage)) { - return rootStorage.getAmount(configuredResource); + return rootStorage.get(configuredResource); } return fuzzyRootStorage.getFuzzy(configuredResource) .stream() - .mapToLong(rootStorage::getAmount) + .mapToLong(rootStorage::get) .sum(); } diff --git a/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImplTest.java b/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImplTest.java index 88e28b72a..5660e7a86 100644 --- a/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImplTest.java +++ b/refinedstorage-common/src/test/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImplTest.java @@ -50,11 +50,11 @@ void testRetrievingFuzzy() { sut.add(DUMMY_D, 15); // Act - final long strictA = sut.getAmount(DUMMY_A); - final long strictB = sut.getAmount(DUMMY_B); - final long strictC = sut.getAmount(DUMMY_C); - final long strictD = sut.getAmount(DUMMY_D); - final long strictE = sut.getAmount(DUMMY_E); + final long strictA = sut.get(DUMMY_A); + final long strictB = sut.get(DUMMY_B); + final long strictC = sut.get(DUMMY_C); + final long strictD = sut.get(DUMMY_D); + final long strictE = sut.get(DUMMY_E); final Collection fuzzyA = sut.getFuzzy(DUMMY_A); final Collection fuzzyB = sut.getFuzzy(DUMMY_B); @@ -105,11 +105,11 @@ void shouldRemoveEntireResourceFromFuzzyIndexAfterRemoval() { sut.add(DUMMY_D, 15); // Act - final long strictA = sut.getAmount(DUMMY_A); - final long strictB = sut.getAmount(DUMMY_B); - final long strictC = sut.getAmount(DUMMY_C); - final long strictD = sut.getAmount(DUMMY_D); - final long strictE = sut.getAmount(DUMMY_E); + final long strictA = sut.get(DUMMY_A); + final long strictB = sut.get(DUMMY_B); + final long strictC = sut.get(DUMMY_C); + final long strictD = sut.get(DUMMY_D); + final long strictE = sut.get(DUMMY_E); final Collection fuzzyA = sut.getFuzzy(DUMMY_A); final Collection fuzzyB = sut.getFuzzy(DUMMY_B); @@ -146,11 +146,11 @@ void shouldRemoveSingleResourceFromFuzzyIndexAfterRemoval() { sut.add(DUMMY_D, 15); // Act - final long strictA = sut.getAmount(DUMMY_A); - final long strictB = sut.getAmount(DUMMY_B); - final long strictC = sut.getAmount(DUMMY_C); - final long strictD = sut.getAmount(DUMMY_D); - final long strictE = sut.getAmount(DUMMY_E); + final long strictA = sut.get(DUMMY_A); + final long strictB = sut.get(DUMMY_B); + final long strictC = sut.get(DUMMY_C); + final long strictD = sut.get(DUMMY_D); + final long strictE = sut.get(DUMMY_E); final Collection fuzzyA = sut.getFuzzy(DUMMY_A); final Collection fuzzyB = sut.getFuzzy(DUMMY_B); diff --git a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/operations/GridOperationsImpl.java b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/operations/GridOperationsImpl.java index f79f4e947..5816432d4 100644 --- a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/operations/GridOperationsImpl.java +++ b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/operations/GridOperationsImpl.java @@ -52,7 +52,7 @@ private long getExtractableAmount(final ResourceKey resource, final GridExtractM } private long getExtractableAmount(final ResourceKey resource) { - final long totalSize = rootStorage.getAmount(resource); + final long totalSize = rootStorage.get(resource); final long maxAmount = maxAmountProvider.applyAsLong(resource); return Math.min(totalSize, maxAmount); } diff --git a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java index 4b61f7e33..fd754bdea 100644 --- a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java +++ b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java @@ -94,7 +94,7 @@ public Optional getTrackedResource(final ResourceKey resource) @Override public long getAmount(final ResourceKey resource) { - return backingList.getAmount(resource); + return backingList.get(resource); } @Override @@ -104,7 +104,7 @@ public void sort() { viewListIndex.clear(); final List newViewList = new ArrayList<>(); - for (final ResourceKey resource : backingList.getResources()) { + for (final ResourceKey resource : backingList.getAll()) { resourceFactory.apply(resource).ifPresent(gridResource -> { if (filter.test(this, gridResource)) { newViewList.add(gridResource); diff --git a/refinedstorage-grid-api/src/test/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImplTest.java b/refinedstorage-grid-api/src/test/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImplTest.java index 5dd5cc47b..7b5efb742 100644 --- a/refinedstorage-grid-api/src/test/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImplTest.java +++ b/refinedstorage-grid-api/src/test/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImplTest.java @@ -115,7 +115,7 @@ void shouldLoadResourcesAndRetrieveTrackedResourcesProperly() { assertThat(a).get().usingRecursiveComparison().isEqualTo(new TrackedResource("RaoulA", 2)); assertThat(b).isEmpty(); assertThat(d).isEmpty(); - assertThat(backingList.getAll()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( + assertThat(backingList.copyState()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( new ResourceAmount(A, 2), new ResourceAmount(B, 2), new ResourceAmount(D, 1) @@ -148,7 +148,7 @@ void shouldInsertNewResource() { new GridResourceImpl(A), new GridResourceImpl(B) ); - assertThat(view.copyBackingList().getAll()) + assertThat(view.copyBackingList().copyState()) .usingRecursiveFieldByFieldElementComparator() .containsExactlyInAnyOrder( new ResourceAmount(D, 10), @@ -256,7 +256,7 @@ void shouldUpdateExistingResource() { new GridResourceImpl(B), new GridResourceImpl(A) ); - assertThat(view.copyBackingList().getAll()) + assertThat(view.copyBackingList().copyState()) .usingRecursiveFieldByFieldElementComparator() .containsExactlyInAnyOrder( new ResourceAmount(D, 10), @@ -291,7 +291,7 @@ void shouldNotUpdateExistingResourceWhenFilteringProhibitsIt() { new GridResourceImpl(D), new GridResourceImpl(A) ); - assertThat(view.copyBackingList().getAll()) + assertThat(view.copyBackingList().copyState()) .usingRecursiveFieldByFieldElementComparator() .containsExactlyInAnyOrder( new ResourceAmount(B, 11), @@ -338,7 +338,7 @@ void shouldNotReorderExistingResourceWhenPreventingSorting() { new GridResourceImpl(D), new GridResourceImpl(A) ); - assertThat(view.copyBackingList().getAll()) + assertThat(view.copyBackingList().copyState()) .usingRecursiveFieldByFieldElementComparator() .containsExactlyInAnyOrder( new ResourceAmount(B, 11), @@ -355,7 +355,7 @@ void shouldNotReorderExistingResourceWhenPreventingSorting() { new GridResourceImpl(B), new GridResourceImpl(A) ); - assertThat(view.copyBackingList().getAll()) + assertThat(view.copyBackingList().copyState()) .usingRecursiveFieldByFieldElementComparator() .containsExactlyInAnyOrder( new ResourceAmount(B, 11), @@ -411,7 +411,7 @@ void shouldUpdateExistingResourceWhenPerformingPartialRemoval() { new GridResourceImpl(B), new GridResourceImpl(A) ); - assertThat(view.copyBackingList().getAll()) + assertThat(view.copyBackingList().copyState()) .usingRecursiveFieldByFieldElementComparator() .containsExactlyInAnyOrder( new ResourceAmount(D, 10), @@ -516,7 +516,7 @@ void shouldRemoveExistingResourceCompletely() { new GridResourceImpl(D), new GridResourceImpl(A) ); - assertThat(view.copyBackingList().getAll()) + assertThat(view.copyBackingList().copyState()) .usingRecursiveFieldByFieldElementComparator() .containsExactlyInAnyOrder( new ResourceAmount(D, 10), @@ -558,7 +558,7 @@ void shouldNotReorderWhenRemovingExistingResourceCompletelyAndPreventingSorting( new GridResourceImpl(A), new GridResourceImpl(B).zeroed() ); - assertThat(view.copyBackingList().getAll()) + assertThat(view.copyBackingList().copyState()) .usingRecursiveFieldByFieldElementComparator() .containsExactlyInAnyOrder( new ResourceAmount(D, 10), @@ -572,7 +572,7 @@ void shouldNotReorderWhenRemovingExistingResourceCompletelyAndPreventingSorting( new GridResourceImpl(D), new GridResourceImpl(A) ); - assertThat(view.copyBackingList().getAll()) + assertThat(view.copyBackingList().copyState()) .usingRecursiveFieldByFieldElementComparator() .containsExactlyInAnyOrder( new ResourceAmount(D, 10), @@ -647,7 +647,7 @@ void shouldClear() { // Assert assertThat(view.getViewList()).isEmpty(); - assertThat(view.copyBackingList().getAll()).isEmpty(); + assertThat(view.copyBackingList().copyState()).isEmpty(); assertThat(view.getTrackedResource(A)).isEmpty(); assertThat(view.getTrackedResource(B)).isEmpty(); assertThat(view.getTrackedResource(D)).isEmpty(); diff --git a/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/detector/DetectorAmountStrategyImpl.java b/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/detector/DetectorAmountStrategyImpl.java index 8f5f5d4c0..9bda0b721 100644 --- a/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/detector/DetectorAmountStrategyImpl.java +++ b/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/detector/DetectorAmountStrategyImpl.java @@ -6,6 +6,6 @@ public class DetectorAmountStrategyImpl extends AbstractDetectorAmountStrategy { @Override public long getAmount(final Network network, final ResourceKey configuredResource) { - return getRootStorage(network).getAmount(configuredResource); + return getRootStorage(network).get(configuredResource); } } diff --git a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/AbstractProxyResourceList.java b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/AbstractProxyResourceList.java index a19a328c0..a4df54f02 100644 --- a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/AbstractProxyResourceList.java +++ b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/AbstractProxyResourceList.java @@ -31,13 +31,13 @@ public Optional remove(final ResourceKey resource, final long a } @Override - public Collection getAll() { - return delegate.getAll(); + public Collection copyState() { + return delegate.copyState(); } @Override - public long getAmount(final ResourceKey resource) { - return delegate.getAmount(resource); + public long get(final ResourceKey resource) { + return delegate.get(resource); } @Override @@ -46,8 +46,8 @@ public boolean contains(final ResourceKey resource) { } @Override - public Set getResources() { - return delegate.getResources(); + public Set getAll() { + return delegate.getAll(); } @Override diff --git a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java index 1f0269a6d..49e2dec39 100644 --- a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java +++ b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java @@ -62,18 +62,18 @@ default Optional remove(ResourceAmount resourceAmount) { * * @return a list of resource amounts */ - Collection getAll(); + Collection copyState(); /** * @return set of resources contained in this list */ - Set getResources(); + Set getAll(); /** * @param resource the resource * @return the amount stored, or zero if not stored */ - long getAmount(ResourceKey resource); + long get(ResourceKey resource); /** * @param resource the resource diff --git a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java index 89790746e..cdd0e2373 100644 --- a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java +++ b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java @@ -87,17 +87,17 @@ private Optional removeCompletely(final ResourceAmount resource } @Override - public Collection getAll() { + public Collection copyState() { return entries.values(); } @Override - public Set getResources() { + public Set getAll() { return entries.keySet(); } @Override - public long getAmount(final ResourceKey resource) { + public long get(final ResourceKey resource) { final ResourceAmount entry = entries.get(resource); return entry != null ? entry.getAmount() : 0; } diff --git a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractResourceListTest.java b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractResourceListTest.java index 588f86820..4b29f561f 100644 --- a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractResourceListTest.java +++ b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractResourceListTest.java @@ -35,13 +35,13 @@ void shouldAddNewResource() { assertThat(result.resourceAmount().getResource()).isEqualTo(TestResource.A); assertThat(result.available()).isTrue(); - assertThat(list.getAll()).usingRecursiveFieldByFieldElementComparator().containsExactly( + assertThat(list.copyState()).usingRecursiveFieldByFieldElementComparator().containsExactly( new ResourceAmount(TestResource.A, 10) ); - assertThat(list.getAmount(TestResource.A)).isEqualTo(10); + assertThat(list.get(TestResource.A)).isEqualTo(10); assertThat(list.contains(TestResource.A)).isTrue(); - assertThat(list.getResources()).containsExactly(TestResource.A); + assertThat(list.getAll()).containsExactly(TestResource.A); } @Test @@ -55,13 +55,13 @@ void shouldAddNewResourceWithResourceAmountDirectly() { assertThat(result.resourceAmount().getResource()).isEqualTo(TestResource.A); assertThat(result.available()).isTrue(); - assertThat(list.getAll()).usingRecursiveFieldByFieldElementComparator().containsExactly( + assertThat(list.copyState()).usingRecursiveFieldByFieldElementComparator().containsExactly( new ResourceAmount(TestResource.A, 10) ); - assertThat(list.getAmount(TestResource.A)).isEqualTo(10); + assertThat(list.get(TestResource.A)).isEqualTo(10); assertThat(list.contains(TestResource.A)).isTrue(); - assertThat(list.getResources()).containsExactly(TestResource.A); + assertThat(list.getAll()).containsExactly(TestResource.A); } @Test @@ -81,13 +81,13 @@ void shouldAddMultipleOfSameResource() { assertThat(result1.resourceAmount().getResource()).isEqualTo(TestResource.A); assertThat(result2.available()).isTrue(); - assertThat(list.getAll()).usingRecursiveFieldByFieldElementComparator().containsExactly( + assertThat(list.copyState()).usingRecursiveFieldByFieldElementComparator().containsExactly( new ResourceAmount(TestResource.A, 15) ); - assertThat(list.getAmount(TestResource.A)).isEqualTo(15); + assertThat(list.get(TestResource.A)).isEqualTo(15); assertThat(list.contains(TestResource.A)).isTrue(); - assertThat(list.getResources()).containsExactly(TestResource.A); + assertThat(list.getAll()).containsExactly(TestResource.A); } @Test @@ -113,16 +113,16 @@ void shouldAddMultipleOfDifferentResources() { assertThat(result3.resourceAmount().getResource()).isEqualTo(TestResource.B); assertThat(result3.available()).isTrue(); - assertThat(list.getAll()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( + assertThat(list.copyState()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( new ResourceAmount(TestResource.A, 15), new ResourceAmount(TestResource.B, 3) ); - assertThat(list.getAmount(TestResource.A)).isEqualTo(15); + assertThat(list.get(TestResource.A)).isEqualTo(15); assertThat(list.contains(TestResource.A)).isTrue(); - assertThat(list.getAmount(TestResource.B)).isEqualTo(3); + assertThat(list.get(TestResource.B)).isEqualTo(3); assertThat(list.contains(TestResource.B)).isTrue(); - assertThat(list.getResources()).containsExactlyInAnyOrder(TestResource.A, TestResource.B); + assertThat(list.getAll()).containsExactlyInAnyOrder(TestResource.A, TestResource.B); } @Test @@ -164,17 +164,17 @@ void shouldRemoveResourcePartly() { assertThat(result2.get().resourceAmount().getResource()).isEqualTo(TestResource.A); assertThat(result2.get().available()).isTrue(); - assertThat(list.getAll()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( + assertThat(list.copyState()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( new ResourceAmount(TestResource.A, 15), new ResourceAmount(TestResource.B, 6) ); - assertThat(list.getAmount(TestResource.A)).isEqualTo(15); + assertThat(list.get(TestResource.A)).isEqualTo(15); assertThat(list.contains(TestResource.A)).isTrue(); - assertThat(list.getAmount(TestResource.B)).isEqualTo(6); + assertThat(list.get(TestResource.B)).isEqualTo(6); assertThat(list.contains(TestResource.B)).isTrue(); - assertThat(list.getResources()).containsExactlyInAnyOrder(TestResource.A, TestResource.B); + assertThat(list.getAll()).containsExactlyInAnyOrder(TestResource.A, TestResource.B); } @Test @@ -196,17 +196,17 @@ void shouldRemoveResourcePartlyWithResourceAmountDirectly() { assertThat(result2.get().resourceAmount().getResource()).isEqualTo(TestResource.A); assertThat(result2.get().available()).isTrue(); - assertThat(list.getAll()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( + assertThat(list.copyState()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( new ResourceAmount(TestResource.A, 15), new ResourceAmount(TestResource.B, 6) ); - assertThat(list.getAmount(TestResource.A)).isEqualTo(15); + assertThat(list.get(TestResource.A)).isEqualTo(15); assertThat(list.contains(TestResource.A)).isTrue(); - assertThat(list.getAmount(TestResource.B)).isEqualTo(6); + assertThat(list.get(TestResource.B)).isEqualTo(6); assertThat(list.contains(TestResource.B)).isTrue(); - assertThat(list.getResources()).containsExactlyInAnyOrder(TestResource.A, TestResource.B); + assertThat(list.getAll()).containsExactlyInAnyOrder(TestResource.A, TestResource.B); } @Test @@ -225,16 +225,16 @@ void shouldRemoveResourceCompletely() { assertThat(result2.get().resourceAmount().getResource()).isEqualTo(TestResource.A); assertThat(result2.get().available()).isFalse(); - assertThat(list.getAll()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( + assertThat(list.copyState()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( new ResourceAmount(TestResource.B, 6) ); - assertThat(list.getAmount(TestResource.A)).isZero(); + assertThat(list.get(TestResource.A)).isZero(); assertThat(list.contains(TestResource.A)).isFalse(); - assertThat(list.getAmount(TestResource.B)).isEqualTo(6); + assertThat(list.get(TestResource.B)).isEqualTo(6); assertThat(list.contains(TestResource.B)).isTrue(); - assertThat(list.getResources()).containsExactly(TestResource.B); + assertThat(list.getAll()).containsExactly(TestResource.B); } @Test @@ -256,16 +256,16 @@ void shouldRemoveResourceCompletelyWithResourceAmountDirectly() { assertThat(result2.get().resourceAmount().getResource()).isEqualTo(TestResource.A); assertThat(result2.get().available()).isFalse(); - assertThat(list.getAll()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( + assertThat(list.copyState()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( new ResourceAmount(TestResource.B, 6) ); - assertThat(list.getAmount(TestResource.A)).isZero(); + assertThat(list.get(TestResource.A)).isZero(); assertThat(list.contains(TestResource.A)).isFalse(); - assertThat(list.getAmount(TestResource.B)).isEqualTo(6); + assertThat(list.get(TestResource.B)).isEqualTo(6); assertThat(list.contains(TestResource.B)).isTrue(); - assertThat(list.getResources()).containsExactly(TestResource.B); + assertThat(list.getAll()).containsExactly(TestResource.B); } @Test @@ -284,16 +284,16 @@ void shouldNotRemoveResourceWithMoreThanIsAvailable() { assertThat(result2.get().resourceAmount().getResource()).isEqualTo(TestResource.A); assertThat(result2.get().available()).isFalse(); - assertThat(list.getAll()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( + assertThat(list.copyState()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( new ResourceAmount(TestResource.B, 6) ); - assertThat(list.getAmount(TestResource.A)).isZero(); + assertThat(list.get(TestResource.A)).isZero(); assertThat(list.contains(TestResource.A)).isFalse(); - assertThat(list.getAmount(TestResource.B)).isEqualTo(6); + assertThat(list.get(TestResource.B)).isEqualTo(6); assertThat(list.contains(TestResource.B)).isTrue(); - assertThat(list.getResources()).containsExactly(TestResource.B); + assertThat(list.getAll()).containsExactly(TestResource.B); } @Test @@ -316,21 +316,21 @@ void shouldClearList() { list.add(TestResource.A, 10); list.add(TestResource.B, 5); - final Collection contentsBeforeClear = new ArrayList<>(list.getAll()); + final Collection contentsBeforeClear = new ArrayList<>(list.copyState()); // Act list.clear(); // Assert - final Collection contentsAfterClear = list.getAll(); + final Collection contentsAfterClear = list.copyState(); assertThat(contentsBeforeClear).hasSize(2); assertThat(contentsAfterClear).isEmpty(); - assertThat(list.getAmount(TestResource.A)).isZero(); - assertThat(list.getAmount(TestResource.B)).isZero(); + assertThat(list.get(TestResource.A)).isZero(); + assertThat(list.get(TestResource.B)).isZero(); - assertThat(list.getResources()).isEmpty(); + assertThat(list.getAll()).isEmpty(); } @Test @@ -349,12 +349,12 @@ void shouldCopyList() { copy.add(TestResource.D, 3); // Assert - assertThat(list.getAll()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( + assertThat(list.copyState()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( new ResourceAmount(TestResource.A, 11), new ResourceAmount(TestResource.B, 5), new ResourceAmount(TestResource.C, 3) ); - assertThat(copy.getAll()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( + assertThat(copy.copyState()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( new ResourceAmount(TestResource.A, 12), new ResourceAmount(TestResource.B, 5), new ResourceAmount(TestResource.D, 3) 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/InMemoryStorageImpl.java index d2236684b..e21e42836 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/InMemoryStorageImpl.java @@ -29,7 +29,7 @@ public InMemoryStorageImpl() { @Override public long extract(final ResourceKey resource, final long amount, final Action action, final Actor actor) { ResourceAmount.validate(resource, amount); - final long availableAmount = list.getAmount(resource); + final long availableAmount = list.get(resource); if (availableAmount == 0) { return 0; } @@ -57,7 +57,7 @@ public long insert(final ResourceKey resource, final long amount, final Action a @Override public Collection getAll() { - return list.getAll(); + return list.copyState(); } @Override diff --git a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/composite/CompositeStorageImpl.java b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/composite/CompositeStorageImpl.java index 167538ab4..845623a76 100644 --- a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/composite/CompositeStorageImpl.java +++ b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/composite/CompositeStorageImpl.java @@ -140,7 +140,7 @@ public long insert(final ResourceKey resource, final long amount, final Action a @Override public Collection getAll() { - return list.getAll(); + return list.copyState(); } @Override diff --git a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/external/ExternalStorage.java b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/external/ExternalStorage.java index 5c3c24310..e8ce6b289 100644 --- a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/external/ExternalStorage.java +++ b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/external/ExternalStorage.java @@ -60,7 +60,7 @@ public boolean detectChanges() { private boolean detectCompleteRemovals(final ResourceList updatedCache) { final Set removedInUpdatedCache = new HashSet<>(); - for (final ResourceKey inOldCache : cache.getResources()) { + for (final ResourceKey inOldCache : cache.getAll()) { if (!updatedCache.contains(inOldCache)) { removedInUpdatedCache.add(inOldCache); } @@ -71,9 +71,9 @@ private boolean detectCompleteRemovals(final ResourceList updatedCache) { private boolean detectAdditionsAndPartialRemovals(final ResourceList updatedCache) { boolean hasChanges = false; - for (final ResourceKey resource : updatedCache.getResources()) { - final long amountInUpdatedCache = updatedCache.getAmount(resource); - final long amountInOldCache = cache.getAmount(resource); + for (final ResourceKey resource : updatedCache.getAll()) { + final long amountInUpdatedCache = updatedCache.get(resource); + final long amountInOldCache = cache.get(resource); final boolean doesNotExistInOldCache = amountInOldCache == 0; if (doesNotExistInOldCache) { addToCache(resource, amountInUpdatedCache); @@ -107,7 +107,7 @@ private void addToCache(final ResourceKey resource, final long amount) { } private void removeFromCache(final ResourceKey resource) { - removeFromCache(resource, cache.getAmount(resource)); + removeFromCache(resource, cache.get(resource)); } private void removeFromCache(final ResourceKey resource, final long amount) { @@ -123,7 +123,7 @@ private ResourceList buildCache() { @Override public Collection getAll() { - return cache.getAll(); + return cache.copyState(); } @Override diff --git a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorage.java b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorage.java index 1770c1cb2..1fb5f228d 100644 --- a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorage.java +++ b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorage.java @@ -34,7 +34,7 @@ public interface RootStorage extends Storage, TrackedStorage { * @param resource the resource * @return the amount stored, or zero if not stored */ - long getAmount(ResourceKey resource); + long get(ResourceKey resource); /** * @param resource the resource diff --git a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImpl.java b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImpl.java index ec3a2ac0d..b85e38871 100644 --- a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImpl.java +++ b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImpl.java @@ -63,8 +63,8 @@ public void removeListener(final ResourceListListener listener) { } @Override - public long getAmount(final ResourceKey resource) { - return list.getAmount(resource); + public long get(final ResourceKey resource) { + return list.get(resource); } @Override diff --git a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImplTest.java b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImplTest.java index 1d6aca0f7..39d94eeac 100644 --- a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImplTest.java +++ b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImplTest.java @@ -231,8 +231,8 @@ void shouldRetrieveResourceAmount() { sut.addSource(storage); // Act & assert - assertThat(sut.getAmount(A)).isEqualTo(25); - assertThat(sut.getAmount(B)).isZero(); + assertThat(sut.get(A)).isEqualTo(25); + assertThat(sut.get(B)).isZero(); } @Test From 5bb69a45639cbac0b25dae4d4902c8e1dda741e3 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Sat, 3 Aug 2024 13:57:48 +0200 Subject: [PATCH 22/36] refactor: use internal entry representation in ResourceList --- .../resource/list/FuzzyResourceListImpl.java | 5 +- .../api/grid/view/GridViewImpl.java | 6 +- .../grid/watcher/GridWatcherRegistration.java | 7 +- .../impl/node/relay/RelayOutputStorage.java | 2 +- .../ExternalStorageNetworkNodeTest.java | 2 +- .../node/iface/InterfaceExportStateImpl.java | 10 +- .../api/resource/ResourceAmount.java | 27 +---- .../api/resource/list/ResourceList.java | 9 +- .../api/resource/list/ResourceListImpl.java | 81 +++++++++------ .../api/resource/ResourceAmountTest.java | 99 ------------------- .../list/AbstractResourceListTest.java | 64 ++++++------ .../ListenableResourceListTest.java | 16 +-- .../api/storage/root/RootStorageImplTest.java | 10 +- 13 files changed, 119 insertions(+), 219 deletions(-) delete mode 100644 refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/ResourceAmountTest.java diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImpl.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImpl.java index 2df754611..71f2254cf 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImpl.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/list/FuzzyResourceListImpl.java @@ -30,8 +30,7 @@ public OperationResult add(final ResourceKey resource, final long amount) { private void addToIndex(final ResourceKey resource, final OperationResult result) { if (resource instanceof FuzzyModeNormalizer normalizer) { - normalizedFuzzyMap.computeIfAbsent(normalizer.normalize(), k -> new HashSet<>()) - .add(result.resourceAmount().getResource()); + normalizedFuzzyMap.computeIfAbsent(normalizer.normalize(), k -> new HashSet<>()).add(result.resource()); } } @@ -54,7 +53,7 @@ private void removeFromIndex(final ResourceKey resource, final OperationResult r if (index == null) { return; } - index.remove(result.resourceAmount().getResource()); + index.remove(result.resource()); if (index.isEmpty()) { normalizedFuzzyMap.remove(normalized); } diff --git a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java index fd754bdea..6f84f5c7e 100644 --- a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java +++ b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/view/GridViewImpl.java @@ -161,8 +161,7 @@ private void reinsertZeroedResourceIntoViewList(final ResourceKey resource, final ResourceList.OperationResult operationResult, final GridResource oldGridResource) { LOGGER.debug("{} was zeroed, unzeroing", resource); - final GridResource newResource = resourceFactory.apply(operationResult.resourceAmount().getResource()) - .orElseThrow(); + final GridResource newResource = resourceFactory.apply(operationResult.resource()).orElseThrow(); viewListIndex.put(resource, newResource); final int index = CoreValidations.validateNotNegative( viewList.indexOf(oldGridResource), @@ -202,8 +201,7 @@ private void updateExistingResourceInViewList(final ResourceKey resource, private void handleChangeForNewResource(final ResourceKey resource, final ResourceList.OperationResult operationResult) { - final GridResource gridResource = resourceFactory.apply(operationResult.resourceAmount().getResource()) - .orElseThrow(); + final GridResource gridResource = resourceFactory.apply(operationResult.resource()).orElseThrow(); if (filter.test(this, gridResource)) { LOGGER.debug("Filter allowed, actually adding {}", resource); viewListIndex.put(resource, gridResource); diff --git a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/watcher/GridWatcherRegistration.java b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/watcher/GridWatcherRegistration.java index 5dae822b6..5dced34a3 100644 --- a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/watcher/GridWatcherRegistration.java +++ b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/watcher/GridWatcherRegistration.java @@ -19,12 +19,9 @@ class GridWatcherRegistration { void attach(final RootStorage rootStorage, final boolean replay) { this.listener = change -> watcher.onChanged( - change.resourceAmount().getResource(), + change.resource(), change.change(), - rootStorage.findTrackedResourceByActorType( - change.resourceAmount().getResource(), - actorType - ).orElse(null) + rootStorage.findTrackedResourceByActorType(change.resource(), actorType).orElse(null) ); rootStorage.addListener(listener); if (replay) { diff --git a/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/relay/RelayOutputStorage.java b/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/relay/RelayOutputStorage.java index 96f1756f5..6fb25259f 100644 --- a/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/relay/RelayOutputStorage.java +++ b/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/relay/RelayOutputStorage.java @@ -163,7 +163,7 @@ public void onChanged(final ResourceList.OperationResult change) { if (delegate != null && delegate.contains(delegate)) { return; } - final ResourceKey resource = change.resourceAmount().getResource(); + final ResourceKey resource = change.resource(); if (!filter.isAllowed(resource)) { return; } 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 a04702497..89489c30e 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 @@ -592,7 +592,7 @@ private AtomicBoolean trackWhetherResourceHasChangedAndTrackedResourceIsAvailabl ) { final AtomicBoolean found = new AtomicBoolean(); networkStorage.addListener(change -> { - if (change.resourceAmount().getResource().equals(A)) { + if (change.resource().equals(A)) { found.set(networkStorage.findTrackedResourceByActorType(A, FakeActor.class).isPresent()); } }); diff --git a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/InterfaceExportStateImpl.java b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/InterfaceExportStateImpl.java index 7b4843241..5aa92b389 100644 --- a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/InterfaceExportStateImpl.java +++ b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/InterfaceExportStateImpl.java @@ -134,7 +134,10 @@ public void shrinkExportedAmount(final int slotIndex, final long amount) { if (resourceAmount.getAmount() - amount <= 0) { this.current.remove(slotIndex); } else { - resourceAmount.decrement(amount); + this.current.put( + slotIndex, + new ResourceAmount(resourceAmount.getResource(), resourceAmount.getAmount() - amount) + ); } } @@ -142,7 +145,10 @@ public void shrinkExportedAmount(final int slotIndex, final long amount) { public void growExportedAmount(final int slotIndex, final long amount) { validateIndex(slotIndex); final ResourceAmount resourceAmount = this.current.get(slotIndex); - resourceAmount.increment(amount); + this.current.put( + slotIndex, + new ResourceAmount(resourceAmount.getResource(), resourceAmount.getAmount() + amount) + ); } @Override diff --git a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/ResourceAmount.java b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/ResourceAmount.java index b9f697637..c815886da 100644 --- a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/ResourceAmount.java +++ b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/ResourceAmount.java @@ -11,7 +11,7 @@ @API(status = API.Status.STABLE, since = "2.0.0-milestone.1.2") public final class ResourceAmount { private final ResourceKey resource; - private long amount; + private final long amount; /** * @param resource the resource, must be non-null @@ -35,31 +35,6 @@ public ResourceAmount copy() { return new ResourceAmount(resource, amount); } - /** - * Increments with the given amount. - * - * @param amountToIncrement the amount to increment, must be larger than 0 - */ - public void increment(final long amountToIncrement) { - CoreValidations.validateLargerThanZero(amountToIncrement, "Amount to increment must be larger than 0"); - this.amount += amountToIncrement; - } - - /** - * Decrements with the given amount. - * The amount, after performing this decrement, may not be 0 or less than 0. - * - * @param amountToDecrement the amount to decrement, a positive number - */ - public void decrement(final long amountToDecrement) { - CoreValidations.validateLargerThanZero(amountToDecrement, "Amount to decrement must be larger than 0"); - CoreValidations.validateLargerThanZero( - amount - amountToDecrement, - "Cannot decrement, amount will be zero or negative" - ); - this.amount -= amountToDecrement; - } - @Override public String toString() { return "ResourceAmount{" diff --git a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java index 49e2dec39..aeeb1e3d5 100644 --- a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java +++ b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java @@ -94,11 +94,12 @@ default Optional remove(ResourceAmount resourceAmount) { /** * Represents the result of an operation in a {@link ResourceList}. * - * @param resourceAmount the current resource amount in the list - * @param change the delta caused by the operation - * @param available whether this resource is still available in the list, or if it was removed + * @param resource the resource affected by the operation + * @param amount teh current amount in the list + * @param change the delta caused by the operation + * @param available whether this resource is still available in the list, or if it was removed */ @API(status = API.Status.STABLE, since = "2.0.0-milestone.1.2") - record OperationResult(ResourceAmount resourceAmount, long change, boolean available) { + record OperationResult(ResourceKey resource, long amount, long change, boolean available) { } } diff --git a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java index cdd0e2373..c47cc8be0 100644 --- a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java +++ b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceListImpl.java @@ -1,5 +1,6 @@ package com.refinedmods.refinedstorage.api.resource.list; +import com.refinedmods.refinedstorage.api.core.CoreValidations; import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.resource.ResourceKey; @@ -17,9 +18,9 @@ */ @API(status = API.Status.STABLE, since = "2.0.0-milestone.1.2") public class ResourceListImpl implements ResourceList { - private final Map entries; + private final Map entries; - private ResourceListImpl(final Map entries) { + private ResourceListImpl(final Map entries) { this.entries = entries; } @@ -33,7 +34,8 @@ public static ResourceListImpl orderPreserving() { @Override public OperationResult add(final ResourceKey resource, final long amount) { - final ResourceAmount existing = entries.get(resource); + ResourceAmount.validate(resource, amount); + final Entry existing = entries.get(resource); if (existing != null) { return addToExisting(existing, amount); } else { @@ -41,54 +43,49 @@ public OperationResult add(final ResourceKey resource, final long amount) { } } - private OperationResult addToExisting(final ResourceAmount resourceAmount, final long amount) { - resourceAmount.increment(amount); - - return new OperationResult(resourceAmount, amount, true); + private OperationResult addToExisting(final Entry entry, final long amount) { + entry.increment(amount); + return new OperationResult(entry.resource, entry.amount, amount, true); } private OperationResult addNew(final ResourceKey resource, final long amount) { - final ResourceAmount resourceAmount = new ResourceAmount(resource, amount); - entries.put(resource, resourceAmount); - return new OperationResult(resourceAmount, amount, true); + final Entry entry = new Entry(resource, amount); + entries.put(resource, entry); + return new OperationResult(resource, amount, amount, true); } @Override public Optional remove(final ResourceKey resource, final long amount) { ResourceAmount.validate(resource, amount); - - final ResourceAmount existing = entries.get(resource); + final Entry existing = entries.get(resource); if (existing != null) { - if (existing.getAmount() - amount <= 0) { + if (existing.amount - amount <= 0) { return removeCompletely(existing); } else { return removePartly(amount, existing); } } - return Optional.empty(); } - private Optional removePartly(final long amount, - final ResourceAmount resourceAmount) { - resourceAmount.decrement(amount); - - return Optional.of(new OperationResult(resourceAmount, -amount, true)); + private Optional removePartly(final long amount, final Entry entry) { + entry.decrement(amount); + return Optional.of(new OperationResult(entry.resource, entry.amount, -amount, true)); } - private Optional removeCompletely(final ResourceAmount resourceAmount) { - entries.remove(resourceAmount.getResource()); - + private Optional removeCompletely(final Entry entry) { + entries.remove(entry.resource); return Optional.of(new OperationResult( - resourceAmount, - -resourceAmount.getAmount(), + entry.resource, + 0, + -entry.amount, false )); } @Override public Collection copyState() { - return entries.values(); + return entries.values().stream().map(Entry::toResourceAmount).toList(); } @Override @@ -98,8 +95,8 @@ public Set getAll() { @Override public long get(final ResourceKey resource) { - final ResourceAmount entry = entries.get(resource); - return entry != null ? entry.getAmount() : 0; + final Entry entry = entries.get(resource); + return entry != null ? entry.amount : 0; } @Override @@ -115,7 +112,35 @@ public void clear() { @Override public ResourceList copy() { final ResourceList copy = ResourceListImpl.create(); - entries.forEach((key, value) -> copy.add(key, value.getAmount())); + entries.forEach((key, entry) -> copy.add(key, entry.amount)); return copy; } + + private static class Entry { + private final ResourceKey resource; + private long amount; + + private Entry(final ResourceKey resource, final long amount) { + this.resource = resource; + this.amount = amount; + } + + private void increment(final long amountToIncrement) { + CoreValidations.validateLargerThanZero(amountToIncrement, "Amount to increment must be larger than 0"); + this.amount += amountToIncrement; + } + + private void decrement(final long amountToDecrement) { + CoreValidations.validateLargerThanZero(amountToDecrement, "Amount to decrement must be larger than 0"); + CoreValidations.validateLargerThanZero( + amount - amountToDecrement, + "Cannot decrement, amount will be zero or negative" + ); + this.amount -= amountToDecrement; + } + + private ResourceAmount toResourceAmount() { + return new ResourceAmount(resource, amount); + } + } } diff --git a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/ResourceAmountTest.java b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/ResourceAmountTest.java deleted file mode 100644 index b692225de..000000000 --- a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/ResourceAmountTest.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.refinedmods.refinedstorage.api.resource; - -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertThrows; - -class ResourceAmountTest { - @Test - void testValidResource() { - // Act - final ResourceAmount resourceAmount = new ResourceAmount(TestResource.A, 1); - - // Assert - assertThat(resourceAmount.getAmount()).isEqualTo(1); - assertThat(resourceAmount.getResource()).isEqualTo(TestResource.A); - } - - @Test - @SuppressWarnings("ConstantConditions") - void testInvalidResource() { - // Act & assert - assertThrows(NullPointerException.class, () -> new ResourceAmount(null, 1)); - } - - @Test - void testInvalidAmount() { - // Act & assert - assertThrows(IllegalArgumentException.class, () -> new ResourceAmount(TestResource.A, 0)); - assertThrows(IllegalArgumentException.class, () -> new ResourceAmount(TestResource.A, -1)); - } - - @Test - void shouldNotIncrementZeroOrNegativeAmount() { - // Arrange - final ResourceAmount sut = new ResourceAmount(TestResource.A, 1); - - // Act & assert - assertThrows(IllegalArgumentException.class, () -> sut.increment(0)); - assertThrows(IllegalArgumentException.class, () -> sut.increment(-1)); - } - - @Test - void shouldNotDecrementZeroOrNegativeAmount() { - // Arrange - final ResourceAmount sut = new ResourceAmount(TestResource.A, 3); - - // Act & assert - assertThrows(IllegalArgumentException.class, () -> sut.decrement(0)); - assertThrows(IllegalArgumentException.class, () -> sut.decrement(-1)); - } - - @Test - void shouldNotDecrementLeadingToZeroAmount() { - // Arrange - final ResourceAmount sut = new ResourceAmount(TestResource.A, 3); - - // Act & assert - assertThrows(IllegalArgumentException.class, () -> sut.decrement(3)); - } - - @Test - void shouldIncrement() { - // Arrange - final ResourceAmount sut = new ResourceAmount(TestResource.A, 3); - - // Act - sut.increment(2); - - // Assert - assertThat(sut.getAmount()).isEqualTo(5); - } - - @Test - void shouldDecrement() { - // Arrange - final ResourceAmount sut = new ResourceAmount(TestResource.A, 3); - - // Act - sut.decrement(2); - - // Assert - assertThat(sut.getAmount()).isEqualTo(1); - } - - @Test - void testToString() { - // Arrange - final ResourceAmount sut = new ResourceAmount(TestResource.A, 3); - - // Act & assert - assertThat(sut).hasToString( - "ResourceAmount{" - + "resource=A" - + ", amount=3" - + '}' - ); - } -} diff --git a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractResourceListTest.java b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractResourceListTest.java index 4b29f561f..2ed6f703c 100644 --- a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractResourceListTest.java +++ b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/AbstractResourceListTest.java @@ -31,8 +31,8 @@ void shouldAddNewResource() { // Assert assertThat(result.change()).isEqualTo(10); - assertThat(result.resourceAmount().getAmount()).isEqualTo(10); - assertThat(result.resourceAmount().getResource()).isEqualTo(TestResource.A); + assertThat(result.amount()).isEqualTo(10); + assertThat(result.resource()).isEqualTo(TestResource.A); assertThat(result.available()).isTrue(); assertThat(list.copyState()).usingRecursiveFieldByFieldElementComparator().containsExactly( @@ -51,8 +51,8 @@ void shouldAddNewResourceWithResourceAmountDirectly() { // Assert assertThat(result.change()).isEqualTo(10); - assertThat(result.resourceAmount().getAmount()).isEqualTo(10); - assertThat(result.resourceAmount().getResource()).isEqualTo(TestResource.A); + assertThat(result.amount()).isEqualTo(10); + assertThat(result.resource()).isEqualTo(TestResource.A); assertThat(result.available()).isTrue(); assertThat(list.copyState()).usingRecursiveFieldByFieldElementComparator().containsExactly( @@ -72,13 +72,13 @@ void shouldAddMultipleOfSameResource() { // Assert assertThat(result1.change()).isEqualTo(10); - assertThat(result1.resourceAmount().getAmount()).isEqualTo(15); - assertThat(result1.resourceAmount().getResource()).isEqualTo(TestResource.A); + assertThat(result1.amount()).isEqualTo(10); + assertThat(result1.resource()).isEqualTo(TestResource.A); assertThat(result1.available()).isTrue(); assertThat(result2.change()).isEqualTo(5); - assertThat(result1.resourceAmount().getAmount()).isEqualTo(15); - assertThat(result1.resourceAmount().getResource()).isEqualTo(TestResource.A); + assertThat(result2.amount()).isEqualTo(15); + assertThat(result2.resource()).isEqualTo(TestResource.A); assertThat(result2.available()).isTrue(); assertThat(list.copyState()).usingRecursiveFieldByFieldElementComparator().containsExactly( @@ -99,18 +99,18 @@ void shouldAddMultipleOfDifferentResources() { // Assert assertThat(result1.change()).isEqualTo(10); - assertThat(result1.resourceAmount().getAmount()).isEqualTo(15); - assertThat(result1.resourceAmount().getResource()).isEqualTo(TestResource.A); + assertThat(result1.amount()).isEqualTo(10); + assertThat(result1.resource()).isEqualTo(TestResource.A); assertThat(result1.available()).isTrue(); assertThat(result2.change()).isEqualTo(5); - assertThat(result2.resourceAmount().getAmount()).isEqualTo(15); - assertThat(result2.resourceAmount().getResource()).isEqualTo(TestResource.A); + assertThat(result2.amount()).isEqualTo(15); + assertThat(result2.resource()).isEqualTo(TestResource.A); assertThat(result2.available()).isTrue(); assertThat(result3.change()).isEqualTo(3); - assertThat(result3.resourceAmount().getAmount()).isEqualTo(3); - assertThat(result3.resourceAmount().getResource()).isEqualTo(TestResource.B); + assertThat(result3.amount()).isEqualTo(3); + assertThat(result3.resource()).isEqualTo(TestResource.B); assertThat(result3.available()).isTrue(); assertThat(list.copyState()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( @@ -160,8 +160,8 @@ void shouldRemoveResourcePartly() { // Assert assertThat(result2).isPresent(); assertThat(result2.get().change()).isEqualTo(-5); - assertThat(result2.get().resourceAmount().getAmount()).isEqualTo(15); - assertThat(result2.get().resourceAmount().getResource()).isEqualTo(TestResource.A); + assertThat(result2.get().amount()).isEqualTo(15); + assertThat(result2.get().resource()).isEqualTo(TestResource.A); assertThat(result2.get().available()).isTrue(); assertThat(list.copyState()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( @@ -192,8 +192,8 @@ void shouldRemoveResourcePartlyWithResourceAmountDirectly() { // Assert assertThat(result2).isPresent(); assertThat(result2.get().change()).isEqualTo(-5); - assertThat(result2.get().resourceAmount().getAmount()).isEqualTo(15); - assertThat(result2.get().resourceAmount().getResource()).isEqualTo(TestResource.A); + assertThat(result2.get().amount()).isEqualTo(15); + assertThat(result2.get().resource()).isEqualTo(TestResource.A); assertThat(result2.get().available()).isTrue(); assertThat(list.copyState()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( @@ -216,14 +216,14 @@ void shouldRemoveResourceCompletely() { list.add(TestResource.B, 6); // Act - final Optional result2 = list.remove(TestResource.A, 20); + final Optional result = list.remove(TestResource.A, 20); // Assert - assertThat(result2).isPresent(); - assertThat(result2.get().change()).isEqualTo(-20); - assertThat(result2.get().resourceAmount().getAmount()).isEqualTo(20); - assertThat(result2.get().resourceAmount().getResource()).isEqualTo(TestResource.A); - assertThat(result2.get().available()).isFalse(); + assertThat(result).isPresent(); + assertThat(result.get().change()).isEqualTo(-20); + assertThat(result.get().amount()).isZero(); + assertThat(result.get().resource()).isEqualTo(TestResource.A); + assertThat(result.get().available()).isFalse(); assertThat(list.copyState()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( new ResourceAmount(TestResource.B, 6) @@ -252,8 +252,8 @@ void shouldRemoveResourceCompletelyWithResourceAmountDirectly() { // Assert assertThat(result2).isPresent(); assertThat(result2.get().change()).isEqualTo(-20); - assertThat(result2.get().resourceAmount().getAmount()).isEqualTo(20); - assertThat(result2.get().resourceAmount().getResource()).isEqualTo(TestResource.A); + assertThat(result2.get().amount()).isZero(); + assertThat(result2.get().resource()).isEqualTo(TestResource.A); assertThat(result2.get().available()).isFalse(); assertThat(list.copyState()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( @@ -275,14 +275,14 @@ void shouldNotRemoveResourceWithMoreThanIsAvailable() { list.add(TestResource.B, 6); // Act - final Optional result2 = list.remove(TestResource.A, 21); + final Optional result = list.remove(TestResource.A, 21); // Assert - assertThat(result2).isPresent(); - assertThat(result2.get().change()).isEqualTo(-20); - assertThat(result2.get().resourceAmount().getAmount()).isEqualTo(20); - assertThat(result2.get().resourceAmount().getResource()).isEqualTo(TestResource.A); - assertThat(result2.get().available()).isFalse(); + assertThat(result).isPresent(); + assertThat(result.get().change()).isEqualTo(-20); + assertThat(result.get().amount()).isZero(); + assertThat(result.get().resource()).isEqualTo(TestResource.A); + assertThat(result.get().available()).isFalse(); assertThat(list.copyState()).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder( new ResourceAmount(TestResource.B, 6) diff --git a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/listenable/ListenableResourceListTest.java b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/listenable/ListenableResourceListTest.java index 24aa02530..4cf2d9393 100644 --- a/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/listenable/ListenableResourceListTest.java +++ b/refinedstorage-resource-api/src/test/java/com/refinedmods/refinedstorage/api/resource/list/listenable/ListenableResourceListTest.java @@ -35,8 +35,8 @@ void shouldCallListenerWhenAdding() { // Assert assertThat(result.change()).isEqualTo(10); - assertThat(result.resourceAmount().getAmount()).isEqualTo(10); - assertThat(result.resourceAmount().getResource()).isEqualTo(TestResource.A); + assertThat(result.amount()).isEqualTo(10); + assertThat(result.resource()).isEqualTo(TestResource.A); assertThat(result.available()).isTrue(); assertThat(listener.changes).hasSize(1); } @@ -48,8 +48,8 @@ void shouldNotCallListenerWhenAddingWithoutListener() { // Assert assertThat(result.change()).isEqualTo(10); - assertThat(result.resourceAmount().getAmount()).isEqualTo(10); - assertThat(result.resourceAmount().getResource()).isEqualTo(TestResource.A); + assertThat(result.amount()).isEqualTo(10); + assertThat(result.resource()).isEqualTo(TestResource.A); assertThat(result.available()).isTrue(); assertThat(listener.changes).isEmpty(); } @@ -66,8 +66,8 @@ void shouldCallListenerWhenRemoving() { // Assert assertThat(result).isPresent(); assertThat(result.get().change()).isEqualTo(-10); - assertThat(result.get().resourceAmount().getAmount()).isEqualTo(10); - assertThat(result.get().resourceAmount().getResource()).isEqualTo(TestResource.A); + assertThat(result.get().amount()).isZero(); + assertThat(result.get().resource()).isEqualTo(TestResource.A); assertThat(result.get().available()).isFalse(); assertThat(listener.changes).hasSize(2); } @@ -83,8 +83,8 @@ void shouldNotCallListenerWhenRemovingWithoutListener() { // Assert assertThat(result).isPresent(); assertThat(result.get().change()).isEqualTo(-10); - assertThat(result.get().resourceAmount().getAmount()).isEqualTo(10); - assertThat(result.get().resourceAmount().getResource()).isEqualTo(TestResource.A); + assertThat(result.get().amount()).isZero(); + assertThat(result.get().resource()).isEqualTo(TestResource.A); assertThat(result.get().available()).isFalse(); assertThat(listener.changes).isEmpty(); } diff --git a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImplTest.java b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImplTest.java index 39d94eeac..da1362897 100644 --- a/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImplTest.java +++ b/refinedstorage-storage-api/src/test/java/com/refinedmods/refinedstorage/api/storage/root/RootStorageImplTest.java @@ -114,9 +114,8 @@ void shouldCallListenerOnInsertion(final Action action) { verify(listener, atMost(1)).onChanged(changedResource.capture()); assertThat(changedResource.getValue().change()).isEqualTo(8); - assertThat(changedResource.getValue().resourceAmount()).usingRecursiveComparison().isEqualTo( - new ResourceAmount(A, 10) - ); + assertThat(changedResource.getValue().resource()).isEqualTo(A); + assertThat(changedResource.getValue().amount()).isEqualTo(10); } else { verify(listener, never()).onChanged(any()); } @@ -145,9 +144,8 @@ void shouldCallListenerOnExtraction(final Action action) { verify(listener, atMost(1)).onChanged(changedResource.capture()); assertThat(changedResource.getValue().change()).isEqualTo(-5); - assertThat(changedResource.getValue().resourceAmount()).usingRecursiveComparison().isEqualTo( - new ResourceAmount(A, 3) - ); + assertThat(changedResource.getValue().resource()).isEqualTo(A); + assertThat(changedResource.getValue().amount()).isEqualTo(3); } else { verify(listener, never()).onChanged(any()); } From a8adc849cc8f1295fd03065c1b6cfb1dda55f5f9 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Sat, 3 Aug 2024 14:12:02 +0200 Subject: [PATCH 23/36] refactor: make ResourceAmount an immutable record --- ...CraftingPatternClientTooltipComponent.java | 6 ++-- .../autocrafting/PatternGridBlockEntity.java | 4 +-- .../common/autocrafting/PatternRendering.java | 4 +-- ...ocessingPatternClientTooltipComponent.java | 12 ++++---- .../grid/AbstractGridContainerMenu.java | 8 ++--- .../common/storage/StorageCodecs.java | 8 ++--- .../storage/portablegrid/PortableGrid.java | 2 +- .../common/support/AbstractBaseScreen.java | 4 +-- .../support/resource/ResourceCodecs.java | 8 ++--- .../resource/ResourceContainerImpl.java | 16 +++++----- .../resource/ResourceContainerSlot.java | 8 ++--- .../ResourceClientTooltipComponent.java | 10 +++---- .../refinedstorage/fabric/PlatformImpl.java | 4 +-- .../ResourceContainerFluidStorageAdapter.java | 4 +-- .../grid/watcher/GridWatcherRegistration.java | 6 ++-- .../refinedstorage/neoforge/PlatformImpl.java | 4 +-- .../ResourceContainerFluidHandlerAdapter.java | 4 +-- .../refinedstorage/common/GameTestUtil.java | 30 +++++++++---------- .../impl/node/relay/RelayOutputStorage.java | 14 ++++----- .../StorageTransferNetworkNode.java | 6 ++-- .../storage/StorageNetworkComponentImpl.java | 2 +- .../node/iface/InterfaceExportStateImpl.java | 14 ++++----- .../api/resource/ResourceAmount.java | 30 ++----------------- .../api/resource/list/ResourceList.java | 4 +-- .../composite/CompositeStorageImpl.java | 4 +-- .../api/storage/external/ExternalStorage.java | 2 +- .../api/storage/TransferHelperTest.java | 12 ++++---- 27 files changed, 102 insertions(+), 128 deletions(-) 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 e06c204a1..52c833fb3 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 @@ -49,14 +49,14 @@ public CraftingPatternClientTooltipComponent(final int width, this.width = width; this.height = height; this.craftingPattern = craftingPattern; - final ItemResource outputResource = craftingPattern.output().getResource() instanceof ItemResource itemResource + final ItemResource outputResource = craftingPattern.output().resource() instanceof ItemResource itemResource ? itemResource : null; this.outputStack = outputResource != null - ? outputResource.toItemStack(craftingPattern.output().getAmount()) + ? outputResource.toItemStack(craftingPattern.output().amount()) : null; this.outputText = outputResource != null - ? Component.literal(String.format("%dx ", craftingPattern.output().getAmount())) + ? Component.literal(String.format("%dx ", craftingPattern.output().amount())) .append(outputResource.toItemStack().getHoverName()) .withStyle(ChatFormatting.GRAY) : null; } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridBlockEntity.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridBlockEntity.java index cf5e736fc..7881f4a9b 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridBlockEntity.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridBlockEntity.java @@ -244,11 +244,11 @@ private ItemStack createProcessingPattern() { final ItemStack result = createPatternStack(PatternType.PROCESSING); final List> inputs = new ArrayList<>(); for (int i = 0; i < processingInput.size(); ++i) { - inputs.add(Optional.ofNullable(processingInput.get(i)).map(ResourceAmount::copy)); + inputs.add(Optional.ofNullable(processingInput.get(i))); } final List> outputs = new ArrayList<>(); for (int i = 0; i < processingOutput.size(); ++i) { - outputs.add(Optional.ofNullable(processingOutput.get(i)).map(ResourceAmount::copy)); + outputs.add(Optional.ofNullable(processingOutput.get(i))); } final ProcessingPatternState patternProcessingState = new ProcessingPatternState( inputs, 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 165abc671..ca1143815 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 @@ -28,12 +28,12 @@ public static Optional getOutput(final ItemStack stack) { } return RefinedStorageApi.INSTANCE.getPattern(stack, level).map(pattern -> { if (pattern instanceof CraftingPattern craftingPattern - && craftingPattern.output().getResource() instanceof ItemResource itemResource) { + && craftingPattern.output().resource() instanceof ItemResource itemResource) { return itemResource.toItemStack(); } if (pattern instanceof ProcessingPattern processingPattern && processingPattern.outputs().size() == 1 - && processingPattern.outputs().getFirst().getResource() instanceof ItemResource itemResource) { + && processingPattern.outputs().getFirst().resource() instanceof ItemResource itemResource) { return itemResource.toItemStack(); } return null; 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 5131a51a2..b3a04f21e 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 @@ -60,14 +60,14 @@ private static List getOutputText(final ProcessingPatternState state) private static Component getOutputText(final ResourceAmount resourceAmount) { final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering( - resourceAmount.getResource() + resourceAmount.resource() ); final String displayAmount = rendering.getDisplayedAmount( - resourceAmount.getAmount(), + resourceAmount.amount(), false ); return Component.literal(String.format("%sx ", displayAmount)) - .append(rendering.getDisplayName(resourceAmount.getResource())) + .append(rendering.getDisplayName(resourceAmount.resource())) .withStyle(ChatFormatting.GRAY); } @@ -113,10 +113,10 @@ private void renderMatrixSlots(final int x, graphics.blitSprite(SLOT, slotX, slotY, 18, 18); slots.get(idx).ifPresent(resourceAmount -> { final ResourceRendering rendering = RefinedStorageApi.INSTANCE.getResourceRendering( - resourceAmount.getResource() + resourceAmount.resource() ); - rendering.render(resourceAmount.getResource(), graphics, slotX + 1, slotY + 1); - AbstractBaseScreen.renderResourceAmount(graphics, slotX + 1, slotY + 1, resourceAmount.getAmount(), + rendering.render(resourceAmount.resource(), graphics, slotX + 1, slotY + 1); + AbstractBaseScreen.renderResourceAmount(graphics, slotX + 1, slotY + 1, resourceAmount.amount(), rendering); }); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/AbstractGridContainerMenu.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/AbstractGridContainerMenu.java index 678bf3ca6..45fdf9efa 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/AbstractGridContainerMenu.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/AbstractGridContainerMenu.java @@ -101,10 +101,10 @@ protected AbstractGridContainerMenu( this.active = gridData.active(); final GridViewBuilder viewBuilder = createViewBuilder(); - gridData.resources().forEach(gridResource -> viewBuilder.withResource( - gridResource.resourceAmount().getResource(), - gridResource.resourceAmount().getAmount(), - gridResource.trackedResource().orElse(null) + gridData.resources().forEach(resource -> viewBuilder.withResource( + resource.resourceAmount().resource(), + resource.resourceAmount().amount(), + resource.trackedResource().orElse(null) )); this.view = viewBuilder.build(); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/StorageCodecs.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/StorageCodecs.java index 9ec837f8f..cfd0c8031 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/StorageCodecs.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/StorageCodecs.java @@ -67,7 +67,7 @@ static StorageData ofSameTypeStorage( ? Optional.of(limitedStorage.getCapacity()) : Optional.empty(); final List> resources = storage.getAll().stream() - .filter(resourceAmount -> valid.test(resourceAmount.getResource())) + .filter(resourceAmount -> valid.test(resourceAmount.resource())) .map(resourceAmount -> getResource(storage, caster, resourceAmount)) .toList(); return new StorageData<>(capacity, resources); @@ -79,8 +79,8 @@ private static StorageResource getResource( final ResourceAmount resourceAmount ) { return new StorageResource<>( - caster.apply(resourceAmount.getResource()), - resourceAmount.getAmount(), + caster.apply(resourceAmount.resource()), + resourceAmount.amount(), getChanged(storage, resourceAmount) ); } @@ -90,7 +90,7 @@ private static Optional getChanged(final Storage storage, if (!(storage instanceof TrackedStorage trackedStorage)) { return Optional.empty(); } - return trackedStorage.findTrackedResourceByActorType(resourceAmount.getResource(), PlayerActor.class) + return trackedStorage.findTrackedResourceByActorType(resourceAmount.resource(), PlayerActor.class) .map(StorageChangedByAt::ofTrackedResource); } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/portablegrid/PortableGrid.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/portablegrid/PortableGrid.java index 22e2c6dde..90d548274 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/portablegrid/PortableGrid.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/storage/portablegrid/PortableGrid.java @@ -106,7 +106,7 @@ public List getResources(final Class act final RootStorage rootStorage = storage.getRootStorage(); return rootStorage.getAll().stream().map(resource -> new TrackedResourceAmount( resource, - rootStorage.findTrackedResourceByActorType(resource.getResource(), actorType).orElse(null) + rootStorage.findTrackedResourceByActorType(resource.resource(), actorType).orElse(null) )).toList(); } 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 713e825c2..a1c8f07e6 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 @@ -250,7 +250,7 @@ private List getResourceSlotHelpTooltip(final ItemStack resourceSlot.getPrimaryResourceFactory().create(carried).ifPresent(primaryResourceInstance -> lines.add( MouseClientTooltipComponent.resource( MouseClientTooltipComponent.Type.LEFT, - primaryResourceInstance.getResource(), + primaryResourceInstance.resource(), null ) )); @@ -258,7 +258,7 @@ private List getResourceSlotHelpTooltip(final ItemStack final var result = alternativeResourceFactory.create(carried); result.ifPresent(alternativeResourceInstance -> lines.add(MouseClientTooltipComponent.resource( MouseClientTooltipComponent.Type.RIGHT, - alternativeResourceInstance.getResource(), + alternativeResourceInstance.resource(), null ))); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceCodecs.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceCodecs.java index 2c1e07eaa..2ebd5e36f 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceCodecs.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceCodecs.java @@ -37,8 +37,8 @@ public final class ResourceCodecs { .codec() .dispatch(PlatformResourceKey::getResourceType, ResourceType::getMapCodec); public static final Codec AMOUNT_CODEC = RecordCodecBuilder.create(instance -> instance.group( - CODEC.fieldOf("resource").forGetter(resourceAmount -> (PlatformResourceKey) resourceAmount.getResource()), - Codec.LONG.fieldOf("amount").forGetter(ResourceAmount::getAmount) + CODEC.fieldOf("resource").forGetter(resourceAmount -> (PlatformResourceKey) resourceAmount.resource()), + Codec.LONG.fieldOf("amount").forGetter(ResourceAmount::amount) ).apply(instance, ResourceAmount::new)); public static final Codec> AMOUNT_OPTIONAL_CODEC = AMOUNT_CODEC.optionalFieldOf("resource") .codec(); @@ -64,12 +64,12 @@ public void encode(final RegistryFriendlyByteBuf buf, final PlatformResourceKey }; public static final StreamCodec AMOUNT_STREAM_CODEC = StreamCodec.of( (buf, resourceAmount) -> { - final ResourceKey resourceKey = resourceAmount.getResource(); + final ResourceKey resourceKey = resourceAmount.resource(); if (!(resourceKey instanceof PlatformResourceKey platformResourceKey)) { throw new DecoderException("Cannot encode non-platform resource key"); } STREAM_CODEC.encode(buf, platformResourceKey); - buf.writeLong(resourceAmount.getAmount()); + buf.writeLong(resourceAmount.amount()); }, buf -> { final PlatformResourceKey resourceKey = STREAM_CODEC.decode(buf); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceContainerImpl.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceContainerImpl.java index 8e62a7724..287d1865d 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceContainerImpl.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceContainerImpl.java @@ -95,7 +95,7 @@ public long getAmount(final int index) { if (slot == null) { return 0; } - return slot.getResourceAmount().getAmount(); + return slot.getResourceAmount().amount(); } @Override @@ -116,7 +116,7 @@ public void setAmount(final int index, final long amount) { if (slot == null) { return; } - final long newAmount = MathUtil.clamp(amount, 0, getMaxAmount(slot.getResourceAmount().getResource())); + final long newAmount = MathUtil.clamp(amount, 0, getMaxAmount(slot.getResourceAmount().resource())); if (newAmount == 0) { remove(index); } else { @@ -190,7 +190,7 @@ public Set getUniqueResources() { if (slot == null) { continue; } - result.add(slot.getResourceAmount().getResource()); + result.add(slot.getResourceAmount().resource()); } return result; } @@ -203,7 +203,7 @@ public List getResources() { if (slot == null) { continue; } - result.add(slot.getResourceAmount().getResource()); + result.add(slot.getResourceAmount().resource()); } return result; } @@ -290,7 +290,7 @@ public long insert(final ResourceKey resource, final long amount, final Action a final ResourceAmount slot = get(i); if (slot == null) { remainder -= insertIntoEmptySlot(i, platformResource, action, remainder); - } else if (slot.getResource().equals(resource)) { + } else if (slot.resource().equals(resource)) { remainder -= insertIntoExistingSlot( i, platformResource, @@ -322,7 +322,7 @@ private long insertIntoExistingSlot(final int slotIndex, final Action action, final long amount, final ResourceAmount existing) { - final long spaceRemaining = resource.getInterfaceExportLimit() - existing.getAmount(); + final long spaceRemaining = resource.getInterfaceExportLimit() - existing.amount(); final long inserted = Math.min(spaceRemaining, amount); if (action == Action.EXECUTE) { grow(slotIndex, inserted); @@ -335,11 +335,11 @@ public long extract(final ResourceKey resource, final long amount, final Action long extracted = 0; for (int i = 0; i < size(); ++i) { final ResourceAmount slotContents = get(i); - if (slotContents == null || !resource.equals(slotContents.getResource())) { + if (slotContents == null || !resource.equals(slotContents.resource())) { continue; } final long stillNeeded = amount - extracted; - final long toExtract = Math.min(slotContents.getAmount(), stillNeeded); + final long toExtract = Math.min(slotContents.amount(), stillNeeded); if (action == Action.EXECUTE) { shrink(i, toExtract); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceContainerSlot.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceContainerSlot.java index b8eff1aed..fed125bb0 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceContainerSlot.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceContainerSlot.java @@ -13,8 +13,8 @@ class ResourceContainerSlot { ResourceContainerSlot(final ResourceAmount resourceAmount) { this.resourceAmount = resourceAmount; - this.stackRepresentation = resourceAmount.getResource() instanceof ItemResource itemResource - ? itemResource.toItemStack(resourceAmount.getAmount()) + this.stackRepresentation = resourceAmount.resource() instanceof ItemResource itemResource + ? itemResource.toItemStack(resourceAmount.amount()) : ItemStack.EMPTY; } @@ -23,7 +23,7 @@ ResourceAmount getResourceAmount() { } PlatformResourceKey getPlatformResource() { - return (PlatformResourceKey) resourceAmount.getResource(); + return (PlatformResourceKey) resourceAmount.resource(); } ItemStack getStackRepresentation() { @@ -31,7 +31,7 @@ ItemStack getStackRepresentation() { } ResourceContainerSlot withAmount(final long newAmount) { - return new ResourceContainerSlot(new ResourceAmount(resourceAmount.getResource(), newAmount)); + return new ResourceContainerSlot(new ResourceAmount(resourceAmount.resource(), newAmount)); } @Override 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 c5bb0b3a4..4a43b83f1 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,8 +33,8 @@ 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.getResource()).render( - resourceAmount.getResource(), + RefinedStorageApi.INSTANCE.getResourceRendering(resourceAmount.resource()).render( + resourceAmount.resource(), graphics, x, y @@ -50,10 +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.getResource() + resourceAmount.resource() ); - final String amount = rendering.getDisplayedAmount(resourceAmount.getAmount(), true); - final Component displayName = rendering.getDisplayName(resourceAmount.getResource()); + final String amount = rendering.getDisplayedAmount(resourceAmount.amount(), true); + final Component displayName = rendering.getDisplayName(resourceAmount.resource()); if (amount.isEmpty()) { return displayName; } diff --git a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/PlatformImpl.java b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/PlatformImpl.java index 6cdaf7999..840267efc 100644 --- a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/PlatformImpl.java +++ b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/PlatformImpl.java @@ -175,7 +175,7 @@ public Optional drainContainer(final ItemStack container) @Override public Optional fillContainer(final ItemStack container, final ResourceAmount resourceAmount) { - if (!(resourceAmount.getResource() instanceof FluidResource fluidResource)) { + if (!(resourceAmount.resource() instanceof FluidResource fluidResource)) { return Optional.empty(); } final SimpleSingleStackStorage interceptingStorage = new SimpleSingleStackStorage(container); @@ -186,7 +186,7 @@ public Optional fillContainer(final ItemStack container, return Optional.empty(); } try (Transaction tx = Transaction.openOuter()) { - final long inserted = storage.insert(toFluidVariant(fluidResource), resourceAmount.getAmount(), tx); + final long inserted = storage.insert(toFluidVariant(fluidResource), resourceAmount.amount(), tx); return Optional.of(new FluidOperationResult( interceptingStorage.getStack(), fluidResource, diff --git a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/support/resource/ResourceContainerFluidStorageAdapter.java b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/support/resource/ResourceContainerFluidStorageAdapter.java index ab9b06a3e..222d680db 100644 --- a/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/support/resource/ResourceContainerFluidStorageAdapter.java +++ b/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/support/resource/ResourceContainerFluidStorageAdapter.java @@ -88,11 +88,11 @@ private StorageViewImpl(final int index) { public long extract(final FluidVariant resource, final long maxAmount, final TransactionContext transaction) { final ResourceAmount resourceAmount = resourceContainer.get(index); if (resourceAmount == null - || !(resourceAmount.getResource() instanceof FluidResource fluidResource) + || !(resourceAmount.resource() instanceof FluidResource fluidResource) || !resource.equals(toFluidVariant(fluidResource))) { return 0; } - final long extracted = Math.min(maxAmount, resourceAmount.getAmount()); + final long extracted = Math.min(maxAmount, resourceAmount.amount()); if (extracted > 0) { updateSnapshots(transaction); } diff --git a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/watcher/GridWatcherRegistration.java b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/watcher/GridWatcherRegistration.java index 5dced34a3..03ce20edb 100644 --- a/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/watcher/GridWatcherRegistration.java +++ b/refinedstorage-grid-api/src/main/java/com/refinedmods/refinedstorage/api/grid/watcher/GridWatcherRegistration.java @@ -26,10 +26,10 @@ void attach(final RootStorage rootStorage, final boolean replay) { rootStorage.addListener(listener); if (replay) { rootStorage.getAll().forEach(resourceAmount -> watcher.onChanged( - resourceAmount.getResource(), - resourceAmount.getAmount(), + resourceAmount.resource(), + resourceAmount.amount(), rootStorage.findTrackedResourceByActorType( - resourceAmount.getResource(), + resourceAmount.resource(), actorType ).orElse(null) )); diff --git a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/PlatformImpl.java b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/PlatformImpl.java index 8c8cf08ab..1e91d7032 100644 --- a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/PlatformImpl.java +++ b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/PlatformImpl.java @@ -155,11 +155,11 @@ public Optional drainContainer(final ItemStack container) @Override public Optional fillContainer(final ItemStack container, final ResourceAmount resourceAmount) { - if (!(resourceAmount.getResource() instanceof FluidResource fluidResource)) { + if (!(resourceAmount.resource() instanceof FluidResource fluidResource)) { return Optional.empty(); } return FluidUtil.getFluidHandler(container).map(handler -> { - final FluidStack fluidStack = toFluidStack(fluidResource, resourceAmount.getAmount()); + final FluidStack fluidStack = toFluidStack(fluidResource, resourceAmount.amount()); final long filled = handler.fill(fluidStack, IFluidHandler.FluidAction.EXECUTE); return new FluidOperationResult(handler.getContainer(), fluidResource, filled); }); diff --git a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/support/resource/ResourceContainerFluidHandlerAdapter.java b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/support/resource/ResourceContainerFluidHandlerAdapter.java index d14f2cbd7..f05f44227 100644 --- a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/support/resource/ResourceContainerFluidHandlerAdapter.java +++ b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/support/resource/ResourceContainerFluidHandlerAdapter.java @@ -30,10 +30,10 @@ public int getTanks() { @Override public FluidStack getFluidInTank(final int tank) { final ResourceAmount resourceAmount = container.get(tank); - if (resourceAmount == null || !(resourceAmount.getResource() instanceof FluidResource fluidResource)) { + if (resourceAmount == null || !(resourceAmount.resource() instanceof FluidResource fluidResource)) { return FluidStack.EMPTY; } - return toFluidStack(fluidResource, resourceAmount.getAmount()); + return toFluidStack(fluidResource, resourceAmount.amount()); } @Override 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 b78757abb..2c68b9160 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 @@ -174,23 +174,23 @@ private static Runnable resourceContainerContainsExactly(final GameTestHelper he final boolean contains = IntStream.range(0, container.size()) .mapToObj(container::get) .anyMatch(resource -> resource != null - && resource.getResource().equals(expectedStack.getResource()) - && resource.getAmount() == expectedStack.getAmount()); + && resource.resource().equals(expectedStack.resource()) + && resource.amount() == expectedStack.amount()); helper.assertTrue(contains, "Expected resource is missing from " + displayName.getString() + ": " - + expectedStack + " with count: " + expectedStack.getAmount()); + + expectedStack + " with count: " + expectedStack.amount()); } 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.getResource().equals(resource.getResource()) - && expectedResource.getAmount() == resource.getAmount() + expectedResource -> expectedResource.resource().equals(resource.resource()) + && expectedResource.amount() == resource.amount() ); helper.assertTrue(wasExpected, "Unexpected resource found in " + displayName.getString() + ": " - + resource.getResource() + " with count: " + resource.getAmount()); + + resource.resource() + " with count: " + resource.amount()); } } }; @@ -206,18 +206,18 @@ public static Runnable containerContainsExactly(final GameTestHelper helper, for (final ResourceAmount expectedStack : expected) { final boolean contains = IntStream.range(0, containerBlockEntity.getContainerSize()) .mapToObj(containerBlockEntity::getItem) - .anyMatch(inContainer -> asResource(inContainer).equals(expectedStack.getResource()) - && inContainer.getCount() == expectedStack.getAmount()); + .anyMatch(inContainer -> asResource(inContainer).equals(expectedStack.resource()) + && inContainer.getCount() == expectedStack.amount()); helper.assertTrue(contains, "Expected resource is missing from container: " - + expectedStack + " with count: " + expectedStack.getAmount()); + + expectedStack + " with count: " + expectedStack.amount()); } 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.getResource().equals(asResource(inContainer)) - && expectedStack.getAmount() == inContainer.getCount() + expectedStack -> expectedStack.resource().equals(asResource(inContainer)) + && expectedStack.amount() == inContainer.getCount() ); helper.assertTrue(wasExpected, "Unexpected resource found in container: " + inContainer.getDescriptionId() + " with count: " + inContainer.getCount()); @@ -234,14 +234,14 @@ public static Runnable storageContainsExactly(final GameTestHelper helper, for (final ResourceAmount expectedResource : expected) { final boolean contains = storage.getAll() .stream() - .anyMatch(inStorage -> inStorage.getResource().equals(expectedResource.getResource()) - && inStorage.getAmount() == expectedResource.getAmount()); + .anyMatch(inStorage -> inStorage.resource().equals(expectedResource.resource()) + && inStorage.amount() == expectedResource.amount()); helper.assertTrue(contains, "Expected resource is missing from storage: " + expectedResource); } for (final ResourceAmount inStorage : storage.getAll()) { final boolean wasExpected = Arrays.stream(expected).anyMatch( - expectedResource -> expectedResource.getResource().equals(inStorage.getResource()) - && expectedResource.getAmount() == inStorage.getAmount() + expectedResource -> expectedResource.resource().equals(inStorage.resource()) + && expectedResource.amount() == inStorage.amount() ); helper.assertTrue(wasExpected, "Unexpected resource found in storage: " + inStorage); } diff --git a/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/relay/RelayOutputStorage.java b/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/relay/RelayOutputStorage.java index 6fb25259f..90674582f 100644 --- a/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/relay/RelayOutputStorage.java +++ b/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/relay/RelayOutputStorage.java @@ -65,16 +65,16 @@ private void reset(final Runnable action) { void setDelegate(@Nullable final StorageNetworkComponent delegate) { if (this.delegate != null) { parentComposites.forEach(parent -> getAll().forEach(resourceAmount -> parent.removeFromCache( - resourceAmount.getResource(), - resourceAmount.getAmount() + resourceAmount.resource(), + resourceAmount.amount() ))); this.delegate.removeListener(this); } this.delegate = delegate; if (delegate != null) { parentComposites.forEach(parent -> getAll().forEach(resourceAmount -> parent.addToCache( - resourceAmount.getResource(), - resourceAmount.getAmount() + resourceAmount.resource(), + resourceAmount.amount() ))); delegate.addListener(this); } @@ -142,7 +142,7 @@ public Collection getAll() { } return delegate.getAll() .stream() - .filter(resourceAmount -> filter.isAllowed(resourceAmount.getResource())) + .filter(resourceAmount -> filter.isAllowed(resourceAmount.resource())) .toList(); } @@ -153,8 +153,8 @@ public long getStored() { } return delegate.getAll() .stream() - .filter(resourceAmount -> filter.isAllowed(resourceAmount.getResource())) - .mapToLong(ResourceAmount::getAmount) + .filter(resourceAmount -> filter.isAllowed(resourceAmount.resource())) + .mapToLong(ResourceAmount::amount) .sum(); } diff --git a/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/storagetransfer/StorageTransferNetworkNode.java b/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/storagetransfer/StorageTransferNetworkNode.java index a6d0bcbf3..7216fd858 100644 --- a/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/storagetransfer/StorageTransferNetworkNode.java +++ b/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/node/storagetransfer/StorageTransferNetworkNode.java @@ -121,11 +121,11 @@ private boolean transfer(final Storage source, final Storage destination, final long remainder = transferQuota; final Collection sourceContents = new LinkedHashSet<>(source.getAll()); for (final ResourceAmount resourceAmount : sourceContents) { - final ResourceKey resource = resourceAmount.getResource(); + final ResourceKey resource = resourceAmount.resource(); if (!filter.isAllowed(resource)) { continue; } - final long amount = Math.min(remainder, resourceAmount.getAmount()); + final long amount = Math.min(remainder, resourceAmount.amount()); final long transferred = TransferHelper.transfer(resource, amount, actor, source, destination, source); remainder -= transferred; if (remainder == 0) { @@ -136,7 +136,7 @@ private boolean transfer(final Storage source, final Storage destination, final } private boolean hasNoExtractableResources(final Storage source) { - return source.getAll().stream().noneMatch(resourceAmount -> filter.isAllowed(resourceAmount.getResource())); + return source.getAll().stream().noneMatch(resourceAmount -> filter.isAllowed(resourceAmount.resource())); } private boolean storageIsFull(final Storage storage) { diff --git a/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/storage/StorageNetworkComponentImpl.java b/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/storage/StorageNetworkComponentImpl.java index d0535d17c..1d4babcbb 100644 --- a/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/storage/StorageNetworkComponentImpl.java +++ b/refinedstorage-network/src/main/java/com/refinedmods/refinedstorage/api/network/impl/storage/StorageNetworkComponentImpl.java @@ -43,7 +43,7 @@ public void onContainerRemoved(final NetworkNodeContainer container) { public List getResources(final Class actorType) { return getAll().stream().map(resourceAmount -> new TrackedResourceAmount( resourceAmount, - findTrackedResourceByActorType(resourceAmount.getResource(), actorType).orElse(null) + findTrackedResourceByActorType(resourceAmount.resource(), actorType).orElse(null) )).toList(); } diff --git a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/InterfaceExportStateImpl.java b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/InterfaceExportStateImpl.java index 5aa92b389..115fd22b2 100644 --- a/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/InterfaceExportStateImpl.java +++ b/refinedstorage-network/src/test/java/com/refinedmods/refinedstorage/api/network/impl/node/iface/InterfaceExportStateImpl.java @@ -83,7 +83,7 @@ public ResourceKey getRequestedResource(final int slotIndex) { if (resourceAmount == null) { return null; } - return resourceAmount.getResource(); + return resourceAmount.resource(); } @Override @@ -93,7 +93,7 @@ public long getRequestedAmount(final int slotIndex) { if (resourceAmount == null) { return 0L; } - return resourceAmount.getAmount(); + return resourceAmount.amount(); } @Nullable @@ -104,7 +104,7 @@ public ResourceKey getExportedResource(final int slotIndex) { if (resourceAmount == null) { return null; } - return resourceAmount.getResource(); + return resourceAmount.resource(); } @Override @@ -114,7 +114,7 @@ public long getExportedAmount(final int slotIndex) { if (resourceAmount == null) { return 0L; } - return resourceAmount.getAmount(); + return resourceAmount.amount(); } @Override @@ -131,12 +131,12 @@ public void setCurrentlyExported(final int index, final ResourceKey resource, fi public void shrinkExportedAmount(final int slotIndex, final long amount) { validateIndex(slotIndex); final ResourceAmount resourceAmount = this.current.get(slotIndex); - if (resourceAmount.getAmount() - amount <= 0) { + if (resourceAmount.amount() - amount <= 0) { this.current.remove(slotIndex); } else { this.current.put( slotIndex, - new ResourceAmount(resourceAmount.getResource(), resourceAmount.getAmount() - amount) + new ResourceAmount(resourceAmount.resource(), resourceAmount.amount() - amount) ); } } @@ -147,7 +147,7 @@ public void growExportedAmount(final int slotIndex, final long amount) { final ResourceAmount resourceAmount = this.current.get(slotIndex); this.current.put( slotIndex, - new ResourceAmount(resourceAmount.getResource(), resourceAmount.getAmount() + amount) + new ResourceAmount(resourceAmount.resource(), resourceAmount.amount() + amount) ); } diff --git a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/ResourceAmount.java b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/ResourceAmount.java index c815886da..bcf027bba 100644 --- a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/ResourceAmount.java +++ b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/ResourceAmount.java @@ -6,41 +6,15 @@ /** * A class representing a resource and a corresponding amount. - * The resource cannot be mutated but the amount can be modified. */ @API(status = API.Status.STABLE, since = "2.0.0-milestone.1.2") -public final class ResourceAmount { - private final ResourceKey resource; - private final long amount; - +public record ResourceAmount(ResourceKey resource, long amount) { /** * @param resource the resource, must be non-null * @param amount the amount, must be larger than 0 */ - public ResourceAmount(final ResourceKey resource, final long amount) { + public ResourceAmount { validate(resource, amount); - this.resource = resource; - this.amount = amount; - } - - public ResourceKey getResource() { - return resource; - } - - public long getAmount() { - return amount; - } - - public ResourceAmount copy() { - return new ResourceAmount(resource, amount); - } - - @Override - public String toString() { - return "ResourceAmount{" - + "resource=" + resource - + ", amount=" + amount - + '}'; } public static void validate(final ResourceKey resource, final long amount) { diff --git a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java index aeeb1e3d5..44f86eaf3 100644 --- a/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java +++ b/refinedstorage-resource-api/src/main/java/com/refinedmods/refinedstorage/api/resource/list/ResourceList.java @@ -32,7 +32,7 @@ public interface ResourceList { * @return the result of the operation */ default OperationResult add(ResourceAmount resourceAmount) { - return add(resourceAmount.getResource(), resourceAmount.getAmount()); + return add(resourceAmount.resource(), resourceAmount.amount()); } /** @@ -54,7 +54,7 @@ default OperationResult add(ResourceAmount resourceAmount) { * @return a result if the removal operation was successful, otherwise an empty {@link Optional} */ default Optional remove(ResourceAmount resourceAmount) { - return remove(resourceAmount.getResource(), resourceAmount.getAmount()); + return remove(resourceAmount.resource(), resourceAmount.amount()); } /** diff --git a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/composite/CompositeStorageImpl.java b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/composite/CompositeStorageImpl.java index 845623a76..829ba79bd 100644 --- a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/composite/CompositeStorageImpl.java +++ b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/composite/CompositeStorageImpl.java @@ -211,8 +211,8 @@ private void addContentOfSourceToList(final Storage source) { private void removeContentOfSourceFromList(final Storage source) { source.getAll().forEach(resourceAmount -> list.remove( - resourceAmount.getResource(), - resourceAmount.getAmount() + resourceAmount.resource(), + resourceAmount.amount() )); } } diff --git a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/external/ExternalStorage.java b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/external/ExternalStorage.java index e8ce6b289..5e063794a 100644 --- a/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/external/ExternalStorage.java +++ b/refinedstorage-storage-api/src/main/java/com/refinedmods/refinedstorage/api/storage/external/ExternalStorage.java @@ -128,7 +128,7 @@ public Collection getAll() { @Override public long getStored() { - return getAll().stream().mapToLong(ResourceAmount::getAmount).sum(); + return getAll().stream().mapToLong(ResourceAmount::amount).sum(); } @Override 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 633034084..d25d33057 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 @@ -74,8 +74,8 @@ void shouldTransferCorrectly(final Transfer transfer) { if (transfer.amountInSource != null) { source.insert( - transfer.amountInSource.getResource(), - transfer.amountInSource.getAmount(), + transfer.amountInSource.resource(), + transfer.amountInSource.amount(), Action.EXECUTE, EmptyActor.INSTANCE ); @@ -83,8 +83,8 @@ void shouldTransferCorrectly(final Transfer transfer) { if (transfer.amountInDestination != null) { destination.insert( - transfer.amountInDestination.getResource(), - transfer.amountInDestination.getAmount(), + transfer.amountInDestination.resource(), + transfer.amountInDestination.amount(), Action.EXECUTE, EmptyActor.INSTANCE ); @@ -92,8 +92,8 @@ void shouldTransferCorrectly(final Transfer transfer) { // Act final long transferred = TransferHelper.transfer( - transfer.amountToTransfer.getResource(), - transfer.amountToTransfer.getAmount(), + transfer.amountToTransfer.resource(), + transfer.amountToTransfer.amount(), EmptyActor.INSTANCE, source, destination, From 02381bfd80fd4468ebb5a93dd97991f3184447af Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Sat, 3 Aug 2024 17:50:43 +0200 Subject: [PATCH 24/36] chore: minor cleanup --- ...CraftingPatternClientTooltipComponent.java | 7 +-- .../autocrafting/PatternGridScreen.java | 12 ++-- .../grid/CraftingGridContainerMenu.java | 5 +- .../common/grid/view/ItemGridResource.java | 6 ++ .../support/containermenu/ResourceSlot.java | 6 +- .../common/support/resource/ItemResource.java | 4 +- .../resource/ResourceContainerImpl.java | 60 ++++++++++--------- .../resource/ResourceContainerSlot.java | 53 ---------------- .../render/FluidStackFluidRenderer.java | 11 ++-- .../support/resource/VariantUtil.java | 4 +- 10 files changed, 61 insertions(+), 107 deletions(-) delete mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceContainerSlot.java 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 52c833fb3..b9bdce08b 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 @@ -25,11 +25,7 @@ public class CraftingPatternClientTooltipComponent implements ClientTooltipComponent { private static final long CYCLE_MS = 1000; - private static long cycleStart = 0; - private static int currentCycle = 0; - private static final int ARROW_SPACING = 8; - private static final ResourceLocation LARGE_SLOT = createIdentifier("large_slot"); private static final int LARGE_SLOT_WIDTH = 26; private static final int LARGE_SLOT_HEIGHT = 26; @@ -43,6 +39,9 @@ public class CraftingPatternClientTooltipComponent implements ClientTooltipCompo @Nullable private final Component outputText; + private long cycleStart = 0; + private int currentCycle = 0; + public CraftingPatternClientTooltipComponent(final int width, final int height, final CraftingPattern craftingPattern) { diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridScreen.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridScreen.java index 30589cd96..d5b6d9855 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridScreen.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridScreen.java @@ -139,6 +139,7 @@ private ImageButton createClearButton(final PatternType patternType) { ); button.setTooltip(Tooltip.create(CLEAR)); button.visible = isClearButtonVisible(); + button.active = getMenu().canCreatePattern(); return button; } @@ -276,9 +277,7 @@ private void renderProcessingBackground(final GuiGraphics graphics, renderProcessingMatrix( graphics, getInsetContentX() + 1, - getInsetY() + 14, getInsetContentX() + 1 + 52 + 1, // include the edge so we get the item counts properly - getInsetY() + 14 + 52 + 1, // include the edge so we get the item counts properly mouseX, mouseY, true @@ -286,9 +285,7 @@ private void renderProcessingBackground(final GuiGraphics graphics, renderProcessingMatrix( graphics, getInsetContentX() + INDIVIDUAL_PROCESSING_MATRIX_SIZE + 2 + 1, - getInsetY() + 14, getInsetContentX() + INDIVIDUAL_PROCESSING_MATRIX_SIZE + 2 + 1 + 52 + 1, - getInsetY() + 14 + 52 + 1, mouseX, mouseY, false @@ -297,12 +294,13 @@ private void renderProcessingBackground(final GuiGraphics graphics, private void renderProcessingMatrix(final GuiGraphics graphics, final int startX, - final int startY, final int endX, - final int endY, final int mouseX, final int mouseY, final boolean input) { + final int startY = getInsetY() + 14; + // include the edge so we get the item counts properly + final int endY = getInsetY() + 14 + 52 + 1; graphics.enableScissor(startX, startY, endX, endY); renderProcessingMatrixSlotBackground(graphics, input); renderProcessingMatrixSlots(graphics, mouseX, mouseY, input); @@ -379,7 +377,7 @@ protected void renderLabels(final GuiGraphics graphics, final int mouseX, final super.renderLabels(graphics, mouseX, mouseY); if (getMenu().getPatternType() == PatternType.PROCESSING) { final int x = getInsetContentX() - leftPos; - final int y = getInsetContentY() - topPos; + final int y = getInsetContentY() - topPos - 1; graphics.drawString(font, INPUTS, x, y, 4210752, false); graphics.drawString(font, OUTPUTS, x + 56, y, 4210752, false); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridContainerMenu.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridContainerMenu.java index 5155a8448..288294916 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridContainerMenu.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/grid/CraftingGridContainerMenu.java @@ -150,9 +150,8 @@ public void transferRecipe(final List> recipe) { public void filterBasedOnCraftingMatrixItems() { final Set craftingMatrixItems = getCraftingMatrixItems(); filterBeforeFilteringBasedOnCraftingMatrixItems = getView().setFilterAndSort( - (view, gridResource) -> gridResource instanceof ItemGridResource itemGridResource - && itemGridResource.getResourceForRecipeMods() != null - && craftingMatrixItems.contains((ItemResource) itemGridResource.getResourceForRecipeMods()) + (view, resource) -> resource instanceof ItemGridResource itemResource + && craftingMatrixItems.contains(itemResource.getItemResource()) ); } 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 c5497557e..25912cab7 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 @@ -31,6 +31,7 @@ public class ItemGridResource extends AbstractPlatformGridResource { private final int id; private final ItemStack itemStack; + private final ItemResource itemResource; public ItemGridResource(final ItemResource resource, final ItemStack itemStack, @@ -47,12 +48,17 @@ public ItemGridResource(final ItemResource resource, )); this.id = Item.getId(resource.item()); this.itemStack = itemStack; + this.itemResource = resource; } public ItemStack getItemStack() { return itemStack; } + public ItemResource getItemResource() { + return itemResource; + } + @Override public int getRegistryId() { return id; diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/containermenu/ResourceSlot.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/containermenu/ResourceSlot.java index b7d4e4b8b..1ee116a77 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/containermenu/ResourceSlot.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/containermenu/ResourceSlot.java @@ -117,11 +117,11 @@ public void change(final ItemStack stack, final boolean tryAlternatives) { resourceContainer.change(getContainerSlot(), stack, tryAlternatives); } - public void change(@Nullable final ResourceAmount instance) { - if (instance == null) { + public void change(@Nullable final ResourceAmount resourceAmount) { + if (resourceAmount == null) { resourceContainer.remove(getContainerSlot()); } else { - resourceContainer.set(getContainerSlot(), instance); + resourceContainer.set(getContainerSlot(), resourceAmount); } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ItemResource.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ItemResource.java index a147b97d0..bef0822ec 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ItemResource.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ItemResource.java @@ -7,6 +7,7 @@ import com.refinedmods.refinedstorage.common.api.support.resource.ResourceType; import net.minecraft.core.component.DataComponentPatch; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import org.apiguardian.api.API; @@ -31,12 +32,11 @@ public ItemStack toItemStack() { return toItemStack(1); } - @SuppressWarnings("deprecation") public ItemStack toItemStack(final long amount) { if (amount > Integer.MAX_VALUE) { LOGGER.warn("Truncating too large amount for {} to fit into ItemStack {}", this, amount); } - return new ItemStack(item.builtInRegistryHolder(), (int) amount, components); + return new ItemStack(BuiltInRegistries.ITEM.wrapAsHolder(item), (int) amount, components); } @Override diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceContainerImpl.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceContainerImpl.java index 287d1865d..9fda3e75a 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceContainerImpl.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceContainerImpl.java @@ -26,7 +26,8 @@ import net.minecraft.world.item.ItemStack; public class ResourceContainerImpl implements ResourceContainer { - private final ResourceContainerSlot[] slots; + private final ResourceAmount[] slots; + private final ItemStack[] stackRepresentations; private final ToLongFunction maxAmountProvider; private final ResourceFactory primaryResourceFactory; private final Set alternativeResourceFactories; @@ -38,7 +39,8 @@ public ResourceContainerImpl(final int size, final ToLongFunction maxAmountProvider, final ResourceFactory primaryResourceFactory, final Set alternativeResourceFactories) { - this.slots = new ResourceContainerSlot[size]; + this.slots = new ResourceAmount[size]; + this.stackRepresentations = new ItemStack[size]; this.maxAmountProvider = maxAmountProvider; this.primaryResourceFactory = primaryResourceFactory; this.alternativeResourceFactories = alternativeResourceFactories; @@ -73,7 +75,10 @@ public void set(final int index, final ResourceAmount resourceAmount) { } private void setSilently(final int index, final ResourceAmount resourceAmount) { - slots[index] = new ResourceContainerSlot(resourceAmount); + slots[index] = resourceAmount; + stackRepresentations[index] = resourceAmount.resource() instanceof ItemResource itemResource + ? itemResource.toItemStack(resourceAmount.amount()) + : null; } @Override @@ -91,11 +96,11 @@ public boolean isValid(final ResourceKey resource) { @Override public long getAmount(final int index) { - final ResourceContainerSlot slot = slots[index]; + final ResourceAmount slot = slots[index]; if (slot == null) { return 0; } - return slot.getResourceAmount().amount(); + return slot.amount(); } @Override @@ -112,15 +117,15 @@ public void shrink(final int index, final long amount) { @Override public void setAmount(final int index, final long amount) { - final ResourceContainerSlot slot = slots[index]; + final ResourceAmount slot = slots[index]; if (slot == null) { return; } - final long newAmount = MathUtil.clamp(amount, 0, getMaxAmount(slot.getResourceAmount().resource())); + final long newAmount = MathUtil.clamp(amount, 0, getMaxAmount(slot.resource())); if (newAmount == 0) { - remove(index); + removeSilently(index); } else { - slots[index] = slot.withAmount(newAmount); + setSilently(index, new ResourceAmount(slot.resource(), newAmount)); } changed(); } @@ -146,6 +151,7 @@ public void clear() { private void removeSilently(final int index) { slots[index] = null; + stackRepresentations[index] = null; } @Override @@ -156,41 +162,37 @@ public int size() { @Override @Nullable public ResourceAmount get(final int index) { - final ResourceContainerSlot slot = slots[index]; - if (slot == null) { - return null; - } - return slot.getResourceAmount(); + return slots[index]; } @Nullable @Override public PlatformResourceKey getResource(final int index) { - final ResourceContainerSlot slot = slots[index]; + final ResourceAmount slot = slots[index]; if (slot == null) { return null; } - return slot.getPlatformResource(); + return (PlatformResourceKey) slot.resource(); } @Override public ItemStack getStackRepresentation(final int index) { - final ResourceContainerSlot slot = slots[index]; - if (slot == null) { + final ItemStack stack = stackRepresentations[index]; + if (stack == null) { return ItemStack.EMPTY; } - return slot.getStackRepresentation(); + return stack; } @Override public Set getUniqueResources() { final Set result = new HashSet<>(); for (int i = 0; i < size(); ++i) { - final ResourceContainerSlot slot = slots[i]; + final ResourceAmount slot = slots[i]; if (slot == null) { continue; } - result.add(slot.getResourceAmount().resource()); + result.add(slot.resource()); } return result; } @@ -199,11 +201,11 @@ public Set getUniqueResources() { public List getResources() { final List result = new ArrayList<>(); for (int i = 0; i < size(); ++i) { - final ResourceContainerSlot slot = slots[i]; + final ResourceAmount slot = slots[i]; if (slot == null) { continue; } - result.add(slot.getResourceAmount().resource()); + result.add(slot.resource()); } return result; } @@ -212,7 +214,7 @@ public List getResources() { public CompoundTag toTag(final HolderLookup.Provider provider) { final CompoundTag tag = new CompoundTag(); for (int i = 0; i < size(); ++i) { - final ResourceContainerSlot slot = slots[i]; + final ResourceAmount slot = slots[i]; if (slot == null) { continue; } @@ -223,10 +225,10 @@ public CompoundTag toTag(final HolderLookup.Provider provider) { private void addToTag(final CompoundTag tag, final int index, - final ResourceContainerSlot slot, + final ResourceAmount slot, final HolderLookup.Provider provider) { final Tag serialized = ResourceCodecs.AMOUNT_CODEC.encode( - slot.getResourceAmount(), + slot, provider.createSerializationContext(NbtOps.INSTANCE), new CompoundTag() ).getOrThrow(); @@ -357,9 +359,9 @@ public ResourceContainer copy() { alternativeResourceFactories ); for (int i = 0; i < size(); ++i) { - final ResourceAmount slotContents = get(i); - if (slotContents != null) { - copy.set(i, slotContents); + final ResourceAmount slot = get(i); + if (slot != null) { + copy.set(i, slot); } } return copy; diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceContainerSlot.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceContainerSlot.java deleted file mode 100644 index fed125bb0..000000000 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/resource/ResourceContainerSlot.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.refinedmods.refinedstorage.common.support.resource; - -import com.refinedmods.refinedstorage.api.resource.ResourceAmount; -import com.refinedmods.refinedstorage.common.api.support.resource.PlatformResourceKey; - -import java.util.Objects; - -import net.minecraft.world.item.ItemStack; - -class ResourceContainerSlot { - private final ResourceAmount resourceAmount; - private final ItemStack stackRepresentation; - - ResourceContainerSlot(final ResourceAmount resourceAmount) { - this.resourceAmount = resourceAmount; - this.stackRepresentation = resourceAmount.resource() instanceof ItemResource itemResource - ? itemResource.toItemStack(resourceAmount.amount()) - : ItemStack.EMPTY; - } - - ResourceAmount getResourceAmount() { - return resourceAmount; - } - - PlatformResourceKey getPlatformResource() { - return (PlatformResourceKey) resourceAmount.resource(); - } - - ItemStack getStackRepresentation() { - return stackRepresentation; - } - - ResourceContainerSlot withAmount(final long newAmount) { - return new ResourceContainerSlot(new ResourceAmount(resourceAmount.resource(), newAmount)); - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final ResourceContainerSlot that = (ResourceContainerSlot) o; - return Objects.equals(resourceAmount, that.resourceAmount); - } - - @Override - public int hashCode() { - return Objects.hash(resourceAmount); - } -} diff --git a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/support/render/FluidStackFluidRenderer.java b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/support/render/FluidStackFluidRenderer.java index b7e071ba9..b3f60a6a0 100644 --- a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/support/render/FluidStackFluidRenderer.java +++ b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/support/render/FluidStackFluidRenderer.java @@ -12,6 +12,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.inventory.InventoryMenu; @@ -23,14 +24,16 @@ public class FluidStackFluidRenderer extends AbstractFluidRenderer { private final Map stackCache = new HashMap<>(); - @SuppressWarnings("deprecation") private FluidStack getFluidStackFromCache(final FluidResource fluidResource) { + if (stackCache.size() > 1000) { + stackCache.clear(); + } return stackCache.computeIfAbsent( fluidResource, - r -> new FluidStack( - r.fluid().builtInRegistryHolder(), + fluid -> new FluidStack( + BuiltInRegistries.FLUID.wrapAsHolder(fluid.fluid()), FluidType.BUCKET_VOLUME, - r.components() + fluid.components() ) ); } diff --git a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/support/resource/VariantUtil.java b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/support/resource/VariantUtil.java index cc45eb941..7cfb1c612 100644 --- a/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/support/resource/VariantUtil.java +++ b/refinedstorage-neoforge/src/main/java/com/refinedmods/refinedstorage/neoforge/support/resource/VariantUtil.java @@ -5,6 +5,7 @@ import java.util.Objects; +import net.minecraft.core.registries.BuiltInRegistries; import net.neoforged.neoforge.fluids.FluidStack; import net.neoforged.neoforge.fluids.capability.IFluidHandler; import org.slf4j.Logger; @@ -27,13 +28,12 @@ public static FluidResource ofFluidStack(final FluidStack fluidStack) { return new FluidResource(fluidStack.getFluid(), fluidStack.getComponents().asPatch()); } - @SuppressWarnings("deprecation") public static FluidStack toFluidStack(final FluidResource fluidResource, final long amount) { if (amount > Integer.MAX_VALUE) { LOGGER.warn("Truncating too large amount for {} to fit into FluidStack {}", fluidResource, amount); } return new FluidStack( - fluidResource.fluid().builtInRegistryHolder(), + BuiltInRegistries.FLUID.wrapAsHolder(fluidResource.fluid()), (int) amount, fluidResource.components() ); From 0d5b1c31a0268d1efea69a57bb8779febde83483 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Sat, 3 Aug 2024 18:42:32 +0200 Subject: [PATCH 25/36] feat: alternatives screen for processing patterns Also fixes amount screen allowing more than the maximum for fluids. --- CHANGELOG.md | 2 + .../support/resource/PlatformResourceKey.java | 6 + .../api/support/resource/ResourceTag.java | 10 + .../common/autocrafting/Alternative.java | 101 ++++ .../AlternativeContainerMenu.java | 89 ++++ .../common/autocrafting/AlternativeSlot.java | 34 ++ .../autocrafting/AlternativesScreen.java | 493 ++++++++++++++++++ .../autocrafting/PatternGridBlockEntity.java | 25 +- .../PatternGridContainerMenu.java | 9 +- .../autocrafting/PatternGridScreen.java | 35 +- .../autocrafting/PatternTypeButton.java | 4 +- .../grid/screen/AbstractGridScreen.java | 35 +- .../grid/screen/CraftingGridScreen.java | 5 +- .../common/support/AbstractBaseScreen.java | 25 +- .../common/support/TextureIds.java | 2 + .../support/amount/AbstractAmountScreen.java | 56 +- .../amount/AmountScreenConfiguration.java | 16 + .../support/amount/ResourceAmountScreen.java | 13 +- .../containermenu/DisabledResourceSlot.java | 46 ++ .../support/containermenu/ResourceSlot.java | 21 +- .../support/resource/FluidResource.java | 21 + .../common/support/resource/ItemResource.java | 19 + .../resource/ResourceContainerImpl.java | 12 +- .../support/widget/CustomCheckboxWidget.java | 26 +- .../support/widget/HoveredImageButton.java | 17 +- .../common/support/widget/TextMarquee.java | 80 +++ .../common/util/IdentifierUtil.java | 19 + .../assets/refinedstorage/lang/en_us.json | 11 +- .../textures/gui/alternatives.png | Bin 0 -> 791 bytes .../textures/gui/crafting_grid.png | Bin 2277 -> 2277 bytes .../refinedstorage/textures/gui/grid.png | Bin 850 -> 850 bytes .../textures/gui/pattern_grid.png | Bin 930 -> 929 bytes .../textures/gui/sprites/search.png | Bin 0 -> 260 bytes .../textures/gui/sprites/widget/collapse.png | Bin 0 -> 371 bytes .../gui/sprites/widget/collapse_focused.png | Bin 0 -> 393 bytes .../textures/gui/sprites/widget/expand.png | Bin 0 -> 364 bytes .../gui/sprites/widget/expand_disabled.png | Bin 0 -> 340 bytes .../gui/sprites/widget/expand_focused.png | Bin 0 -> 388 bytes 38 files changed, 1160 insertions(+), 72 deletions(-) create mode 100644 refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/ResourceTag.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/Alternative.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/AlternativeContainerMenu.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/AlternativeSlot.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/AlternativesScreen.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/containermenu/DisabledResourceSlot.java create mode 100644 refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/widget/TextMarquee.java create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/alternatives.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/search.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/collapse.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/collapse_focused.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/expand.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/expand_disabled.png create mode 100644 refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/widget/expand_focused.png diff --git a/CHANGELOG.md b/CHANGELOG.md index 01f7e9fa4..030a24eaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Clicking on a scrollbar no longer makes a clicking sound. - Incorrect and outdated (mentioning NBT tags) help explanations for fuzzy mode. +- Amount screen allowing more than the maximum for fluids. +- Potential text overflow in the Grid for localization with long "Grid" text. ## [2.0.0-milestone.4.5] - 2024-07-26 diff --git a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/PlatformResourceKey.java b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/PlatformResourceKey.java index 220f29367..a8c5d977d 100644 --- a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/PlatformResourceKey.java +++ b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/PlatformResourceKey.java @@ -2,11 +2,17 @@ import com.refinedmods.refinedstorage.api.resource.ResourceKey; +import java.util.List; + import org.apiguardian.api.API; @API(status = API.Status.STABLE, since = "2.0.0-milestone.3.4") public interface PlatformResourceKey extends ResourceKey { long getInterfaceExportLimit(); + long getProcessingPatternLimit(); + + List getTags(); + ResourceType getResourceType(); } diff --git a/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/ResourceTag.java b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/ResourceTag.java new file mode 100644 index 000000000..aac568286 --- /dev/null +++ b/refinedstorage-common-api/src/main/java/com/refinedmods/refinedstorage/common/api/support/resource/ResourceTag.java @@ -0,0 +1,10 @@ +package com.refinedmods.refinedstorage.common.api.support.resource; + +import java.util.List; + +import net.minecraft.tags.TagKey; +import org.apiguardian.api.API; + +@API(status = API.Status.STABLE, since = "2.0.0-milestone.4.6") +public record ResourceTag(TagKey key, List resources) { +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/Alternative.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/Alternative.java new file mode 100644 index 000000000..3dd18a5a1 --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/Alternative.java @@ -0,0 +1,101 @@ +package com.refinedmods.refinedstorage.common.autocrafting; + +import com.refinedmods.refinedstorage.common.api.support.resource.PlatformResourceKey; + +import java.util.ArrayList; +import java.util.List; +import javax.annotation.Nullable; + +import net.minecraft.resources.ResourceLocation; + +class Alternative { + private static final long EXPAND_COLLAPSE_DELAY = 10; + + private final ResourceLocation id; + private final String translationKey; + private final List resources; + private final List mainSlots = new ArrayList<>(); + private final List overflowSlots = new ArrayList<>(); + private boolean visible = true; + private double expandPct; + private int expandCollapseElapsed; + @Nullable + private ExpandCollapse expandCollapse; + + Alternative(final ResourceLocation id, final String translationKey, final List resources) { + this.id = id; + this.translationKey = translationKey; + this.resources = resources; + } + + List getMainSlots() { + return mainSlots; + } + + List getOverflowSlots() { + return overflowSlots; + } + + ResourceLocation getId() { + return id; + } + + String getTranslationKey() { + return translationKey; + } + + List getResources() { + return resources; + } + + double getExpandPct() { + return expandPct; + } + + boolean expandOrCollapse() { + if (expandCollapse != null) { + expandCollapse = expandCollapse == ExpandCollapse.EXPAND ? ExpandCollapse.COLLAPSE : ExpandCollapse.EXPAND; + expandCollapseElapsed = (int) (EXPAND_COLLAPSE_DELAY - expandCollapseElapsed); + return expandCollapse == ExpandCollapse.EXPAND; + } + expandCollapse = expandPct > 0 ? ExpandCollapse.COLLAPSE : ExpandCollapse.EXPAND; + return expandCollapse == ExpandCollapse.EXPAND; + } + + void update() { + if (expandCollapse == null) { + return; + } + ++expandCollapseElapsed; + if (expandCollapse == ExpandCollapse.EXPAND) { + expandPct = (double) expandCollapseElapsed / EXPAND_COLLAPSE_DELAY; + if (expandPct >= 1) { + stopExpandCollapse(); + } + } else { + expandPct = 1 - (double) expandCollapseElapsed / EXPAND_COLLAPSE_DELAY; + if (expandPct <= 0) { + stopExpandCollapse(); + } + } + } + + boolean isVisible() { + return visible; + } + + void setVisible(final boolean visible) { + this.visible = visible; + } + + private void stopExpandCollapse() { + expandPct = expandCollapse == ExpandCollapse.EXPAND ? 1 : 0; + expandCollapseElapsed = 0; + expandCollapse = null; + } + + private enum ExpandCollapse { + EXPAND, + COLLAPSE + } +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/AlternativeContainerMenu.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/AlternativeContainerMenu.java new file mode 100644 index 000000000..9e7309932 --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/AlternativeContainerMenu.java @@ -0,0 +1,89 @@ +package com.refinedmods.refinedstorage.common.autocrafting; + +import com.refinedmods.refinedstorage.api.resource.ResourceAmount; +import com.refinedmods.refinedstorage.common.api.support.resource.ResourceContainer; +import com.refinedmods.refinedstorage.common.api.support.resource.ResourceTag; +import com.refinedmods.refinedstorage.common.support.containermenu.AbstractResourceContainerMenu; +import com.refinedmods.refinedstorage.common.support.containermenu.ResourceSlot; +import com.refinedmods.refinedstorage.common.support.resource.ResourceContainerImpl; + +import java.util.Collections; +import java.util.List; +import java.util.Locale; + +import net.minecraft.client.resources.language.I18n; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; + +import static com.refinedmods.refinedstorage.common.autocrafting.AlternativesScreen.ALTERNATIVE_HEIGHT; +import static com.refinedmods.refinedstorage.common.autocrafting.AlternativesScreen.ALTERNATIVE_ROW_HEIGHT; +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.getTagTranslationKey; + +public class AlternativeContainerMenu extends AbstractResourceContainerMenu { + private final List alternatives; + private final ResourceSlot amountSlot; + + AlternativeContainerMenu(final ResourceSlot amountSlot) { + super(null, 0); + this.amountSlot = amountSlot.forAmountScreen(118, 48); + final List tags = amountSlot.getResource() == null + ? Collections.emptyList() + : amountSlot.getResource().getTags(); + this.alternatives = tags.stream().map(tag -> new Alternative( + tag.key().location(), + getTagTranslationKey(tag.key()), + tag.resources() + )).toList(); + addSlot(this.amountSlot); + addAlternativeSlots(); + } + + void filter(final String query) { + final String normalizedQuery = query.trim().toLowerCase(Locale.ROOT); + alternatives.forEach(alternative -> { + final boolean titleMatch = I18n.exists(alternative.getTranslationKey()) + && I18n.get(alternative.getTranslationKey()).trim().toLowerCase(Locale.ROOT).contains(normalizedQuery); + final boolean idMatch = alternative.getId().toString().trim().toLowerCase(Locale.ROOT) + .contains(normalizedQuery); + alternative.setVisible(titleMatch || idMatch); + }); + } + + private void addAlternativeSlots() { + final int x = 8; + for (int i = 0; i < alternatives.size(); ++i) { + final int y = 122 + (i * ALTERNATIVE_HEIGHT); + final Alternative alternative = alternatives.get(i); + final ResourceContainer resources = ResourceContainerImpl.createForFilter( + alternative.getResources().size() + ); + for (int j = 0; j < resources.size(); ++j) { + resources.set(j, new ResourceAmount(alternative.getResources().get(j), 1)); + final int row = j / 8; + final int col = j % 8; + final int slotX = x + 1 + 1 + col * 18; + final int slotY = y + ALTERNATIVE_ROW_HEIGHT + (row * 18) + 1; + final AlternativeSlot resourceSlot = new AlternativeSlot(resources, j, slotX, slotY); + if (j < 8) { + alternative.getMainSlots().add(resourceSlot); + } else { + alternative.getOverflowSlots().add(resourceSlot); + } + addSlot(resourceSlot); + } + } + } + + ResourceSlot getAmountSlot() { + return amountSlot; + } + + List getAlternatives() { + return alternatives; + } + + @Override + public ItemStack quickMoveStack(final Player player, final int slot) { + return ItemStack.EMPTY; + } +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/AlternativeSlot.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/AlternativeSlot.java new file mode 100644 index 000000000..548002c9d --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/AlternativeSlot.java @@ -0,0 +1,34 @@ +package com.refinedmods.refinedstorage.common.autocrafting; + +import com.refinedmods.refinedstorage.common.api.support.resource.ResourceContainer; +import com.refinedmods.refinedstorage.common.support.containermenu.DisabledResourceSlot; +import com.refinedmods.refinedstorage.common.support.containermenu.ResourceSlotType; + +import net.minecraft.network.chat.Component; + +class AlternativeSlot extends DisabledResourceSlot { + private boolean active = true; + + AlternativeSlot( + final ResourceContainer container, + final int index, + final int x, + final int y + ) { + super(container, index, Component.empty(), x, y, ResourceSlotType.FILTER); + } + + @Override + public boolean isHighlightable() { + return false; // we render the highlight in the scissor render + } + + @Override + public boolean isActive() { + return active; + } + + void setActive(final boolean active) { + this.active = active; + } +} diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/AlternativesScreen.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/AlternativesScreen.java new file mode 100644 index 000000000..c3cfa6293 --- /dev/null +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/AlternativesScreen.java @@ -0,0 +1,493 @@ +package com.refinedmods.refinedstorage.common.autocrafting; + +import com.refinedmods.refinedstorage.common.Platform; +import com.refinedmods.refinedstorage.common.support.TextureIds; +import com.refinedmods.refinedstorage.common.support.amount.AbstractAmountScreen; +import com.refinedmods.refinedstorage.common.support.amount.AmountScreenConfiguration; +import com.refinedmods.refinedstorage.common.support.amount.DoubleAmountOperations; +import com.refinedmods.refinedstorage.common.support.containermenu.ResourceSlot; +import com.refinedmods.refinedstorage.common.support.widget.CustomCheckboxWidget; +import com.refinedmods.refinedstorage.common.support.widget.HoveredImageButton; +import com.refinedmods.refinedstorage.common.support.widget.ScrollbarWidget; + +import java.util.ArrayList; +import java.util.List; +import javax.annotation.Nullable; + +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.Button; +import net.minecraft.client.gui.components.EditBox; +import net.minecraft.client.gui.components.Tooltip; +import net.minecraft.client.gui.components.WidgetSprites; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.resources.language.I18n; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Inventory; +import org.joml.Vector3f; + +import static com.refinedmods.refinedstorage.common.support.TextureIds.SEARCH_SIZE; +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; +import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createTranslation; + +public class AlternativesScreen extends AbstractAmountScreen { + static final int ALTERNATIVE_ROW_HEIGHT = 18; + static final int ALTERNATIVE_HEIGHT = ALTERNATIVE_ROW_HEIGHT * 2; + + private static final ResourceLocation TEXTURE = createIdentifier("textures/gui/alternatives.png"); + private static final MutableComponent TITLE = createTranslation("gui", "configure_amount"); + private static final MutableComponent ALTERNATIVES = createTranslation("gui", "pattern_grid.alternatives"); + private static final MutableComponent EXPAND = createTranslation("gui", "pattern_grid.alternatives.expand"); + private static final WidgetSprites EXPAND_SPRITES = new WidgetSprites( + createIdentifier("widget/expand"), + createIdentifier("widget/expand_disabled"), + createIdentifier("widget/expand_focused"), + createIdentifier("widget/expand_disabled") + ); + private static final WidgetSprites COLLAPSE_SPRITES = new WidgetSprites( + createIdentifier("widget/collapse"), + createIdentifier("widget/collapse_focused") + ); + + private static final int ALTERNATIVES_DISPLAYED = 2; + private static final int ROWS_PER_ALTERNATIVE = 2; + private static final int RESOURCES_PER_ROW = 8; + private static final int INSET_WIDTH = 146; + private static final int INSET_HEIGHT = ALTERNATIVE_HEIGHT * ALTERNATIVES_DISPLAYED; + + private final ResourceSlot slot; + + @Nullable + private ScrollbarWidget scrollbar; + @Nullable + private EditBox searchField; + + private final List alternativeCheckboxes = new ArrayList<>(); + private final List