diff --git a/.gitignore b/.gitignore index 0521ad558..766ed11d8 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ out/ /bin/ logs/ .cache/ +run/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 54f138daa..954c79c7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,21 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [2.0.0-milestone.4.3] - 2024-07-06 + +### Added + +- Ability to open Portable Grid with a keybinding. + +### Fixed + +- Fixed Relay model not being able to load correctly. +- Fixed not being able to ghost drag resources from recipe viewers into filter slots on NeoForge. +- Fixed extra dark backgrounds due to drawing background on GUIs twice. +- Fixed Configuration Card not being able to transfer upgrades for the Wireless Transmitter. +- Fixed upgrade inventories not maintaining order after reloading. Upgrade inventories from the milestone 4.2 are incompatible and will be empty. +- Fixed Wireless Transmitter not dropping upgrades when breaking block. + ## [2.0.0-milestone.4.2] - 2024-07-06 ## [2.0.0-milestone.4.1] - 2024-07-05 @@ -647,7 +662,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - The Grid can now use smooth scrolling. - The Grid now has syntax highlighting for the search query. -[Unreleased]: https://github.com/refinedmods/refinedstorage2/compare/v2.0.0-milestone.4.2...HEAD +[Unreleased]: https://github.com/refinedmods/refinedstorage2/compare/v2.0.0-milestone.4.3...HEAD + +[2.0.0-milestone.4.3]: https://github.com/refinedmods/refinedstorage2/compare/v2.0.0-milestone.4.2...v2.0.0-milestone.4.3 [2.0.0-milestone.4.2]: https://github.com/refinedmods/refinedstorage2/compare/v2.0.0-milestone.4.1...v2.0.0-milestone.4.2 diff --git a/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/PlatformApi.java b/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/PlatformApi.java index f9a49ed50..7a31b58f2 100644 --- a/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/PlatformApi.java +++ b/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/PlatformApi.java @@ -33,14 +33,14 @@ import com.refinedmods.refinedstorage.platform.api.support.network.ConnectionLogic; import com.refinedmods.refinedstorage.platform.api.support.network.InWorldNetworkNodeContainer; import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.NetworkBoundItemHelper; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReferenceFactory; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReferenceProvider; import com.refinedmods.refinedstorage.platform.api.support.registry.PlatformRegistry; import com.refinedmods.refinedstorage.platform.api.support.resource.RecipeModIngredientConverter; import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceFactory; import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceRendering; import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceType; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReferenceFactory; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReferenceProvider; import com.refinedmods.refinedstorage.platform.api.upgrade.BuiltinUpgradeDestinations; import com.refinedmods.refinedstorage.platform.api.upgrade.UpgradeRegistry; import com.refinedmods.refinedstorage.platform.api.wirelesstransmitter.WirelessTransmitterRangeModifier; @@ -192,7 +192,7 @@ EnergyStorage asBlockItemEnergyStorage( SlotReference createInventorySlotReference(Player player, InteractionHand hand); - void useNetworkBoundItem(Player player, Item... items); + void useSlotReferencedItem(Player player, Item... items); BuiltinPermissions getBuiltinPermissions(); diff --git a/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/PlatformApiProxy.java b/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/PlatformApiProxy.java index 10365398d..1d7b23193 100644 --- a/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/PlatformApiProxy.java +++ b/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/PlatformApiProxy.java @@ -33,14 +33,14 @@ import com.refinedmods.refinedstorage.platform.api.support.network.ConnectionLogic; import com.refinedmods.refinedstorage.platform.api.support.network.InWorldNetworkNodeContainer; import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.NetworkBoundItemHelper; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReferenceFactory; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReferenceProvider; import com.refinedmods.refinedstorage.platform.api.support.registry.PlatformRegistry; import com.refinedmods.refinedstorage.platform.api.support.resource.RecipeModIngredientConverter; import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceFactory; import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceRendering; import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceType; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReferenceFactory; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReferenceProvider; import com.refinedmods.refinedstorage.platform.api.upgrade.BuiltinUpgradeDestinations; import com.refinedmods.refinedstorage.platform.api.upgrade.UpgradeRegistry; import com.refinedmods.refinedstorage.platform.api.wirelesstransmitter.WirelessTransmitterRangeModifier; @@ -368,8 +368,8 @@ public SlotReference createInventorySlotReference(final Player player, final Int } @Override - public void useNetworkBoundItem(final Player player, final Item... items) { - ensureLoaded().useNetworkBoundItem(player, items); + public void useSlotReferencedItem(final Player player, final Item... items) { + ensureLoaded().useSlotReferencedItem(player, items); } @Override diff --git a/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/energy/AbstractNetworkBoundEnergyItem.java b/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/energy/AbstractNetworkBoundEnergyItem.java index 683af95e9..94fe2078b 100644 --- a/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/energy/AbstractNetworkBoundEnergyItem.java +++ b/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/energy/AbstractNetworkBoundEnergyItem.java @@ -3,7 +3,8 @@ import com.refinedmods.refinedstorage.platform.api.PlatformApi; import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.NetworkBoundItemHelper; import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.NetworkBoundItemSession; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReferenceHandlerItem; import java.util.List; import java.util.Optional; @@ -22,7 +23,7 @@ import org.apiguardian.api.API; @API(status = API.Status.STABLE, since = "2.0.0-milestone.3.1") -public abstract class AbstractNetworkBoundEnergyItem extends AbstractEnergyItem { +public abstract class AbstractNetworkBoundEnergyItem extends AbstractEnergyItem implements SlotReferenceHandlerItem { protected final NetworkBoundItemHelper networkBoundItemHelper; protected AbstractNetworkBoundEnergyItem(final Properties properties, @@ -56,17 +57,22 @@ public InteractionResultHolder use(final Level level, final Player pl final ItemStack stack = player.getItemInHand(hand); if (player instanceof ServerPlayer serverPlayer && level.getServer() != null) { final SlotReference slotReference = PlatformApi.INSTANCE.createInventorySlotReference(player, hand); - final NetworkBoundItemSession session = networkBoundItemHelper.openSession( - stack, - serverPlayer, - slotReference - ); - use(serverPlayer, slotReference, session); + slotReference.resolve(player).ifPresent(s -> use(serverPlayer, s, slotReference)); } return InteractionResultHolder.consume(stack); } - public abstract void use(ServerPlayer player, SlotReference slotReference, NetworkBoundItemSession session); + @Override + public void use(final ServerPlayer player, final ItemStack stack, final SlotReference slotReference) { + final NetworkBoundItemSession session = PlatformApi.INSTANCE.getNetworkBoundItemHelper().openSession( + stack, + player, + slotReference + ); + use(player, slotReference, session); + } + + protected abstract void use(ServerPlayer player, SlotReference slotReference, NetworkBoundItemSession session); public boolean isBound(final ItemStack stack) { return networkBoundItemHelper.isBound(stack); diff --git a/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/network/bounditem/NetworkBoundItemHelper.java b/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/network/bounditem/NetworkBoundItemHelper.java index 5870ffe23..a1082b94b 100644 --- a/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/network/bounditem/NetworkBoundItemHelper.java +++ b/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/network/bounditem/NetworkBoundItemHelper.java @@ -1,5 +1,7 @@ package com.refinedmods.refinedstorage.platform.api.support.network.bounditem; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; + import java.util.List; import java.util.Optional; diff --git a/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/network/bounditem/SlotReference.java b/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/slotreference/SlotReference.java similarity index 83% rename from refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/network/bounditem/SlotReference.java rename to refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/slotreference/SlotReference.java index 539506ef6..903495ad3 100644 --- a/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/network/bounditem/SlotReference.java +++ b/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/slotreference/SlotReference.java @@ -1,4 +1,4 @@ -package com.refinedmods.refinedstorage.platform.api.support.network.bounditem; +package com.refinedmods.refinedstorage.platform.api.support.slotreference; import java.util.Optional; diff --git a/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/network/bounditem/SlotReferenceFactory.java b/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/slotreference/SlotReferenceFactory.java similarity index 93% rename from refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/network/bounditem/SlotReferenceFactory.java rename to refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/slotreference/SlotReferenceFactory.java index f515774a7..aab1c8c84 100644 --- a/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/network/bounditem/SlotReferenceFactory.java +++ b/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/slotreference/SlotReferenceFactory.java @@ -1,4 +1,4 @@ -package com.refinedmods.refinedstorage.platform.api.support.network.bounditem; +package com.refinedmods.refinedstorage.platform.api.support.slotreference; import com.refinedmods.refinedstorage.platform.api.PlatformApi; diff --git a/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/slotreference/SlotReferenceHandlerItem.java b/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/slotreference/SlotReferenceHandlerItem.java new file mode 100644 index 000000000..edeeabe5c --- /dev/null +++ b/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/slotreference/SlotReferenceHandlerItem.java @@ -0,0 +1,11 @@ +package com.refinedmods.refinedstorage.platform.api.support.slotreference; + +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.item.ItemStack; +import org.apiguardian.api.API; + +@FunctionalInterface +@API(status = API.Status.STABLE, since = "2.0.0-milestone.4.3") +public interface SlotReferenceHandlerItem { + void use(ServerPlayer player, ItemStack stack, SlotReference slotReference); +} diff --git a/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/network/bounditem/SlotReferenceProvider.java b/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/slotreference/SlotReferenceProvider.java similarity index 81% rename from refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/network/bounditem/SlotReferenceProvider.java rename to refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/slotreference/SlotReferenceProvider.java index 760a30987..c86829255 100644 --- a/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/network/bounditem/SlotReferenceProvider.java +++ b/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/slotreference/SlotReferenceProvider.java @@ -1,4 +1,4 @@ -package com.refinedmods.refinedstorage.platform.api.support.network.bounditem; +package com.refinedmods.refinedstorage.platform.api.support.slotreference; import java.util.List; import java.util.Set; diff --git a/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/slotreference/package-info.java b/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/slotreference/package-info.java new file mode 100644 index 000000000..44928fbd8 --- /dev/null +++ b/refinedstorage-platform-api/src/main/java/com/refinedmods/refinedstorage/platform/api/support/slotreference/package-info.java @@ -0,0 +1,7 @@ +@ParametersAreNonnullByDefault +@FieldsAndMethodsAreNonnullByDefault +package com.refinedmods.refinedstorage.platform.api.support.slotreference; + +import com.refinedmods.refinedstorage.api.core.FieldsAndMethodsAreNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/AbstractClientModInitializer.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/AbstractClientModInitializer.java index d984184de..4cebb7e41 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/AbstractClientModInitializer.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/AbstractClientModInitializer.java @@ -95,12 +95,20 @@ protected static void handleInputEvents() { } final KeyMapping openWirelessGrid = KeyMappings.INSTANCE.getOpenWirelessGrid(); while (openWirelessGrid != null && openWirelessGrid.consumeClick()) { - PlatformApi.INSTANCE.useNetworkBoundItem( + PlatformApi.INSTANCE.useSlotReferencedItem( player, Items.INSTANCE.getWirelessGrid(), Items.INSTANCE.getCreativeWirelessGrid() ); } + final KeyMapping openPortableGrid = KeyMappings.INSTANCE.getOpenPortableGrid(); + while (openPortableGrid != null && openPortableGrid.consumeClick()) { + PlatformApi.INSTANCE.useSlotReferencedItem( + player, + Items.INSTANCE.getPortableGrid(), + Items.INSTANCE.getCreativePortableGrid() + ); + } } protected static void registerDiskModels() { diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/AbstractModInitializer.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/AbstractModInitializer.java index 4f68e9153..c16987a07 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/AbstractModInitializer.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/AbstractModInitializer.java @@ -119,11 +119,11 @@ import com.refinedmods.refinedstorage.platform.common.support.containermenu.SingleAmountData; import com.refinedmods.refinedstorage.platform.common.support.energy.EnergyLootItemFunction; import com.refinedmods.refinedstorage.platform.common.support.network.BaseNetworkNodeContainerBlockEntity; -import com.refinedmods.refinedstorage.platform.common.support.network.bounditem.InventorySlotReferenceFactory; import com.refinedmods.refinedstorage.platform.common.support.network.component.PlatformStorageNetworkComponent; import com.refinedmods.refinedstorage.platform.common.support.resource.FluidResourceFactory; import com.refinedmods.refinedstorage.platform.common.support.resource.ResourceContainerData; import com.refinedmods.refinedstorage.platform.common.support.resource.ResourceTypes; +import com.refinedmods.refinedstorage.platform.common.support.slotreference.InventorySlotReferenceFactory; import com.refinedmods.refinedstorage.platform.common.upgrade.FortuneUpgradeItem; import com.refinedmods.refinedstorage.platform.common.upgrade.RangeUpgradeItem; import com.refinedmods.refinedstorage.platform.common.upgrade.RegulatorUpgradeContainerMenu; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/PlatformApiImpl.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/PlatformApiImpl.java index 1509064ff..8cf2c9d94 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/PlatformApiImpl.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/PlatformApiImpl.java @@ -38,14 +38,14 @@ import com.refinedmods.refinedstorage.platform.api.support.network.InWorldNetworkNodeContainer; import com.refinedmods.refinedstorage.platform.api.support.network.NetworkNodeContainerBlockEntity; import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.NetworkBoundItemHelper; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReferenceFactory; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReferenceProvider; import com.refinedmods.refinedstorage.platform.api.support.registry.PlatformRegistry; import com.refinedmods.refinedstorage.platform.api.support.resource.RecipeModIngredientConverter; import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceFactory; import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceRendering; import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceType; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReferenceFactory; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReferenceProvider; import com.refinedmods.refinedstorage.platform.api.upgrade.BuiltinUpgradeDestinations; import com.refinedmods.refinedstorage.platform.api.upgrade.UpgradeRegistry; import com.refinedmods.refinedstorage.platform.api.wirelesstransmitter.WirelessTransmitterRangeModifier; @@ -68,8 +68,6 @@ import com.refinedmods.refinedstorage.platform.common.support.energy.ItemEnergyStorage; import com.refinedmods.refinedstorage.platform.common.support.network.ConnectionProviderImpl; import com.refinedmods.refinedstorage.platform.common.support.network.InWorldNetworkNodeContainerImpl; -import com.refinedmods.refinedstorage.platform.common.support.network.bounditem.CompositeSlotReferenceProvider; -import com.refinedmods.refinedstorage.platform.common.support.network.bounditem.InventorySlotReference; import com.refinedmods.refinedstorage.platform.common.support.network.bounditem.NetworkBoundItemHelperImpl; import com.refinedmods.refinedstorage.platform.common.support.packet.c2s.C2SPackets; import com.refinedmods.refinedstorage.platform.common.support.packet.s2c.S2CPackets; @@ -77,6 +75,8 @@ import com.refinedmods.refinedstorage.platform.common.support.resource.CompositeRecipeModIngredientConverter; import com.refinedmods.refinedstorage.platform.common.support.resource.FluidResourceFactory; import com.refinedmods.refinedstorage.platform.common.support.resource.ItemResourceFactory; +import com.refinedmods.refinedstorage.platform.common.support.slotreference.CompositeSlotReferenceProvider; +import com.refinedmods.refinedstorage.platform.common.support.slotreference.InventorySlotReference; import com.refinedmods.refinedstorage.platform.common.upgrade.BuiltinUpgradeDestinationsImpl; import com.refinedmods.refinedstorage.platform.common.upgrade.UpgradeRegistryImpl; import com.refinedmods.refinedstorage.platform.common.util.ServerEventQueue; @@ -519,9 +519,9 @@ public SlotReference createInventorySlotReference(final Player player, final Int } @Override - public void useNetworkBoundItem(final Player player, final Item... items) { + public void useSlotReferencedItem(final Player player, final Item... items) { final Set validItems = new HashSet<>(Arrays.asList(items)); - slotReferenceProvider.findForUse(player, items[0], validItems).ifPresent(C2SPackets::sendUseNetworkBoundItem); + slotReferenceProvider.findForUse(player, items[0], validItems).ifPresent(C2SPackets::sendUseSlotReferencedItem); } @Override diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/content/ContentNames.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/content/ContentNames.java index e4ed7de26..ec4706e4f 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/content/ContentNames.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/content/ContentNames.java @@ -5,10 +5,12 @@ import static com.refinedmods.refinedstorage.platform.common.util.IdentifierUtil.MOD_ID; import static com.refinedmods.refinedstorage.platform.common.util.IdentifierUtil.createTranslation; +import static com.refinedmods.refinedstorage.platform.common.util.IdentifierUtil.createTranslationKey; public final class ContentNames { public static final String MOD_TRANSLATION_KEY = "mod." + MOD_ID; public static final MutableComponent MOD = Component.translatable(MOD_TRANSLATION_KEY); + public static final MutableComponent CABLE = name("cable"); public static final MutableComponent GRID = name("grid"); public static final MutableComponent CRAFTING_GRID = name("crafting_grid"); @@ -35,6 +37,14 @@ public final class ContentNames { public static final MutableComponent RELAY = name("relay"); public static final MutableComponent DISK_INTERFACE = name("disk_interface"); + public static final String CLEAR_CRAFTING_MATRIX_TO_NETWORK_TRANSLATION_KEY = + createTranslationKey("key", "clear_crafting_grid_matrix_to_network"); + public static final String CLEAR_CRAFTING_MATRIX_TO_INVENTORY_TRANSLATION_KEY = + createTranslationKey("key", "clear_crafting_grid_matrix_to_inventory"); + public static final String FOCUS_SEARCH_BAR_TRANSLATION_KEY = createTranslationKey("key", "focus_search_bar"); + public static final String OPEN_WIRELESS_GRID_TRANSLATION_KEY = createTranslationKey("key", "open_wireless_grid"); + public static final String OPEN_PORTABLE_GRID_TRANSLATION_KEY = createTranslationKey("key", "open_portable_grid"); + private ContentNames() { } diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/content/KeyMappings.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/content/KeyMappings.java index e4235a948..897727fda 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/content/KeyMappings.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/content/KeyMappings.java @@ -16,6 +16,8 @@ public final class KeyMappings { private KeyMapping clearCraftingGridMatrixToInventory; @Nullable private KeyMapping openWirelessGrid; + @Nullable + private KeyMapping openPortableGrid; private KeyMappings() { } @@ -54,4 +56,13 @@ public KeyMapping getOpenWirelessGrid() { public void setOpenWirelessGrid(final KeyMapping openWirelessGrid) { this.openWirelessGrid = openWirelessGrid; } + + @Nullable + public KeyMapping getOpenPortableGrid() { + return openPortableGrid; + } + + public void setOpenPortableGrid(final KeyMapping openPortableGrid) { + this.openPortableGrid = openPortableGrid; + } } diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/grid/PortableGridData.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/grid/PortableGridData.java index eaf7de47b..c64433452 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/grid/PortableGridData.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/grid/PortableGridData.java @@ -1,7 +1,7 @@ package com.refinedmods.refinedstorage.platform.common.grid; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReferenceFactory; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReferenceFactory; import java.util.Optional; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/grid/WirelessGridContainerMenu.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/grid/WirelessGridContainerMenu.java index 845ab69c5..a7a75ef40 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/grid/WirelessGridContainerMenu.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/grid/WirelessGridContainerMenu.java @@ -1,7 +1,7 @@ package com.refinedmods.refinedstorage.platform.common.grid; import com.refinedmods.refinedstorage.platform.api.grid.Grid; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; import com.refinedmods.refinedstorage.platform.common.content.Menus; import net.minecraft.world.entity.player.Inventory; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/grid/WirelessGridData.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/grid/WirelessGridData.java index 60c17531f..b547e00e3 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/grid/WirelessGridData.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/grid/WirelessGridData.java @@ -1,7 +1,7 @@ package com.refinedmods.refinedstorage.platform.common.grid; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReferenceFactory; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReferenceFactory; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/grid/WirelessGridExtendedMenuProvider.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/grid/WirelessGridExtendedMenuProvider.java index 90e3fa1b0..e8881f5a0 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/grid/WirelessGridExtendedMenuProvider.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/grid/WirelessGridExtendedMenuProvider.java @@ -1,7 +1,7 @@ package com.refinedmods.refinedstorage.platform.common.grid; import com.refinedmods.refinedstorage.platform.api.grid.Grid; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; import com.refinedmods.refinedstorage.platform.common.content.ContentNames; import com.refinedmods.refinedstorage.platform.common.support.containermenu.ExtendedMenuProvider; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/grid/WirelessGridItem.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/grid/WirelessGridItem.java index 5fcdd9351..e27de441d 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/grid/WirelessGridItem.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/grid/WirelessGridItem.java @@ -7,7 +7,7 @@ import com.refinedmods.refinedstorage.platform.api.security.SecurityHelper; import com.refinedmods.refinedstorage.platform.api.support.energy.AbstractNetworkBoundEnergyItem; import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.NetworkBoundItemSession; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; import com.refinedmods.refinedstorage.platform.common.Platform; import com.refinedmods.refinedstorage.platform.common.content.ContentNames; import com.refinedmods.refinedstorage.platform.common.security.BuiltinPermission; @@ -33,9 +33,9 @@ public EnergyStorage createEnergyStorage(final ItemStack stack) { } @Override - public void use(final ServerPlayer player, - final SlotReference slotReference, - final NetworkBoundItemSession session) { + protected void use(final ServerPlayer player, + final SlotReference slotReference, + final NetworkBoundItemSession session) { final boolean isAllowed = session.resolveNetwork() .map(network -> SecurityHelper.isAllowed(player, BuiltinPermission.OPEN, network)) .orElse(true); // if the network can't be resolved that will be apparent later in the UI. diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/networking/NetworkTransmitterBlockEntity.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/networking/NetworkTransmitterBlockEntity.java index f3fd8a91e..f60dea301 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/networking/NetworkTransmitterBlockEntity.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/networking/NetworkTransmitterBlockEntity.java @@ -10,6 +10,7 @@ import com.refinedmods.refinedstorage.platform.common.support.BlockEntityWithDrops; import com.refinedmods.refinedstorage.platform.common.support.containermenu.NetworkNodeExtendedMenuProvider; import com.refinedmods.refinedstorage.platform.common.support.network.AbstractRedstoneModeNetworkNodeContainerBlockEntity; +import com.refinedmods.refinedstorage.platform.common.util.ContainerUtil; import javax.annotation.Nullable; @@ -19,7 +20,6 @@ import net.minecraft.core.HolderLookup; import net.minecraft.core.NonNullList; import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; @@ -155,17 +155,14 @@ Container getNetworkCardInventory() { @Override public void saveAdditional(final CompoundTag tag, final HolderLookup.Provider provider) { super.saveAdditional(tag, provider); - tag.put(TAG_NETWORK_CARD_INVENTORY, networkCardInventory.createTag(provider)); + tag.put(TAG_NETWORK_CARD_INVENTORY, ContainerUtil.write(networkCardInventory, provider)); } @Override public void loadAdditional(final CompoundTag tag, final HolderLookup.Provider provider) { super.loadAdditional(tag, provider); if (tag.contains(TAG_NETWORK_CARD_INVENTORY)) { - networkCardInventory.fromTag( - tag.getList(TAG_NETWORK_CARD_INVENTORY, Tag.TAG_COMPOUND), - provider - ); + ContainerUtil.read(tag.getCompound(TAG_NETWORK_CARD_INVENTORY), networkCardInventory, provider); } updateReceiverLocation(); } diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/AbstractSecurityCardContainerMenu.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/AbstractSecurityCardContainerMenu.java index 3904a8acb..8c1e864d4 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/AbstractSecurityCardContainerMenu.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/AbstractSecurityCardContainerMenu.java @@ -1,7 +1,7 @@ package com.refinedmods.refinedstorage.platform.common.security; import com.refinedmods.refinedstorage.platform.api.security.PlatformPermission; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; import com.refinedmods.refinedstorage.platform.common.support.AbstractBaseContainerMenu; import com.refinedmods.refinedstorage.platform.common.support.packet.c2s.C2SPackets; import com.refinedmods.refinedstorage.platform.common.support.stretching.ScreenSizeListener; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/AbstractSecurityCardItem.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/AbstractSecurityCardItem.java index 9994efd51..4431ace77 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/AbstractSecurityCardItem.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/AbstractSecurityCardItem.java @@ -5,7 +5,7 @@ import com.refinedmods.refinedstorage.platform.api.PlatformApi; import com.refinedmods.refinedstorage.platform.api.security.PlatformPermission; import com.refinedmods.refinedstorage.platform.api.security.SecurityPolicyContainerItem; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; import com.refinedmods.refinedstorage.platform.common.Platform; import com.refinedmods.refinedstorage.platform.common.content.DataComponents; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/FallbackSecurityCardContainerMenu.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/FallbackSecurityCardContainerMenu.java index f1d57ba2c..436114180 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/FallbackSecurityCardContainerMenu.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/FallbackSecurityCardContainerMenu.java @@ -1,6 +1,6 @@ package com.refinedmods.refinedstorage.platform.common.security; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; import com.refinedmods.refinedstorage.platform.common.content.Menus; import net.minecraft.world.entity.player.Inventory; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/FallbackSecurityCardExtendedMenuProvider.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/FallbackSecurityCardExtendedMenuProvider.java index 598eb288a..bd8270107 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/FallbackSecurityCardExtendedMenuProvider.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/FallbackSecurityCardExtendedMenuProvider.java @@ -2,7 +2,7 @@ import com.refinedmods.refinedstorage.api.network.security.SecurityPolicy; import com.refinedmods.refinedstorage.platform.api.security.PlatformPermission; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; import com.refinedmods.refinedstorage.platform.common.content.ContentNames; import java.util.Set; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/FallbackSecurityCardItem.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/FallbackSecurityCardItem.java index 7034cb6e8..dcb4dcb8a 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/FallbackSecurityCardItem.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/FallbackSecurityCardItem.java @@ -4,7 +4,7 @@ import com.refinedmods.refinedstorage.api.network.security.SecurityPolicy; import com.refinedmods.refinedstorage.platform.api.security.PlatformPermission; import com.refinedmods.refinedstorage.platform.api.support.HelpTooltipComponent; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; import com.refinedmods.refinedstorage.platform.common.Platform; import java.util.Optional; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/SecurityCardContainerMenu.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/SecurityCardContainerMenu.java index 438d716a9..a16f66548 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/SecurityCardContainerMenu.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/SecurityCardContainerMenu.java @@ -1,6 +1,6 @@ package com.refinedmods.refinedstorage.platform.common.security; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; import com.refinedmods.refinedstorage.platform.common.content.Menus; import com.refinedmods.refinedstorage.platform.common.support.packet.c2s.C2SPackets; import com.refinedmods.refinedstorage.platform.common.support.stretching.ScreenSizeListener; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/SecurityCardData.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/SecurityCardData.java index f1a5a0a88..2f1358792 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/SecurityCardData.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/SecurityCardData.java @@ -2,8 +2,8 @@ import com.refinedmods.refinedstorage.platform.api.PlatformApi; import com.refinedmods.refinedstorage.platform.api.security.PlatformPermission; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReferenceFactory; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReferenceFactory; import java.util.ArrayList; import java.util.List; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/SecurityCardExtendedMenuProvider.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/SecurityCardExtendedMenuProvider.java index 54dab1eb5..04800ccca 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/SecurityCardExtendedMenuProvider.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/SecurityCardExtendedMenuProvider.java @@ -2,7 +2,7 @@ import com.refinedmods.refinedstorage.api.network.security.SecurityPolicy; import com.refinedmods.refinedstorage.platform.api.security.PlatformPermission; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; import com.refinedmods.refinedstorage.platform.common.content.ContentNames; import java.util.Set; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/SecurityCardItem.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/SecurityCardItem.java index 04574364c..b0de34657 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/SecurityCardItem.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/security/SecurityCardItem.java @@ -4,7 +4,7 @@ import com.refinedmods.refinedstorage.api.network.security.SecurityPolicy; import com.refinedmods.refinedstorage.platform.api.security.PlatformPermission; import com.refinedmods.refinedstorage.platform.api.support.HelpTooltipComponent; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; import com.refinedmods.refinedstorage.platform.common.Platform; import com.refinedmods.refinedstorage.platform.common.content.DataComponents; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/storage/diskinterface/AbstractDiskInterfaceBlockEntity.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/storage/diskinterface/AbstractDiskInterfaceBlockEntity.java index 35c061945..86002c063 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/storage/diskinterface/AbstractDiskInterfaceBlockEntity.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/storage/diskinterface/AbstractDiskInterfaceBlockEntity.java @@ -15,8 +15,8 @@ import com.refinedmods.refinedstorage.platform.common.support.FilterModeSettings; import com.refinedmods.refinedstorage.platform.common.upgrade.UpgradeContainer; import com.refinedmods.refinedstorage.platform.common.upgrade.UpgradeDestinations; +import com.refinedmods.refinedstorage.platform.common.util.ContainerUtil; -import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.function.UnaryOperator; @@ -25,7 +25,6 @@ import net.minecraft.core.HolderLookup; import net.minecraft.core.NonNullList; import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; @@ -34,13 +33,12 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.state.BlockState; -// TODO: upgradeable + level interacting class hierarchy? Disk Interface is copying stuff now... :( public abstract class AbstractDiskInterfaceBlockEntity extends AbstractDiskContainerBlockEntity implements StorageTransferListener { public static final int AMOUNT_OF_DISKS = 6; - private static final String TAG_UPGRADES = "u"; + private static final String TAG_UPGRADES = "upgr"; private static final String TAG_FILTER_MODE = "fim"; private static final String TAG_TRANSFER_MODE = "tm"; @@ -71,15 +69,11 @@ protected AbstractDiskInterfaceBlockEntity(final BlockPos pos, final BlockState } private void upgradeContainerChanged() { - configureAccordingToUpgrades(); - setChanged(); - } - - private void configureAccordingToUpgrades() { final int amountOfSpeedUpgrades = upgradeContainer.getAmount(Items.INSTANCE.getSpeedUpgrade()); this.workTickRate = 9 - (amountOfSpeedUpgrades * 2); final long baseEnergyUsage = Platform.INSTANCE.getConfig().getDiskInterface().getEnergyUsage(); mainNode.setEnergyUsage(baseEnergyUsage + upgradeContainer.getEnergyUsage()); + setChanged(); } @Override @@ -102,16 +96,15 @@ protected void setNormalizer(final UnaryOperator normalizer) { @Override public void loadAdditional(final CompoundTag tag, final HolderLookup.Provider provider) { if (tag.contains(TAG_UPGRADES)) { - upgradeContainer.fromTag(tag.getList(TAG_UPGRADES, Tag.TAG_COMPOUND), provider); + ContainerUtil.read(tag.getCompound(TAG_UPGRADES), upgradeContainer, provider); } - configureAccordingToUpgrades(); super.loadAdditional(tag, provider); } @Override public void saveAdditional(final CompoundTag tag, final HolderLookup.Provider provider) { super.saveAdditional(tag, provider); - tag.put(TAG_UPGRADES, upgradeContainer.createTag(provider)); + tag.put(TAG_UPGRADES, ContainerUtil.write(upgradeContainer, provider)); tag.putInt(TAG_FILTER_MODE, FilterModeSettings.getFilterMode(mainNode.getFilterMode())); } @@ -134,20 +127,12 @@ public void writeConfiguration(final CompoundTag tag, final HolderLookup.Provide @Override public List getUpgradeItems() { - final List upgradeItems = new ArrayList<>(); - for (int i = 0; i < upgradeContainer.getContainerSize(); ++i) { - final ItemStack itemStack = upgradeContainer.getItem(i); - if (itemStack.isEmpty()) { - continue; - } - upgradeItems.add(itemStack.getItem()); - } - return upgradeItems; + return upgradeContainer.getUpgradeItems(); } @Override public boolean addUpgradeItem(final Item upgradeItem) { - return upgradeContainer.addItem(new ItemStack(upgradeItem)).isEmpty(); + return upgradeContainer.addUpgradeItem(upgradeItem); } @Override diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/storage/portablegrid/PortableGridBlockItem.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/storage/portablegrid/PortableGridBlockItem.java index 7bd6fe81a..1d72f81c1 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/storage/portablegrid/PortableGridBlockItem.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/storage/portablegrid/PortableGridBlockItem.java @@ -11,7 +11,8 @@ import com.refinedmods.refinedstorage.platform.api.storage.StorageRepository; import com.refinedmods.refinedstorage.platform.api.support.HelpTooltipComponent; import com.refinedmods.refinedstorage.platform.api.support.energy.AbstractEnergyBlockItem; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReferenceHandlerItem; import com.refinedmods.refinedstorage.platform.common.Platform; import com.refinedmods.refinedstorage.platform.common.content.BlockEntities; import com.refinedmods.refinedstorage.platform.common.storage.Disk; @@ -38,7 +39,7 @@ import static com.refinedmods.refinedstorage.platform.common.util.IdentifierUtil.createTranslation; -public class PortableGridBlockItem extends AbstractEnergyBlockItem { +public class PortableGridBlockItem extends AbstractEnergyBlockItem implements SlotReferenceHandlerItem { private static final Component HELP = createTranslation("item", "portable_grid.help"); private final PortableGridType type; @@ -116,29 +117,35 @@ public InteractionResultHolder use(final Level level, final Player pl final ItemStack stack = player.getItemInHand(hand); if (player instanceof ServerPlayer serverPlayer && level.getServer() != null) { final SlotReference slotReference = PlatformApi.INSTANCE.createInventorySlotReference(player, hand); - final PortableGridEnergyStorage energyStorage = createEnergyStorageInternal(stack); - final DiskInventoryListenerImpl listener = new DiskInventoryListenerImpl(stack, level.registryAccess()); - final DiskInventory diskInventory = createDiskInventory(stack, listener, level.registryAccess()); - diskInventory.setStorageRepository(PlatformApi.INSTANCE.getStorageRepository(level)); - final PortableGrid portableGrid = new PortableGrid( - energyStorage, - diskInventory, - () -> { - } - ); - listener.portableGrid = portableGrid; - energyStorage.portableGrid = portableGrid; - portableGrid.updateStorage(); - Platform.INSTANCE.getMenuOpener().openMenu(serverPlayer, new PortableGridItemExtendedMenuProvider( - portableGrid, - energyStorage, - diskInventory, - slotReference - )); + slotReference.resolve(player).ifPresent(s -> use(serverPlayer, s, slotReference)); } return InteractionResultHolder.consume(stack); } + @Override + public void use(final ServerPlayer player, final ItemStack stack, final SlotReference slotReference) { + final PortableGridEnergyStorage energyStorage = createEnergyStorageInternal(stack); + final Level level = player.serverLevel(); + final DiskInventoryListenerImpl listener = new DiskInventoryListenerImpl(stack, level.registryAccess()); + final DiskInventory diskInventory = createDiskInventory(stack, listener, level.registryAccess()); + diskInventory.setStorageRepository(PlatformApi.INSTANCE.getStorageRepository(level)); + final PortableGrid portableGrid = new PortableGrid( + energyStorage, + diskInventory, + () -> { + } + ); + listener.portableGrid = portableGrid; + energyStorage.portableGrid = portableGrid; + portableGrid.updateStorage(); + Platform.INSTANCE.getMenuOpener().openMenu(player, new PortableGridItemExtendedMenuProvider( + portableGrid, + energyStorage, + diskInventory, + slotReference + )); + } + private PortableGridEnergyStorage createEnergyStorageInternal(final ItemStack stack) { if (type == PortableGridType.CREATIVE) { return new PortableGridEnergyStorage(CreativeEnergyStorage.INSTANCE); diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/storage/portablegrid/PortableGridItemContainerMenu.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/storage/portablegrid/PortableGridItemContainerMenu.java index 60870ed25..4b38368e8 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/storage/portablegrid/PortableGridItemContainerMenu.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/storage/portablegrid/PortableGridItemContainerMenu.java @@ -2,7 +2,7 @@ import com.refinedmods.refinedstorage.api.network.energy.EnergyStorage; import com.refinedmods.refinedstorage.platform.api.grid.Grid; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; import com.refinedmods.refinedstorage.platform.common.content.Menus; import com.refinedmods.refinedstorage.platform.common.grid.PortableGridData; import com.refinedmods.refinedstorage.platform.common.storage.DiskInventory; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/storage/portablegrid/PortableGridItemExtendedMenuProvider.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/storage/portablegrid/PortableGridItemExtendedMenuProvider.java index 97a2bd0da..3ec8e8479 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/storage/portablegrid/PortableGridItemExtendedMenuProvider.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/storage/portablegrid/PortableGridItemExtendedMenuProvider.java @@ -2,7 +2,7 @@ import com.refinedmods.refinedstorage.api.network.energy.EnergyStorage; import com.refinedmods.refinedstorage.platform.api.grid.Grid; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; import com.refinedmods.refinedstorage.platform.common.content.ContentNames; import com.refinedmods.refinedstorage.platform.common.grid.GridData; import com.refinedmods.refinedstorage.platform.common.grid.PortableGridData; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/AbstractBaseContainerMenu.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/AbstractBaseContainerMenu.java index 6f2ccad79..544bf430f 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/AbstractBaseContainerMenu.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/AbstractBaseContainerMenu.java @@ -1,6 +1,6 @@ package com.refinedmods.refinedstorage.platform.common.support; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; import com.refinedmods.refinedstorage.platform.common.Platform; import com.refinedmods.refinedstorage.platform.common.support.containermenu.ClientProperty; import com.refinedmods.refinedstorage.platform.common.support.containermenu.DisabledSlot; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/AbstractBaseScreen.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/AbstractBaseScreen.java index 1057a1ba4..d4ae30e09 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/AbstractBaseScreen.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/AbstractBaseScreen.java @@ -90,7 +90,6 @@ protected void renderBg(final GuiGraphics graphics, final float delta, final int @Override public void render(final GuiGraphics graphics, final int mouseX, final int mouseY, final float delta) { - renderBackground(graphics, mouseX, mouseY, delta); super.render(graphics, mouseX, mouseY, delta); renderTooltip(graphics, mouseX, mouseY); } diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/ClientToServerCommunications.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/ClientToServerCommunications.java index e438a253b..708fb6eb3 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/ClientToServerCommunications.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/ClientToServerCommunications.java @@ -4,8 +4,8 @@ import com.refinedmods.refinedstorage.api.grid.operations.GridInsertMode; import com.refinedmods.refinedstorage.platform.api.grid.GridScrollMode; import com.refinedmods.refinedstorage.platform.api.security.PlatformPermission; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; import com.refinedmods.refinedstorage.platform.api.support.resource.PlatformResourceKey; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; import com.refinedmods.refinedstorage.platform.common.support.containermenu.PropertyType; import com.refinedmods.refinedstorage.platform.common.support.resource.ItemResource; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/containermenu/AbstractSingleAmountContainerMenu.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/containermenu/AbstractSingleAmountContainerMenu.java index 4fff5e509..22c7a0c44 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/containermenu/AbstractSingleAmountContainerMenu.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/containermenu/AbstractSingleAmountContainerMenu.java @@ -1,7 +1,7 @@ package com.refinedmods.refinedstorage.platform.common.support.containermenu; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceContainer; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; import com.refinedmods.refinedstorage.platform.common.support.packet.c2s.C2SPackets; import com.refinedmods.refinedstorage.platform.common.support.resource.ResourceContainerImpl; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/containermenu/SingleAmountData.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/containermenu/SingleAmountData.java index bd4a34de5..448f3e9d1 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/containermenu/SingleAmountData.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/containermenu/SingleAmountData.java @@ -1,7 +1,7 @@ package com.refinedmods.refinedstorage.platform.common.support.containermenu; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReferenceFactory; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReferenceFactory; import com.refinedmods.refinedstorage.platform.common.support.resource.ResourceContainerData; import java.util.Optional; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/AbstractUpgradeableNetworkNodeContainerBlockEntity.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/AbstractUpgradeableNetworkNodeContainerBlockEntity.java index c59505b40..36b9ac59f 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/AbstractUpgradeableNetworkNodeContainerBlockEntity.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/AbstractUpgradeableNetworkNodeContainerBlockEntity.java @@ -6,15 +6,14 @@ import com.refinedmods.refinedstorage.platform.common.support.BlockEntityWithDrops; import com.refinedmods.refinedstorage.platform.common.upgrade.UpgradeContainer; import com.refinedmods.refinedstorage.platform.common.upgrade.UpgradeDestinations; +import com.refinedmods.refinedstorage.platform.common.util.ContainerUtil; -import java.util.ArrayList; import java.util.List; import net.minecraft.core.BlockPos; import net.minecraft.core.HolderLookup; import net.minecraft.core.NonNullList; import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -30,7 +29,7 @@ public abstract class AbstractUpgradeableNetworkNodeContainerBlockEntity getUpgradeItems() { - final List upgradeItems = new ArrayList<>(); - for (int i = 0; i < upgradeContainer.getContainerSize(); ++i) { - final ItemStack itemStack = upgradeContainer.getItem(i); - if (itemStack.isEmpty()) { - continue; - } - upgradeItems.add(itemStack.getItem()); - } - return upgradeItems; + return upgradeContainer.getUpgradeItems(); } @Override public boolean addUpgradeItem(final Item upgradeItem) { - return upgradeContainer.addItem(new ItemStack(upgradeItem)).isEmpty(); + return upgradeContainer.addUpgradeItem(upgradeItem); } @Override public void saveAdditional(final CompoundTag tag, final HolderLookup.Provider provider) { super.saveAdditional(tag, provider); - tag.put(TAG_UPGRADES, upgradeContainer.createTag(provider)); + tag.put(TAG_UPGRADES, ContainerUtil.write(upgradeContainer, provider)); } @Override public void loadAdditional(final CompoundTag tag, final HolderLookup.Provider provider) { if (tag.contains(TAG_UPGRADES)) { - upgradeContainer.fromTag(tag.getList(TAG_UPGRADES, Tag.TAG_COMPOUND), provider); + ContainerUtil.read(tag.getCompound(TAG_UPGRADES), upgradeContainer, provider); } - configureAccordingToUpgrades(); super.loadAdditional(tag, provider); } - private void configureAccordingToUpgrades() { - LOGGER.debug("Reconfiguring {} for upgrades", getBlockPos()); - final int amountOfSpeedUpgrades = upgradeContainer.getAmount(Items.INSTANCE.getSpeedUpgrade()); - this.workTickRate = 9 - (amountOfSpeedUpgrades * 2); - this.setEnergyUsage(upgradeContainer.getEnergyUsage()); - } - protected abstract void setEnergyUsage(long upgradeEnergyUsage); @Override - public NonNullList getDrops() { + public final NonNullList getDrops() { final NonNullList drops = NonNullList.create(); for (int i = 0; i < upgradeContainer.getContainerSize(); ++i) { drops.add(upgradeContainer.getItem(i)); diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/bounditem/NetworkBoundItemHelperImpl.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/bounditem/NetworkBoundItemHelperImpl.java index a9a9458bc..493f1ab44 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/bounditem/NetworkBoundItemHelperImpl.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/bounditem/NetworkBoundItemHelperImpl.java @@ -4,7 +4,7 @@ import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.NetworkBoundItemHelper; import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.NetworkBoundItemSession; import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.NetworkBoundItemTargetBlockEntity; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; import com.refinedmods.refinedstorage.platform.common.content.DataComponents; import java.util.List; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/bounditem/NetworkBoundItemSessionImpl.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/bounditem/NetworkBoundItemSessionImpl.java index b1afe9bb6..d8fc7e9a1 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/bounditem/NetworkBoundItemSessionImpl.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/bounditem/NetworkBoundItemSessionImpl.java @@ -5,7 +5,7 @@ import com.refinedmods.refinedstorage.api.network.node.GraphNetworkComponent; import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.NetworkBoundItemSession; import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.NetworkBoundItemTargetBlockEntity; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; import com.refinedmods.refinedstorage.platform.api.wirelesstransmitter.WirelessTransmitter; import com.refinedmods.refinedstorage.platform.common.Platform; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/packet/c2s/C2SPackets.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/packet/c2s/C2SPackets.java index 03dd0d8a2..7575266e7 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/packet/c2s/C2SPackets.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/packet/c2s/C2SPackets.java @@ -4,8 +4,8 @@ import com.refinedmods.refinedstorage.api.grid.operations.GridInsertMode; import com.refinedmods.refinedstorage.platform.api.grid.GridScrollMode; import com.refinedmods.refinedstorage.platform.api.security.PlatformPermission; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; import com.refinedmods.refinedstorage.platform.api.support.resource.PlatformResourceKey; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; import com.refinedmods.refinedstorage.platform.common.Platform; import com.refinedmods.refinedstorage.platform.common.support.containermenu.PropertyType; import com.refinedmods.refinedstorage.platform.common.support.resource.ItemResource; @@ -65,8 +65,8 @@ public static void sendSingleAmountChange(final double amount) { Platform.INSTANCE.sendPacketToServer(new SingleAmountChangePacket(amount)); } - public static void sendUseNetworkBoundItem(final SlotReference slotReference) { - Platform.INSTANCE.sendPacketToServer(new UseNetworkBoundItemPacket(slotReference)); + public static void sendUseSlotReferencedItem(final SlotReference slotReference) { + Platform.INSTANCE.sendPacketToServer(new UseSlotReferencedItemPacket(slotReference)); } public static void sendSecurityCardPermission(final PlatformPermission permission, final boolean allowed) { diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/packet/c2s/UseNetworkBoundItemPacket.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/packet/c2s/UseNetworkBoundItemPacket.java deleted file mode 100644 index 36cf611cf..000000000 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/packet/c2s/UseNetworkBoundItemPacket.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.refinedmods.refinedstorage.platform.common.support.packet.c2s; - -import com.refinedmods.refinedstorage.platform.api.PlatformApi; -import com.refinedmods.refinedstorage.platform.api.support.energy.AbstractNetworkBoundEnergyItem; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.NetworkBoundItemSession; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReferenceFactory; -import com.refinedmods.refinedstorage.platform.common.support.packet.PacketContext; - -import net.minecraft.network.RegistryFriendlyByteBuf; -import net.minecraft.network.codec.StreamCodec; -import net.minecraft.network.protocol.common.custom.CustomPacketPayload; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.player.Player; - -import static com.refinedmods.refinedstorage.platform.common.util.IdentifierUtil.createIdentifier; - -public record UseNetworkBoundItemPacket(SlotReference slotReference) implements CustomPacketPayload { - public static final Type PACKET_TYPE = new Type<>( - createIdentifier("use_network_bound_item") - ); - public static final StreamCodec STREAM_CODEC = StreamCodec - .composite( - SlotReferenceFactory.STREAM_CODEC, UseNetworkBoundItemPacket::slotReference, - UseNetworkBoundItemPacket::new - ); - - public static void handle(final UseNetworkBoundItemPacket packet, final PacketContext ctx) { - final Player player = ctx.getPlayer(); - packet.slotReference.resolve(player).ifPresent(stack -> { - if (!(stack.getItem() instanceof AbstractNetworkBoundEnergyItem networkBoundItem)) { - return; - } - final NetworkBoundItemSession sess = PlatformApi.INSTANCE.getNetworkBoundItemHelper().openSession( - stack, - (ServerPlayer) player, - packet.slotReference - ); - networkBoundItem.use((ServerPlayer) player, packet.slotReference, sess); - }); - } - - @Override - public Type type() { - return PACKET_TYPE; - } -} diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/packet/c2s/UseSlotReferencedItemPacket.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/packet/c2s/UseSlotReferencedItemPacket.java new file mode 100644 index 000000000..7d1d65720 --- /dev/null +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/packet/c2s/UseSlotReferencedItemPacket.java @@ -0,0 +1,40 @@ +package com.refinedmods.refinedstorage.platform.common.support.packet.c2s; + +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReferenceFactory; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReferenceHandlerItem; +import com.refinedmods.refinedstorage.platform.common.support.packet.PacketContext; + +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.player.Player; + +import static com.refinedmods.refinedstorage.platform.common.util.IdentifierUtil.createIdentifier; + +public record UseSlotReferencedItemPacket(SlotReference slotReference) implements CustomPacketPayload { + public static final Type PACKET_TYPE = new Type<>( + createIdentifier("use_slot_referenced_item") + ); + public static final StreamCodec STREAM_CODEC = StreamCodec + .composite( + SlotReferenceFactory.STREAM_CODEC, UseSlotReferencedItemPacket::slotReference, + UseSlotReferencedItemPacket::new + ); + + public static void handle(final UseSlotReferencedItemPacket packet, final PacketContext ctx) { + final Player player = ctx.getPlayer(); + packet.slotReference.resolve(player).ifPresent(stack -> { + if (!(stack.getItem() instanceof SlotReferenceHandlerItem handlerItem)) { + return; + } + handlerItem.use((ServerPlayer) player, stack, packet.slotReference); + }); + } + + @Override + public Type type() { + return PACKET_TYPE; + } +} diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/bounditem/CompositeSlotReferenceProvider.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/slotreference/CompositeSlotReferenceProvider.java similarity index 84% rename from refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/bounditem/CompositeSlotReferenceProvider.java rename to refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/slotreference/CompositeSlotReferenceProvider.java index e19b32165..f01a8cf60 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/bounditem/CompositeSlotReferenceProvider.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/slotreference/CompositeSlotReferenceProvider.java @@ -1,7 +1,7 @@ -package com.refinedmods.refinedstorage.platform.common.support.network.bounditem; +package com.refinedmods.refinedstorage.platform.common.support.slotreference; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReferenceProvider; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReferenceProvider; import java.util.ArrayList; import java.util.List; @@ -48,6 +48,6 @@ public Optional findForUse(final Player player, ).withStyle(ChatFormatting.RED)); return Optional.empty(); } - return Optional.of(foundReferences.get(0)); + return Optional.of(foundReferences.getFirst()); } } diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/bounditem/InventorySlotReference.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/slotreference/InventorySlotReference.java similarity index 81% rename from refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/bounditem/InventorySlotReference.java rename to refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/slotreference/InventorySlotReference.java index 9ad2f5d61..5af624b67 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/bounditem/InventorySlotReference.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/slotreference/InventorySlotReference.java @@ -1,7 +1,7 @@ -package com.refinedmods.refinedstorage.platform.common.support.network.bounditem; +package com.refinedmods.refinedstorage.platform.common.support.slotreference; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReferenceFactory; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReferenceFactory; import java.util.Optional; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/bounditem/InventorySlotReferenceFactory.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/slotreference/InventorySlotReferenceFactory.java similarity index 75% rename from refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/bounditem/InventorySlotReferenceFactory.java rename to refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/slotreference/InventorySlotReferenceFactory.java index 3e81c6aa0..ec6f5660b 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/bounditem/InventorySlotReferenceFactory.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/slotreference/InventorySlotReferenceFactory.java @@ -1,7 +1,7 @@ -package com.refinedmods.refinedstorage.platform.common.support.network.bounditem; +package com.refinedmods.refinedstorage.platform.common.support.slotreference; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReferenceFactory; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReferenceFactory; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.ByteBufCodecs; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/bounditem/InventorySlotReferenceProvider.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/slotreference/InventorySlotReferenceProvider.java similarity index 74% rename from refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/bounditem/InventorySlotReferenceProvider.java rename to refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/slotreference/InventorySlotReferenceProvider.java index bb7ab5a9a..d5ec557e1 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/bounditem/InventorySlotReferenceProvider.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/slotreference/InventorySlotReferenceProvider.java @@ -1,7 +1,7 @@ -package com.refinedmods.refinedstorage.platform.common.support.network.bounditem; +package com.refinedmods.refinedstorage.platform.common.support.slotreference; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReferenceProvider; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReferenceProvider; import java.util.ArrayList; import java.util.List; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/slotreference/package-info.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/slotreference/package-info.java new file mode 100644 index 000000000..e88132e07 --- /dev/null +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/slotreference/package-info.java @@ -0,0 +1,7 @@ +@ParametersAreNonnullByDefault +@FieldsAndMethodsAreNonnullByDefault +package com.refinedmods.refinedstorage.platform.common.support.slotreference; + +import com.refinedmods.refinedstorage.api.core.FieldsAndMethodsAreNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/upgrade/RegulatorUpgradeContainerMenu.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/upgrade/RegulatorUpgradeContainerMenu.java index 66b9eedb6..a0a0feb62 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/upgrade/RegulatorUpgradeContainerMenu.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/upgrade/RegulatorUpgradeContainerMenu.java @@ -1,7 +1,7 @@ package com.refinedmods.refinedstorage.platform.common.upgrade; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceContainer; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; import com.refinedmods.refinedstorage.platform.common.content.Menus; import com.refinedmods.refinedstorage.platform.common.support.containermenu.AbstractSingleAmountContainerMenu; import com.refinedmods.refinedstorage.platform.common.support.containermenu.SingleAmountData; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/upgrade/RegulatorUpgradeItem.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/upgrade/RegulatorUpgradeItem.java index cf77de199..a11139476 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/upgrade/RegulatorUpgradeItem.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/upgrade/RegulatorUpgradeItem.java @@ -3,9 +3,9 @@ import com.refinedmods.refinedstorage.api.resource.ResourceAmount; import com.refinedmods.refinedstorage.api.resource.ResourceKey; import com.refinedmods.refinedstorage.platform.api.PlatformApi; -import com.refinedmods.refinedstorage.platform.api.support.network.bounditem.SlotReference; import com.refinedmods.refinedstorage.platform.api.support.resource.PlatformResourceKey; import com.refinedmods.refinedstorage.platform.api.support.resource.ResourceContainer; +import com.refinedmods.refinedstorage.platform.api.support.slotreference.SlotReference; import com.refinedmods.refinedstorage.platform.api.upgrade.AbstractUpgradeItem; import com.refinedmods.refinedstorage.platform.api.upgrade.UpgradeRegistry; import com.refinedmods.refinedstorage.platform.common.Platform; diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/upgrade/UpgradeContainer.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/upgrade/UpgradeContainer.java index 945ca75f5..9d805c137 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/upgrade/UpgradeContainer.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/upgrade/UpgradeContainer.java @@ -7,14 +7,14 @@ import com.refinedmods.refinedstorage.platform.api.upgrade.UpgradeRegistry; import com.refinedmods.refinedstorage.platform.api.upgrade.UpgradeState; +import java.util.ArrayList; +import java.util.List; import java.util.OptionalLong; import java.util.Set; import java.util.stream.IntStream; import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; -import net.minecraft.core.HolderLookup; -import net.minecraft.nbt.ListTag; import net.minecraft.world.SimpleContainer; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -76,12 +76,6 @@ public OptionalLong getRegulatedAmount(final ResourceKey resource) { .findFirst(); } - @Override - public void fromTag(final ListTag tag, final HolderLookup.Provider provider) { - super.fromTag(tag, provider); - updateIndex(); - } - private void updateIndex() { LOGGER.debug("Updating upgrade index for {}", destination); index.clear(); @@ -123,4 +117,20 @@ public long getEnergyUsage() { } return usage; } + + public List getUpgradeItems() { + final List upgradeItems = new ArrayList<>(); + for (int i = 0; i < getContainerSize(); ++i) { + final ItemStack itemStack = getItem(i); + if (itemStack.isEmpty()) { + continue; + } + upgradeItems.add(itemStack.getItem()); + } + return upgradeItems; + } + + public boolean addUpgradeItem(final Item upgradeItem) { + return addItem(new ItemStack(upgradeItem)).isEmpty(); + } } diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/wirelesstransmitter/WirelessTransmitterBlockEntity.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/wirelesstransmitter/WirelessTransmitterBlockEntity.java index 72ab2a1d1..873ff63f1 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/wirelesstransmitter/WirelessTransmitterBlockEntity.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/wirelesstransmitter/WirelessTransmitterBlockEntity.java @@ -8,30 +8,35 @@ import com.refinedmods.refinedstorage.platform.common.content.BlockEntities; import com.refinedmods.refinedstorage.platform.common.content.ContentNames; import com.refinedmods.refinedstorage.platform.common.support.AbstractDirectionalBlock; +import com.refinedmods.refinedstorage.platform.common.support.BlockEntityWithDrops; import com.refinedmods.refinedstorage.platform.common.support.containermenu.NetworkNodeExtendedMenuProvider; import com.refinedmods.refinedstorage.platform.common.support.network.AbstractRedstoneModeNetworkNodeContainerBlockEntity; import com.refinedmods.refinedstorage.platform.common.upgrade.UpgradeContainer; import com.refinedmods.refinedstorage.platform.common.upgrade.UpgradeDestinations; +import com.refinedmods.refinedstorage.platform.common.util.ContainerUtil; +import java.util.List; import javax.annotation.Nullable; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.HolderLookup; +import net.minecraft.core.NonNullList; import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; 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.AbstractContainerMenu; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.state.BlockState; public class WirelessTransmitterBlockEntity extends AbstractRedstoneModeNetworkNodeContainerBlockEntity - implements NetworkNodeExtendedMenuProvider { - private static final String TAG_UPGRADES = "u"; + implements NetworkNodeExtendedMenuProvider, BlockEntityWithDrops { + private static final String TAG_UPGRADES = "upgr"; private final UpgradeContainer upgradeContainer = new UpgradeContainer( UpgradeDestinations.WIRELESS_TRANSMITTER, @@ -53,18 +58,27 @@ protected InWorldNetworkNodeContainer createMainContainer(final SimpleNetworkNod @Override public void saveAdditional(final CompoundTag tag, final HolderLookup.Provider provider) { super.saveAdditional(tag, provider); - tag.put(TAG_UPGRADES, upgradeContainer.createTag(provider)); + tag.put(TAG_UPGRADES, ContainerUtil.write(upgradeContainer, provider)); } @Override public void loadAdditional(final CompoundTag tag, final HolderLookup.Provider provider) { if (tag.contains(TAG_UPGRADES)) { - upgradeContainer.fromTag(tag.getList(TAG_UPGRADES, Tag.TAG_COMPOUND), provider); + ContainerUtil.read(tag.getCompound(TAG_UPGRADES), upgradeContainer, provider); } - configureAccordingToUpgrades(); super.loadAdditional(tag, provider); } + @Override + public List getUpgradeItems() { + return upgradeContainer.getUpgradeItems(); + } + + @Override + public boolean addUpgradeItem(final Item upgradeItem) { + return upgradeContainer.addUpgradeItem(upgradeItem); + } + @Override public void addOutgoingConnections(final ConnectionSink sink) { final Direction myDirection = getDirection(); @@ -109,13 +123,18 @@ int getRange() { } private void upgradeContainerChanged() { + final long baseUsage = Platform.INSTANCE.getConfig().getWirelessTransmitter().getEnergyUsage(); + mainNode.setEnergyUsage(baseUsage + upgradeContainer.getEnergyUsage()); setChanged(); - configureAccordingToUpgrades(); } - private void configureAccordingToUpgrades() { - final long baseUsage = Platform.INSTANCE.getConfig().getWirelessTransmitter().getEnergyUsage(); - mainNode.setEnergyUsage(baseUsage + upgradeContainer.getEnergyUsage()); + @Override + public NonNullList getDrops() { + final NonNullList drops = NonNullList.create(); + for (int i = 0; i < upgradeContainer.getContainerSize(); ++i) { + drops.add(upgradeContainer.getItem(i)); + } + return drops; } @Override diff --git a/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/lang/en_us.json b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/lang/en_us.json index f08f87e3b..828ac42e9 100644 --- a/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/lang/en_us.json +++ b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/lang/en_us.json @@ -302,6 +302,7 @@ "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", "key.refinedstorage.open_wireless_grid": "Open Wireless Grid", + "key.refinedstorage.open_portable_grid": "Open Portable Grid", "refinedstorage.subtitle.wrench": "Wrench used", "permission.refinedstorage.insert": "Insert", "permission.refinedstorage.insert.description": "Whether the player can insert resources in a network.", diff --git a/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/lang/ru_ru.json b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/lang/ru_ru.json index 8cb4a0d60..0b3c8b15c 100644 --- a/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/lang/ru_ru.json +++ b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/lang/ru_ru.json @@ -2,7 +2,7 @@ "mod.refinedstorage": "Refined Storage", "block.refinedstorage.cable": "Кабель", "block.refinedstorage.quartz_enriched_iron_block": "Блок обогащённого кварцем железа", - "block.refinedstorage.quartz_enriched_copper_block": "Block of Quartz Enriched Copper", + "block.refinedstorage.quartz_enriched_copper_block": "Блок обогащённой кварцем меди", "block.refinedstorage.disk_drive": "Дисковый привод", "block.refinedstorage.machine_casing": "Корпус механизма", "block.refinedstorage.grid": "Терминал", @@ -34,13 +34,13 @@ "block.refinedstorage.creative_portable_grid": "Творческий переносной терминал", "block.refinedstorage.security_manager": "Диспетчер безопасности", "block.refinedstorage.security_manager.help": "Когда это устройство активно, оно по умолчанию защищает сеть и блокирует все операции. Начните добавлять карты безопасности, чтобы разрешить или запретить определённые операции для игрока.", - "block.refinedstorage.relay": "Relay", - "block.refinedstorage.disk_interface": "Disk Interface", - "gui.refinedstorage.controller.redstone_mode_help": "When this device is inactive, the storage network will not be able to use this device as an energy source.", + "block.refinedstorage.relay": "Реле", + "block.refinedstorage.disk_interface": "Интерфейс диска", + "gui.refinedstorage.controller.redstone_mode_help": "Когда это устройство неактивно, сеть хранения не сможет использовать это устройство в качестве источника энергии.", "gui.refinedstorage.disk_drive.disks": "Диски", - "gui.refinedstorage.storage.redstone_mode_help": "When this device is inactive, the contained storage will no longer be accessible from within the storage network.", - "gui.refinedstorage.storage.filter_help": "The resources that may or may not be allowed in this storage, depending if the device is in allowlist or blocklist mode.", - "gui.refinedstorage.storage.filter_mode.empty_warning": "Without any configured filters, no resources will be accepted in this storage.", + "gui.refinedstorage.storage.redstone_mode_help": "Когда это устройство неактивно, автономное хранилище больше не будет доступно из сети хранения данных.", + "gui.refinedstorage.storage.filter_help": "Ресурсы, которые могут быть разрешены или не разрешены в этом хранилище, зависят от того, находится ли устройство в режиме списка разрешений или списка блокировок.", + "gui.refinedstorage.storage.filter_mode.empty_warning": "Без каких-либо настроенных фильтров ресурсы не будут приниматься в этом хранилище.", "gui.refinedstorage.storage.filter_mode.allow.help": "Only allow resources into this storage that are configured in the filters.", "gui.refinedstorage.storage.filter_mode.block.help": "Disallow resources into this storage that are configured in the filters.", "gui.refinedstorage.grid.sorting.direction": "Порядок сортировки", @@ -50,29 +50,29 @@ "gui.refinedstorage.grid.sorting.type.quantity": "Кол-во", "gui.refinedstorage.grid.sorting.type.name": "Название", "gui.refinedstorage.grid.sorting.type.id": "Идентификатор", - "gui.refinedstorage.grid.sorting.type.last_modified": "Last modified", + "gui.refinedstorage.grid.sorting.type.last_modified": "Последнее изменение", "gui.refinedstorage.grid.auto_selected": "Auto-selected", "gui.refinedstorage.grid.auto_selected.help": "Whether to auto-select the search box when opening the Grid.", "gui.refinedstorage.grid.synchronizer": "Режим синхронизации", "gui.refinedstorage.grid.synchronizer.off": "Выкл.", "gui.refinedstorage.grid.synchronizer.off.help": "Don't sync the search box text.", "gui.refinedstorage.grid.resource_type": "Resource type", - "gui.refinedstorage.grid.resource_type.all": "All", - "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.screen_size": "Screen size", - "gui.refinedstorage.screen_size.stretch": "Stretch", - "gui.refinedstorage.screen_size.small": "Small", - "gui.refinedstorage.screen_size.medium": "Medium", - "gui.refinedstorage.screen_size.large": "Large", - "gui.refinedstorage.screen_size.extra_large": "Extra large", + "gui.refinedstorage.grid.resource_type.all": "Все", + "gui.refinedstorage.grid.resource_type.help": "Фильтр конкретных типов ресурсов.", + "gui.refinedstorage.crafting_grid.move.network": "Переместить предметы в сеть", + "gui.refinedstorage.crafting_grid.move.inventory": "Переместить предметы в инвентарь", + "gui.refinedstorage.screen_size": "Размер экрана", + "gui.refinedstorage.screen_size.stretch": "Растянуть", + "gui.refinedstorage.screen_size.small": "Маленький", + "gui.refinedstorage.screen_size.medium": "Средний", + "gui.refinedstorage.screen_size.large": "Большой", + "gui.refinedstorage.screen_size.extra_large": "Очень большой", "gui.refinedstorage.detector.mode": "Режим", - "gui.refinedstorage.detector.mode.under": "Emit redstone signal when under the amount", - "gui.refinedstorage.detector.mode.equal": "Emit redstone signal when on the amount", - "gui.refinedstorage.detector.mode.above": "Emit redstone signal when above the amount", - "gui.refinedstorage.detector.filter_help": "The resource that should be detected in the storage network.", - "gui.refinedstorage.destructor.pickup_items": "Pickup items instead of breaking", + "gui.refinedstorage.detector.mode.under": "Выдать сигнал красного камня при меньшем количестве", + "gui.refinedstorage.detector.mode.equal": "Выдать сигнал красного камня при количестве", + "gui.refinedstorage.detector.mode.above": "Выдать сигнал красного камня при большем количестве", + "gui.refinedstorage.detector.filter_help": "Ресурс, который должен быть обнаружен в сети.", + "gui.refinedstorage.destructor.pickup_items": "Подбирать предметы вместо разрушения", "gui.refinedstorage.destructor.filter_help": "The blocks that may or may not be destroyed, depending if the device is in allowlist or blocklist mode.", "gui.refinedstorage.destructor.filter_mode.allow.help": "Only allow blocks into the storage network that are configured in the filters.", "gui.refinedstorage.destructor.filter_mode.block.help": "Disallow blocks into the storage network that are configured in the filters.", @@ -85,9 +85,9 @@ "gui.refinedstorage.importer.filter_mode.block.help": "Disallow resources into the storage network that are configured in the filters.", "gui.refinedstorage.wireless_transmitter.distance": "%d block(s)", "gui.refinedstorage.storage_monitor.filter_help": "The resource to display.", - "gui.refinedstorage.redstone_mode": "Redstone mode", - "gui.refinedstorage.redstone_mode.ignore": "Ignore", - "gui.refinedstorage.redstone_mode.ignore.help": "This device will always be active, regardless of redstone signal.", + "gui.refinedstorage.redstone_mode": "Режим красного камня", + "gui.refinedstorage.redstone_mode.ignore": "Игнорировать", + "gui.refinedstorage.redstone_mode.ignore.help": "Это устройство всегда будет активным, независимо от редстоун-сигнала.", "gui.refinedstorage.redstone_mode.high": "High", "gui.refinedstorage.redstone_mode.high.help": "This device will only be active with a redstone signal.", "gui.refinedstorage.redstone_mode.low": "Low", diff --git a/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/.gitignore b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/.gitignore new file mode 100644 index 000000000..2664d9bf9 --- /dev/null +++ b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/.gitignore @@ -0,0 +1 @@ +!out/ \ No newline at end of file diff --git a/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/black.png b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/black.png new file mode 100644 index 000000000..58f7b9244 Binary files /dev/null and b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/black.png differ diff --git a/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/blue.png b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/blue.png new file mode 100644 index 000000000..00d6eb6f0 Binary files /dev/null and b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/blue.png differ diff --git a/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/brown.png b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/brown.png new file mode 100644 index 000000000..63204a3af Binary files /dev/null and b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/brown.png differ diff --git a/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/cyan.png b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/cyan.png new file mode 100644 index 000000000..dc7165708 Binary files /dev/null and b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/cyan.png differ diff --git a/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/gray.png b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/gray.png new file mode 100644 index 000000000..f529f259e Binary files /dev/null and b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/gray.png differ diff --git a/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/green.png b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/green.png new file mode 100644 index 000000000..77523987d Binary files /dev/null and b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/green.png differ diff --git a/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/inactive.png b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/inactive.png new file mode 100644 index 000000000..b5bc63f8f Binary files /dev/null and b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/inactive.png differ diff --git a/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/light_blue.png b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/light_blue.png new file mode 100644 index 000000000..a6b017a44 Binary files /dev/null and b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/light_blue.png differ diff --git a/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/light_gray.png b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/light_gray.png new file mode 100644 index 000000000..fca72ba2e Binary files /dev/null and b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/light_gray.png differ diff --git a/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/lime.png b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/lime.png new file mode 100644 index 000000000..d2dc60135 Binary files /dev/null and b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/lime.png differ diff --git a/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/magenta.png b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/magenta.png new file mode 100644 index 000000000..039d61ef9 Binary files /dev/null and b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/magenta.png differ diff --git a/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/orange.png b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/orange.png new file mode 100644 index 000000000..7389d27e3 Binary files /dev/null and b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/orange.png differ diff --git a/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/pink.png b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/pink.png new file mode 100644 index 000000000..7991ef0d9 Binary files /dev/null and b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/pink.png differ diff --git a/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/purple.png b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/purple.png new file mode 100644 index 000000000..204cbc55c Binary files /dev/null and b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/purple.png differ diff --git a/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/red.png b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/red.png new file mode 100644 index 000000000..d4b83ce38 Binary files /dev/null and b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/red.png differ diff --git a/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/white.png b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/white.png new file mode 100644 index 000000000..ddbc7f2dd Binary files /dev/null and b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/white.png differ diff --git a/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/yellow.png b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/yellow.png new file mode 100644 index 000000000..b6fcecf4b Binary files /dev/null and b/refinedstorage-platform-common/src/main/resources/assets/refinedstorage/textures/block/relay/cutouts/out/yellow.png differ diff --git a/refinedstorage-platform-fabric/.gitignore b/refinedstorage-platform-fabric/.gitignore deleted file mode 100644 index 737e26b00..000000000 --- a/refinedstorage-platform-fabric/.gitignore +++ /dev/null @@ -1 +0,0 @@ -run/ \ No newline at end of file diff --git a/refinedstorage-platform-fabric/src/main/java/com/refinedmods/refinedstorage/platform/fabric/ClientModInitializerImpl.java b/refinedstorage-platform-fabric/src/main/java/com/refinedmods/refinedstorage/platform/fabric/ClientModInitializerImpl.java index e393957b5..e8d34a1b1 100644 --- a/refinedstorage-platform-fabric/src/main/java/com/refinedmods/refinedstorage/platform/fabric/ClientModInitializerImpl.java +++ b/refinedstorage-platform-fabric/src/main/java/com/refinedmods/refinedstorage/platform/fabric/ClientModInitializerImpl.java @@ -69,7 +69,6 @@ import org.lwjgl.glfw.GLFW; import static com.refinedmods.refinedstorage.platform.common.util.IdentifierUtil.createIdentifier; -import static com.refinedmods.refinedstorage.platform.common.util.IdentifierUtil.createTranslationKey; public class ClientModInitializerImpl extends AbstractClientModInitializer implements ClientModInitializer { private static final String BLOCK_PREFIX = "block"; @@ -393,13 +392,19 @@ private CompositeClientTooltipComponent createRegulatorUpgradeClientTooltipCompo private void registerKeyBindings() { KeyMappings.INSTANCE.setFocusSearchBar(KeyBindingHelper.registerKeyBinding(new KeyMapping( - createTranslationKey("key", "focus_search_bar"), + ContentNames.FOCUS_SEARCH_BAR_TRANSLATION_KEY, InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_TAB, ContentNames.MOD_TRANSLATION_KEY ))); KeyMappings.INSTANCE.setOpenWirelessGrid(KeyBindingHelper.registerKeyBinding(new KeyMapping( - createTranslationKey("key", "open_wireless_grid"), + ContentNames.OPEN_WIRELESS_GRID_TRANSLATION_KEY, + InputConstants.Type.KEYSYM, + InputConstants.UNKNOWN.getValue(), + ContentNames.MOD_TRANSLATION_KEY + ))); + KeyMappings.INSTANCE.setOpenPortableGrid(KeyBindingHelper.registerKeyBinding(new KeyMapping( + ContentNames.OPEN_PORTABLE_GRID_TRANSLATION_KEY, InputConstants.Type.KEYSYM, InputConstants.UNKNOWN.getValue(), ContentNames.MOD_TRANSLATION_KEY diff --git a/refinedstorage-platform-fabric/src/main/java/com/refinedmods/refinedstorage/platform/fabric/ModInitializerImpl.java b/refinedstorage-platform-fabric/src/main/java/com/refinedmods/refinedstorage/platform/fabric/ModInitializerImpl.java index 640f5c6b8..fb864b9a3 100644 --- a/refinedstorage-platform-fabric/src/main/java/com/refinedmods/refinedstorage/platform/fabric/ModInitializerImpl.java +++ b/refinedstorage-platform-fabric/src/main/java/com/refinedmods/refinedstorage/platform/fabric/ModInitializerImpl.java @@ -39,7 +39,7 @@ import com.refinedmods.refinedstorage.platform.common.support.packet.c2s.SecurityCardResetPermissionPacket; import com.refinedmods.refinedstorage.platform.common.support.packet.c2s.SingleAmountChangePacket; import com.refinedmods.refinedstorage.platform.common.support.packet.c2s.StorageInfoRequestPacket; -import com.refinedmods.refinedstorage.platform.common.support.packet.c2s.UseNetworkBoundItemPacket; +import com.refinedmods.refinedstorage.platform.common.support.packet.c2s.UseSlotReferencedItemPacket; import com.refinedmods.refinedstorage.platform.common.support.packet.s2c.EnergyInfoPacket; import com.refinedmods.refinedstorage.platform.common.support.packet.s2c.GridActivePacket; import com.refinedmods.refinedstorage.platform.common.support.packet.s2c.GridClearPacket; @@ -447,8 +447,8 @@ private void registerClientToServerPackets() { StorageInfoRequestPacket.STREAM_CODEC ); PayloadTypeRegistry.playC2S().register( - UseNetworkBoundItemPacket.PACKET_TYPE, - UseNetworkBoundItemPacket.STREAM_CODEC + UseSlotReferencedItemPacket.PACKET_TYPE, + UseSlotReferencedItemPacket.STREAM_CODEC ); } @@ -498,8 +498,8 @@ private void registerPacketHandlers() { wrapHandler(SingleAmountChangePacket::handle) ); ServerPlayNetworking.registerGlobalReceiver( - UseNetworkBoundItemPacket.PACKET_TYPE, - wrapHandler(UseNetworkBoundItemPacket::handle) + UseSlotReferencedItemPacket.PACKET_TYPE, + wrapHandler(UseSlotReferencedItemPacket::handle) ); ServerPlayNetworking.registerGlobalReceiver( SecurityCardPermissionPacket.PACKET_TYPE, diff --git a/refinedstorage-platform-neoforge/.gitignore b/refinedstorage-platform-neoforge/.gitignore deleted file mode 100644 index 737e26b00..000000000 --- a/refinedstorage-platform-neoforge/.gitignore +++ /dev/null @@ -1 +0,0 @@ -run/ \ No newline at end of file diff --git a/refinedstorage-platform-neoforge/src/main/java/com/refinedmods/refinedstorage/platform/neoforge/ClientModInitializer.java b/refinedstorage-platform-neoforge/src/main/java/com/refinedmods/refinedstorage/platform/neoforge/ClientModInitializer.java index 08f60497a..8ddc97359 100644 --- a/refinedstorage-platform-neoforge/src/main/java/com/refinedmods/refinedstorage/platform/neoforge/ClientModInitializer.java +++ b/refinedstorage-platform-neoforge/src/main/java/com/refinedmods/refinedstorage/platform/neoforge/ClientModInitializer.java @@ -53,7 +53,6 @@ import static com.refinedmods.refinedstorage.platform.common.content.ContentIds.DISK_DRIVE; import static com.refinedmods.refinedstorage.platform.common.content.ContentIds.PORTABLE_GRID; import static com.refinedmods.refinedstorage.platform.common.util.IdentifierUtil.createIdentifier; -import static com.refinedmods.refinedstorage.platform.common.util.IdentifierUtil.createTranslationKey; public final class ClientModInitializer extends AbstractClientModInitializer { private ClientModInitializer() { @@ -109,7 +108,7 @@ public > void @SubscribeEvent public static void onRegisterKeyMappings(final RegisterKeyMappingsEvent e) { final KeyMapping focusSearchBarKeyBinding = new KeyMapping( - createTranslationKey("key", "focus_search_bar"), + ContentNames.FOCUS_SEARCH_BAR_TRANSLATION_KEY, InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_TAB, ContentNames.MOD_TRANSLATION_KEY @@ -118,7 +117,7 @@ public static void onRegisterKeyMappings(final RegisterKeyMappingsEvent e) { KeyMappings.INSTANCE.setFocusSearchBar(focusSearchBarKeyBinding); final KeyMapping clearCraftingGridMatrixToNetwork = new KeyMapping( - createTranslationKey("key", "clear_crafting_grid_matrix_to_network"), + ContentNames.CLEAR_CRAFTING_MATRIX_TO_NETWORK_TRANSLATION_KEY, KeyConflictContext.GUI, KeyModifier.CONTROL, InputConstants.Type.KEYSYM, @@ -129,7 +128,7 @@ public static void onRegisterKeyMappings(final RegisterKeyMappingsEvent e) { KeyMappings.INSTANCE.setClearCraftingGridMatrixToNetwork(clearCraftingGridMatrixToNetwork); final KeyMapping clearCraftingGridMatrixToInventory = new KeyMapping( - createTranslationKey("key", "clear_crafting_grid_matrix_to_inventory"), + ContentNames.CLEAR_CRAFTING_MATRIX_TO_INVENTORY_TRANSLATION_KEY, InputConstants.UNKNOWN.getValue(), ContentNames.MOD_TRANSLATION_KEY ); @@ -137,13 +136,22 @@ public static void onRegisterKeyMappings(final RegisterKeyMappingsEvent e) { KeyMappings.INSTANCE.setClearCraftingGridMatrixToInventory(clearCraftingGridMatrixToInventory); final KeyMapping openWirelessGrid = new KeyMapping( - createTranslationKey("key", "open_wireless_grid"), + ContentNames.OPEN_WIRELESS_GRID_TRANSLATION_KEY, KeyConflictContext.IN_GAME, InputConstants.UNKNOWN, ContentNames.MOD_TRANSLATION_KEY ); e.register(openWirelessGrid); KeyMappings.INSTANCE.setOpenWirelessGrid(openWirelessGrid); + + final KeyMapping openPortableGrid = new KeyMapping( + ContentNames.OPEN_PORTABLE_GRID_TRANSLATION_KEY, + KeyConflictContext.IN_GAME, + InputConstants.UNKNOWN, + ContentNames.MOD_TRANSLATION_KEY + ); + e.register(openPortableGrid); + KeyMappings.INSTANCE.setOpenPortableGrid(openPortableGrid); } private static void registerBlockEntityRenderer() { diff --git a/refinedstorage-platform-neoforge/src/main/java/com/refinedmods/refinedstorage/platform/neoforge/ModInitializer.java b/refinedstorage-platform-neoforge/src/main/java/com/refinedmods/refinedstorage/platform/neoforge/ModInitializer.java index ee6a5f8b2..97d07acf3 100644 --- a/refinedstorage-platform-neoforge/src/main/java/com/refinedmods/refinedstorage/platform/neoforge/ModInitializer.java +++ b/refinedstorage-platform-neoforge/src/main/java/com/refinedmods/refinedstorage/platform/neoforge/ModInitializer.java @@ -29,6 +29,7 @@ import com.refinedmods.refinedstorage.platform.common.support.packet.c2s.GridInsertPacket; import com.refinedmods.refinedstorage.platform.common.support.packet.c2s.GridScrollPacket; import com.refinedmods.refinedstorage.platform.common.support.packet.c2s.PropertyChangePacket; +import com.refinedmods.refinedstorage.platform.common.support.packet.c2s.ResourceFilterSlotChangePacket; import com.refinedmods.refinedstorage.platform.common.support.packet.c2s.ResourceSlotAmountChangePacket; import com.refinedmods.refinedstorage.platform.common.support.packet.c2s.ResourceSlotChangePacket; import com.refinedmods.refinedstorage.platform.common.support.packet.c2s.SecurityCardBoundPlayerPacket; @@ -36,7 +37,7 @@ import com.refinedmods.refinedstorage.platform.common.support.packet.c2s.SecurityCardResetPermissionPacket; import com.refinedmods.refinedstorage.platform.common.support.packet.c2s.SingleAmountChangePacket; import com.refinedmods.refinedstorage.platform.common.support.packet.c2s.StorageInfoRequestPacket; -import com.refinedmods.refinedstorage.platform.common.support.packet.c2s.UseNetworkBoundItemPacket; +import com.refinedmods.refinedstorage.platform.common.support.packet.c2s.UseSlotReferencedItemPacket; import com.refinedmods.refinedstorage.platform.common.support.packet.s2c.EnergyInfoPacket; import com.refinedmods.refinedstorage.platform.common.support.packet.s2c.GridActivePacket; import com.refinedmods.refinedstorage.platform.common.support.packet.s2c.GridClearPacket; @@ -573,6 +574,11 @@ private static void registerClientToServerPackets(final PayloadRegistrar registr PropertyChangePacket.STREAM_CODEC, wrapHandler(PropertyChangePacket::handle) ); + registrar.playToServer( + ResourceFilterSlotChangePacket.PACKET_TYPE, + ResourceFilterSlotChangePacket.STREAM_CODEC, + wrapHandler(ResourceFilterSlotChangePacket::handle) + ); registrar.playToServer( ResourceSlotAmountChangePacket.PACKET_TYPE, ResourceSlotAmountChangePacket.STREAM_CODEC, @@ -594,9 +600,9 @@ private static void registerClientToServerPackets(final PayloadRegistrar registr wrapHandler(StorageInfoRequestPacket::handle) ); registrar.playToServer( - UseNetworkBoundItemPacket.PACKET_TYPE, - UseNetworkBoundItemPacket.STREAM_CODEC, - wrapHandler(UseNetworkBoundItemPacket::handle) + UseSlotReferencedItemPacket.PACKET_TYPE, + UseSlotReferencedItemPacket.STREAM_CODEC, + wrapHandler(UseSlotReferencedItemPacket::handle) ); registrar.playToServer( SecurityCardPermissionPacket.PACKET_TYPE,