Add blacklist item tag (#scout:blacklist) (fixes GH-5)

This commit is contained in:
Cynthia Foxwell 2024-03-25 13:05:04 -06:00
parent 54aabf557c
commit e622b3d9bb
2 changed files with 12 additions and 1 deletions

View file

@ -3,11 +3,15 @@ package pm.c7.scout;
import dev.emi.trinkets.api.SlotReference; import dev.emi.trinkets.api.SlotReference;
import dev.emi.trinkets.api.TrinketComponent; import dev.emi.trinkets.api.TrinketComponent;
import dev.emi.trinkets.api.TrinketsApi; import dev.emi.trinkets.api.TrinketsApi;
import net.minecraft.block.Block;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventory; import net.minecraft.inventory.Inventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtList; import net.minecraft.nbt.NbtList;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.screen.PlayerScreenHandler; import net.minecraft.screen.PlayerScreenHandler;
import net.minecraft.screen.slot.Slot; import net.minecraft.screen.slot.Slot;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
@ -25,7 +29,9 @@ import java.util.Optional;
public class ScoutUtil { public class ScoutUtil {
public static final Logger LOGGER = LoggerFactory.getLogger("Scout"); public static final Logger LOGGER = LoggerFactory.getLogger("Scout");
public static final String MOD_ID = "scout"; public static final String MOD_ID = "scout";
public static final Identifier SLOT_TEXTURE = new Identifier("scout", "textures/gui/slots.png"); public static final Identifier SLOT_TEXTURE = new Identifier(MOD_ID, "textures/gui/slots.png");
public static final TagKey<Item> TAG_ITEM_BLACKLIST = TagKey.of(RegistryKeys.ITEM, new Identifier(MOD_ID, "blacklist"));
public static final int MAX_SATCHEL_SLOTS = 18; public static final int MAX_SATCHEL_SLOTS = 18;
public static final int MAX_POUCH_SLOTS = 6; public static final int MAX_POUCH_SLOTS = 6;

View file

@ -6,6 +6,7 @@ import net.minecraft.inventory.Inventory;
import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.screen.slot.Slot; import net.minecraft.screen.slot.Slot;
import pm.c7.scout.ScoutUtil;
import pm.c7.scout.config.ScoutConfig; import pm.c7.scout.config.ScoutConfig;
import pm.c7.scout.item.BaseBagItem; import pm.c7.scout.item.BaseBagItem;
@ -36,6 +37,10 @@ public class BagSlot extends Slot {
if (stack.getItem() instanceof BaseBagItem) if (stack.getItem() instanceof BaseBagItem)
return false; return false;
if (stack.isIn(ScoutUtil.TAG_ITEM_BLACKLIST)) {
return false;
}
if (stack.getItem() instanceof BlockItem blockItem) { if (stack.getItem() instanceof BlockItem blockItem) {
if (blockItem.getBlock() instanceof ShulkerBoxBlock) if (blockItem.getBlock() instanceof ShulkerBoxBlock)
return enabled && inventory != null && ScoutConfig.allowShulkers; return enabled && inventory != null && ScoutConfig.allowShulkers;