mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
Merge branch '1.11' of https://github.com/aidancbrady/Mekanism into 1.11
# By Tom Elfring # Via GitHub (2) and Tom Elfring (1) * '1.11' of https://github.com/aidancbrady/Mekanism: Fix null Itemstacks in miner and recipes Fix IMC recipe removal
This commit is contained in:
commit
840de86d11
7 files changed
+35
-33
No files matched your search
@@ -23,7 +23,7 @@ import org.lwjgl.opengl.GL11;
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiDictionary extends GuiMekanism
|
||||
{
|
||||
public ItemStack itemType;
|
||||
public ItemStack itemType = ItemStack.EMPTY;
|
||||
|
||||
public GuiScrollList scrollList;
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ public class IMCHandler
|
||||
|
||||
for(Recipe type : Recipe.values())
|
||||
{
|
||||
if(msg.key.equalsIgnoreCase(type.getRecipeName() + "Recipe"))
|
||||
if(message.equalsIgnoreCase(type.getRecipeName() + "Recipe"))
|
||||
{
|
||||
MachineInput input = type.createInput(msg.getNBTValue());
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package mekanism.common.recipe;
|
||||
import java.util.HashMap;
|
||||
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismItems;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.RecipeUtils;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -28,7 +29,7 @@ public class ShapedMekanismRecipe implements IRecipe
|
||||
private static final int MAX_CRAFT_GRID_WIDTH = 3;
|
||||
private static final int MAX_CRAFT_GRID_HEIGHT = 3;
|
||||
|
||||
private ItemStack output = null;
|
||||
private ItemStack output = ItemStack.EMPTY;
|
||||
private Object[] input = null;
|
||||
|
||||
public int width = 0;
|
||||
@@ -227,7 +228,7 @@ public class ShapedMekanismRecipe implements IRecipe
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(target == null && slot != null)
|
||||
else if(target == null && !slot.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -259,7 +260,7 @@ public class ShapedMekanismRecipe implements IRecipe
|
||||
ItemStack result = InventoryUtils.loadFromNBT(nbtTags.getCompoundTag("result"));
|
||||
NBTTagList list = nbtTags.getTagList("input", NBT.TAG_COMPOUND);
|
||||
|
||||
if(result == null || list.tagCount() == 0)
|
||||
if(result.isEmpty() || list.tagCount() == 0)
|
||||
{
|
||||
Mekanism.logger.error("[Mekanism] Shaped recipe parse error: invalid result stack or input data list.");
|
||||
return null;
|
||||
|
||||
@@ -22,7 +22,7 @@ import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class ShapelessMekanismRecipe implements IRecipe
|
||||
{
|
||||
private ItemStack output = null;
|
||||
private ItemStack output = ItemStack.EMPTY;
|
||||
private ArrayList<Object> input = new ArrayList<Object>();
|
||||
|
||||
public ShapelessMekanismRecipe(Block result, Object... recipe){ this(new ItemStack(result), recipe); }
|
||||
@@ -98,7 +98,7 @@ public class ShapelessMekanismRecipe implements IRecipe
|
||||
{
|
||||
ItemStack slot = inv.getStackInSlot(x);
|
||||
|
||||
if(slot != null)
|
||||
if(!slot.isEmpty())
|
||||
{
|
||||
boolean inRecipe = false;
|
||||
Iterator<Object> req = required.iterator();
|
||||
@@ -158,7 +158,7 @@ public class ShapelessMekanismRecipe implements IRecipe
|
||||
ItemStack result = InventoryUtils.loadFromNBT(nbtTags.getCompoundTag("result"));
|
||||
NBTTagList list = nbtTags.getTagList("input", NBT.TAG_COMPOUND);
|
||||
|
||||
if(result == null || list.tagCount() == 0)
|
||||
if(result.isEmpty() || list.tagCount() == 0)
|
||||
{
|
||||
Mekanism.logger.error("[Mekanism] Shapeless recipe parse error: invalid result stack or input data list.");
|
||||
return null;
|
||||
|
||||
@@ -305,19 +305,19 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
|
||||
}
|
||||
}
|
||||
|
||||
if(doEject && delayTicks == 0 && !getTopEject(false, null).isEmpty() && getEjectInv() != null && getEjectTile() != null)
|
||||
if(doEject && delayTicks == 0 && !getTopEject(false, ItemStack.EMPTY).isEmpty() && getEjectInv() != null && getEjectTile() != null)
|
||||
{
|
||||
if(getEjectInv() instanceof IInventory)
|
||||
{
|
||||
ItemStack remains = InventoryUtils.putStackInInventory((IInventory)getEjectInv(), getTopEject(false, null), facing.getOpposite(), false);
|
||||
ItemStack remains = InventoryUtils.putStackInInventory((IInventory)getEjectInv(), getTopEject(false, ItemStack.EMPTY), facing.getOpposite(), false);
|
||||
|
||||
getTopEject(true, remains);
|
||||
}
|
||||
else if(CapabilityUtils.hasCapability(getEjectInv(), Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, facing.getOpposite()))
|
||||
{
|
||||
ItemStack rejected = TransporterUtils.insert(getEjectTile(), CapabilityUtils.getCapability(getEjectInv(), Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, facing.getOpposite()), getTopEject(false, null), null, true, 0);
|
||||
ItemStack rejected = TransporterUtils.insert(getEjectTile(), CapabilityUtils.getCapability(getEjectInv(), Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, facing.getOpposite()), getTopEject(false, ItemStack.EMPTY), null, true, 0);
|
||||
|
||||
if(TransporterManager.didEmit(getTopEject(false, null), rejected))
|
||||
if(TransporterManager.didEmit(getTopEject(false, ItemStack.EMPTY), rejected))
|
||||
{
|
||||
getTopEject(true, rejected);
|
||||
}
|
||||
@@ -396,8 +396,8 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
|
||||
}
|
||||
else {
|
||||
MinerFilter filter = replaceMap.get(index);
|
||||
|
||||
if(filter == null || (filter.replaceStack == null || !filter.requireStack))
|
||||
|
||||
if(filter == null || (filter.replaceStack.isEmpty() || !filter.requireStack))
|
||||
{
|
||||
world.setBlockToAir(obj.getPos());
|
||||
|
||||
@@ -443,7 +443,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public NonNullList<ItemStack> copy(NonNullList<ItemStack> stacks)
|
||||
|
||||
@@ -76,6 +76,7 @@ import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumFacing.Axis;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
@@ -1317,37 +1318,37 @@ public final class MekanismUtils
|
||||
*/
|
||||
public static ItemStack findMatchingRecipe(InventoryCrafting inv, World world)
|
||||
{
|
||||
ItemStack[] dmgItems = new ItemStack[2];
|
||||
NonNullList<ItemStack> dmgItems = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||
|
||||
for(int i = 0; i < inv.getSizeInventory(); i++)
|
||||
{
|
||||
if(inv.getStackInSlot(i) != null)
|
||||
if(!inv.getStackInSlot(i).isEmpty())
|
||||
{
|
||||
if(dmgItems[0] == null)
|
||||
if(dmgItems.get(0).isEmpty())
|
||||
{
|
||||
dmgItems[0] = inv.getStackInSlot(i);
|
||||
dmgItems.set(0, inv.getStackInSlot(i));
|
||||
}
|
||||
else {
|
||||
dmgItems[1] = inv.getStackInSlot(i);
|
||||
dmgItems.set(1, inv.getStackInSlot(i));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if((dmgItems[0] == null) || (dmgItems[0].getItem() == null))
|
||||
if((dmgItems.get(0).isEmpty()) || (dmgItems.get(0).getItem() == null))
|
||||
{
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if((dmgItems[1] != null) && (dmgItems[0].getItem() == dmgItems[1].getItem()) && (dmgItems[0].getCount() == 1) && (dmgItems[1].getCount() == 1) && dmgItems[0].getItem().isRepairable())
|
||||
if((!dmgItems.get(1).isEmpty()) && (dmgItems.get(0).getItem() == dmgItems.get(1).getItem()) && (dmgItems.get(0).getCount() == 1) && (dmgItems.get(1).getCount() == 1) && dmgItems.get(0).getItem().isRepairable())
|
||||
{
|
||||
Item theItem = dmgItems[0].getItem();
|
||||
int dmgDiff0 = theItem.getMaxDamage() - dmgItems[0].getItemDamage();
|
||||
int dmgDiff1 = theItem.getMaxDamage() - dmgItems[1].getItemDamage();
|
||||
Item theItem = dmgItems.get(0).getItem();
|
||||
int dmgDiff0 = theItem.getMaxDamage() - dmgItems.get(0).getItemDamage();
|
||||
int dmgDiff1 = theItem.getMaxDamage() - dmgItems.get(1).getItemDamage();
|
||||
int value = dmgDiff0 + dmgDiff1 + theItem.getMaxDamage() * 5 / 100;
|
||||
int solve = Math.max(0, theItem.getMaxDamage() - value);
|
||||
|
||||
return new ItemStack(dmgItems[0].getItem(), 1, solve);
|
||||
return new ItemStack(dmgItems.get(0).getItem(), 1, solve);
|
||||
}
|
||||
|
||||
List<IRecipe> list = (List<IRecipe>)((ArrayList<IRecipe>)CraftingManager.getInstance().getRecipeList()).clone();
|
||||
@@ -1360,7 +1361,7 @@ public final class MekanismUtils
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1383,7 +1384,7 @@ public final class MekanismUtils
|
||||
|
||||
/**
|
||||
* Whether or not a given EntityPlayer is considered an Op.
|
||||
* @param player - player to check
|
||||
* @param p - player to check
|
||||
* @return if the player has operator privileges
|
||||
*/
|
||||
public static boolean isOp(EntityPlayer p)
|
||||
|
||||
@@ -35,11 +35,11 @@ public class RecipeUtils
|
||||
{
|
||||
public static boolean areItemsEqualForCrafting(ItemStack target, ItemStack input)
|
||||
{
|
||||
if(target == null && input != null || target != null && input == null)
|
||||
if(target.isEmpty() && !input.isEmpty() || !target.isEmpty() && input.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if(target == null && input == null)
|
||||
else if(target.isEmpty() && input.isEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -202,7 +202,7 @@ public class RecipeUtils
|
||||
if(BasicBlockType.get(toReturn) == BasicBlockType.BIN)
|
||||
{
|
||||
int foundCount = 0;
|
||||
ItemStack foundType = null;
|
||||
ItemStack foundType = ItemStack.EMPTY;
|
||||
|
||||
for(int i = 0; i < 9; i++)
|
||||
{
|
||||
@@ -217,7 +217,7 @@ public class RecipeUtils
|
||||
}
|
||||
}
|
||||
|
||||
if(foundCount > 0 && foundType != null)
|
||||
if(foundCount > 0 && !foundType.isEmpty())
|
||||
{
|
||||
InventoryBin binInv = new InventoryBin(toReturn);
|
||||
binInv.setItemCount(foundCount);
|
||||
|
||||
Reference in new issue
Block a user