2020-05-08 22:58:16 +02:00
|
|
|
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;
|
2020-05-09 01:00:59 +02:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.nbt.CompoundNBT;
|
2020-05-08 22:58:16 +02:00
|
|
|
import net.minecraft.util.text.ITextComponent;
|
|
|
|
import net.minecraft.util.text.TranslationTextComponent;
|
2020-05-09 01:00:59 +02:00
|
|
|
import net.minecraftforge.items.ItemStackHandler;
|
2020-05-08 22:58:16 +02:00
|
|
|
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
|
|
|
public class CraftingTerminalTileEntity extends ItemTerminalTileEntity {
|
|
|
|
|
2020-05-09 01:00:59 +02:00
|
|
|
public final ItemStackHandler craftItems = new ItemStackHandler(9);
|
|
|
|
|
2020-05-08 22:58:16 +02:00
|
|
|
public CraftingTerminalTileEntity() {
|
|
|
|
super(Registry.craftingTerminalTileEntity);
|
|
|
|
}
|
|
|
|
|
2020-05-09 01:00:59 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2020-05-08 22:58:16 +02:00
|
|
|
@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);
|
|
|
|
}
|
|
|
|
}
|