From a60e8e999b8bbd0ea6c8f4fa5bef380a19272ebd Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Thu, 4 Apr 2024 16:36:47 +0200 Subject: [PATCH] fix: slight desync when transferring fallback card --- .../platform/common/AbstractModInitializer.java | 7 +++---- .../security/SecurityManagerContainerMenu.java | 13 +++++++------ .../common/support/NetworkNodeBlockItem.java | 2 -- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/AbstractModInitializer.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/AbstractModInitializer.java index 4d6966ae8..a346ee107 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/AbstractModInitializer.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/AbstractModInitializer.java @@ -734,10 +734,9 @@ protected final void registerMenus(final RegistryCallback> callback, FALLBACK_SECURITY_CARD, () -> menuTypeFactory.create(FallbackSecurityCardContainerMenu::new) )); - Menus.INSTANCE.setSecurityManager(callback.register( - SECURITY_MANAGER, - () -> menuTypeFactory.create(SecurityManagerContainerMenu::new) - )); + Menus.INSTANCE.setSecurityManager(callback.register(SECURITY_MANAGER, () -> menuTypeFactory.create( + (syncId, playerInventory, buf) -> new SecurityManagerContainerMenu(syncId, playerInventory) + ))); } protected final void registerLootFunctions(final RegistryCallback callback) { diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/security/SecurityManagerContainerMenu.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/security/SecurityManagerContainerMenu.java index 6fb7bf048..78ece2d4e 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/security/SecurityManagerContainerMenu.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/security/SecurityManagerContainerMenu.java @@ -3,6 +3,7 @@ import com.refinedmods.refinedstorage2.platform.common.content.Menus; import com.refinedmods.refinedstorage2.platform.common.support.AbstractBaseContainerMenu; import com.refinedmods.refinedstorage2.platform.common.support.RedstoneMode; +import com.refinedmods.refinedstorage2.platform.common.support.SimpleFilteredContainer; import com.refinedmods.refinedstorage2.platform.common.support.containermenu.ClientProperty; import com.refinedmods.refinedstorage2.platform.common.support.containermenu.PropertyTypes; import com.refinedmods.refinedstorage2.platform.common.support.containermenu.ServerProperty; @@ -10,9 +11,7 @@ import javax.annotation.Nullable; -import net.minecraft.network.FriendlyByteBuf; import net.minecraft.world.Container; -import net.minecraft.world.SimpleContainer; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.inventory.Slot; @@ -22,11 +21,13 @@ public class SecurityManagerContainerMenu extends AbstractBaseContainerMenu { @Nullable private Slot fallbackSecurityCardSlot; - public SecurityManagerContainerMenu(final int syncId, - final Inventory playerInventory, - final FriendlyByteBuf buf) { + public SecurityManagerContainerMenu(final int syncId, final Inventory playerInventory) { super(Menus.INSTANCE.getSecurityManager(), syncId); - addSlots(playerInventory, new SimpleContainer(CARD_AMOUNT), new SimpleContainer(1)); + addSlots( + playerInventory, + new SimpleFilteredContainer(CARD_AMOUNT, SecurityManagerBlockEntity::isValidSecurityCard), + new SimpleFilteredContainer(1, SecurityManagerBlockEntity::isValidFallbackSecurityCard) + ); registerProperty(new ClientProperty<>(PropertyTypes.REDSTONE_MODE, RedstoneMode.IGNORE)); } diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/support/NetworkNodeBlockItem.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/support/NetworkNodeBlockItem.java index eca931d13..1139dea97 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/support/NetworkNodeBlockItem.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/support/NetworkNodeBlockItem.java @@ -10,9 +10,7 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; -// TODO: fix slot shuffle security manager w/ fallback // TODO: sonar fixes -// TODO: server test before release public class NetworkNodeBlockItem extends BaseBlockItem { public NetworkNodeBlockItem(final Block block) { super(block);