Skip to content

Commit 15feb38

Browse files
fix tests due to world being null
1 parent 2ab30f3 commit 15feb38

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/test/java/gregtech/api/capability/impl/AbstractRecipeLogicTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
import gregtech.api.recipes.*;
66
import gregtech.api.recipes.builders.*;
77
import gregtech.api.render.*;
8+
import gregtech.api.util.world.DummyWorld;
89
import net.minecraft.init.*;
910
import net.minecraft.item.*;
11+
import net.minecraft.tileentity.TileEntity;
1012
import net.minecraft.util.*;
13+
import net.minecraft.world.World;
1114
import org.junit.*;
1215

1316
import static org.junit.Assert.*;
@@ -22,6 +25,8 @@ public static void init() {
2225
@Test
2326
public void trySearchNewRecipe() {
2427

28+
World world = DummyWorld.INSTANCE;
29+
2530
// Create an empty recipe map to work with
2631
RecipeMap<SimpleRecipeBuilder> map = new RecipeMap<>("chemical_reactor",
2732
0,
@@ -43,6 +48,7 @@ public void trySearchNewRecipe() {
4348
1));
4449

4550
MetaTileEntity atte = new MetaTileEntityHolder().setMetaTileEntity(at);
51+
atte.getHolder().setWorld(world);
4652
map.recipeBuilder()
4753
.inputs(new ItemStack(Blocks.COBBLESTONE))
4854
.outputs(new ItemStack(Blocks.STONE))
@@ -72,14 +78,14 @@ public void trySearchNewRecipe() {
7278
// put an item in the inventory that will trigger recipe recheck
7379
arl.getInputInventory().insertItem(0, new ItemStack(Blocks.COBBLESTONE, 16), false);
7480
// Inputs change. did we detect it ?
75-
assertTrue(arl.getMetaTileEntity().isInputsDirty());
81+
assertTrue(arl.hasNotifiedInputs());
7682
arl.trySearchNewRecipe();
7783
assertFalse(arl.invalidInputsForRecipes);
7884
assertNotNull(arl.previousRecipe);
7985
assertTrue(arl.isActive);
8086
assertEquals(15, arl.getInputInventory().getStackInSlot(0).getCount());
8187
//assert the consumption of the inputs did not mark the arl to look for a new recipe
82-
assertFalse(arl.getMetaTileEntity().isInputsDirty());
88+
assertFalse(arl.hasNotifiedInputs());
8389

8490
// Save a reference to the old recipe so we can make sure it's getting reused
8591
Recipe prev = arl.previousRecipe;

src/test/java/gregtech/api/capability/impl/MultiblockRecipeLogicTest.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import gregtech.api.recipes.RecipeMap;
1212
import gregtech.api.recipes.RecipeMaps;
1313
import gregtech.api.recipes.builders.BlastRecipeBuilder;
14+
import gregtech.api.util.world.DummyWorld;
1415
import gregtech.common.metatileentities.electric.multiblockpart.MetaTileEntityFluidHatch;
1516
import gregtech.common.metatileentities.electric.multiblockpart.MetaTileEntityItemBus;
1617
import gregtech.common.metatileentities.electric.multiblockpart.MetaTileEntityMultiblockPart;
@@ -20,6 +21,7 @@
2021
import net.minecraft.init.Bootstrap;
2122
import net.minecraft.item.ItemStack;
2223
import net.minecraft.util.ResourceLocation;
24+
import net.minecraft.world.World;
2325
import net.minecraftforge.items.IItemHandlerModifiable;
2426

2527
import org.junit.BeforeClass;
@@ -43,6 +45,8 @@ private static ResourceLocation gregtechId(String name) {
4345
@Test
4446
public void trySearchNewRecipe() {
4547

48+
World world = DummyWorld.INSTANCE;
49+
4650
// Create an empty recipe map to work with
4751
RecipeMap<BlastRecipeBuilder> map = new RecipeMap<>("blast_furnace",
4852
1,
@@ -94,6 +98,8 @@ public boolean checkRecipe(Recipe recipe, boolean consumeIfSuccess) {
9498
e.printStackTrace();
9599
}
96100

101+
mbt.getHolder().setWorld(world);
102+
97103
//Controller and isAttachedToMultiBlock need the world so we fake it here.
98104
MetaTileEntityItemBus importItemBus = new MetaTileEntityItemBus(gregtechId("item_bus.export.lv"), 1, false) {
99105
@Override
@@ -209,14 +215,14 @@ protected IMultipleTankHandler getOutputTank() {
209215
// put an item in the inventory that will trigger recipe recheck
210216
mbl.getInputInventory().insertItem(0, new ItemStack(Blocks.COBBLESTONE, 16), false);
211217
// Inputs change. did we detect it ?
212-
assertTrue(mbt.isInputsDirty());
218+
assertTrue(mbl.hasNotifiedInputs());
213219
mbl.trySearchNewRecipe();
214220
assertFalse(mbl.invalidInputsForRecipes);
215221
assertNotNull(mbl.previousRecipe);
216222
assertTrue(mbl.isActive);
217223
assertEquals(15, mbl.getInputInventory().getStackInSlot(0).getCount());
218224
//assert the consumption of the inputs did not mark the arl to look for a new recipe
219-
assertFalse(mbt.isInputsDirty());
225+
assertFalse(mbl.hasNotifiedInputs());
220226

221227
// Save a reference to the old recipe so we can make sure it's getting reused
222228
Recipe prev = mbl.previousRecipe;
@@ -244,7 +250,7 @@ protected IMultipleTankHandler getOutputTank() {
244250

245251
// Some room is freed in the output bus, so we can continue now.
246252
mbl.getOutputInventory().setStackInSlot(1, ItemStack.EMPTY);
247-
assertTrue(mbt.isOutputsDirty());
253+
assertTrue(mbl.hasNotifiedOutputs());
248254
mbl.updateWorkable();
249255
assertTrue(mbl.isActive);
250256
assertFalse(mbl.isOutputsFull);

0 commit comments

Comments
 (0)