Fix up the Energizer and Enervator

This commit is contained in:
Mrbysco 2024-03-11 02:10:19 +01:00
parent 1bcf01101e
commit e7e2de68f3
6 changed files with 26 additions and 21 deletions

View file

@ -10,20 +10,24 @@
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.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;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnergizer; import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnergizer;
import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.InventoryMenu;
import net.minecraft.world.inventory.Slot; import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.neoforged.neoforge.capabilities.Capabilities; import net.neoforged.neoforge.capabilities.Capabilities;
import org.jetbrains.annotations.Nullable;
import java.util.Objects; import java.util.Objects;
@ -76,13 +80,11 @@ public class ContainerEnergizer extends AbstractContainerMenu {
return (itemstack.isEmpty() || player.isCreative() || !EnchantmentHelper.hasBindingCurse(itemstack)) && super.mayPickup(player); return (itemstack.isEmpty() || player.isCreative() || !EnchantmentHelper.hasBindingCurse(itemstack)) && super.mayPickup(player);
} }
// TODO: [port] add back @Nullable
@Override
// @Override public Pair<ResourceLocation, ResourceLocation> getNoItemIcon() {
// @OnlyIn(Dist.CLIENT) return Pair.of(InventoryMenu.BLOCK_ATLAS, InventoryMenu.TEXTURE_EMPTY_SLOTS[slot.getIndex()]);
// public String getSlotTexture() { }
// return Armor.EMPTY_SLOT_NAMES[slot.getIndex()];
// }
}); });
} }
} }

View file

@ -10,19 +10,23 @@
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.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;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnervator; import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnervator;
import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.InventoryMenu;
import net.minecraft.world.inventory.Slot; import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.ArmorItem;
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 org.jetbrains.annotations.Nullable;
import java.util.Objects; import java.util.Objects;
@ -64,13 +68,11 @@ public class ContainerEnervator extends AbstractContainerMenu {
return StackUtil.isValid(stack) && stack.getItem() instanceof ArmorItem; return StackUtil.isValid(stack) && stack.getItem() instanceof ArmorItem;
} }
// TODO: [port] add this back @Nullable
@Override
// @Override public Pair<ResourceLocation, ResourceLocation> getNoItemIcon() {
// @OnlyIn(Dist.CLIENT) return Pair.of(InventoryMenu.BLOCK_ATLAS, InventoryMenu.TEXTURE_EMPTY_SLOTS[slot.getIndex()]);
// public String getSlotTexture() { }
// return ItemArmor.EMPTY_SLOT_NAMES[slot.getIndex()];
// }
}); });
} }
} }

View file

@ -64,7 +64,7 @@ public class TileEntityEnergizer extends TileEntityInventoryBase implements Menu
if (t instanceof TileEntityEnergizer tile) { if (t instanceof TileEntityEnergizer tile) {
tile.serverTick(); tile.serverTick();
if (StackUtil.isValid(tile.inv.getStackInSlot(0)) && !StackUtil.isValid(tile.inv.getStackInSlot(1))) { if (!tile.inv.getStackInSlot(0).isEmpty() && tile.inv.getStackInSlot(1).isEmpty()) {
if (tile.storage.getEnergyStored() > 0) { if (tile.storage.getEnergyStored() > 0) {
Optional<IEnergyStorage> capability = Optional.ofNullable(tile.inv.getStackInSlot(0).getCapability(Capabilities.EnergyStorage.ITEM, null)); Optional<IEnergyStorage> capability = Optional.ofNullable(tile.inv.getStackInSlot(0).getCapability(Capabilities.EnergyStorage.ITEM, null));
@ -109,7 +109,7 @@ public class TileEntityEnergizer extends TileEntityInventoryBase implements Menu
@Override @Override
public Component getDisplayName() { public Component getDisplayName() {
return Component.empty(); return Component.translatable("container.actuallyadditions.energizer");
} }
@Nullable @Nullable

View file

@ -63,7 +63,7 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements ISha
if (t instanceof TileEntityEnervator tile) { if (t instanceof TileEntityEnervator tile) {
tile.serverTick(); tile.serverTick();
if (StackUtil.isValid(tile.inv.getStackInSlot(0)) && !StackUtil.isValid(tile.inv.getStackInSlot(1))) { if (!tile.inv.getStackInSlot(0).isEmpty() && tile.inv.getStackInSlot(1).isEmpty()) {
if (tile.storage.getEnergyStored() < tile.storage.getMaxEnergyStored()) { if (tile.storage.getEnergyStored() < tile.storage.getMaxEnergyStored()) {
Optional<IEnergyStorage> capability = Optional.ofNullable(tile.inv.getStackInSlot(0).getCapability(Capabilities.EnergyStorage.ITEM, null)); Optional<IEnergyStorage> capability = Optional.ofNullable(tile.inv.getStackInSlot(0).getCapability(Capabilities.EnergyStorage.ITEM, null));
@ -129,7 +129,7 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements ISha
@Override @Override
public Component getDisplayName() { public Component getDisplayName() {
return Component.empty(); return Component.translatable("container.actuallyadditions.enervator");
} }
@Nullable @Nullable

View file

@ -2,4 +2,5 @@ public net.minecraft.world.damagesource.DamageSources *() # DamageSources
public net.minecraft.world.damagesource.DamageSources damageTypes public net.minecraft.world.damagesource.DamageSources damageTypes
public-f net.minecraft.data.recipes.RecipeProvider getName()Ljava/lang/String; public-f net.minecraft.data.recipes.RecipeProvider getName()Ljava/lang/String;
public-f net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorList list public-f net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorList list
public net.minecraft.world.item.crafting.ShapedRecipe pattern # pattern public net.minecraft.world.item.crafting.ShapedRecipe pattern
public net.minecraft.world.inventory.InventoryMenu TEXTURE_EMPTY_SLOTS

View file

@ -114,8 +114,8 @@
"block.actuallyadditions.item_repairer": "Item Repairer (wip)", "block.actuallyadditions.item_repairer": "Item Repairer (wip)",
"block.actuallyadditions.wood_casing": "Wood Casing (wip)", "block.actuallyadditions.wood_casing": "Wood Casing (wip)",
"block.actuallyadditions.greenhouse_glass": "Greenhouse Glass (wip)", "block.actuallyadditions.greenhouse_glass": "Greenhouse Glass (wip)",
"block.actuallyadditions.energizer": "Energizer (wip)", "block.actuallyadditions.energizer": "Energizer",
"block.actuallyadditions.enervator": "Enervator (wip)", "block.actuallyadditions.enervator": "Enervator",
"block.actuallyadditions.rice": "Rice Plant", "block.actuallyadditions.rice": "Rice Plant",
"block.actuallyadditions.coal_generator": "Coal Generator", "block.actuallyadditions.coal_generator": "Coal Generator",
"block.actuallyadditions.lamp_controller": "Lamp Controller (wip)", "block.actuallyadditions.lamp_controller": "Lamp Controller (wip)",