Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new cauldron mix recipe to mix two fluids into an item
Adds a default recipe with that for obsidian, disabled by default
- Loading branch information
1 parent
cf43380
commit 238bfcc
Showing
7 changed files
with
140 additions
and
14 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
84 changes: 84 additions & 0 deletions
84
src/main/java/knightminer/inspirations/library/recipe/cauldron/CauldronMixRecipe.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,84 @@ | ||
package knightminer.inspirations.library.recipe.cauldron; | ||
|
||
import java.util.List; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
|
||
import knightminer.inspirations.library.InspirationsRegistry; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraftforge.fluids.Fluid; | ||
import net.minecraftforge.fluids.FluidStack; | ||
import net.minecraftforge.fluids.FluidUtil; | ||
import net.minecraftforge.fluids.capability.IFluidHandlerItem; | ||
|
||
/** | ||
* Recipe to combine two fluids into an item output | ||
*/ | ||
public class CauldronMixRecipe implements ISimpleCauldronRecipe { | ||
|
||
private CauldronState input1, input2; | ||
private ItemStack result; | ||
|
||
/** | ||
* Combines two inputs into an item output. Input order does not matter, both can be either the container or in the cauldron | ||
* @param result Item result | ||
* @param input1 First fluid for either container or cauldron, will show in JEI as the cauldron contents | ||
* @param input2 Second fluid for either container or cauldron, will show in JEI as a bucket | ||
*/ | ||
public CauldronMixRecipe(Fluid input1, Fluid input2, ItemStack result) { | ||
this.result = result; | ||
this.input1 = CauldronState.fluid(input1); | ||
this.input2 = CauldronState.fluid(input2); | ||
} | ||
|
||
@Override | ||
public boolean matches(ItemStack stack, boolean boiling, int level, CauldronState state) { | ||
// cauldron must be full of a fluid | ||
if(level != InspirationsRegistry.getCauldronMax() || state.getFluid() == null) { | ||
return false; | ||
} | ||
|
||
// stack must be a fluid container | ||
IFluidHandlerItem fluidHandler = FluidUtil.getFluidHandler(stack); | ||
if(fluidHandler == null) { | ||
return false; | ||
} | ||
|
||
// fluid in stack must be a cauldron fluid | ||
FluidStack fluidStack = fluidHandler.drain(1000, false); | ||
if(!CauldronState.fluidValid(fluidStack)) { | ||
return false; | ||
} | ||
|
||
// either input must be in the cauldron | ||
Fluid fluid = fluidStack.getFluid(); | ||
return input1.matches(state) && input2.getFluid() == fluid | ||
|| input2.matches(state) && input1.getFluid() == fluid; | ||
} | ||
|
||
@Override | ||
public int getLevel(int level) { | ||
return 0; | ||
} | ||
|
||
/* JEI */ | ||
@Override | ||
public Fluid getInputState() { | ||
return input1.getFluid(); | ||
} | ||
|
||
@Override | ||
public List<ItemStack> getInput() { | ||
return ImmutableList.of(FluidUtil.getFilledBucket(input2.getFluidStack())); | ||
} | ||
|
||
@Override | ||
public ItemStack getResult() { | ||
return result; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("CauldronMixRecipe: %s from %s and %s", getResult().toString(), input1.getFluid().getName(), input2.getFluid().getName()); | ||
} | ||
} |
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
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