diff --git a/src/main/java/mekanism/common/integration/OreDictManager.java b/src/main/java/mekanism/common/integration/OreDictManager.java index 88cab5314..50cc732d7 100644 --- a/src/main/java/mekanism/common/integration/OreDictManager.java +++ b/src/main/java/mekanism/common/integration/OreDictManager.java @@ -19,6 +19,7 @@ import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.RecipeHandler.Recipe; import mekanism.common.util.MekanismUtils; import mekanism.common.util.StackUtils; +import mekanism.common.world.DummyWorld; import net.minecraft.block.BlockPlanks; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -402,6 +403,7 @@ public final class OreDictManager { return false; } }; + DummyWorld dummyWorld = new DummyWorld(); InventoryCrafting tempCrafting = new InventoryCrafting(tempContainer, 3, 3); @@ -414,17 +416,17 @@ public final class OreDictManager { for (ItemStack logEntry : logs) { if (logEntry.getItemDamage() == OreDictionary.WILDCARD_VALUE) { for (int j = 0; j < 16; j++) { - addSawmillLog(tempCrafting, new ItemStack(logEntry.getItem(), 1, j)); + addSawmillLog(tempCrafting, new ItemStack(logEntry.getItem(), 1, j), dummyWorld); } } else { - addSawmillLog(tempCrafting, StackUtils.size(logEntry, 1)); + addSawmillLog(tempCrafting, StackUtils.size(logEntry, 1), dummyWorld); } } } - private static void addSawmillLog(InventoryCrafting tempCrafting, ItemStack log) { + private static void addSawmillLog(InventoryCrafting tempCrafting, ItemStack log, DummyWorld world) { tempCrafting.setInventorySlotContents(0, log); - ItemStack resultEntry = MekanismUtils.findMatchingRecipe(tempCrafting, null); + ItemStack resultEntry = MekanismUtils.findMatchingRecipe(tempCrafting, world); if (!resultEntry.isEmpty()) { RecipeHandler.addPrecisionSawmillRecipe(log, StackUtils.size(resultEntry, 6), new ItemStack(MekanismItems.Sawdust), diff --git a/src/main/java/mekanism/common/world/DummyWorld.java b/src/main/java/mekanism/common/world/DummyWorld.java new file mode 100644 index 000000000..8923a259c --- /dev/null +++ b/src/main/java/mekanism/common/world/DummyWorld.java @@ -0,0 +1,31 @@ +package mekanism.common.world; + +import net.minecraft.world.DimensionType; +import net.minecraft.world.World; +import net.minecraft.world.WorldProvider; +import net.minecraft.world.chunk.IChunkProvider; + +/** + * Dummy object for providing something to CraftingManager#findMatchingRecipe during startup, to prevent in-dev non-null assertions from breaking things + */ +public class DummyWorld extends World { + + public DummyWorld() { + super(null, null, new WorldProvider() { + @Override + public DimensionType getDimensionType() { + return DimensionType.OVERWORLD; + } + }, null, false); + } + + @Override + protected IChunkProvider createChunkProvider() { + throw new UnsupportedOperationException(); + } + + @Override + protected boolean isChunkLoaded(int x, int z, boolean allowEmpty) { + return false; + } +}