Skip to content

Commit

Permalink
fix: slight desync when transferring fallback card
Browse files Browse the repository at this point in the history
  • Loading branch information
raoulvdberge committed Apr 4, 2024
1 parent 295ec2f commit a60e8e9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -734,10 +734,9 @@ protected final void registerMenus(final RegistryCallback<MenuType<?>> 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<LootItemFunctionType> callback) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
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;
import com.refinedmods.refinedstorage2.platform.common.support.containermenu.ValidatedSlot;

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;

Expand All @@ -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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a60e8e9

Please sign in to comment.