-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix machine menus displaying wrong crafting cost
- Loading branch information
1 parent
1d2f449
commit 3cc3518
Showing
7 changed files
with
71 additions
and
124 deletions.
There are no files selected for viewing
36 changes: 3 additions & 33 deletions
36
src/main/java/com/github/elenterius/biomancy/block/biolab/BioLabStateData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,18 @@ | ||
package com.github.elenterius.biomancy.block.biolab; | ||
|
||
import com.github.elenterius.biomancy.block.state.RecipeCraftingStateData; | ||
import com.github.elenterius.biomancy.block.state.FuelConsumingRecipeCraftingStateData; | ||
import com.github.elenterius.biomancy.recipe.BioLabRecipe; | ||
import com.github.elenterius.biomancy.util.fuel.IFuelHandler; | ||
|
||
public class BioLabStateData extends RecipeCraftingStateData<BioLabRecipe> { | ||
|
||
public static final int FUEL_INDEX = 2; | ||
public final IFuelHandler fuelHandler; | ||
public class BioLabStateData extends FuelConsumingRecipeCraftingStateData<BioLabRecipe> { | ||
|
||
public BioLabStateData(IFuelHandler fuelHandler) { | ||
this.fuelHandler = fuelHandler; | ||
super(fuelHandler); | ||
} | ||
|
||
@Override | ||
protected Class<BioLabRecipe> getRecipeType() { | ||
return BioLabRecipe.class; | ||
} | ||
|
||
@Override | ||
public int getFuelCost() { | ||
return fuelHandler.getFuelCost(timeForCompletion); | ||
} | ||
|
||
@Override | ||
public int get(int index) { | ||
validateIndex(index); | ||
if (index == TIME_INDEX) return timeElapsed; | ||
else if (index == TIME_FOR_COMPLETION_INDEX) return timeForCompletion; | ||
else if (index == FUEL_INDEX) return fuelHandler.getFuelAmount(); | ||
return 0; | ||
} | ||
|
||
@Override | ||
public void set(int index, int value) { | ||
validateIndex(index); | ||
if (index == TIME_INDEX) timeElapsed = value; | ||
else if (index == TIME_FOR_COMPLETION_INDEX) timeForCompletion = value; | ||
else if (index == FUEL_INDEX) fuelHandler.setFuelAmount(value); | ||
} | ||
|
||
@Override | ||
public int getCount() { | ||
return 3; | ||
} | ||
|
||
} |
42 changes: 3 additions & 39 deletions
42
src/main/java/com/github/elenterius/biomancy/block/decomposer/DecomposerStateData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,18 @@ | ||
package com.github.elenterius.biomancy.block.decomposer; | ||
|
||
import com.github.elenterius.biomancy.block.state.RecipeCraftingStateData; | ||
import com.github.elenterius.biomancy.block.state.FuelConsumingRecipeCraftingStateData; | ||
import com.github.elenterius.biomancy.recipe.DecomposerRecipe; | ||
import com.github.elenterius.biomancy.util.fuel.IFuelHandler; | ||
|
||
public class DecomposerStateData extends RecipeCraftingStateData<DecomposerRecipe> { | ||
|
||
public static final int FUEL_INDEX = 2; | ||
|
||
public final IFuelHandler fuelHandler; | ||
public class DecomposerStateData extends FuelConsumingRecipeCraftingStateData<DecomposerRecipe> { | ||
|
||
public DecomposerStateData(IFuelHandler fuelHandler) { | ||
this.fuelHandler = fuelHandler; | ||
super(fuelHandler); | ||
} | ||
|
||
@Override | ||
protected Class<DecomposerRecipe> getRecipeType() { | ||
return DecomposerRecipe.class; | ||
} | ||
|
||
@Override | ||
public int getFuelCost() { | ||
return fuelHandler.getFuelCost(timeForCompletion); | ||
} | ||
|
||
@Override | ||
public int get(int index) { | ||
validateIndex(index); | ||
return switch (index) { | ||
case TIME_INDEX -> timeElapsed; | ||
case TIME_FOR_COMPLETION_INDEX -> timeForCompletion; | ||
case FUEL_INDEX -> fuelHandler.getFuelAmount(); | ||
default -> 0; | ||
}; | ||
} | ||
|
||
@Override | ||
public void set(int index, int value) { | ||
validateIndex(index); | ||
switch (index) { | ||
case TIME_INDEX -> timeElapsed = value; | ||
case TIME_FOR_COMPLETION_INDEX -> timeForCompletion = value; | ||
case FUEL_INDEX -> fuelHandler.setFuelAmount(value); | ||
default -> throw new IllegalStateException("Unexpected value: " + index); | ||
} | ||
} | ||
|
||
@Override | ||
public int getCount() { | ||
return 3; | ||
} | ||
|
||
} |
42 changes: 3 additions & 39 deletions
42
src/main/java/com/github/elenterius/biomancy/block/digester/DigesterStateData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,18 @@ | ||
package com.github.elenterius.biomancy.block.digester; | ||
|
||
import com.github.elenterius.biomancy.block.state.RecipeCraftingStateData; | ||
import com.github.elenterius.biomancy.block.state.FuelConsumingRecipeCraftingStateData; | ||
import com.github.elenterius.biomancy.recipe.DigesterRecipe; | ||
import com.github.elenterius.biomancy.util.fuel.IFuelHandler; | ||
|
||
public class DigesterStateData extends RecipeCraftingStateData<DigesterRecipe> { | ||
|
||
public static final int FUEL_AMOUNT_INDEX = 2; | ||
|
||
public final IFuelHandler fuelHandler; | ||
public class DigesterStateData extends FuelConsumingRecipeCraftingStateData<DigesterRecipe> { | ||
|
||
public DigesterStateData(IFuelHandler fuelHandler) { | ||
this.fuelHandler = fuelHandler; | ||
super(fuelHandler); | ||
} | ||
|
||
@Override | ||
protected Class<DigesterRecipe> getRecipeType() { | ||
return DigesterRecipe.class; | ||
} | ||
|
||
@Override | ||
public int getFuelCost() { | ||
return fuelHandler.getFuelCost(timeForCompletion); | ||
} | ||
|
||
@Override | ||
public int get(int index) { | ||
validateIndex(index); | ||
return switch (index) { | ||
case TIME_INDEX -> timeElapsed; | ||
case TIME_FOR_COMPLETION_INDEX -> timeForCompletion; | ||
case FUEL_AMOUNT_INDEX -> fuelHandler.getFuelAmount(); | ||
default -> 0; | ||
}; | ||
} | ||
|
||
@Override | ||
public void set(int index, int value) { | ||
validateIndex(index); | ||
switch (index) { | ||
case TIME_INDEX -> timeElapsed = value; | ||
case TIME_FOR_COMPLETION_INDEX -> timeForCompletion = value; | ||
case FUEL_AMOUNT_INDEX -> fuelHandler.setFuelAmount(value); | ||
default -> throw new IllegalStateException("Unexpected value: " + index); | ||
} | ||
} | ||
|
||
@Override | ||
public int getCount() { | ||
return 3; | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
...java/com/github/elenterius/biomancy/block/state/FuelConsumingRecipeCraftingStateData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.github.elenterius.biomancy.block.state; | ||
|
||
import com.github.elenterius.biomancy.recipe.ProcessingRecipe; | ||
import com.github.elenterius.biomancy.util.fuel.IFuelHandler; | ||
|
||
public abstract class FuelConsumingRecipeCraftingStateData<T extends ProcessingRecipe> extends RecipeCraftingStateData<T> { | ||
|
||
public static final int FUEL_INDEX = 3; | ||
|
||
public final IFuelHandler fuelHandler; | ||
|
||
protected FuelConsumingRecipeCraftingStateData(IFuelHandler fuelHandler) { | ||
this.fuelHandler = fuelHandler; | ||
} | ||
|
||
@Override | ||
public int getFuelCost() { | ||
return fuelHandler.getFuelCost(nutrientsCost); | ||
} | ||
|
||
@Override | ||
public int get(int index) { | ||
if (index == FUEL_INDEX) return fuelHandler.getFuelAmount(); | ||
return super.get(index); | ||
} | ||
|
||
@Override | ||
public void set(int index, int value) { | ||
if (index == FUEL_INDEX) { | ||
fuelHandler.setFuelAmount(value); | ||
return; | ||
} | ||
super.set(index, value); | ||
} | ||
|
||
@Override | ||
public int getCount() { | ||
return 4; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters