More stuff

This commit is contained in:
Raoul Van den Berge
2016-04-10 19:50:18 +02:00
parent 2c1707c72f
commit 9b52409e67
6 changed files with 65 additions and 28 deletions

View File

@@ -0,0 +1,11 @@
package refinedstorage.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
public class ContainerDummy extends Container {
@Override
public boolean canInteractWith(EntityPlayer player) {
return false;
}
}

View File

@@ -1,16 +1,10 @@
package refinedstorage.gui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import refinedstorage.container.ContainerDummy;
public class GuiCraftingSettings extends GuiBase {
public GuiCraftingSettings() {
super(new Container() {
@Override
public boolean canInteractWith(EntityPlayer player) {
return false;
}
}, 143, 61);
super(new ContainerDummy(), 143, 61);
}
@Override

View File

@@ -7,7 +7,6 @@ import net.minecraft.nbt.NBTTagCompound;
import java.util.List;
public class ItemPattern extends ItemBase {
public static final String NBT_SLOT = "Slot_%d";
public static final String NBT_RESULT = "Result";
public ItemPattern() {
@@ -21,17 +20,6 @@ public class ItemPattern extends ItemBase {
}
}
public static void setSlot(ItemStack pattern, int i, ItemStack stack) {
if (pattern.getTagCompound() == null) {
pattern.setTagCompound(new NBTTagCompound());
}
NBTTagCompound stackTag = new NBTTagCompound();
stack.writeToNBT(stackTag);
pattern.getTagCompound().setTag(String.format(NBT_SLOT, i), stackTag);
}
public static void setResult(ItemStack pattern, ItemStack stack) {
if (pattern.getTagCompound() == null) {
pattern.setTagCompound(new NBTTagCompound());

View File

@@ -28,6 +28,7 @@ import refinedstorage.network.MessageWirelessGridItems;
import refinedstorage.storage.IStorage;
import refinedstorage.storage.IStorageProvider;
import refinedstorage.storage.ItemGroup;
import refinedstorage.tile.autocrafting.CraftingTask;
import refinedstorage.tile.config.IRedstoneModeConfig;
import refinedstorage.tile.config.RedstoneMode;
import refinedstorage.tile.grid.WirelessGridConsumer;
@@ -57,6 +58,8 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
private List<TileMachine> machines = new ArrayList<TileMachine>();
private List<ClientSideMachine> clientSideMachines = new ArrayList<ClientSideMachine>();
private List<CraftingTask> craftingTasks = new ArrayList<CraftingTask>();
private List<BlockPos> visited = new ArrayList<BlockPos>();
private EnergyStorage energy = new EnergyStorage(ENERGY_CAPACITY);
@@ -200,6 +203,10 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
return itemGroups;
}
public List<CraftingTask> getCraftingTasks() {
return craftingTasks;
}
private void syncItems() {
itemGroups.clear();

View File

@@ -0,0 +1,45 @@
package refinedstorage.tile.autocrafting;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import refinedstorage.container.ContainerDummy;
import refinedstorage.util.InventoryUtils;
import java.util.ArrayList;
import java.util.List;
public class CraftingTask {
private ItemStack result;
private List<ItemStack> ingredients;
public CraftingTask(ItemStack result, List<ItemStack> ingredients) {
this.result = result;
this.ingredients = ingredients;
}
public static CraftingTask create(ItemStack result) {
List<ItemStack> ingredients = new ArrayList<ItemStack>();
addCraftingIngredients(ingredients, result);
return new CraftingTask(result, ingredients);
}
private static void addCraftingIngredients(List<ItemStack> ingredients, ItemStack stack) {
for (IRecipe recipe : CraftingManager.getInstance().getRecipeList()) {
ItemStack output = recipe.getRecipeOutput();
// this may seem unnecessary but keep it, some horrible mods return a null itemstack
if (output != null && output.getItem() != null) {
// first check if the output is the stack we're adding the ingredients for
if (InventoryUtils.compareStack(output, stack)) {
// now get all the ingredients from that recipe
for (ItemStack ingredient : recipe.getRemainingItems(new InventoryCrafting(new ContainerDummy(), 3, 3))) {
ingredients.add(ingredient);
}
}
}
}
}
}

View File

@@ -170,14 +170,6 @@ public class TileGrid extends TileMachine implements IGrid {
ItemStack pattern = new ItemStack(RefinedStorageItems.PATTERN);
ItemPattern.setResult(pattern, crafted);
for (int i = 0; i < 9; ++i) {
ItemStack slot = craftingInventory.getStackInSlot(i);
if (slot != null) {
ItemPattern.setSlot(pattern, i, slot);
}
}
patternsInventory.setInventorySlotContents(1, pattern);
}
}