Added Item Tag, to filter by a item tag.

This commit is contained in:
Flanks255 2024-04-02 18:46:52 -05:00
parent 52b5765a41
commit 6f56772560
21 changed files with 358 additions and 5 deletions

View file

@ -1,4 +1,4 @@
// 1.20.4 2024-03-16T12:15:55.7079887 Item Recipes // 1.20.4 2024-04-02T18:39:06.8390218 Item Recipes
d374edde9294d1a224b4b5610b50117a11328c00 data/actuallyadditions/recipes/advanced_coil.json d374edde9294d1a224b4b5610b50117a11328c00 data/actuallyadditions/recipes/advanced_coil.json
f67629e45d152c96f3467a90a67520f78ecf9f07 data/actuallyadditions/recipes/advanced_leaf_blower.json f67629e45d152c96f3467a90a67520f78ecf9f07 data/actuallyadditions/recipes/advanced_leaf_blower.json
d65e5a70232fa2f0e74d2a67c1cd4b0e87124242 data/actuallyadditions/recipes/basic_coil.json d65e5a70232fa2f0e74d2a67c1cd4b0e87124242 data/actuallyadditions/recipes/basic_coil.json
@ -84,6 +84,7 @@ ffa7a52a39d9261b9c90c62709183a1f2d8f8352 data/actuallyadditions/recipes/drill_up
811730c9a8496dd65e208a36d015b0671e86df1b data/actuallyadditions/recipes/gold_aiot.json 811730c9a8496dd65e208a36d015b0671e86df1b data/actuallyadditions/recipes/gold_aiot.json
8b2ce2abfa8f78f7903c22347a54cdcf018d03eb data/actuallyadditions/recipes/handheld_filler.json 8b2ce2abfa8f78f7903c22347a54cdcf018d03eb data/actuallyadditions/recipes/handheld_filler.json
a4e0e3bb72d472302f2ab4e5d282cbc7fd6882a6 data/actuallyadditions/recipes/iron_aiot.json a4e0e3bb72d472302f2ab4e5d282cbc7fd6882a6 data/actuallyadditions/recipes/iron_aiot.json
a444be2b854569191ca5f539bcf2536851eba59a data/actuallyadditions/recipes/item_tag.json
5615f6ad2e28e9c105491acb965e763dfe8cacab data/actuallyadditions/recipes/laser_upgrade_invisibility.json 5615f6ad2e28e9c105491acb965e763dfe8cacab data/actuallyadditions/recipes/laser_upgrade_invisibility.json
38f744e92f1a5ff6a64e37cdfbb646422f741b3c data/actuallyadditions/recipes/laser_upgrade_range.json 38f744e92f1a5ff6a64e37cdfbb646422f741b3c data/actuallyadditions/recipes/laser_upgrade_range.json
0792f7ad8ae9bbe9e10951db70a41fc802a92f19 data/actuallyadditions/recipes/laser_wrench.json 0792f7ad8ae9bbe9e10951db70a41fc802a92f19 data/actuallyadditions/recipes/laser_wrench.json

View file

