From c1d10d12ce72f0bdf16ac0a10f34391103d95e16 Mon Sep 17 00:00:00 2001 From: Mrbysco Date: Fri, 29 Nov 2024 22:14:07 +0100 Subject: [PATCH] Add off-hand slot to Energizer/Enervator (See #1456 ) --- CHANGELOG.md | 1 + .../mod/inventory/ContainerEnergizer.java | 19 ++++++++++++++++-- .../mod/inventory/ContainerEnervator.java | 14 +++++++++++++ .../textures/gui/gui_energizer.png | Bin 1831 -> 903 bytes 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7305cd1ac..f9483b88a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * Added the ability for fluid collectors to collect water and lava from filled cauldrons. * Explicitly made the Drills unbreakable. * Fixed worldgenned AA plants breaking on block update. +* Add off-hand slot to Energizer/Enervator # 1.3.10+mc1.21.1 * Fixed Fluid placer not being harvestable. diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerEnergizer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerEnergizer.java index dd042f29c..05a98441e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerEnergizer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerEnergizer.java @@ -10,6 +10,7 @@ package de.ellpeck.actuallyadditions.mod.inventory; +import com.mojang.datafixers.util.Pair; import de.ellpeck.actuallyadditions.mod.inventory.slot.ArmorSlot; import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput; @@ -25,6 +26,7 @@ import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; import net.neoforged.neoforge.capabilities.Capabilities; +import java.util.Map; import java.util.Objects; public class ContainerEnergizer extends AbstractContainerMenu { @@ -59,9 +61,22 @@ public class ContainerEnergizer extends AbstractContainerMenu { for (int k = 0; k < 4; ++k) { EquipmentSlot slot = VALID_EQUIPMENT_SLOTS[k]; - ResourceLocation resourcelocation = InventoryMenu.TEXTURE_EMPTY_SLOTS.get(slot); - this.addSlot(new ArmorSlot(inventory, slot, 36 + 3 - k, 102, 19 + k * 18, resourcelocation)); + ResourceLocation resourcelocation = InventoryMenu.TEXTURE_EMPTY_SLOTS.getOrDefault(slot, InventoryMenu.EMPTY_ARMOR_SLOT_SHIELD); + this.addSlot(new ArmorSlot(inventory, slot, 36 + 3 - k, 102, 19 + k * 18, resourcelocation) {}); } + + this.addSlot(new Slot(inventory, 40, 120, 19 + 3 * 18) { + @Override + public void setByPlayer(ItemStack newStack, ItemStack oldStack) { + inventory.player.onEquipItem(EquipmentSlot.OFFHAND, oldStack, newStack); + super.setByPlayer(newStack, oldStack); + } + + @Override + public Pair getNoItemIcon() { + return Pair.of(InventoryMenu.BLOCK_ATLAS, InventoryMenu.EMPTY_ARMOR_SLOT_SHIELD); + } + }); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerEnervator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerEnervator.java index 8aef02190..81bdd5511 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerEnervator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerEnervator.java @@ -10,6 +10,7 @@ package de.ellpeck.actuallyadditions.mod.inventory; +import com.mojang.datafixers.util.Pair; import de.ellpeck.actuallyadditions.mod.inventory.slot.ArmorSlot; import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput; @@ -57,6 +58,19 @@ public class ContainerEnervator extends AbstractContainerMenu { ResourceLocation resourcelocation = InventoryMenu.TEXTURE_EMPTY_SLOTS.get(slot); this.addSlot(new ArmorSlot(inventory, slot, 36 + 3 - k, 102, 19 + k * 18, resourcelocation)); } + + this.addSlot(new Slot(inventory, 40, 120, 19 + 3 * 18) { + @Override + public void setByPlayer(ItemStack newStack, ItemStack oldStack) { + inventory.player.onEquipItem(EquipmentSlot.OFFHAND, oldStack, newStack); + super.setByPlayer(newStack, oldStack); + } + + @Override + public Pair getNoItemIcon() { + return Pair.of(InventoryMenu.BLOCK_ATLAS, InventoryMenu.EMPTY_ARMOR_SLOT_SHIELD); + } + }); } @Nonnull diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/gui_energizer.png b/src/main/resources/assets/actuallyadditions/textures/gui/gui_energizer.png index 238b0c4af6267d95e8ac1cf1943e221227c54575..59f8bfc550926d31ba45d1e9e330e3472cd81c20 100644 GIT binary patch literal 903 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|G$6&2?&#~tz_78e=6B#^1_ow3 zPZ!6KiaBrZzRq3jAklWQKcn00iCKn@;&B^nC;&gBK))CpPBeR`(OTQ*Sb}E@B6NqzL$N2(&T#P?YGyS3Jf!j()yXt zxa0nNYrdti&p+>6wMuWgcWCtf`5wBmjDM0o9k%ghW0>L2pfH2M!GN(Lfr;TD3qunp z1B);NhZ=)`53)qv8(W5d-~Rpk_rdJfzV(-1ZaI{ZF_S?iHK#!&DFu#*)OnjuB>J40FVRqPtt% z7{rPS`=(j2;&-eKSB(Quzcy0=lnRKmf}7^YC{|F|ca7r!)AGwFD@}b1xi&0%{Wa?P z>(cj$2XdG;Ogb+d&r%`Aw4tfqw?goNB*%f~eY0LD9k{rYWcEfk6qw{OpZoISt%-$_J17d$q}mQX-f7~_khbgo`>(%#?fPzz5Q-L2Z$39W zT+UluAr!s#%I0fzW)kn?_Rq{){@3jJ5ekn6l*YEsb4@)Ccl|e~&aDxT5_KdQOE8K7J@B0aIsi&)-%Q~lo FCICyOC}#iw literal 1831 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|G$6&2?&#~tz_78O`%fY(kk47* z5n0T@z_$T}8U0TGwF3%Dl(rIsj|=o#o)<`~!cF)*+# z^>lFzsfc@fBd|#3BrmJOT`%>ED@*iay^l%caV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