Start work on intelligent item insertion.
This commit is contained in:
parent
43d741d4b6
commit
04721e447d
2 changed files with 40 additions and 3 deletions
|
@ -2,6 +2,7 @@ package techreborn.tiles;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
|
import net.minecraft.inventory.ISidedInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.IRecipe;
|
import net.minecraft.item.crafting.IRecipe;
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
import net.minecraft.item.crafting.Ingredient;
|
||||||
|
@ -23,11 +24,11 @@ import javax.annotation.Nullable;
|
||||||
/**
|
/**
|
||||||
* Created by modmuss50 on 20/06/2017.
|
* Created by modmuss50 on 20/06/2017.
|
||||||
*/
|
*/
|
||||||
public class TileAutoCraftingTable extends TilePowerAcceptor implements IContainerProvider, IInventoryProvider {
|
public class TileAutoCraftingTable extends TilePowerAcceptor implements IContainerProvider, IInventoryProvider, ISidedInventory {
|
||||||
|
|
||||||
ResourceLocation currentRecipe;
|
ResourceLocation currentRecipe;
|
||||||
|
|
||||||
public Inventory inventory = new Inventory(10, "TileAutoCraftingTable", 64, this);
|
public Inventory inventory = new AutoCraftingInventory(10, "TileAutoCraftingTable", 64, this);
|
||||||
public int progress;
|
public int progress;
|
||||||
public int maxProgress = 120;
|
public int maxProgress = 120;
|
||||||
public int euTick = 10;
|
public int euTick = 10;
|
||||||
|
@ -57,6 +58,9 @@ public class TileAutoCraftingTable extends TilePowerAcceptor implements IContain
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
super.update();
|
super.update();
|
||||||
|
if(world.isRemote){
|
||||||
|
return;
|
||||||
|
}
|
||||||
IRecipe recipe = getIRecipe();
|
IRecipe recipe = getIRecipe();
|
||||||
if (recipe != null) {
|
if (recipe != null) {
|
||||||
if (progress >= maxProgress) {
|
if (progress >= maxProgress) {
|
||||||
|
@ -240,4 +244,37 @@ public class TileAutoCraftingTable extends TilePowerAcceptor implements IContain
|
||||||
}
|
}
|
||||||
super.readFromNBT(tag);
|
super.readFromNBT(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int[] getSlotsForFace(EnumFacing side) {
|
||||||
|
return new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isItemValidForRecipeSlot(IRecipe recipe, ItemStack stack, int slotID){
|
||||||
|
if(recipe == null){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//TODO check slot is the best place for the recipe, round robin if possible
|
||||||
|
//If there is a better slot return false for it to be added their later.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class AutoCraftingInventory extends Inventory {
|
||||||
|
|
||||||
|
TileAutoCraftingTable tile;
|
||||||
|
|
||||||
|
public AutoCraftingInventory(int size, String invName, int invStackLimit, TileAutoCraftingTable tileEntity) {
|
||||||
|
super(size, invName, invStackLimit, tileEntity);
|
||||||
|
this.tile = tileEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
|
||||||
|
IRecipe recipe = tile.getIRecipe();
|
||||||
|
if(recipe != null){
|
||||||
|
return tile.isItemValidForRecipeSlot(recipe, itemstack, i);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ tile.techreborn:adjustable_su.name=Adjustable SU
|
||||||
tile.techreborn:lapotronic_su.name=LESU Controller
|
tile.techreborn:lapotronic_su.name=LESU Controller
|
||||||
tile.techreborn:lsu_storage.name=LESU Storage
|
tile.techreborn:lsu_storage.name=LESU Storage
|
||||||
tile.techreborn:distillation_tower.name=Distillation Tower
|
tile.techreborn:distillation_tower.name=Distillation Tower
|
||||||
tile.techreborn:electric_crafting_table.name=Electric Autocrafting Table
|
tile.techreborn:electric_crafting_table.name=Automatic Autocrafting Table
|
||||||
tile.techreborn:vacuum_freezer.name=Vacuum Freezer
|
tile.techreborn:vacuum_freezer.name=Vacuum Freezer
|
||||||
tile.techreborn:plasma_generator.name=Plasma Generator
|
tile.techreborn:plasma_generator.name=Plasma Generator
|
||||||
tile.techreborn:fusion_control_computer.name=Fusion Control Computer
|
tile.techreborn:fusion_control_computer.name=Fusion Control Computer
|
||||||
|
|
Loading…
Add table
Reference in a new issue