Skip to content

Commit

Permalink
fix empty filters in whitelist matching anything even tho they should…
Browse files Browse the repository at this point in the history
…n't (see #239)
  • Loading branch information
Mari023 committed Jan 20, 2024
1 parent b965704 commit 7765f04
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/de/mari_023/ae2wtlib/AE2wtlibEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.neoforged.neoforge.network.PacketDistributor;

import appeng.api.config.Actionable;
import appeng.api.config.IncludeExclude;
import appeng.api.stacks.AEItemKey;
import appeng.me.helpers.PlayerSource;

Expand Down Expand Up @@ -78,6 +79,10 @@ public static boolean insertStackInME(ItemStack stack, Player player) {
MagnetHost magnetHost = cTHandler.getMagnetHost();
if (magnetHost == null)
return false;

// if the filter is empty, it will match anything, even in whitelist mode
if (magnetHost.getInsertFilter().isEmpty() && magnetHost.getInsertMode() == IncludeExclude.WHITELIST)
return false;
if (!magnetHost.getInsertFilter().matchesFilter(AEItemKey.of(stack), magnetHost.getInsertMode()))
return false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.world.item.ItemStack;
import net.neoforged.neoforge.network.PacketDistributor;

import appeng.api.config.IncludeExclude;
import appeng.api.stacks.AEItemKey;
import appeng.api.stacks.KeyCounter;
import appeng.api.upgrades.IUpgradeableItem;
Expand Down Expand Up @@ -90,6 +91,10 @@ private static void handleMagnet(Player player) {
if (magnetHost == null)
return;

// if the filter is empty, it will match anything, even in whitelist mode
if (magnetHost.getPickupFilter().isEmpty() && magnetHost.getPickupMode() == IncludeExclude.WHITELIST)
return;

List<ItemEntity> entityItems = player.level().getEntitiesOfClass(ItemEntity.class,
player.getBoundingBox().inflate(AE2wtlibConfig.CONFIG.magnetCardRange()),
EntitySelector.ENTITY_STILL_ALIVE);
Expand Down

0 comments on commit 7765f04

Please sign in to comment.