Builders Crafts & Additions (Forge)

Builders Crafts & Additions (Forge)

7M Downloads

Suggestion: Allow Bookshelf to accept items tagged "forge:books"

mc-ganduron opened this issue ยท 3 comments

commented

Currently the bookshelf accepts standard books and items with registry names that match certain patterns. I think it would be useful to accept items tagged as "forge:books" to allow more books to work. For example, some of the new books in Tinker's Construct don't fit the current rules, but they are tagged as "forge:books".

Current Behavior:

buildersaddition_current.mp4

I tweaked class Util to accept book items by tag:

diff --git a/src/main/java/com/mrh0/buildersaddition/util/Util.java b/src/main/java/com/mrh0/buildersaddition/util/Util.java
index 6e70438..80f2566 100644
--- a/src/main/java/com/mrh0/buildersaddition/util/Util.java
+++ b/src/main/java/com/mrh0/buildersaddition/util/Util.java
@@ -9,12 +9,16 @@ import net.minecraft.item.Item;
 import net.minecraft.item.ItemStack;
 import net.minecraft.item.Items;
 import net.minecraft.item.KnowledgeBookItem;
+import net.minecraft.tags.ItemTags;
+import net.minecraft.tags.ITag;
 import net.minecraft.util.Direction;
+import net.minecraft.util.ResourceLocation;
 import net.minecraft.util.math.BlockPos;
 import net.minecraft.world.IBlockReader;
 import net.minecraft.world.World;
 
 public class Util {
+    private static final ITag<Item> FORGE_BOOK_TAG = ItemTags.makeWrapperTag(new ResourceLocation("forge", "books").toString());
 	public static boolean isBook(ItemStack stack) {
 		Item i = stack.getItem();
 		String n = i.getRegistryName().getPath();
@@ -22,7 +26,8 @@ public class Util {
 		return (i instanceof EnchantedBookItem) || (i instanceof KnowledgeBookItem) || i == Items.BOOK || i == Items.WRITABLE_BOOK || i == Items.WRITTEN_BOOK 
 				|| n.endsWith("book") || n.endsWith("manual") || n.endsWith("journal") || n.endsWith("tome")  || n.startsWith("tome") || n.endsWith("lexicon")  || n.endsWith("codex")
 				|| n.endsWith("guide") || n.startsWith("guide") || n.startsWith("handbook") || n.endsWith("chronicle") || n.endsWith("companion") || n.endsWith("binder") || n.endsWith("nomicon")
-				|| n.endsWith("dictionary") || n.startsWith("dictionary") || n.endsWith("materials_and_you") || n.endsWith("binder") || n.startsWith("binder");
+				|| n.endsWith("dictionary") || n.startsWith("dictionary") || n.endsWith("materials_and_you") || n.endsWith("binder") || n.startsWith("binder")
+                || i.isIn(FORGE_BOOK_TAG);
 	}
 	
 	public static BlockState crackedState(BlockState cur) {

New Behavior:

buildersaddition_tag_testing.mp4

Let me know what you think.

commented

Fixed in 20210730b, however only on 1.17.1 atm.

commented

in 1.16.5 20210807a

commented

Yes!