Made TileAssemblyTable aware of OreDictionary.
This commit is contained in:
parent
da4ec07112
commit
400cde7d78
7 changed files with 77 additions and 18 deletions
15
buildcraft_resources/changelog/3.6.0
Normal file
15
buildcraft_resources/changelog/3.6.0
Normal file
|
@ -0,0 +1,15 @@
|
|||
|
||||
#3.6.0
|
||||
|
||||
- Added: Oil biomes! Additional changes to oil generation. (CovertJaguar)
|
||||
- Added: Pump control list. Can be used to prohibit the pumping of specific liquids in specific dimensions. (immibis)
|
||||
- Changed: Rewrote the Auto Crafting Table from the ground up. Now called "Auto Workbench". 100 % compatible with vanilla hoppers. Items that cannot stack can't be used in them anymore. They will not pull from adjacent inventories anymore, use hoppers/chutes instead. Crafting now has a time cost, the auto workbench does however not require power. (CovertJaguar)
|
||||
- Changed: Improved oil physics to produce behaviour between water and lava. (CovertJaguar)
|
||||
- Changed: Oil is now flammable. (viliml, Krapht, CovertJaguar)
|
||||
- Changed: Stirling engine only accepts valid fuels from pipes. Combustion engines accepts liquids containers and ice.
|
||||
- Bugfix: Several fixes to the laser crafting table. (CovertJaguar)
|
||||
- Bugfix: Pipe wire state now persists on reload. (target-san)
|
||||
- Bugfix: Removed builder crafting recipe, builder from creative inventory. (mcrobin4002, SirSengir)
|
||||
- Bugfix: Disabled grass facades. (Krapht)
|
||||
- Bugfix: Fixed crash on facade removal. (Flow86)
|
||||
- Bugfix: Fixed addToRandomInventory. (Flow86, CovertJaguar)
|
|
@ -9,7 +9,7 @@ package buildcraft.core.gui;
|
|||
|
||||
import buildcraft.core.gui.slots.IPhantomSlot;
|
||||
import buildcraft.core.gui.slots.SlotBase;
|
||||
import buildcraft.core.inventory.StackMergeHelper;
|
||||
import buildcraft.core.inventory.StackHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
@ -18,7 +18,7 @@ import net.minecraft.item.ItemStack;
|
|||
|
||||
public abstract class BuildCraftContainer extends Container {
|
||||
|
||||
private final StackMergeHelper MERGE_HELPER = new StackMergeHelper();
|
||||
private final StackHelper MERGE_HELPER = new StackHelper();
|
||||
private int inventorySize;
|
||||
|
||||
public BuildCraftContainer(int inventorySize) {
|
||||
|
|
|
@ -10,9 +10,11 @@
|
|||
package buildcraft.core.inventory;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class StackMergeHelper {
|
||||
public class StackHelper {
|
||||
|
||||
/* STACK MERGING */
|
||||
/**
|
||||
* Checks if two ItemStacks are identical enough to be merged
|
||||
* @param stack1 - The first stack
|
||||
|
@ -45,4 +47,49 @@ public class StackMergeHelper {
|
|||
return mergeCount;
|
||||
}
|
||||
|
||||
/* ITEM COMPARISONS */
|
||||
|
||||
/**
|
||||
* Determines whether the given itemstacks should be considered equivalent for crafting purposes.
|
||||
* @param base The stack to compare to.
|
||||
* @param comparison The stack to compare.
|
||||
* @param oreDictionary true to take the Forge OreDictionary into account.
|
||||
* @return true if comparison should be considered a crafting equivalent for base.
|
||||
*/
|
||||
public boolean isCraftingEquivalent(ItemStack base, ItemStack comparison, boolean oreDictionary) {
|
||||
if(isIdenticalItem(base, comparison))
|
||||
return true;
|
||||
|
||||
if(oreDictionary) {
|
||||
int idBase = OreDictionary.getOreID(base);
|
||||
int idComp = OreDictionary.getOreID(comparison);
|
||||
if(idBase >= 0 && idComp >= 0) {
|
||||
if(idBase == idComp)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares item id, damage and NBT. Accepts wildcard damage in the base itemstack.
|
||||
* @param base The stack to compare to.
|
||||
* @param comparison The stack to compare.
|
||||
* @return true if id, damage and NBT match.
|
||||
*/
|
||||
public boolean isIdenticalItem(ItemStack base, ItemStack comparison) {
|
||||
if (base == null || comparison == null)
|
||||
return false;
|
||||
|
||||
if (base.itemID != comparison.itemID)
|
||||
return false;
|
||||
|
||||
if (base.getItemDamage() != OreDictionary.WILDCARD_VALUE)
|
||||
if (base.getItemDamage() != comparison.getItemDamage())
|
||||
return false;
|
||||
|
||||
return ItemStack.areItemStackTagsEqual(base, comparison);
|
||||
}
|
||||
|
||||
}
|
|
@ -9,7 +9,7 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
|
||||
public class TransactorSimple extends Transactor {
|
||||
|
||||
protected static final StackMergeHelper MERGE_HELPER = new StackMergeHelper();
|
||||
protected static final StackHelper MERGE_HELPER = new StackHelper();
|
||||
protected IInventory inventory;
|
||||
|
||||
public TransactorSimple(IInventory inventory) {
|
||||
|
|
|
@ -58,6 +58,7 @@ public class Utils {
|
|||
public static float pipeNormalSpeed = 0.01F;
|
||||
private static final List<ForgeDirection> directions = new ArrayList<ForgeDirection>(Arrays.asList(ForgeDirection.VALID_DIRECTIONS));
|
||||
|
||||
/* IINVENTORY HELPERS */
|
||||
/**
|
||||
* Tries to add the passed stack to any valid inventories around the given
|
||||
* coordinates.
|
||||
|
@ -186,6 +187,7 @@ public class Utils {
|
|||
}
|
||||
}
|
||||
|
||||
/* STACK DROPS */
|
||||
public static void dropItems(World world, ItemStack stack, int i, int j, int k) {
|
||||
if (stack.stackSize <= 0) {
|
||||
return;
|
||||
|
|
|
@ -19,7 +19,7 @@ import net.minecraft.inventory.InventoryCrafting;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import buildcraft.core.inventory.StackMergeHelper;
|
||||
import buildcraft.core.inventory.StackHelper;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.CraftingHelper;
|
||||
import buildcraft.core.inventory.SimpleInventory;
|
||||
|
@ -33,7 +33,7 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
|
||||
public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory {
|
||||
|
||||
private static final StackMergeHelper MERGE_HELPER = new StackMergeHelper();
|
||||
private static final StackHelper MERGE_HELPER = new StackHelper();
|
||||
public static final int SLOT_RESULT = 0;
|
||||
public static final int CRAFT_TIME = 256;
|
||||
public static final int UPDATE_TIME = 16;
|
||||
|
|
|
@ -17,6 +17,7 @@ import buildcraft.api.recipes.AssemblyRecipe;
|
|||
import buildcraft.api.transport.IPipeConnection;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.IMachine;
|
||||
import buildcraft.core.inventory.StackHelper;
|
||||
import buildcraft.core.network.PacketIds;
|
||||
import buildcraft.core.network.PacketUpdate;
|
||||
import buildcraft.core.network.TileNetworkData;
|
||||
|
@ -26,6 +27,8 @@ import buildcraft.core.utils.Utils;
|
|||
|
||||
public class TileAssemblyTable extends TileEntity implements IMachine, IInventory, IPipeConnection, ILaserTarget {
|
||||
|
||||
private final StackHelper STACK_HELPER = new StackHelper();
|
||||
|
||||
ItemStack[] items = new ItemStack[12];
|
||||
|
||||
LinkedList<AssemblyRecipe> plannedOutput = new LinkedList<AssemblyRecipe>();
|
||||
|
@ -114,7 +117,7 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
|
|||
continue; // Broken out of large if statement, increases clarity
|
||||
}
|
||||
|
||||
if (items[i].isItemEqual(in)) {
|
||||
if (STACK_HELPER.isCraftingEquivalent(in, items[i], true)) {
|
||||
|
||||
int supply = items[i].stackSize;
|
||||
int toBeFound = in.stackSize - found;
|
||||
|
@ -159,6 +162,7 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
|
|||
return energyStored / currentRecipe.energy * ratio;
|
||||
}
|
||||
|
||||
/* IINVENTORY */
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return items.length;
|
||||
|
@ -212,17 +216,8 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
|
|||
return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChest() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeChest() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@Override public void openChest() {}
|
||||
@Override public void closeChest() {}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
|
|
Loading…
Reference in a new issue