Add off-hand slot to Energizer/Enervator (See #1456 )

This commit is contained in:
Mrbysco 2024-11-29 22:14:07 +01:00
parent e62fb634d1
commit c1d10d12ce
4 changed files with 32 additions and 2 deletions

View file

@ -7,6 +7,7 @@
* Added the ability for fluid collectors to collect water and lava from filled cauldrons. * Added the ability for fluid collectors to collect water and lava from filled cauldrons.
* Explicitly made the Drills unbreakable. * Explicitly made the Drills unbreakable.
* Fixed worldgenned AA plants breaking on block update. * Fixed worldgenned AA plants breaking on block update.
* Add off-hand slot to Energizer/Enervator
# 1.3.10+mc1.21.1 # 1.3.10+mc1.21.1
* Fixed Fluid placer not being harvestable. * Fixed Fluid placer not being harvestable.

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.inventory; 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.ArmorSlot;
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput; 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.minecraft.world.item.ItemStack;
import net.neoforged.neoforge.capabilities.Capabilities; import net.neoforged.neoforge.capabilities.Capabilities;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
public class ContainerEnergizer extends AbstractContainerMenu { public class ContainerEnergizer extends AbstractContainerMenu {
@ -59,9 +61,22 @@ public class ContainerEnergizer extends AbstractContainerMenu {
for (int k = 0; k < 4; ++k) { for (int k = 0; k < 4; ++k) {
EquipmentSlot slot = VALID_EQUIPMENT_SLOTS[k]; EquipmentSlot slot = VALID_EQUIPMENT_SLOTS[k];
ResourceLocation resourcelocation = InventoryMenu.TEXTURE_EMPTY_SLOTS.get(slot); 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 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<ResourceLocation, ResourceLocation> getNoItemIcon() {
return Pair.of(InventoryMenu.BLOCK_ATLAS, InventoryMenu.EMPTY_ARMOR_SLOT_SHIELD);
}
});
} }
@Override @Override

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.inventory; 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.ArmorSlot;
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput; 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); 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 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<ResourceLocation, ResourceLocation> getNoItemIcon() {
return Pair.of(InventoryMenu.BLOCK_ATLAS, InventoryMenu.EMPTY_ARMOR_SLOT_SHIELD);
}
});
} }
@Nonnull @Nonnull

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 903 B