mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-14 01:04:16 +00:00
Made the Pure Daisy more performant and added a water->snow recipe.
This commit is contained in:
1 parent
dcc08c25cd
commit
e36546bbb6
6 files changed
+28
-11
No files matched your search
@@ -1,4 +1,4 @@
|
||||
@API(owner = "Botania", apiVersion = "55", provides = "BotaniaAPI")
|
||||
@API(owner = "Botania", apiVersion = "56", provides = "BotaniaAPI")
|
||||
package vazkii.botania.api;
|
||||
import cpw.mods.fml.common.API;
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
*/
|
||||
package vazkii.botania.api.recipe;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
@@ -18,6 +22,8 @@ import vazkii.botania.api.subtile.SubTileEntity;
|
||||
|
||||
public class RecipePureDaisy {
|
||||
|
||||
private static final Map<String, List<ItemStack>> oreMap = new HashMap();
|
||||
|
||||
Object input;
|
||||
Block output;
|
||||
int outputMeta;
|
||||
@@ -34,13 +40,11 @@ public class RecipePureDaisy {
|
||||
/**
|
||||
* This gets called every tick, please be careful with your checks.
|
||||
*/
|
||||
public boolean matches(World world, int x, int y, int z, SubTileEntity pureDaisy) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
world.getBlockMetadata(x, y, z);
|
||||
if(input instanceof Block && block == input)
|
||||
return true;
|
||||
public boolean matches(World world, int x, int y, int z, SubTileEntity pureDaisy, Block block, int meta) {
|
||||
if(input instanceof Block)
|
||||
return block == input;
|
||||
|
||||
ItemStack stack = new ItemStack(block, 1, world.getBlockMetadata(x, y, z));
|
||||
ItemStack stack = new ItemStack(block, 1, meta);
|
||||
String oredict = (String) input;
|
||||
return isOreDict(stack, oredict);
|
||||
}
|
||||
@@ -49,7 +53,15 @@ public class RecipePureDaisy {
|
||||
if(stack == null || stack.getItem() == null)
|
||||
return false;
|
||||
|
||||
for(ItemStack ostack : OreDictionary.getOres(entry)) {
|
||||
List<ItemStack> ores;
|
||||
if(oreMap.containsKey(entry))
|
||||
ores = oreMap.get(entry);
|
||||
else {
|
||||
ores = OreDictionary.getOres(entry);
|
||||
oreMap.put(entry, ores);
|
||||
}
|
||||
|
||||
for(ItemStack ostack : ores) {
|
||||
ItemStack cstack = ostack.copy();
|
||||
if(cstack.getItemDamage() == Short.MAX_VALUE)
|
||||
cstack.setItemDamage(stack.getItemDamage());
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
@@ -36,7 +37,7 @@ public class RecipeHandlerPureDaisy extends TemplateRecipeHandler {
|
||||
|
||||
if(recipe.getInput() instanceof String)
|
||||
inputs.add(new PositionedStack(OreDictionary.getOres((String) recipe.getInput()), 42, 23));
|
||||
else inputs.add(new PositionedStack(recipe.getInput(), 42, 23));
|
||||
else inputs.add(new PositionedStack(new ItemStack((Block) recipe.getInput()), 42, 23));
|
||||
|
||||
output = new PositionedStack(new ItemStack(recipe.getOutput()), 101, 23);
|
||||
}
|
||||
|
||||
@@ -54,9 +54,11 @@ public class SubTilePureDaisy extends SubTileEntity {
|
||||
ChunkCoordinates coords = new ChunkCoordinates(supertile.xCoord + acoords[0], supertile.yCoord + acoords[1], supertile.zCoord + acoords[2]);
|
||||
World world = supertile.getWorldObj();
|
||||
if(!world.isAirBlock(coords.posX, coords.posY, coords.posZ)) {
|
||||
Block block = world.getBlock(coords.posX, coords.posY, coords.posZ);
|
||||
int meta = world.getBlockMetadata(coords.posX, coords.posY, coords.posZ);
|
||||
RecipePureDaisy recipe = null;
|
||||
for(RecipePureDaisy recipe_ : BotaniaAPI.pureDaisyRecipes)
|
||||
if(recipe_.matches(world, coords.posX, coords.posY, coords.posZ, this)) {
|
||||
if(recipe_.matches(world, coords.posX, coords.posY, coords.posZ, this, block, meta)) {
|
||||
recipe = recipe_;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package vazkii.botania.common.crafting;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.lib.LibOreDict;
|
||||
@@ -25,6 +26,7 @@ public final class ModPureDaisyRecipes {
|
||||
BotaniaAPI.registerPureDaisyRecipe("soulSand", Blocks.sand, 0);
|
||||
BotaniaAPI.registerPureDaisyRecipe("ice", Blocks.packed_ice, 0);
|
||||
BotaniaAPI.registerPureDaisyRecipe(LibOreDict.BLAZE_BLOCK, Blocks.obsidian, 0);
|
||||
BotaniaAPI.registerPureDaisyRecipe(Blocks.water, Blocks.snow, 0);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user