From 9ed5269183e1c87162a365609ae2756b1e9e3ba3 Mon Sep 17 00:00:00 2001 From: IchHabeHunger54 Date: Mon, 6 Jan 2025 17:56:00 +0100 Subject: [PATCH] fix a dupe issue with the slotted book --- changelog.md | 11 ++----- gradle.properties | 2 +- .../content/slottedbook/SlottedBookMenu.java | 30 +++++++++++++++++-- summary.txt | 2 +- 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/changelog.md b/changelog.md index 2a2d029b..5860b647 100644 --- a/changelog.md +++ b/changelog.md @@ -1,10 +1,3 @@ -# Additions +# Fixes -- New fancy clock and grandfather clock blocks -- Sounds for the tape measure -- Config to allow removing the various wooden and colored variants from JEI - -# Changes - -- Bookcases now have enchantment power depending on the amount of books in them -- Redstone: Volume 1 was renamed to Redstone Book +- Fix a dupe issue with the slotted book diff --git a/gradle.properties b/gradle.properties index c0a4a309..95a36cea 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ org.gradle.configuration-cache=true mod.group=com.github.minecraftschurlimods mod.id=bibliocraft -mod.version=1.3.0 +mod.version=1.3.1 mod.name=Bibliocraft Legacy mod.vendor=MinecraftschurliMods mod.authors=IchHabeHunger54, Minecraftschurli diff --git a/src/main/java/com/github/minecraftschurlimods/bibliocraft/content/slottedbook/SlottedBookMenu.java b/src/main/java/com/github/minecraftschurlimods/bibliocraft/content/slottedbook/SlottedBookMenu.java index 21ef1849..01b28b4c 100644 --- a/src/main/java/com/github/minecraftschurlimods/bibliocraft/content/slottedbook/SlottedBookMenu.java +++ b/src/main/java/com/github/minecraftschurlimods/bibliocraft/content/slottedbook/SlottedBookMenu.java @@ -1,5 +1,6 @@ package com.github.minecraftschurlimods.bibliocraft.content.slottedbook; +import com.github.minecraftschurlimods.bibliocraft.init.BCItems; import com.github.minecraftschurlimods.bibliocraft.init.BCMenus; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.world.Container; @@ -17,11 +18,20 @@ public SlottedBookMenu(int id, Inventory inventory, ItemStack stack) { addSlot(new SlottedBookSlot(container, 0, 80, 34)); for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { - addSlot(new Slot(inventory, i * 9 + j + 9, 8 + j * 18, 141 + i * 18)); + int slot = i * 9 + j + 9; + if (inventory.getItem(slot).is(BCItems.SLOTTED_BOOK.get())) { + addSlot(new ReadOnlySlot(inventory, slot, 8 + j * 18, 141 + i * 18)); + } else { + addSlot(new Slot(inventory, slot, 8 + j * 18, 141 + i * 18)); + } } } for (int i = 0; i < 9; i++) { - addSlot(new Slot(inventory, i, 8 + i * 18, 199)); + if (inventory.getItem(i).is(BCItems.SLOTTED_BOOK.get())) { + addSlot(new ReadOnlySlot(inventory, i, 8 + i * 18, 199)); + } else { + addSlot(new Slot(inventory, i, 8 + i * 18, 199)); + } } } @@ -67,4 +77,20 @@ public ItemStack quickMoveStack(Player player, int index) { public boolean stillValid(Player player) { return true; } + + private static class ReadOnlySlot extends Slot { + public ReadOnlySlot(Container container, int slot, int x, int y) { + super(container, slot, x, y); + } + + @Override + public boolean mayPickup(Player player) { + return false; + } + + @Override + public boolean mayPlace(ItemStack stack) { + return false; + } + } } diff --git a/summary.txt b/summary.txt index 32812d78..309f7780 100644 --- a/summary.txt +++ b/summary.txt @@ -1 +1 @@ -Clocks + some minor changes and additions \ No newline at end of file +Fix a dupe bug \ No newline at end of file