@ -1,4 +1,4 @@
// 1.20.4 2024-03-13T16:28:37.0564484 Item Models: actuallyadditions // 1.20.4 2024-03-17T15:47:34.5137353 Item Models: actuallyadditions
34463d3d2ae3fafaaea338e7ffc03cd139d3cfeb assets/actuallyadditions/models/item/advanced_coil.json 34463d3d2ae3fafaaea338e7ffc03cd139d3cfeb assets/actuallyadditions/models/item/advanced_coil.json
24594fc68e66011dc2d7b79b92c94b387e710318 assets/actuallyadditions/models/item/advanced_leaf_blower.json 24594fc68e66011dc2d7b79b92c94b387e710318 assets/actuallyadditions/models/item/advanced_leaf_blower.json
ba2d814e269cdef72e1045f200b3c20ed6961517 assets/actuallyadditions/models/item/atomic_reconstructor.json ba2d814e269cdef72e1045f200b3c20ed6961517 assets/actuallyadditions/models/item/atomic_reconstructor.json
@ -130,6 +130,7 @@ d058286787b169cd09245f2cae6606bfedeb4813 assets/actuallyadditions/models/item/he
f9f045a7713addffc4c419d1a3acdc9eac176065 assets/actuallyadditions/models/item/iron_aiot.json f9f045a7713addffc4c419d1a3acdc9eac176065 assets/actuallyadditions/models/item/iron_aiot.json
bd9be4f8d1235d6a418280c0a9a585c53360a99e assets/actuallyadditions/models/item/iron_casing.json bd9be4f8d1235d6a418280c0a9a585c53360a99e assets/actuallyadditions/models/item/iron_casing.json
4b742b7bf9df6b8f745ed00ac29860959ff6f076 assets/actuallyadditions/models/item/item_interface.json 4b742b7bf9df6b8f745ed00ac29860959ff6f076 assets/actuallyadditions/models/item/item_interface.json
9186aec3aa11a45a2b24103e84126c200f2ac5c2 assets/actuallyadditions/models/item/item_tag.json
a0545bce8530d20e0d87775144ed47f2df070219 assets/actuallyadditions/models/item/lamp_black.json a0545bce8530d20e0d87775144ed47f2df070219 assets/actuallyadditions/models/item/lamp_black.json
ddecd4c60d4d0f77175eaa0178f6397afd7ee98f assets/actuallyadditions/models/item/lamp_blue.json ddecd4c60d4d0f77175eaa0178f6397afd7ee98f assets/actuallyadditions/models/item/lamp_blue.json
53e733a0cf113affea99490724efd72ee28cf823 assets/actuallyadditions/models/item/lamp_brown.json 53e733a0cf113affea99490724efd72ee28cf823 assets/actuallyadditions/models/item/lamp_brown.json

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "minecraft:item/paper"
}
}

View file

@ -0,0 +1,15 @@
{
"type": "minecraft:crafting_shapeless",
"category": "misc",
"ingredients": [
{
"item": "minecraft:paper"
},
{
"item": "actuallyadditions:black_quartz"
}
],
"result": {
"item": "actuallyadditions:item_tag"
}
}

View file

