Skip to content

Commit 381d009

Browse files
formatting
1 parent 84a29ae commit 381d009

9 files changed

Lines changed: 88 additions & 69 deletions

File tree

src/main/java/gregtech/api/capability/INotifiableHandler.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ public interface INotifiableHandler {
1717

1818
default <T> void addToNotifiedList(MetaTileEntity metaTileEntity, T handler, boolean isExport) {
1919
if (metaTileEntity != null && metaTileEntity.isValid()) {
20-
if (isExport) metaTileEntity.addNotifiedOutput(handler);
21-
else metaTileEntity.addNotifiedInput(handler);
20+
if (isExport) {
21+
metaTileEntity.addNotifiedOutput(handler);
22+
} else {
23+
metaTileEntity.addNotifiedInput(handler);
24+
}
2225
}
2326
}
2427

src/main/java/gregtech/api/capability/impl/AbstractRecipeLogic.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,18 +191,18 @@ protected void trySearchNewRecipe() {
191191
// see if the last recipe we used still works
192192
if (this.previousRecipe != null && this.previousRecipe.matches(false, importInventory, importFluids))
193193
currentRecipe = this.previousRecipe;
194-
// If there is no active recipe, then we need to find one.
194+
// If there is no active recipe, then we need to find one.
195195
else {
196196
currentRecipe = findRecipe(maxVoltage, importInventory, importFluids);
197197
}
198198
// If a recipe was found, then inputs were valid.
199199
if (currentRecipe != null) {
200200
this.invalidInputsForRecipes = false;
201201
this.previousRecipe = currentRecipe;
202-
// Add-ons may Override findRecipe method but not trySearchNewRecipe, in that case
203-
// they may return a null recipe. Since we only check for items and fluid here, having
204-
// findRecipe return a null recipe with isOutputsFull being true, means we have a valid
205-
// recipe in the input waiting for space in the output.
202+
// Add-ons may Override findRecipe method but not trySearchNewRecipe, in that case
203+
// they may return a null recipe. Since we only check for items and fluid here, having
204+
// findRecipe return a null recipe with isOutputsFull being true, means we have a valid
205+
// recipe in the input waiting for space in the output.
206206
} else this.invalidInputsForRecipes = !this.isOutputsFull;
207207

208208
// proceed if we have a usable recipe.

src/main/java/gregtech/api/metatileentity/MetaTileEntity.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public final String getMetaFullName() {
259259
return getMetaName() + ".name";
260260
}
261261

262-
public <T> void addNotifiedInput (T input) {
262+
public <T> void addNotifiedInput(T input) {
263263
if (input instanceof IItemHandlerModifiable) {
264264
if (!notifiedItemInputList.contains(input)) {
265265
this.notifiedItemInputList.add((IItemHandlerModifiable) input);
@@ -271,7 +271,7 @@ public <T> void addNotifiedInput (T input) {
271271
}
272272
}
273273

274-
public <T> void addNotifiedOutput (T output) {
274+
public <T> void addNotifiedOutput(T output) {
275275
if (output instanceof IItemHandlerModifiable) {
276276
if (!notifiedItemOutputList.contains(output)) {
277277
this.notifiedItemOutputList.add((IItemHandlerModifiable) output);
@@ -283,14 +283,14 @@ public <T> void addNotifiedOutput (T output) {
283283
}
284284
}
285285

286-
public <T> void removeNotifiedInput (T input) {
286+
public <T> void removeNotifiedInput(T input) {
287287
if (input instanceof IItemHandlerModifiable)
288288
this.notifiedItemInputList.remove(input);
289289
else if (input instanceof FluidTank)
290290
this.notifiedFluidInputList.remove(input);
291291
}
292292

293-
public <T> void removeNotifiedOutput (T input) {
293+
public <T> void removeNotifiedOutput(T input) {
294294
if (input instanceof IItemHandlerModifiable)
295295
this.notifiedItemOutputList.remove(input);
296296
else if (input instanceof FluidTank)

src/main/java/gregtech/api/metatileentity/WorkableTieredMetaTileEntity.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,21 @@ public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation,
5454
@Override
5555
protected IItemHandlerModifiable createImportItemHandler() {
5656
if (workable == null) return new ItemStackHandler(0);
57-
return new NotifiableItemStackHandler(workable.recipeMap.getMaxInputs(), this,false);
57+
return new NotifiableItemStackHandler(workable.recipeMap.getMaxInputs(), this, false);
5858
}
5959

6060
@Override
6161
protected IItemHandlerModifiable createExportItemHandler() {
6262
if (workable == null) return new ItemStackHandler(0);
63-
return new NotifiableItemStackHandler(workable.recipeMap.getMaxOutputs(), this,true);
63+
return new NotifiableItemStackHandler(workable.recipeMap.getMaxOutputs(), this, true);
6464
}
6565

6666
@Override
6767
protected FluidTankList createImportFluidHandler() {
6868
if (workable == null) return new FluidTankList(false);
6969
FilteredFluidHandler[] fluidImports = new FilteredFluidHandler[workable.recipeMap.getMaxFluidInputs()];
7070
for (int i = 0; i < fluidImports.length; i++) {
71-
NotifiableFilteredFluidHandler filteredFluidHandler = new NotifiableFilteredFluidHandler(getInputTankCapacity(i),this,false);
71+
NotifiableFilteredFluidHandler filteredFluidHandler = new NotifiableFilteredFluidHandler(getInputTankCapacity(i), this, false);
7272
filteredFluidHandler.setFillPredicate(this::canInputFluid);
7373
fluidImports[i] = filteredFluidHandler;
7474
}
@@ -80,7 +80,7 @@ protected FluidTankList createExportFluidHandler() {
8080
if (workable == null) return new FluidTankList(false);
8181
FluidTank[] fluidExports = new FluidTank[workable.recipeMap.getMaxFluidOutputs()];
8282
for (int i = 0; i < fluidExports.length; i++) {
83-
fluidExports[i] = new NotifiableFluidTank(getOutputTankCapacity(i),this,true);
83+
fluidExports[i] = new NotifiableFluidTank(getOutputTankCapacity(i), this, true);
8484
}
8585
return new FluidTankList(false, fluidExports);
8686
}

src/main/java/gregtech/api/metatileentity/multiblock/IMultiblockPart.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ public interface IMultiblockPart {
1111
void removeFromMultiBlock(MultiblockControllerBase controllerBase);
1212

1313
default void setupNotifiableMetaTileEntity(MetaTileEntity metaTileEntity) {
14-
1514
}
15+
1616
}

src/main/java/gregtech/common/metatileentities/electric/multiblockpart/MetaTileEntityItemBus.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ private int getInventorySize() {
7171

7272
@Override
7373
protected IItemHandlerModifiable createExportItemHandler() {
74-
return isExportHatch ? new NotifiableItemStackHandler(getInventorySize(),getController(),true) : new ItemStackHandler(0);
74+
return isExportHatch ? new NotifiableItemStackHandler(getInventorySize(), getController(), true) : new ItemStackHandler(0);
7575
}
7676

7777
@Override
7878
protected IItemHandlerModifiable createImportItemHandler() {
79-
return isExportHatch ? new ItemStackHandler(0) : new NotifiableItemStackHandler(getInventorySize(),getController(), false);
79+
return isExportHatch ? new ItemStackHandler(0) : new NotifiableItemStackHandler(getInventorySize(), getController(), false);
8080
}
8181

8282
@Override
@@ -92,10 +92,11 @@ public void registerAbilities(List<IItemHandlerModifiable> abilityList) {
9292
@Override
9393
public void setupNotifiableMetaTileEntity(MetaTileEntity metaTileEntity) {
9494
NotifiableItemStackHandler handler = null;
95-
if (isExportHatch && getExportItems() instanceof NotifiableItemStackHandler)
95+
if (isExportHatch && getExportItems() instanceof NotifiableItemStackHandler) {
9696
handler = (NotifiableItemStackHandler) getExportItems();
97-
else if (!isExportHatch && getImportItems() instanceof NotifiableItemStackHandler)
97+
} else if (!isExportHatch && getImportItems() instanceof NotifiableItemStackHandler) {
9898
handler = (NotifiableItemStackHandler) getImportItems();
99+
}
99100
if (handler != null) {
100101
handler.setNotifiableMetaTileEntity(metaTileEntity);
101102
handler.addToNotifiedList(this, handler, isExportHatch);

src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityMultiFurnace.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ protected void trySearchNewRecipe() {
111111
//otherwise, we need to recompute it for new ingredients
112112
//but technically, it means we can cache multi smelter recipe, but changing inputs have more priority
113113
if (hasNotifiedInputs() ||
114-
previousRecipe == null ||
115-
!previousRecipe.matches(false,importInventory,importFluids)) {
114+
previousRecipe == null ||
115+
!previousRecipe.matches(false, importInventory, importFluids)) {
116116
//Inputs changed, try searching new recipe for given inputs
117117
currentRecipe = findRecipe(maxVoltage, importInventory, importFluids);
118-
} else {
118+
} else {
119119
//if previous recipe still matches inputs, try to use it
120120
currentRecipe = previousRecipe;
121121
}

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

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,41 +29,52 @@ public void trySearchNewRecipe() {
2929

3030
// Create an empty recipe map to work with
3131
RecipeMap<SimpleRecipeBuilder> map = new RecipeMap<>("chemical_reactor",
32-
0,
33-
2,
34-
0,
35-
2,
36-
0,
37-
3,
38-
0,
39-
2,
40-
new SimpleRecipeBuilder().EUt(30));
32+
0,
33+
2,
34+
0,
35+
2,
36+
0,
37+
3,
38+
0,
39+
2,
40+
new SimpleRecipeBuilder().EUt(30));
4141

4242
MetaTileEntity at =
43-
GregTechAPI.registerMetaTileEntity(190,
44-
new SimpleMachineMetaTileEntity(
45-
new ResourceLocation(GTValues.MODID,"chemical_reactor.lv"),
46-
map,
47-
Textures.CHEMICAL_REACTOR_OVERLAY,
48-
1));
43+
GregTechAPI.registerMetaTileEntity(190,
44+
new SimpleMachineMetaTileEntity(
45+
new ResourceLocation(GTValues.MODID, "chemical_reactor.lv"),
46+
map,
47+
Textures.CHEMICAL_REACTOR_OVERLAY,
48+
1));
4949

5050
MetaTileEntity atte = new MetaTileEntityHolder().setMetaTileEntity(at);
5151
atte.getHolder().setWorld(world);
5252
map.recipeBuilder()
53-
.inputs(new ItemStack(Blocks.COBBLESTONE))
54-
.outputs(new ItemStack(Blocks.STONE))
55-
.EUt(1).duration(1)
56-
.buildAndRegister();
53+
.inputs(new ItemStack(Blocks.COBBLESTONE))
54+
.outputs(new ItemStack(Blocks.STONE))
55+
.EUt(1).duration(1)
56+
.buildAndRegister();
5757

5858
AbstractRecipeLogic arl = new AbstractRecipeLogic(atte, map) {
5959
@Override
60-
protected long getEnergyStored() { return Long.MAX_VALUE; }
60+
protected long getEnergyStored() {
61+
return Long.MAX_VALUE;
62+
}
63+
6164
@Override
62-
protected long getEnergyCapacity() { return Long.MAX_VALUE; }
65+
protected long getEnergyCapacity() {
66+
return Long.MAX_VALUE;
67+
}
68+
6369
@Override
64-
protected boolean drawEnergy(int recipeEUt) { return true; }
70+
protected boolean drawEnergy(int recipeEUt) {
71+
return true;
72+
}
73+
6574
@Override
66-
protected long getMaxVoltage() { return 32; }
75+
protected long getMaxVoltage() {
76+
return 32;
77+
}
6778
};
6879

6980
arl.isOutputsFull = false;
@@ -94,7 +105,7 @@ public void trySearchNewRecipe() {
94105
arl.update();
95106
assertEquals(prev, arl.previousRecipe);
96107
assertTrue(AbstractRecipeLogic.areItemStacksEqual(arl.getOutputInventory().getStackInSlot(0),
97-
new ItemStack(Blocks.STONE, 1)));
108+
new ItemStack(Blocks.STONE, 1)));
98109
assertTrue(arl.isActive);
99110

100111
// Complete the second iteration, but the machine stops because its output is now full

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

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import org.junit.BeforeClass;
2828
import org.junit.Test;
29+
2930
import java.lang.reflect.Field;
3031

3132
import static org.junit.Assert.*;
@@ -49,15 +50,15 @@ public void trySearchNewRecipe() {
4950

5051
// Create an empty recipe map to work with
5152
RecipeMap<BlastRecipeBuilder> map = new RecipeMap<>("blast_furnace",
52-
1,
53-
3,
54-
1,
55-
2,
56-
0,
57-
1,
58-
0,
59-
1,
60-
new BlastRecipeBuilder().EUt(32));
53+
1,
54+
3,
55+
1,
56+
2,
57+
0,
58+
1,
59+
0,
60+
1,
61+
new BlastRecipeBuilder().EUt(32));
6162

6263
RecipeMaps.BLAST_RECIPES.recipeBuilder()
6364
.inputs(new ItemStack(Blocks.COBBLESTONE))
@@ -68,19 +69,21 @@ public void trySearchNewRecipe() {
6869

6970
RecipeMapMultiblockController mbt =
7071
GregTechAPI.registerMetaTileEntity(511,
71-
new MetaTileEntityElectricBlastFurnace(
72-
// super function calls the world, which equal null in test
73-
new ResourceLocation(GTValues.MODID, "electric_blast_furnace")) {
74-
@Override
75-
protected IBlockState getCasingState() {
76-
return null;
77-
}
78-
// function checks for the temperature of the recipe against the coils
79-
@Override
80-
public boolean checkRecipe(Recipe recipe, boolean consumeIfSuccess) {
81-
return true;
82-
}
83-
});
72+
new MetaTileEntityElectricBlastFurnace(
73+
// super function calls the world, which equal null in test
74+
new ResourceLocation(GTValues.MODID, "electric_blast_furnace")) {
75+
@Override
76+
protected void reinitializeStructurePattern() {
77+
78+
}
79+
80+
// function checks for the temperature of the recipe against the coils
81+
@Override
82+
public boolean checkRecipe(Recipe recipe, boolean consumeIfSuccess) {
83+
return true;
84+
}
85+
});
86+
8487
//isValid() check in the dirtying logic requires both a metatileentity and a holder
8588
try {
8689
Field field = MetaTileEntity.class.getDeclaredField("holder");
@@ -179,6 +182,7 @@ protected boolean drawEnergy(int recipeEUt) {
179182
protected long getMaxVoltage() {
180183
return 32;
181184
}
185+
182186
// since the hatches were not really added to a valid multiblock structure,
183187
// refer to their inventories directly
184188
@Override

0 commit comments

Comments
 (0)