mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 10:55:17 +00:00
Allow pure daisy inputs to be state-sensitive. Closes #2501
This commit is contained in:
1 parent
1b4566388a
commit
23377aeee9
3 files changed
+14
-8
No files matched your search
@@ -411,7 +411,7 @@ public final class BotaniaAPI {
|
||||
|
||||
/**
|
||||
* Registers a Pure Daisy Recipe with the default time
|
||||
* @param input The block that works as an input for the recipe. Can be a Block or an oredict String.
|
||||
* @param input The input for the recipe. Can be a Block (meta-insensitive), IBlockState (meta-sensitive), or an oredict String.
|
||||
* @param outputState The blockstate to be placed upon recipe completion.
|
||||
* @return The recipe created.
|
||||
*/
|
||||
@@ -421,7 +421,7 @@ public final class BotaniaAPI {
|
||||
|
||||
/**
|
||||
* Registers a Pure Daisy Recipe.
|
||||
* @param input The block that works as an input for the recipe. Can be a Block or an oredict String.
|
||||
* @param input The input for the recipe. Can be a Block (meta-insensitive), IBlockState (meta-sensitive), or an oredict String.
|
||||
* @param outputState The blockstate to be placed upon recipe completion.
|
||||
* @param time The amount of time in ticks to complete this recipe. Note that this is ticks on your block, not total time.
|
||||
* The Pure Daisy only ticks one block at a time in a round robin fashion.
|
||||
|
||||
@@ -41,8 +41,8 @@ public class RecipePureDaisy {
|
||||
this.input = input;
|
||||
outputState = state;
|
||||
this.time = time;
|
||||
if(input != null && !(input instanceof String || input instanceof Block))
|
||||
throw new IllegalArgumentException("input must be an oredict String or a Block.");
|
||||
if(input != null && !(input instanceof String || input instanceof Block || input instanceof IBlockState))
|
||||
throw new IllegalArgumentException("input must be an oredict String, Block, or IBlockState");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,6 +52,9 @@ public class RecipePureDaisy {
|
||||
if(input instanceof Block)
|
||||
return state.getBlock() == input;
|
||||
|
||||
if(input instanceof IBlockState)
|
||||
return state == input;
|
||||
|
||||
ItemStack stack = new ItemStack(state.getBlock(), 1, state.getBlock().damageDropped(state));
|
||||
String oredict = (String) input;
|
||||
return isOreDict(stack, oredict);
|
||||
@@ -88,7 +91,7 @@ public class RecipePureDaisy {
|
||||
*/
|
||||
public boolean set(World world, BlockPos pos, SubTileEntity pureDaisy) {
|
||||
if(!world.isRemote)
|
||||
world.setBlockState(pos, outputState, 1 | 2);
|
||||
world.setBlockState(pos, outputState);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+6
-3
@@ -12,6 +12,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
@@ -32,12 +33,14 @@ public class PureDaisyRecipeWrapper implements IRecipeWrapper {
|
||||
public PureDaisyRecipeWrapper(RecipePureDaisy recipe) {
|
||||
if(recipe.getInput() instanceof String) {
|
||||
inputs = ImmutableList.copyOf(OreDictionary.getOres((String) recipe.getInput()));
|
||||
} else if(recipe.getInput() instanceof Block) {
|
||||
Block b = (Block) recipe.getInput();
|
||||
} else if(recipe.getInput() instanceof Block || recipe.getInput() instanceof IBlockState) {
|
||||
IBlockState state = recipe.getInput() instanceof IBlockState ? (IBlockState) recipe.getInput() : ((Block) recipe.getInput()).getDefaultState();
|
||||
Block b = state.getBlock();
|
||||
|
||||
if(FluidRegistry.lookupFluidForBlock(b) != null) {
|
||||
fluidInput = new FluidStack(FluidRegistry.lookupFluidForBlock(b), 1000);
|
||||
} else {
|
||||
inputs = ImmutableList.of(new ItemStack(b, 1, b.getMetaFromState(b.getDefaultState())));
|
||||
inputs = ImmutableList.of(new ItemStack(b, 1, b.getMetaFromState(state)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user