mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
Merge branch 'development' into 1.8.9
Huge merge with 202 conflicts, hopefully not *too* broken.
This commit is contained in:
commit
84336ec4d1
571 files changed
+10295
-4773
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package mekanism.common.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -8,11 +9,14 @@ import java.util.Map;
|
||||
import mekanism.api.energy.IEnergizedItem;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.api.util.StackUtils;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IEnergyCube;
|
||||
import mekanism.common.base.IFactory;
|
||||
import mekanism.common.base.ITierItem;
|
||||
import mekanism.common.block.BlockBasic.BasicType;
|
||||
import mekanism.common.block.states.BlockStateMachine;
|
||||
import mekanism.common.item.ItemBlockBasic;
|
||||
import mekanism.common.inventory.InventoryBin;
|
||||
import mekanism.common.recipe.ShapedMekanismRecipe;
|
||||
import mekanism.common.recipe.ShapelessMekanismRecipe;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -42,61 +46,37 @@ public class RecipeUtils
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!(target.getItem() instanceof IEnergizedItem) && !(input.getItem() instanceof IEnergizedItem) && !(target.getItem() instanceof IGasItem) && !(input.getItem() instanceof IGasItem))
|
||||
|
||||
if(target.getItemDamage() != input.getItemDamage() && target.getItemDamage() != OreDictionary.WILDCARD_VALUE)
|
||||
{
|
||||
if(target.getItemDamage() != input.getItemDamage() && target.getItemDamage() != OreDictionary.WILDCARD_VALUE)
|
||||
return false;
|
||||
}
|
||||
|
||||
if(target.getItem() instanceof IEnergyCube && input.getItem() instanceof IEnergyCube)
|
||||
{
|
||||
if(((IEnergyCube)target.getItem()).getEnergyCubeTier(target) != ((IEnergyCube)input.getItem()).getEnergyCubeTier(input))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(target.getItem() instanceof IEnergizedItem && input.getItem() instanceof IEnergizedItem)
|
||||
|
||||
if(target.getItem() instanceof ITierItem && input.getItem() instanceof ITierItem)
|
||||
{
|
||||
if(((ITierItem)target.getItem()).getBaseTier(target) != ((ITierItem)input.getItem()).getBaseTier(input))
|
||||
{
|
||||
if(((IEnergizedItem)target.getItem()).isMetadataSpecific(target) && ((IEnergizedItem)input.getItem()).isMetadataSpecific(input))
|
||||
{
|
||||
if(target.getItemDamage() != input.getItemDamage() && target.getItemDamage() != OreDictionary.WILDCARD_VALUE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if(target.getItem() instanceof IGasItem && input.getItem() instanceof IGasItem)
|
||||
}
|
||||
|
||||
if(target.getItem() instanceof IFactory && input.getItem() instanceof IFactory)
|
||||
{
|
||||
if(isFactory(target) && isFactory(input))
|
||||
{
|
||||
if(((IGasItem)target.getItem()).isMetadataSpecific(target) && ((IGasItem)input.getItem()).isMetadataSpecific(input))
|
||||
{
|
||||
if(target.getItemDamage() != input.getItemDamage() && target.getItemDamage() != OreDictionary.WILDCARD_VALUE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(target.getItem() instanceof IEnergyCube && input.getItem() instanceof IEnergyCube)
|
||||
{
|
||||
if(((IEnergyCube)target.getItem()).getEnergyCubeTier(target) != ((IEnergyCube)input.getItem()).getEnergyCubeTier(input))
|
||||
if(((IFactory)target.getItem()).getRecipeType(target) != ((IFactory)input.getItem()).getRecipeType(input))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(target.getItem() instanceof ItemBlockBasic && input.getItem() instanceof ItemBlockBasic)
|
||||
{
|
||||
if(((ItemBlockBasic)target.getItem()).getTier(target) != ((ItemBlockBasic)input.getItem()).getTier(input))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(target.getItem() instanceof IFactory && input.getItem() instanceof IFactory)
|
||||
{
|
||||
if(isFactory(target) && isFactory(input))
|
||||
{
|
||||
if(((IFactory)target.getItem()).getRecipeType(target) != ((IFactory)input.getItem()).getRecipeType(input))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -167,6 +147,74 @@ public class RecipeUtils
|
||||
((IGasItem)toReturn.getItem()).setGas(toReturn, gasFound);
|
||||
}
|
||||
}
|
||||
|
||||
if(toReturn.getItem() instanceof IFluidContainerItem)
|
||||
{
|
||||
FluidStack fluidFound = null;
|
||||
|
||||
for(int i = 0; i < 9; i++)
|
||||
{
|
||||
ItemStack itemstack = inv.getStackInSlot(i);
|
||||
|
||||
if(itemstack != null && itemstack.getItem() instanceof IFluidContainerItem)
|
||||
{
|
||||
FluidStack stored = ((IFluidContainerItem)itemstack.getItem()).getFluid(itemstack);
|
||||
|
||||
if(stored != null)
|
||||
{
|
||||
if(((IFluidContainerItem)toReturn.getItem()).fill(toReturn, stored, false) == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if(fluidFound == null)
|
||||
{
|
||||
fluidFound = stored;
|
||||
}
|
||||
else {
|
||||
if(fluidFound.getFluid() != stored.getFluid())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
fluidFound.amount += stored.amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(fluidFound != null)
|
||||
{
|
||||
fluidFound.amount = Math.min(((IFluidContainerItem)toReturn.getItem()).getCapacity(toReturn), fluidFound.amount);
|
||||
((IFluidContainerItem)toReturn.getItem()).fill(toReturn, fluidFound, true);
|
||||
}
|
||||
}
|
||||
|
||||
if(BasicType.get(toReturn) == BasicType.BIN)
|
||||
{
|
||||
int foundCount = 0;
|
||||
ItemStack foundType = null;
|
||||
|
||||
for(int i = 0; i < 9; i++)
|
||||
{
|
||||
ItemStack itemstack = inv.getStackInSlot(i);
|
||||
|
||||
if(BasicType.get(itemstack) == BasicType.BIN)
|
||||
{
|
||||
InventoryBin binInv = new InventoryBin(itemstack);
|
||||
|
||||
foundCount = binInv.getItemCount();
|
||||
foundType = binInv.getItemType();
|
||||
}
|
||||
}
|
||||
|
||||
if(foundCount > 0 && foundType != null)
|
||||
{
|
||||
InventoryBin binInv = new InventoryBin(toReturn);
|
||||
binInv.setItemCount(foundCount);
|
||||
binInv.setItemType(foundType);
|
||||
}
|
||||
}
|
||||
|
||||
if(BlockStateMachine.MachineType.get(toReturn) != null && BlockStateMachine.MachineType.get(toReturn).supportsUpgrades)
|
||||
{
|
||||
@@ -254,7 +302,7 @@ public class RecipeUtils
|
||||
|
||||
if(iterRecipe instanceof ShapedMekanismRecipe || iterRecipe instanceof ShapelessMekanismRecipe)
|
||||
{
|
||||
if(ItemStack.areItemStacksEqual(stack, iterRecipe.getRecipeOutput()))
|
||||
if(StackUtils.equalsWildcard(stack, iterRecipe.getRecipeOutput()))
|
||||
{
|
||||
iter.remove();
|
||||
}
|
||||
@@ -263,4 +311,21 @@ public class RecipeUtils
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static IRecipe getRecipeFromGrid(InventoryCrafting inv, World world)
|
||||
{
|
||||
List<IRecipe> list = new ArrayList<IRecipe>(CraftingManager.getInstance().getRecipeList());
|
||||
|
||||
for(Iterator<IRecipe> iter = list.iterator(); iter.hasNext();)
|
||||
{
|
||||
IRecipe recipe = iter.next();
|
||||
|
||||
if(recipe.matches(inv, world))
|
||||
{
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user