@ -36,6 +36,8 @@ public class ItemModelGenerator extends ItemModelProvider {
ActuallyItems.SIMPLE_ITEMS.forEach(this::simpleItem); ActuallyItems.SIMPLE_ITEMS.forEach(this::simpleItem);
ActuallyItems.TOOLS.forEach(this::simpleTool); ActuallyItems.TOOLS.forEach(this::simpleTool);
singleTexture("item_tag", mcLoc("item/generated"), "layer0", mcLoc("item/paper"));
// Toolsets // Toolsets
/* ActuallyItems.ALL_TOOL_SETS.stream() /* ActuallyItems.ALL_TOOL_SETS.stream()
.map(ToolSet::getItemGroup) .map(ToolSet::getItemGroup)

View file

@ -517,6 +517,12 @@ public class ItemRecipeGenerator extends RecipeProvider {
.define('I', Items.IRON_HELMET) .define('I', Items.IRON_HELMET)
.save(recipeOutput); .save(recipeOutput);
// Item Tag
Recipe.shapeless(ActuallyItems.ITEM_TAG.get())
.requires(Items.PAPER)
.requires(ActuallyItems.BLACK_QUARTZ)
.save(recipeOutput);
// Sticky Piston from tagged slime balls // Sticky Piston from tagged slime balls
Recipe.shaped(Items.STICKY_PISTON) Recipe.shaped(Items.STICKY_PISTON)
.pattern("R", "P") .pattern("R", "P")

View file

@ -0,0 +1,20 @@
package de.ellpeck.actuallyadditions.mixin;
import de.ellpeck.actuallyadditions.mod.items.ItemTag;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AnvilMenu;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(AnvilMenu.class)
public class AnvilMixin{
@Inject(method = "mayPickup", at = @At("HEAD"), cancellable = true)
public void pickupMixin(Player pPlayer, boolean pHasStack, CallbackInfoReturnable<Boolean> cir) {
AnvilMenu anvilMenu = (AnvilMenu) (Object) this;
if (((ItemCombinerMenuAccessor)anvilMenu).getInputSlots().getItem(0).getItem() instanceof ItemTag) {
cir.setReturnValue(true);
}
}
}

View file

@ -0,0 +1,12 @@
package de.ellpeck.actuallyadditions.mixin;
import net.minecraft.world.Container;
import net.minecraft.world.inventory.ItemCombinerMenu;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(ItemCombinerMenu.class)
public interface ItemCombinerMenuAccessor {
@Accessor
Container getInputSlots();
}

View file

@ -66,6 +66,7 @@ public class ActuallyAdditionsClient {
evt.register(ActuallyContainers.PHANTOM_PLACER_CONTAINER.get(), GuiPhantomPlacer::new); evt.register(ActuallyContainers.PHANTOM_PLACER_CONTAINER.get(), GuiPhantomPlacer::new);
evt.register(ActuallyContainers.RANGED_COLLECTOR_CONTAINER.get(), GuiRangedCollector::new); evt.register(ActuallyContainers.RANGED_COLLECTOR_CONTAINER.get(), GuiRangedCollector::new);
evt.register(ActuallyContainers.XPSOLIDIFIER_CONTAINER.get(), GuiXPSolidifier::new); evt.register(ActuallyContainers.XPSOLIDIFIER_CONTAINER.get(), GuiXPSolidifier::new);
evt.register(ActuallyContainers.ITEM_TAG_CONTAINER.get(), ItemTagScreen::new);
} }
public static void setup(FMLClientSetupEvent event) { public static void setup(FMLClientSetupEvent event) {

View file

@ -17,6 +17,9 @@ public class ActuallyAttachments {
public static final Supplier<AttachmentType<CustomEnergyStorage>> ENERGY_STORAGE = ATTACHMENT_TYPES.register( public static final Supplier<AttachmentType<CustomEnergyStorage>> ENERGY_STORAGE = ATTACHMENT_TYPES.register(
"energy", ActuallyAttachments.itemEnergyStorageAttachment()); "energy", ActuallyAttachments.itemEnergyStorageAttachment());
public static final Supplier<AttachmentType<ItemTagAttachment>> ITEM_TAG = ATTACHMENT_TYPES.register(
"item_tag", () -> AttachmentType.serializable(ItemTagAttachment::new).build());
/* /*
* This is a supplier for an attachment type that can be used to attach an energy storage to an item. * This is a supplier for an attachment type that can be used to attach an energy storage to an item.
* Implementation is based on EnderIO's https://github.com/Team-EnderIO/EnderIO/blob/e1f022df745131ed5fea718bd860880a5785d4c7/src/core/java/com/enderio/core/common/attachment/AttachmentUtil.java#L47-L60 * Implementation is based on EnderIO's https://github.com/Team-EnderIO/EnderIO/blob/e1f022df745131ed5fea718bd860880a5785d4c7/src/core/java/com/enderio/core/common/attachment/AttachmentUtil.java#L47-L60

View file

@ -0,0 +1,41 @@
package de.ellpeck.actuallyadditions.mod.attachments;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.neoforged.neoforge.common.util.INBTSerializable;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Optional;
public class ItemTagAttachment implements INBTSerializable<CompoundTag> {
private TagKey<Item> tag;
@Override
public CompoundTag serializeNBT() {
CompoundTag nbt = new CompoundTag();
if (tag != null) {
nbt.putString("tag", tag.location().toString());
}
return nbt;
}
@Override
public void deserializeNBT(@Nonnull CompoundTag nbt) {
if (nbt.contains("tag")) {
tag = TagKey.create(Registries.ITEM, new ResourceLocation(nbt.getString("tag")));
}
}
public Optional<TagKey<Item>> getTag() {
return Optional.ofNullable(tag);
}
public void setTag(@Nullable TagKey<Item> tag) {
this.tag = tag;
}
}

View file

@ -11,11 +11,13 @@
package de.ellpeck.actuallyadditions.mod.event; package de.ellpeck.actuallyadditions.mod.event;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.attachments.ActuallyAttachments;
import de.ellpeck.actuallyadditions.mod.config.CommonConfig; import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.data.PlayerData; import de.ellpeck.actuallyadditions.mod.data.PlayerData;
import de.ellpeck.actuallyadditions.mod.data.WorldData; import de.ellpeck.actuallyadditions.mod.data.WorldData;
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
import de.ellpeck.actuallyadditions.mod.items.ItemTag;
import de.ellpeck.actuallyadditions.mod.items.Sack; import de.ellpeck.actuallyadditions.mod.items.Sack;
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper; import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
import de.ellpeck.actuallyadditions.mod.sack.SackManager; import de.ellpeck.actuallyadditions.mod.sack.SackManager;
@ -24,15 +26,20 @@ import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.tags.TagKey;
import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.monster.Spider; import net.minecraft.world.entity.monster.Spider;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.bus.api.Event; import net.neoforged.bus.api.Event;
import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.neoforge.event.AnvilUpdateEvent;
import net.neoforged.neoforge.event.entity.living.LivingDropsEvent; import net.neoforged.neoforge.event.entity.living.LivingDropsEvent;
import net.neoforged.neoforge.event.entity.player.EntityItemPickupEvent; import net.neoforged.neoforge.event.entity.player.EntityItemPickupEvent;
import net.neoforged.neoforge.event.entity.player.PlayerEvent; import net.neoforged.neoforge.event.entity.player.PlayerEvent;
@ -203,4 +210,24 @@ public class CommonEvents {
public void onPickupEvent(EntityItemPickupEvent event) { public void onPickupEvent(EntityItemPickupEvent event) {
//checkAchievements(event.getItem().getItem(), event.getEntityPlayer(), InitAchievements.Type.PICK_UP); //checkAchievements(event.getItem().getItem(), event.getEntityPlayer(), InitAchievements.Type.PICK_UP);
} }
@SubscribeEvent
public void onAnvilEvent(AnvilUpdateEvent event) {
if (!event.getLeft().isEmpty() && event.getLeft().getItem() instanceof ItemTag && event.getName() != null && !event.getName().isEmpty()) {
event.setCost(0);
if (ResourceLocation.isValidResourceLocation(event.getName())) {
TagKey<Item> tagKey = TagKey.create(Registries.ITEM, new ResourceLocation(event.getName()));
var tag = BuiltInRegistries.ITEM.getTag(tagKey);
if (tag.isPresent()) {
ItemStack stack = event.getLeft().copy();
stack.getData(ActuallyAttachments.ITEM_TAG).setTag(tagKey);
event.setOutput(stack);
} else {
event.setCanceled(true);
}
}
else {
event.setCanceled(true);
}
}
}
} }

View file

@ -38,6 +38,6 @@ public class ActuallyContainers {
public static final Supplier<MenuType<ContainerPhantomPlacer>> PHANTOM_PLACER_CONTAINER = CONTAINERS.register("phantom_placer_container", () -> IMenuTypeExtension.create(ContainerPhantomPlacer::fromNetwork)); public static final Supplier<MenuType<ContainerPhantomPlacer>> PHANTOM_PLACER_CONTAINER = CONTAINERS.register("phantom_placer_container", () -> IMenuTypeExtension.create(ContainerPhantomPlacer::fromNetwork));
public static final Supplier<MenuType<ContainerRangedCollector>> RANGED_COLLECTOR_CONTAINER = CONTAINERS.register("ranged_collector_container", () -> IMenuTypeExtension.create(ContainerRangedCollector::fromNetwork)); public static final Supplier<MenuType<ContainerRangedCollector>> RANGED_COLLECTOR_CONTAINER = CONTAINERS.register("ranged_collector_container", () -> IMenuTypeExtension.create(ContainerRangedCollector::fromNetwork));
public static final Supplier<MenuType<ContainerXPSolidifier>> XPSOLIDIFIER_CONTAINER = CONTAINERS.register("xpsolidifier_container", () -> IMenuTypeExtension.create(ContainerXPSolidifier::fromNetwork)); public static final Supplier<MenuType<ContainerXPSolidifier>> XPSOLIDIFIER_CONTAINER = CONTAINERS.register("xpsolidifier_container", () -> IMenuTypeExtension.create(ContainerXPSolidifier::fromNetwork));
public static final Supplier<MenuType<ItemTagContainer>> ITEM_TAG_CONTAINER = CONTAINERS.register("item_tag_container", () -> IMenuTypeExtension.create(ItemTagContainer::fromNetwork));
} }

View file

@ -0,0 +1,42 @@
package de.ellpeck.actuallyadditions.mod.inventory;
import de.ellpeck.actuallyadditions.mod.attachments.ActuallyAttachments;
import de.ellpeck.actuallyadditions.mod.items.ItemTag;
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
import net.minecraft.network.FriendlyByteBuf;
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.ItemStack;
import javax.annotation.Nonnull;
public class ItemTagContainer extends AbstractContainerMenu implements IButtonReactor {
public ItemTagContainer(int windowId, Inventory playerInventory) {
super(ActuallyContainers.ITEM_TAG_CONTAINER.get(), windowId);
}
public static ItemTagContainer fromNetwork(int windowId, Inventory inv, FriendlyByteBuf data) {
return new ItemTagContainer(windowId, inv);
}
@Nonnull
@Override
public ItemStack quickMoveStack(@Nonnull Player pPlayer, int pIndex) {
return ItemStack.EMPTY;
}
@Override
public boolean stillValid(@Nonnull Player pPlayer) {
return pPlayer.getInventory().getSelected().getItem() instanceof ItemTag;
}
@Override
public void onButtonPressed(int buttonID, Player player) {
ItemStack stack = player.getInventory().getSelected();
stack.getExistingData(ActuallyAttachments.ITEM_TAG).ifPresent(data -> {
data.setTag(null);
stack.setData(ActuallyAttachments.ITEM_TAG, data);
});
}
}

View file

@ -0,0 +1,99 @@
package de.ellpeck.actuallyadditions.mod.inventory.gui;
import de.ellpeck.actuallyadditions.mod.inventory.ItemTagContainer;
import de.ellpeck.actuallyadditions.mod.network.PacketClientToServer;
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.components.StringWidget;
import net.minecraft.core.HolderSet;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.item.Item;
import net.neoforged.neoforge.network.PacketDistributor;
import org.lwjgl.glfw.GLFW;
import javax.annotation.Nonnull;
import java.util.Optional;
public class ItemTagScreen extends AAScreen<ItemTagContainer> {
private EditBox tagBox;
private StringWidget testText;
private boolean validTag = false;
public ItemTagScreen(ItemTagContainer container, Inventory inventory, Component pTitle) {
super(container, inventory, pTitle);
}
@Override
protected void init() {
super.init();
this.testText = new StringWidget(this.leftPos + 7, this.topPos + 27, 162, 20, Component.literal(""), font);
this.addRenderableWidget(this.testText);
this.tagBox = new EditBox(this.font, this.leftPos + 7, this.topPos + 7, 162, 20, Component.nullToEmpty("Tag"));
this.tagBox.setMaxLength(128);
this.tagBox.setCanLoseFocus(false);
setInitialFocus(this.tagBox);
this.tagBox.setValue("");
this.tagBox.setResponder(this::textChanged);
this.addRenderableWidget(this.tagBox);
}
@Override
protected void renderBg(@Nonnull GuiGraphics pGuiGraphics, float pPartialTick, int pMouseX, int pMouseY) {
}
private void textChanged(String text) {
boolean valid = validateTag(text);
if (valid) {
this.tagBox.setTextColor(0x00FF00);
TagKey<Item> tagKey = TagKey.create(Registries.ITEM, new ResourceLocation(text));
Optional<HolderSet.Named<Item>> optionalNamed = BuiltInRegistries.ITEM.getTag(tagKey);
if (optionalNamed.isPresent()) {
this.testText.setMessage(Component.literal("Valid Tag"));
this.testText.setColor(0x00FF00);
validTag = true;
} else {
this.testText.setMessage(Component.literal("Invalid Tag"));
this.testText.setColor(0xFF0000);
}
}
else {
tagBox.setTextColor(0xFF0000);
validTag = false;
}
}
@Override
public boolean keyPressed(int pKeyCode, int pScanCode, int pModifiers) {
if (pKeyCode == GLFW.GLFW_KEY_ESCAPE) {
this.minecraft.player.closeContainer();
}
if (pKeyCode == GLFW.GLFW_KEY_ENTER && validTag) {
CompoundTag data = new CompoundTag();
data.putInt("ButtonID", 0);
data.putInt("PlayerID", Minecraft.getInstance().player.getId());
data.putString("WorldID", Minecraft.getInstance().level.dimension().location().toString());
data.putString("Tag", tagBox.getValue());
PacketDistributor.SERVER.noArg().send(new PacketClientToServer(data, PacketHandler.GUI_BUTTON_TO_CONTAINER_HANDLER));
this.minecraft.player.closeContainer();
}
return tagBox.keyPressed(pKeyCode, pScanCode, pModifiers) || tagBox.canConsumeInput() || super.keyPressed(pKeyCode, pScanCode, pModifiers);
}
private boolean validateTag(String tag) {
return ResourceLocation.isValidResourceLocation(tag);
//return !tag.matches("^[a-z0-9_\\-]+:[a-z0-9_\\-]+(/[a-z0-9_\\-]+)*$");
}
}

View file

@ -109,6 +109,7 @@ public final class ActuallyItems {
public static final DeferredItem<Worm> WORM = ITEMS.register("worm", Worm::new); public static final DeferredItem<Worm> WORM = ITEMS.register("worm", Worm::new);
public static final DeferredItem<ItemPlayerProbe> PLAYER_PROBE = ITEMS.register("player_probe", ItemPlayerProbe::new); public static final DeferredItem<ItemPlayerProbe> PLAYER_PROBE = ITEMS.register("player_probe", ItemPlayerProbe::new);
public static final DeferredItem<ItemFilter> FILTER = ITEMS.register("filter", ItemFilter::new); public static final DeferredItem<ItemFilter> FILTER = ITEMS.register("filter", ItemFilter::new);
public static final DeferredItem<Item> ITEM_TAG = ITEMS.register("item_tag", ItemTag::new);
public static final DeferredItem<ItemWaterBowl> WATER_BOWL = ITEMS.register("water_bowl", ItemWaterBowl::new); public static final DeferredItem<ItemWaterBowl> WATER_BOWL = ITEMS.register("water_bowl", ItemWaterBowl::new);
public static final DeferredItem<ItemGeneric> CRATE_KEEPER = ITEMS.register("crate_keeper", () -> new ItemGeneric(defaultProps().stacksTo(1))); public static final DeferredItem<ItemGeneric> CRATE_KEEPER = ITEMS.register("crate_keeper", () -> new ItemGeneric(defaultProps().stacksTo(1)));
public static final DeferredItem<ItemLens> LENS_OF_COLOR = ITEMS.register("lens_of_color", () -> new ItemLens(ActuallyAdditionsAPI.lensColor)); public static final DeferredItem<ItemLens> LENS_OF_COLOR = ITEMS.register("lens_of_color", () -> new ItemLens(ActuallyAdditionsAPI.lensColor));

View file

@ -0,0 +1,43 @@
package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.mod.attachments.ActuallyAttachments;
import de.ellpeck.actuallyadditions.mod.attachments.ItemTagAttachment;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import javax.annotation.Nullable;
import java.util.List;
public class ItemTag extends ItemBase {
@Override
public void appendHoverText(ItemStack pStack, @Nullable Level pLevel, List<Component> pTooltipComponents, TooltipFlag pIsAdvanced) {
var data = pStack.getExistingData(ActuallyAttachments.ITEM_TAG);
/* data.flatMap(ItemTagAttachment::getTag).ifPresent(itemTag -> {
BuiltInRegistries.ITEM.getTag(itemTag).ifPresent(itemTagCollection -> {
pTooltipComponents.add(Component.literal("Valid Tag").withStyle(ChatFormatting.GREEN));
pTooltipComponents.add(Component.literal("Tag: " + itemTag.location()).withStyle(ChatFormatting.GRAY));
pTooltipComponents.add(Component.literal("Contains: " + itemTagCollection.stream().count() + " items").withStyle(ChatFormatting.GRAY));
});
});*/
data.flatMap(ItemTagAttachment::getTag).ifPresentOrElse(
itemTag -> pTooltipComponents.add(Component.literal("Tag: " + itemTag.location()).withStyle(ChatFormatting.GRAY)),
() -> pTooltipComponents.add(Component.translatable("tooltip.actuallyadditions.item_tag.no_tag").withStyle(ChatFormatting.RED)
));
super.appendHoverText(pStack, pLevel, pTooltipComponents, pIsAdvanced);
}
/* @Nonnull
@Override
public InteractionResultHolder<ItemStack> use(Level pLevel, @Nonnull Player pPlayer, @Nonnull InteractionHand pUsedHand) {
if (!pLevel.isClientSide)
pPlayer.openMenu(new SimpleMenuProvider((pId, pInventory, player) -> new ItemTagContainer(pId, pInventory), Component.translatable("container.actuallyadditions.item_tag")));
return super.use(pLevel, pPlayer, pUsedHand);
}*/
}

