PrettyPipes/src/main/java/de/ellpeck/prettypipes/terminal/CraftingTerminalTileEntity.java

54 lines
1.8 KiB
Java

package de.ellpeck.prettypipes.terminal;
import de.ellpeck.prettypipes.PrettyPipes;
import de.ellpeck.prettypipes.Registry;
import de.ellpeck.prettypipes.terminal.containers.CraftingTerminalContainer;
import de.ellpeck.prettypipes.terminal.containers.ItemTerminalContainer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.items.ItemStackHandler;
import javax.annotation.Nullable;
public class CraftingTerminalTileEntity extends ItemTerminalTileEntity {
public final ItemStackHandler craftItems = new ItemStackHandler(9);
public CraftingTerminalTileEntity() {
super(Registry.craftingTerminalTileEntity);
}
public ItemStack getRequestedCraftItem(int slot) {
// TODO put ghost slot contents here
return this.craftItems.getStackInSlot(slot);
}
@Override
public CompoundNBT write(CompoundNBT compound) {
compound.put("craft_items", this.craftItems.serializeNBT());
return super.write(compound);
}
@Override
public void read(CompoundNBT compound) {
this.craftItems.deserializeNBT(compound.getCompound("craft_items"));
super.read(compound);
}
@Override
public ITextComponent getDisplayName() {
return new TranslationTextComponent("container." + PrettyPipes.ID + ".crafting_terminal");
}
@Nullable
@Override
public Container createMenu(int window, PlayerInventory inv, PlayerEntity player) {
return new CraftingTerminalContainer(Registry.craftingTerminalContainer, window, player, this.pos);
}
}