-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added custom Recipe maps for Recycler and typical IC2 machines
- Loading branch information
1 parent
429d472
commit f492b86
Showing
9 changed files
with
108 additions
and
104 deletions.
There are no files selected for viewing
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,37 @@ | ||
package gregtechmod.common.recipe; | ||
|
||
import java.util.Optional; | ||
import java.util.Random; | ||
|
||
import gregtechmod.api.recipe.ChancedOutput; | ||
import gregtechmod.common.recipe.factory.SimpleRecipeFactory; | ||
import net.minecraft.item.ItemStack; | ||
|
||
/** | ||
* @author TheDarkDnKTv | ||
* | ||
*/ | ||
public class ChancedStack implements ChancedOutput { | ||
private int chance; | ||
private ItemStack stack; | ||
|
||
public ChancedStack(ItemStack stack, int chance) { | ||
this.stack = stack.copy(); | ||
this.chance = chance; | ||
} | ||
|
||
@Override | ||
public int getChance() { | ||
return chance; | ||
} | ||
|
||
@Override | ||
public ItemStack getStack() { | ||
return stack.copy(); | ||
} | ||
|
||
@Override | ||
public Optional<ItemStack> get(Random random) { | ||
return Optional.ofNullable(random.nextInt(SimpleRecipeFactory.MAX_CHANCE) <= chance ? stack.copy() : null); | ||
} | ||
} |
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
41 changes: 41 additions & 0 deletions
41
src/main/java/gregtechmod/common/recipe/maps/RecyclerRecipeMap.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,41 @@ | ||
package gregtechmod.common.recipe.maps; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import gregtechmod.api.enums.GT_Items; | ||
import gregtechmod.api.recipe.Recipe; | ||
import gregtechmod.api.util.GT_ModHandler; | ||
import gregtechmod.api.util.GT_Utility; | ||
import gregtechmod.common.recipe.ChancedStack; | ||
import gregtechmod.common.recipe.RecipeEntry; | ||
|
||
import net.minecraft.item.ItemStack; | ||
|
||
/** | ||
* @author TheDarkDnKTv | ||
* | ||
*/ | ||
public class RecyclerRecipeMap extends DummyRecipeMap { | ||
public RecyclerRecipeMap(int minInputs, int maxInputs, int minOutputs, int maxOutputs) { | ||
super(minInputs, maxInputs, minOutputs, maxOutputs); | ||
} | ||
|
||
@Override | ||
public Recipe findRecipe(List<ItemStack> inputs) { | ||
for (ItemStack slot : inputs) { | ||
if (GT_Utility.isStackValid(slot)) { | ||
ItemStack instance = slot.copy(); | ||
instance.stackSize = 1; | ||
|
||
ChancedStack st = new ChancedStack(GT_Items.IC2_Scrap.get(1), (GT_ModHandler.getRecyclerOutput(instance, 0) != null) ? 12_50 : 0); | ||
return new Recipe(0, 1, 45, false, | ||
Collections.singleton(RecipeEntry.singleton(instance)), | ||
Collections.emptyList(), | ||
Collections.singleton(st)); | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
} |
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
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