The Solderer isn't sided anymore, fixes #1121
This commit is contained in:
@@ -21,11 +21,11 @@ public interface ISoldererRegistry {
|
||||
/**
|
||||
* Returns a solderer recipe from the rows.
|
||||
*
|
||||
* @param rows an item handler, where slots 0 - 2 are the rows
|
||||
* @param ingredients an item handler, where slots 0 - 2 are the ingredient rows
|
||||
* @return the recipe, or null if no recipe was found
|
||||
*/
|
||||
@Nullable
|
||||
ISoldererRecipe getRecipe(@Nonnull IItemHandler rows);
|
||||
ISoldererRecipe getRecipe(@Nonnull IItemHandler ingredients);
|
||||
|
||||
/**
|
||||
* @return a list with all the solderer recipes
|
||||
|
||||
@@ -4,8 +4,8 @@ import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerInterface;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerProxy;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
|
||||
import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
||||
@@ -24,7 +24,7 @@ public class NetworkNodeInterface extends NetworkNode implements IComparable {
|
||||
private ItemHandlerBase exportSpecimenItems = new ItemHandlerBase(9, new ItemHandlerListenerNetworkNode(this));
|
||||
private ItemHandlerBase exportItems = new ItemHandlerBase(9, new ItemHandlerListenerNetworkNode(this));
|
||||
|
||||
private ItemHandlerInterface items = new ItemHandlerInterface(importItems, exportItems);
|
||||
private ItemHandlerProxy items = new ItemHandlerProxy(importItems, exportItems);
|
||||
|
||||
private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ItemHandlerListenerNetworkNode(this), ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_STACK, ItemUpgrade.TYPE_CRAFTING);
|
||||
|
||||
@@ -178,7 +178,7 @@ public class NetworkNodeInterface extends NetworkNode implements IComparable {
|
||||
return exportItems;
|
||||
}
|
||||
|
||||
public ItemHandlerInterface getItems() {
|
||||
public ItemHandlerProxy getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerProxy;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
|
||||
import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -23,7 +24,7 @@ public class NetworkNodeSolderer extends NetworkNode {
|
||||
public static final String NBT_WORKING = "Working";
|
||||
private static final String NBT_PROGRESS = "Progress";
|
||||
|
||||
private ItemHandlerBase items = new ItemHandlerBase(3, new ItemHandlerListenerNetworkNode(this)) {
|
||||
private ItemHandlerBase ingredients = new ItemHandlerBase(3, new ItemHandlerListenerNetworkNode(this)) {
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
|
||||
@@ -36,6 +37,7 @@ public class NetworkNodeSolderer extends NetworkNode {
|
||||
return stack;
|
||||
}
|
||||
};
|
||||
|
||||
private ItemHandlerBase result = new ItemHandlerBase(1, new ItemHandlerListenerNetworkNode(this)) {
|
||||
@Override
|
||||
@Nonnull
|
||||
@@ -43,6 +45,9 @@ public class NetworkNodeSolderer extends NetworkNode {
|
||||
return stack;
|
||||
}
|
||||
};
|
||||
|
||||
private ItemHandlerProxy items = new ItemHandlerProxy(ingredients, result);
|
||||
|
||||
private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ItemHandlerListenerNetworkNode(this), ItemUpgrade.TYPE_SPEED);
|
||||
|
||||
private ISoldererRecipe recipe;
|
||||
@@ -76,10 +81,10 @@ public class NetworkNodeSolderer extends NetworkNode {
|
||||
return;
|
||||
}
|
||||
|
||||
if (items.getStackInSlot(1).isEmpty() && items.getStackInSlot(2).isEmpty() && result.getStackInSlot(0).isEmpty()) {
|
||||
if (ingredients.getStackInSlot(1).isEmpty() && ingredients.getStackInSlot(2).isEmpty() && result.getStackInSlot(0).isEmpty()) {
|
||||
stop();
|
||||
} else {
|
||||
ISoldererRecipe newRecipe = API.instance().getSoldererRegistry().getRecipe(items);
|
||||
ISoldererRecipe newRecipe = API.instance().getSoldererRegistry().getRecipe(ingredients);
|
||||
|
||||
if (newRecipe == null) {
|
||||
stop();
|
||||
@@ -105,7 +110,7 @@ public class NetworkNodeSolderer extends NetworkNode {
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (!recipe.getRow(i).isEmpty()) {
|
||||
items.extractItem(i, recipe.getRow(i).getCount(), false);
|
||||
ingredients.extractItem(i, recipe.getRow(i).getCount(), false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,11 +143,11 @@ public class NetworkNodeSolderer extends NetworkNode {
|
||||
public void read(NBTTagCompound tag) {
|
||||
super.read(tag);
|
||||
|
||||
RSUtils.readItems(items, 0, tag);
|
||||
RSUtils.readItems(ingredients, 0, tag);
|
||||
RSUtils.readItems(upgrades, 1, tag);
|
||||
RSUtils.readItems(result, 2, tag);
|
||||
|
||||
recipe = API.instance().getSoldererRegistry().getRecipe(items);
|
||||
recipe = API.instance().getSoldererRegistry().getRecipe(ingredients);
|
||||
|
||||
if (tag.hasKey(NBT_WORKING)) {
|
||||
working = tag.getBoolean(NBT_WORKING);
|
||||
@@ -163,7 +168,7 @@ public class NetworkNodeSolderer extends NetworkNode {
|
||||
public NBTTagCompound write(NBTTagCompound tag) {
|
||||
super.write(tag);
|
||||
|
||||
RSUtils.writeItems(items, 0, tag);
|
||||
RSUtils.writeItems(ingredients, 0, tag);
|
||||
RSUtils.writeItems(upgrades, 1, tag);
|
||||
RSUtils.writeItems(result, 2, tag);
|
||||
|
||||
@@ -173,14 +178,18 @@ public class NetworkNodeSolderer extends NetworkNode {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public ItemHandlerBase getItems() {
|
||||
return items;
|
||||
public ItemHandlerBase getIngredients() {
|
||||
return ingredients;
|
||||
}
|
||||
|
||||
public ItemHandlerBase getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public ItemHandlerProxy getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public IItemHandler getUpgrades() {
|
||||
return upgrades;
|
||||
}
|
||||
@@ -199,6 +208,6 @@ public class NetworkNodeSolderer extends NetworkNode {
|
||||
|
||||
@Override
|
||||
public IItemHandler getDrops() {
|
||||
return new CombinedInvWrapper(items, result, upgrades);
|
||||
return new CombinedInvWrapper(ingredients, result, upgrades);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,18 +24,18 @@ public class SoldererRegistry implements ISoldererRegistry {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ISoldererRecipe getRecipe(@Nonnull IItemHandler rows) {
|
||||
public ISoldererRecipe getRecipe(@Nonnull IItemHandler ingredients) {
|
||||
for (ISoldererRecipe recipe : recipes) {
|
||||
boolean found = true;
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (!API.instance().getComparer().isEqual(recipe.getRow(i), rows.getStackInSlot(i), IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT | IComparer.COMPARE_OREDICT | IComparer.COMPARE_STRIP_NBT)) {
|
||||
if (!API.instance().getComparer().isEqual(recipe.getRow(i), ingredients.getStackInSlot(i), IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT | IComparer.COMPARE_OREDICT | IComparer.COMPARE_STRIP_NBT)) {
|
||||
found = false;
|
||||
}
|
||||
|
||||
ItemStack row = recipe.getRow(i);
|
||||
|
||||
if (rows.getStackInSlot(i).getCount() < row.getCount()) {
|
||||
if (ingredients.getStackInSlot(i).getCount() < row.getCount()) {
|
||||
found = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.raoulvdberge.refinedstorage.container;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RSItems;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeSolderer;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.SlotOutput;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileSolderer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -17,7 +16,7 @@ public class ContainerSolderer extends ContainerBase {
|
||||
int y = 20;
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
addSlotToContainer(new SlotItemHandler(solderer.getNode().getItems(), i, x, y));
|
||||
addSlotToContainer(new SlotItemHandler(solderer.getNode().getIngredients(), i, x, y));
|
||||
|
||||
y += 18;
|
||||
}
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.inventory;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ItemHandlerInterface implements IItemHandler {
|
||||
private IItemHandler importItems;
|
||||
private IItemHandler exportItems;
|
||||
|
||||
public ItemHandlerInterface(IItemHandler importItems, IItemHandler exportItems) {
|
||||
this.importItems = importItems;
|
||||
this.exportItems = exportItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlots() {
|
||||
return importItems.getSlots() + exportItems.getSlots();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return slot < importItems.getSlots() ? importItems.getStackInSlot(slot) : exportItems.getStackInSlot(slot - importItems.getSlots());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
|
||||
return slot < importItems.getSlots() ? importItems.insertItem(slot, stack, simulate) : stack;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack extractItem(int slot, int amount, boolean simulate) {
|
||||
return slot >= importItems.getSlots() ? exportItems.extractItem(slot - importItems.getSlots(), amount, simulate) : ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotLimit(int slot) {
|
||||
return slot < importItems.getSlots() ? importItems.getSlotLimit(slot) : exportItems.getSlotLimit(slot - importItems.getSlots());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.raoulvdberge.refinedstorage.inventory;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ItemHandlerProxy implements IItemHandler {
|
||||
private IItemHandler insertHandler;
|
||||
private IItemHandler extractHandler;
|
||||
|
||||
public ItemHandlerProxy(IItemHandler insertHandler, IItemHandler extractHandler) {
|
||||
this.insertHandler = insertHandler;
|
||||
this.extractHandler = extractHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlots() {
|
||||
return insertHandler.getSlots() + extractHandler.getSlots();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return slot < insertHandler.getSlots() ? insertHandler.getStackInSlot(slot) : extractHandler.getStackInSlot(slot - insertHandler.getSlots());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
|
||||
return slot < insertHandler.getSlots() ? insertHandler.insertItem(slot, stack, simulate) : stack;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack extractItem(int slot, int amount, boolean simulate) {
|
||||
return slot >= insertHandler.getSlots() ? extractHandler.extractItem(slot - insertHandler.getSlots(), amount, simulate) : ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotLimit(int slot) {
|
||||
return slot < insertHandler.getSlots() ? insertHandler.getSlotLimit(slot) : extractHandler.getSlotLimit(slot - insertHandler.getSlots());
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public class TileSolderer extends TileNode<NetworkNodeSolderer> {
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(facing == EnumFacing.DOWN ? getNode().getResult() : getNode().getItems());
|
||||
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(getNode().getItems());
|
||||
}
|
||||
|
||||
return super.getCapability(capability, facing);
|
||||
|
||||
Reference in New Issue
Block a user