View file

@ -10,9 +10,11 @@
package de.ellpeck.actuallyadditions.mod.tile; package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.attachments.ActuallyAttachments;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerFilter; import de.ellpeck.actuallyadditions.mod.inventory.ContainerFilter;
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotFilter; import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotFilter;
import de.ellpeck.actuallyadditions.mod.items.DrillItem; import de.ellpeck.actuallyadditions.mod.items.DrillItem;
import de.ellpeck.actuallyadditions.mod.items.ItemTag;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
@ -61,7 +63,19 @@ public class FilterSettings {
return whitelist; return whitelist;
} }
} }
} else if (areEqualEnough(slot, stack, mod)) { }
else if (slot.getItem() instanceof ItemTag) {
var data = slot.getExistingData(ActuallyAttachments.ITEM_TAG);
if (data.isPresent()) {
var tag = data.get().getTag();
if (tag.isPresent()) {
if (stack.is(tag.get())) {
return whitelist;
}
}
}
}
else if (areEqualEnough(slot, stack, mod)) {
return whitelist; return whitelist;
} }
} }

View file

@ -12,6 +12,8 @@ authors="Ellpeck"
description=''' description='''
Do you want Automation? Wireless Transport? Better Machines? A cup o\' Coffee? Chests? Better Hoppers? Leaf Blowers? Faster Growth? Plants? Well, Actually Additions has all that and a lot more! Do you want Automation? Wireless Transport? Better Machines? A cup o\' Coffee? Chests? Better Hoppers? Leaf Blowers? Faster Growth? Plants? Well, Actually Additions has all that and a lot more!
''' '''
[[mixins]]
config = "actuallyadditions.mixins.json"
[[dependencies.actuallyadditions]] [[dependencies.actuallyadditions]]
modId="neoforge" modId="neoforge"

