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 238b0c4af..59f8bfc55 100644 Binary files a/src/main/resources/assets/actuallyadditions/textures/gui/gui_energizer.png and b/src/main/resources/assets/actuallyadditions/textures/gui/gui_energizer.png differ