View file

@ -0,0 +1,14 @@
{
"required": true,
"minVersion": "0.8.5",
"compatibilityLevel": "JAVA_17",
"package": "de.ellpeck.actuallyadditions.mixin",
"target": "@env(DEFAULT)",
"mixins": [
"AnvilMixin",
"ItemCombinerMenuAccessor"
],
"injectors": {
"defaultRequire": 1
}
}

View file

@ -397,6 +397,7 @@
"item.actuallyadditions.phan_con_pattern.desc": "Phantom Connector", "item.actuallyadditions.phan_con_pattern.desc": "Phantom Connector",
"item.actuallyadditions.book_pattern": "Banner Pattern", "item.actuallyadditions.book_pattern": "Banner Pattern",
"item.actuallyadditions.book_pattern.desc": "Book", "item.actuallyadditions.book_pattern.desc": "Book",
"item.actuallyadditions.item_tag" : "Item Tag",
"_comment": "Tooltips", "_comment": "Tooltips",
"tooltip.actuallyadditions.onSuffix.desc": "On", "tooltip.actuallyadditions.onSuffix.desc": "On",
"tooltip.actuallyadditions.phantom.connected.desc": "<Block connected!>", "tooltip.actuallyadditions.phantom.connected.desc": "<Block connected!>",
@ -443,6 +444,7 @@
"tooltip.actuallyadditions.item_filling_wand.selected_block": "Selected Block: %s", "tooltip.actuallyadditions.item_filling_wand.selected_block": "Selected Block: %s",
"tooltip.actuallyadditions.item_filling_wand.selected_block.none": "None", "tooltip.actuallyadditions.item_filling_wand.selected_block.none": "None",
"tooltip.actuallyadditions.coffeeCup.noEffect": "No Effects", "tooltip.actuallyadditions.coffeeCup.noEffect": "No Effects",
"tooltip.actuallyadditions.item_tag.no_tag": "Use Anvil to set tag.",
"_comment": "Gui Information", "_comment": "Gui Information",
"info.actuallyadditions.gui.animals": "Animals", "info.actuallyadditions.gui.animals": "Animals",
"info.actuallyadditions.gui.enoughToBreed": "Enough to breed!", "info.actuallyadditions.gui.enoughToBreed": "Enough to breed!",
@ -985,5 +987,6 @@
"jei.actuallyadditions.coffee.maxAmount": "Max Amount", "jei.actuallyadditions.coffee.maxAmount": "Max Amount",
"jei.actuallyadditions.coffee.extra.milk": "+01:00, -1 Level", "jei.actuallyadditions.coffee.extra.milk": "+01:00, -1 Level",
"jei.actuallyadditions.mining_lens": "Lens of the Miner", "jei.actuallyadditions.mining_lens": "Lens of the Miner",
"jei.actuallyadditions.mining_lens.weight": "Weight:" "jei.actuallyadditions.mining_lens.weight": "Weight:",
"container.actuallyadditions.item_tag": "Item Tag"
} }