diff options
Diffstat (limited to 'src/Java')
18 files changed, 42 insertions, 1096 deletions
diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java b/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java index 3038f77ac0..9d33550bc3 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java @@ -7,6 +7,7 @@ import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.tileentities.machines.TileEntityWorkbench; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.player.PlayerUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import ic2.core.item.tool.ItemToolWrench; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -18,6 +19,7 @@ import net.minecraft.util.IIcon; import net.minecraft.world.World; import buildcraft.api.tools.IToolWrench; import cpw.mods.fml.common.Optional; +import cpw.mods.fml.common.Optional.Interface; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; @@ -101,26 +103,50 @@ public class Machine_Workbench extends BlockContainer return new TileEntityWorkbench(); } - public static boolean isWrench(ItemStack item){ - + public static boolean isWrench(ItemStack item){ if (item.getItem() instanceof ItemToolWrench){ return true; } - if (item.getItem() instanceof IToolWrench){ - return true; + if (LoadedMods.BuildCraft){ + return checkBuildcraftWrench(item); } if (LoadedMods.EnderIO){ return checkEnderIOWrench(item); } - return false; } @Optional.Method(modid = "EnderIO") private static boolean checkEnderIOWrench(ItemStack item){ - if (item.getItem() instanceof crazypants.enderio.api.tool.ITool){ - return true; - } + if (ReflectionUtils.doesClassExist("crazypants.enderio.api.tool.ITool")){ + Class<?> wrenchClass; + try { + wrenchClass = Class.forName("crazypants.enderio.api.tool.ITool"); + if (wrenchClass.isInstance(item.getItem())){ + return true; + } + } + catch (ClassNotFoundException e1) { + return false; + } + } + return false; + } + + @Optional.Method(modid = "Buildcraft") + private static boolean checkBuildcraftWrench(ItemStack item){ + if (ReflectionUtils.doesClassExist("buildcraft.api.tools.IToolWrench")){ + Class<?> wrenchClass; + try { + wrenchClass = Class.forName("buildcraft.api.tools.IToolWrench"); + if (wrenchClass.isInstance(item.getItem())){ + return true; + } + } + catch (ClassNotFoundException e1) { + return false; + } + } return false; } diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java index ccf2b83837..b30487c070 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java @@ -5,7 +5,6 @@ import gtPlusPlus.xmod.forestry.HANDLER_FR; import gtPlusPlus.xmod.gregtech.HANDLER_GT; import gtPlusPlus.xmod.growthcraft.HANDLER_GC; import gtPlusPlus.xmod.ic2.HANDLER_IC2; -import gtPlusPlus.xmod.psychedelicraft.HANDLER_Psych; import gtPlusPlus.xmod.thermalfoundation.HANDLER_TF; public class COMPAT_IntermodStaging { @@ -15,7 +14,6 @@ public class COMPAT_IntermodStaging { HANDLER_GC.preInit(); HANDLER_TF.preInit(); HANDLER_FR.preInit(); - HANDLER_Psych.preInit(); HANDLER_IC2.preInit(); HANDLER_Computronics.preInit(); @@ -26,7 +24,6 @@ public class COMPAT_IntermodStaging { HANDLER_GC.init(); HANDLER_TF.init(); HANDLER_FR.Init(); - HANDLER_Psych.init(); HANDLER_IC2.init(); HANDLER_Computronics.init(); } @@ -36,7 +33,6 @@ public class COMPAT_IntermodStaging { HANDLER_GC.postInit(); HANDLER_TF.postInit(); HANDLER_FR.postInit(); - HANDLER_Psych.postInit(); HANDLER_IC2.postInit(); HANDLER_Computronics.postInit(); } diff --git a/src/Java/gtPlusPlus/core/lib/LoadedMods.java b/src/Java/gtPlusPlus/core/lib/LoadedMods.java index 440f72d2c8..9e07f48bf3 100644 --- a/src/Java/gtPlusPlus/core/lib/LoadedMods.java +++ b/src/Java/gtPlusPlus/core/lib/LoadedMods.java @@ -11,6 +11,7 @@ public class LoadedMods { //Initialize Variables public static boolean Gregtech = false; + public static boolean BuildCraft = false; public static boolean EnderIO = false; public static boolean Big_Reactors = false; public static boolean IndustrialCraft2 = false; @@ -60,6 +61,11 @@ public class LoadedMods { totalMods++; } + if (Loader.isModLoaded("BuildCraft") == true){ + BuildCraft = true; + Utils.LOG_INFO("Components enabled for: BuildCraft"); + totalMods++; + } if (Loader.isModLoaded("EnderIO") == true && !configSwitches.disableEnderIOIntegration){ EnderIO = true; Utils.LOG_INFO("Components enabled for: EnderIO"); diff --git a/src/Java/gtPlusPlus/xmod/forestry/Forestry.java b/src/Java/gtPlusPlus/xmod/forestry/Forestry.java index b21d9a154d..698e6a8d01 100644 --- a/src/Java/gtPlusPlus/xmod/forestry/Forestry.java +++ b/src/Java/gtPlusPlus/xmod/forestry/Forestry.java @@ -4,8 +4,6 @@ import static cpw.mods.fml.common.registry.GameRegistry.findBlock; import static cpw.mods.fml.common.registry.GameRegistry.findItem; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.xmod.forestry.trees.ForestryLeaf; -import gtPlusPlus.xmod.forestry.trees.ForestrySapling; import net.minecraft.block.Block; import net.minecraft.item.Item; @@ -46,7 +44,7 @@ public class Forestry { item = findItem(name, "sapling"); Block block = findBlock(name, "saplingGE"); if (item != null && block != null) { - ForestrySapling sapling = new ForestrySapling(item, block); + //ForestrySapling sapling = new ForestrySapling(item, block); //MFRRegistry.registerPlantable(sapling); //MFRRegistry.registerFertilizable(sapling); } else @@ -100,7 +98,7 @@ public class Forestry { block = findBlock(name, "leaves"); if (block != null) { - ForestryLeaf leaf = new ForestryLeaf(block); + //ForestryLeaf leaf = new ForestryLeaf(block); //MFRRegistry.registerFertilizable(leaf); //MFRRegistry.registerHarvestable(leaf); //MFRRegistry.registerFruit(leaf); diff --git a/src/Java/gtPlusPlus/xmod/forestry/trees/ForestryLeaf.java b/src/Java/gtPlusPlus/xmod/forestry/trees/ForestryLeaf.java deleted file mode 100644 index e2550f4643..0000000000 --- a/src/Java/gtPlusPlus/xmod/forestry/trees/ForestryLeaf.java +++ /dev/null @@ -1,160 +0,0 @@ -package gtPlusPlus.xmod.forestry.trees; - -import java.util.*; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import powercrystals.minefactoryreloaded.api.*; -import powercrystals.minefactoryreloaded.farmables.harvestables.HarvestableTreeLeaves; -import forestry.api.arboriculture.*; -import forestry.api.genetics.*; - - -public class ForestryLeaf extends HarvestableTreeLeaves implements IFactoryFruit -{ - private ITreeRoot root; - private ReplacementBlock repl; - protected Item _item; - - public ForestryLeaf(Block block) - { - super(block); - root = (ITreeRoot)AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees"); - repl = EmptyReplacement.INSTANCE; - _item = Item.getItemFromBlock(block); - } - - @Override - public boolean canBePicked(World world, int x, int y, int z) - { - TileEntity te = world.getTileEntity(x, y, z); - if (te instanceof IFruitBearer) - { - IFruitBearer fruit = (IFruitBearer)te; - return fruit.getRipeness() >= 0.99f; - } - return false; - } - - public boolean canFertilize(World world, int x, int y, int z) - { - return !canBePicked(world, x, y, z); - } - - public boolean fertilize(World world, Random rand, int x, int y, int z) - { - TileEntity te = world.getTileEntity(x, y, z); - if (te instanceof IFruitBearer) - { - IFruitBearer fruit = (IFruitBearer)te; - fruit.addRipeness(1f); - return true; - } - return false; - } - - @Override - public ReplacementBlock getReplacementBlock(World world, int x, int y, int z) - { - return repl; - } - - @Override - public void prePick(World world, int x, int y, int z) - { - } - - @Override // HARVESTER - public List<ItemStack> getDrops(World world, Random rand, Map<String, Boolean> settings, int x, int y, int z) - { - ITree tree = getTree(world, x, y, z); - if (tree == null) - return null; - - ArrayList<ItemStack> prod = new ArrayList<ItemStack>(); - - float modifier = 1f; - if (settings.get("silkTouch") == Boolean.TRUE) - { - ItemStack item = new ItemStack(_item); - NBTTagCompound tag = new NBTTagCompound(); - tree.writeToNBT(tag); - item.setTagCompound(tag); - prod.add(item); - } - else - { - boolean hasMate = tree.getMate() != null; - for (ITree s : getSaplings(tree, world, x, y, z, modifier)) - if (s != null) { - if ((hasMate && !s.isGeneticEqual(tree)) || rand.nextInt(32) == 0) - if (rand.nextBoolean()) - prod.add(root.getMemberStack(s, EnumGermlingType.POLLEN.ordinal())); - - prod.add(root.getMemberStack(s, EnumGermlingType.SAPLING.ordinal())); - } - - getFruits(world, x, y, z, tree, prod); - } - - return prod; - } - - - private static ITree[] getSaplings(ITree tree, World world, int x, int y, int z, float modifier) { - return tree.getSaplings(world, null, x, y, z, modifier); - } - - @Override // FRUIT PICKER - public List<ItemStack> getDrops(World world, Random rand, int x, int y, int z) - { - ITree tree = getTree(world, x, y, z); - if (tree == null) - return null; - - ArrayList<ItemStack> prod = new ArrayList<ItemStack>(); - getFruits(world, x, y, z, tree, prod); - return prod; - } - - private ITree getTree(World world, int x, int y, int z) - { - TileEntity te = world.getTileEntity(x, y, z); - if (te instanceof IPollinatable) { - IIndividual t = ((IPollinatable)te).getPollen(); - if (t instanceof ITree) - return (ITree)t; - } - return null; - } - - private void getFruits(World world, int x, int y, int z, ITree tree, ArrayList<ItemStack> prod) - { - TileEntity te = world.getTileEntity(x, y, z); - if (te instanceof IFruitBearer) - { - IFruitBearer fruit = (IFruitBearer)te; - if (fruit.hasFruit()) - { - //int period = tree.getGenome().getFruitProvider().getRipeningPeriod(); - //ItemStack[] o = tree.produceStacks(world, x, y, z, (int)(fruit.getRipeness() * period + 0.1f)); - prod.addAll(fruit.pickFruit(null)); - } - } - } - - @Override - public void postPick(World world, int x, int y, int z) - { - TileEntity te = world.getTileEntity(x, y, z); - if (te instanceof IFruitBearer) - { - IFruitBearer fruit = (IFruitBearer)te; - fruit.addRipeness(-fruit.getRipeness()); - } - } -} diff --git a/src/Java/gtPlusPlus/xmod/forestry/trees/ForestrySapling.java b/src/Java/gtPlusPlus/xmod/forestry/trees/ForestrySapling.java deleted file mode 100644 index 7c81ea0928..0000000000 --- a/src/Java/gtPlusPlus/xmod/forestry/trees/ForestrySapling.java +++ /dev/null @@ -1,55 +0,0 @@ -package gtPlusPlus.xmod.forestry.trees; - -import java.util.Random; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import powercrystals.minefactoryreloaded.api.ReplacementBlock; -import powercrystals.minefactoryreloaded.farmables.plantables.PlantableStandard; -import forestry.api.arboriculture.ITreeRoot; -import forestry.api.genetics.AlleleManager; - -public class ForestrySapling extends PlantableStandard -{ - private ITreeRoot root; - - public ForestrySapling(Item item, Block block) - { - super(item, block, WILDCARD, null); - root = (ITreeRoot)AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees"); - _plantedBlock = new ReplacementBlock((Block)null) { - @Override - public boolean replaceBlock(World world, int x, int y, int z, ItemStack stack) { - return root.plantSapling(world, root.getMember(stack), null, x, y, z); - } - }; - } - - public Block getPlant() - { - return _block; - } - - @Override - public boolean canBePlantedHere(World world, int x, int y, int z, ItemStack stack) - { - if (!world.isAirBlock(x, y, z)) - return false; - - return root.getMember(stack).canStay(world, x, y, z); - } - - public boolean canFertilize(World world, int x, int y, int z) - { - return true; - } - - public boolean fertilize(World world, Random rand, int x, int y, int z) - { - Block block = world.getBlock(x, y, z); - root.getTree(world, x, y, z).getTreeGenerator(world, x, y, z, true).generate(world, rand, x, y, z); - return world.getBlock(x, y, z) != block; - } -} diff --git a/src/Java/gtPlusPlus/xmod/psychedelicraft/HANDLER_Psych.java b/src/Java/gtPlusPlus/xmod/psychedelicraft/HANDLER_Psych.java deleted file mode 100644 index 84faed5479..0000000000 --- a/src/Java/gtPlusPlus/xmod/psychedelicraft/HANDLER_Psych.java +++ /dev/null @@ -1,26 +0,0 @@ -package gtPlusPlus.xmod.psychedelicraft; - -import gtPlusPlus.core.lib.LoadedMods; - - -public class HANDLER_Psych { - - public static void preInit(){ - if (LoadedMods.Psychedelicraft){ - //PS_Fluids.registerFluids(); - } - } - - public static void init(){ - if (LoadedMods.Psychedelicraft){ - //PS_Fluids.registerAlcohols(); - } - } - - public static void postInit(){ - if (LoadedMods.Psychedelicraft){ - - } - } - -} diff --git a/src/Java/gtPlusPlus/xmod/psychedelicraft/fluids/PS_Fluids.java b/src/Java/gtPlusPlus/xmod/psychedelicraft/fluids/PS_Fluids.java deleted file mode 100644 index 4de44c7efc..0000000000 --- a/src/Java/gtPlusPlus/xmod/psychedelicraft/fluids/PS_Fluids.java +++ /dev/null @@ -1,54 +0,0 @@ -package gtPlusPlus.xmod.psychedelicraft.fluids; - -import gtPlusPlus.core.lib.CORE; -import ivorius.ivtoolkit.gui.IntegerRange; -import ivorius.psychedelicraft.blocks.TileEntityMashTub; -import ivorius.psychedelicraft.config.PSConfig; -import ivorius.psychedelicraft.fluids.FluidAlcohol; -import ivorius.psychedelicraft.items.PSItems; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.oredict.ShapelessOreRecipe; -import cpw.mods.fml.common.registry.GameRegistry; - -public class PS_Fluids { - - public static FluidAlcohol alcJD; - - public static void registerFluids(){ - alcJD = new FluidAlcohol("psc_JD", 2, 0.45D, 1.9D, 0.15D, PSConfig.alcInfoPotato); - alcJD.addName(CORE.MODID + ":" + "drinkMash", new IntegerRange(0, -1), new IntegerRange(0, 0)); - alcJD.addName(CORE.MODID + ":" + "drinkAgedWhisky", new IntegerRange(0, 0), new IntegerRange(1, -1)); - alcJD.addName(CORE.MODID + ":" + "drinkWhisky", new IntegerRange(0, -1), new IntegerRange(1, -1)); - alcJD.setColor(-1426150904); - alcJD.setStillIconName(CORE.MODID + ":" + "mash_still"); - alcJD.setFlowingIconName(CORE.MODID + ":" + "mash_flow"); - alcJD.addIcon(new IntegerRange(-1, -1), new IntegerRange(0, 3), new IntegerRange(2, -1), CORE.MODID + ":" + "clear_still", CORE.MODID + ":" + "clear_flow"); - alcJD.addIcon(new IntegerRange(-1, -1), new IntegerRange(4, 13), new IntegerRange(0, -1), CORE.MODID + ":" + "rum_semi_mature_still", CORE.MODID + ":" + "rum_semi_mature_flow"); - alcJD.addIcon(new IntegerRange(-1, -1), new IntegerRange(14, -1), new IntegerRange(0, -1), CORE.MODID + ":" + "rum_mature_still", CORE.MODID + ":" + "rum_mature_flow"); - FluidRegistry.registerFluid(alcJD); - } - - public static void registerAlcohols(){ - addMashTubRecipe2(new FluidStack(alcJD, TileEntityMashTub.MASH_TUB_CAPACITY), new Object[] { "foodPotato", "foodPotato", "foodPotato", "foodPotato", "foodPotato", "foodBanana", "foodBanana", "foodBanana" }); - } - - private static void addMashTubRecipe2(FluidStack fluid, Object... ingredients) - { - ItemStack mashTubStack = new ItemStack(PSItems.itemMashTub); - PSItems.itemMashTub.fill(mashTubStack, fluid, true); - - Object[] ing = new Object[ingredients.length + 1]; - System.arraycopy(ingredients, 0, ing, 1, ingredients.length); - ing[0] = new ItemStack(PSItems.itemMashTub); - - addShapelessRecipe2(mashTubStack, ing); - } - - private static void addShapelessRecipe2(ItemStack output, Object... params) - { - GameRegistry.addRecipe(new ShapelessOreRecipe(output, params)); - } - -} diff --git a/src/Java/powercrystals/minefactoryreloaded/api/EmptyReplacement.java b/src/Java/powercrystals/minefactoryreloaded/api/EmptyReplacement.java deleted file mode 100644 index ef3fd46bb2..0000000000 --- a/src/Java/powercrystals/minefactoryreloaded/api/EmptyReplacement.java +++ /dev/null @@ -1,20 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -public class EmptyReplacement extends ReplacementBlock -{ - public static final EmptyReplacement INSTANCE = new EmptyReplacement(); - - public EmptyReplacement() - { - super((Block)null); - } - - @Override - public boolean replaceBlock(World world, int x, int y, int z, ItemStack stack) { - return true; - } -} diff --git a/src/Java/powercrystals/minefactoryreloaded/api/HarvestType.java b/src/Java/powercrystals/minefactoryreloaded/api/HarvestType.java deleted file mode 100644 index 85ef23835c..0000000000 --- a/src/Java/powercrystals/minefactoryreloaded/api/HarvestType.java +++ /dev/null @@ -1,56 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -/** - * Determines what algorithm the Harvester uses when it encounters this - * IFactoryHarvestable in the world. - * - * @author PowerCrystals - */ -public enum HarvestType { - - /** - * Just break the single block - no special action needed. e.g. Carrots, - * flowers, wheat. - */ - Normal, - /** - * Search for harvestable blocks adjacent to this block but leave this - * block. e.g. Pumpkin, melon - */ - Gourd, - /** - * Search for identical blocks above. - */ - Column, - /** - * Search for identical blocks above but leave the bottom one for the - * future. e.g. Cactus, sugarcane. - */ - LeaveBottom, - /** - * This block is the base of a tree and the harvester should enter - * tree-cutting mode. - */ - Tree, - /** - * This block is the base of the tree and the harvester should enter - * tree-cutting mode. - * The tree is searched for in the negative y axis instead. - */ - TreeFlipped, - /** - * This block is part of a tree as above, but leaves are cut before logs. - * The tree is searched for in the current mode. - * <p> - * If not in tree-cutting mode, tree-cutting mode will be entered as though - * the type was Tree. - */ - TreeLeaf, - /** - * This block is part of a tree as above, but fruits are cut before logs. - * e.g. cocoa - * The tree is not searched for. - */ - TreeFruit - -} diff --git a/src/Java/powercrystals/minefactoryreloaded/api/IFactoryFruit.java b/src/Java/powercrystals/minefactoryreloaded/api/IFactoryFruit.java deleted file mode 100644 index 3f956422c0..0000000000 --- a/src/Java/powercrystals/minefactoryreloaded/api/IFactoryFruit.java +++ /dev/null @@ -1,106 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import java.util.List; -import java.util.Random; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -/** - * Defines a fruit entry for the Fruit Picker. - * - * @author powercrystals - * - */ -public interface IFactoryFruit { - - /** - * @return The block this fruit has in the world. - */ - public Block getPlant(); - - /** - * Used to determine if this fruit can be picked (is it ripe yet, etc) - * - * @param world - * The world where the fruit is being picked - * @param x - * The x-coordinate of the fruit - * @param y - * The y-coordinate of the fruit - * @param z - * The z-coordinate of the fruit - * - * @return True if the fruit can be picked - */ - public boolean canBePicked(World world, int x, int y, int z); - - /** - * @deprecated This method is no longer called. ReplacementBlock now handles - * interaction. - */ - @Deprecated - public boolean breakBlock(); - - /** - * Called by the Fruit Picker to determine what block to replace the picked - * block with. At the time this method is called, the fruit still exists. - * - * @param world - * The world where the fruit is being picked - * @param x - * The x-coordinate of the fruit - * @param y - * The y-coordinate of the fruit - * @param z - * The z-coordinate of the fruit - * - * @return The block to replace the fruit block with, or null for air. - */ - public ReplacementBlock getReplacementBlock(World world, int x, int y, int z); - - /** - * Called by the Fruit Picker to determine what drops to generate. At the - * time this method is called, the fruit still exists. - * - * @param world - * The world where the fruit is being picked - * @param x - * The x-coordinate of the fruit - * @param y - * The y-coordinate of the fruit - * @param z - * The z-coordinate of the fruit - */ - public List<ItemStack> getDrops(World world, Random rand, int x, int y, int z); - - /** - * Called by the Fruit Picker after getDrops, prior to the block being - * replaced/removed. - * - * @param world - * The world where the fruit is being picked - * @param x - * The x-coordinate of the fruit - * @param y - * The y-coordinate of the fruit - * @param z - * The z-coordinate of the fruit - */ - public void prePick(World world, int x, int y, int z); - - /** - * Called by the Fruit Picker after the fruit is picked. - * - * @param world - * The world where the fruit is being picked - * @param x - * The x-coordinate of the fruit - * @param y - * The y-coordinate of the fruit - * @param z - * The z-coordinate of the fruit - */ - public void postPick(World world, int x, int y, int z); -} diff --git a/src/Java/powercrystals/minefactoryreloaded/api/IFactoryHarvestable.java b/src/Java/powercrystals/minefactoryreloaded/api/IFactoryHarvestable.java deleted file mode 100644 index 5b6be99f89..0000000000 --- a/src/Java/powercrystals/minefactoryreloaded/api/IFactoryHarvestable.java +++ /dev/null @@ -1,104 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import java.util.*; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -/** - * Defines a harvestable block for the Harvester. - * - * @author PowerCrystals - */ -public interface IFactoryHarvestable { - - /** - * @return The block this harvestable instance is managing. - */ - public Block getPlant(); - - /** - * @return The type of harvest the Harvester should perform on this block. - */ - public HarvestType getHarvestType(); - - /** - * Used to determine if the harvester should replace this block with air. - * - * @return Whether or not the Harvester should break the block when - * harvesting. If false, no changes will be performed by the - * Harvester itself. - */ - public boolean breakBlock(); - - /** - * Used to determine if this crop can be harvested (is it at a stage that - * drops crops, etc.) - * - * @param world - * The world this block is in. - * @param harvesterSettings - * The harvester's current settings. Do not modify these. - * @param x - * The X coordinate of the block being harvested. - * @param y - * The Y coordinate of the block being harvested. - * @param z - * The Z coordinate of the block being harvested. - * - * @return True if this block can be harvested. - */ - public boolean canBeHarvested(World world, Map<String, Boolean> harvesterSettings, int x, int y, int z); - - /** - * @param world - * The world this block is in. - * @param rand - * A Random instance to use when generating drops. - * @param harvesterSettings - * The harvester's current settings. Do not modify these. - * @param x - * The X coordinate of the block being harvested. - * @param y - * The Y coordinate of the block being harvested. - * @param z - * The Z coordinate of the block being harvested. - * - * @return The drops generated by breaking this block. For a default - * implementation, calling Block.getDrops() is usually - * sufficient. - */ - public List<ItemStack> getDrops(World world, Random rand, Map<String, Boolean> harvesterSettings, int x, int y, int z); - - /** - * Called before the block is going to be harvested, after getDrops. Usually - * empty. - * - * @param world - * The world this block is in. - * @param x - * The X coordinate of the block being harvested. - * @param y - * The Y coordinate of the block being harvested. - * @param z - * The Z coordinate of the block being harvested. - */ - public void preHarvest(World world, int x, int y, int z); - - /** - * Called after the block is going to be harvested. Used to re-till soil, - * for example. - * - * @param world - * The world this block is in. - * @param x - * The X coordinate of the block being harvested. - * @param y - * The Y coordinate of the block being harvested. - * @param z - * The Z coordinate of the block being harvested. - */ - public void postHarvest(World world, int x, int y, int z); - -} diff --git a/src/Java/powercrystals/minefactoryreloaded/api/IFactoryPlantable.java b/src/Java/powercrystals/minefactoryreloaded/api/IFactoryPlantable.java deleted file mode 100644 index 1d620b37ed..0000000000 --- a/src/Java/powercrystals/minefactoryreloaded/api/IFactoryPlantable.java +++ /dev/null @@ -1,94 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -/** - * Defines a plantable object for use in the Planter. - * - * @author PowerCrystals - */ -public interface IFactoryPlantable { - - /** - * @return The item this plantable is managing. - */ - public Item getSeed(); - - /** - * @param stack - * The stack being planted. - * @param forFermenting - * True if this stack will be converted to biofuel - * - * @return True if this plantable can be planted (useful for metadata - * items). - */ - public boolean canBePlanted(ItemStack stack, boolean forFermenting); - - /** - * @param world - * The world instance this block or item will be placed into. - * @param x - * The destination X coordinate. - * @param y - * The destination Y coordinate. - * @param z - * The destination Z coordinate. - * @param stack - * The stack being planted. - * - * @return The block that will be placed into the world. - */ - public ReplacementBlock getPlantedBlock(World world, int x, int y, int z, ItemStack stack); - - /** - * @param world - * The world instance this block or item will be placed into. - * @param x - * The destination X coordinate. - * @param y - * The destination Y coordinate. - * @param z - * The destination Z coordinate. - * @param stack - * The stack being planted. - * - * @return True if this plantable can be placed at the provided coordinates. - */ - public boolean canBePlantedHere(World world, int x, int y, int z, ItemStack stack); - - /** - * Called before planting is performed. Used to till soil, for example. - * - * @param world - * The world instance this block or item will be placed into. - * @param x - * The destination X coordinate. - * @param y - * The destination Y coordinate. - * @param z - * The destination Z coordinate. - * @param stack - * The stack being planted. - */ - public void prePlant(World world, int x, int y, int z, ItemStack stack); - - /** - * Called after planting is performed. Usually empty. - * - * @param world - * The world instance this block or item will be placed into. - * @param x - * The destination X coordinate. - * @param y - * The destination Y coordinate. - * @param z - * The destination Z coordinate. - * @param stack - * The stack being planted. - */ - public void postPlant(World world, int x, int y, int z, ItemStack stack); - -} diff --git a/src/Java/powercrystals/minefactoryreloaded/api/ReplacementBlock.java b/src/Java/powercrystals/minefactoryreloaded/api/ReplacementBlock.java deleted file mode 100644 index c67e8a39a2..0000000000 --- a/src/Java/powercrystals/minefactoryreloaded/api/ReplacementBlock.java +++ /dev/null @@ -1,135 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import net.minecraft.block.Block; -import net.minecraft.item.*; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -public class ReplacementBlock -{ - protected byte _hasMeta; - protected int _meta; - protected final Block _block; - protected final NBTTagCompound _tileTag; - - /** - * Called to replace a block in the world. - * @param world The world object - * @param x The X coord - * @param y The Y coord - * @param z The Z coord - * @param stack The ItemStack being used to replace the block (may be null) - * @return True if the block was set successfully - */ - public boolean replaceBlock(World world, int x, int y, int z, ItemStack stack) - { - int meta = getMeta(world, x, y, z, stack); - if (world.setBlock(x, y, z, _block, meta, 3)) - { - if (hasTag(stack) && _block.hasTileEntity(meta)) - { - TileEntity tile = world.getTileEntity(x, y, z); - if (tile != null) - tile.readFromNBT(getTag(world, x, y, z, stack)); - } - return true; - } - return false; - } - - /** - * Called to get the metadata of the replacement block in the world. - * @param world The world object - * @param x The X coord - * @param y The Y coord - * @param z The Z coord - * @param stack The ItemStack being used to replace the block (may be null) - * @return The metadata of the block - */ - protected int getMeta(World world, int x, int y, int z, ItemStack stack) - { - int m = 0; - if (_hasMeta > 0) - { - if (_hasMeta > 1) - return _meta; - m = stack.getItemDamage(); - Item item = stack.getItem(); - if (item instanceof ItemBlock) - m = ((ItemBlock)item).getMetadata(m); - } - return m; - } - - /** - * Called to set the metdata of this ReplacementBlock to a fixed value - * @param meta The metadata of the block - * @return This instance - */ - public ReplacementBlock setMeta(int meta) - { - if (meta >= 0) - { - _hasMeta = 2; - _meta = meta; - } - return this; - } - - /** - * Called to set the metdata of this ReplacementBlock to a value read from an ItemStack - * @param meta The metadata of the block - * @return This instance - */ - public ReplacementBlock setMeta(boolean hasMeta) - { - _hasMeta = (byte) (hasMeta ? 1 : 0); - return this; - } - - /** - * Called to get the NBTTagCompound a TileEntity will read its state from - * @param world The world object - * @param x The X coord - * @param y The Y coord - * @param z The Z coord - * @param stack The ItemStack being used to replace the block (may be null) - * @return The NBTTagCompound a TileEntity will read its state from - */ - protected NBTTagCompound getTag(World world, int x, int y, int z, ItemStack stack) - { - return _tileTag; - } - - /** - * Called to see if a TileEntity should have its state set - * @param stack The ItemStack being used to replace the block (may be null) - * @return True if the TileEntity should have its state set - */ - protected boolean hasTag(ItemStack stack) - { - return _tileTag != null; - } - - public ReplacementBlock(Item block) - { - this(Block.getBlockFromItem(block)); - } - - public ReplacementBlock(Item block, NBTTagCompound tag) - { - this(Block.getBlockFromItem(block), tag); - } - - public ReplacementBlock(Block block) - { - this(block, null); - } - - public ReplacementBlock(Block block, NBTTagCompound tag) - { - _block = block; - _tileTag = tag; - } -} diff --git a/src/Java/powercrystals/minefactoryreloaded/farmables/harvestables/HarvestableShearable.java b/src/Java/powercrystals/minefactoryreloaded/farmables/harvestables/HarvestableShearable.java deleted file mode 100644 index 1719ae2486..0000000000 --- a/src/Java/powercrystals/minefactoryreloaded/farmables/harvestables/HarvestableShearable.java +++ /dev/null @@ -1,50 +0,0 @@ -package powercrystals.minefactoryreloaded.farmables.harvestables; - -import java.util.*; - -import net.minecraft.block.Block; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import net.minecraftforge.common.IShearable; -import powercrystals.minefactoryreloaded.api.HarvestType; - -public class HarvestableShearable extends HarvestableStandard -{ - public HarvestableShearable(Block block, HarvestType harvestType) - { - super(block, harvestType); - } - - public HarvestableShearable(Block block) - { - super(block); - } - - @Override - public List<ItemStack> getDrops(World world, Random rand, Map<String, Boolean> settings, int x, int y, int z) - { - Block block = world.getBlock(x, y, z); - if (settings.get("silkTouch") == Boolean.TRUE) - { - if (block instanceof IShearable) - { - ItemStack stack = new ItemStack(Items.shears, 1, 0); - if (((IShearable)block).isShearable(stack, world, x, y, z)) - { - return ((IShearable)block).onSheared(stack, world, x, y, z, 0); - } - } - if (Item.getItemFromBlock(block) != null) - { - ArrayList<ItemStack> drops = new ArrayList<ItemStack>(); - int meta = block.getDamageValue(world, x, y, z); - drops.add(new ItemStack(block, 1, meta)); - return drops; - } - } - - return block.getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), 0); - } -} diff --git a/src/Java/powercrystals/minefactoryreloaded/farmables/harvestables/HarvestableStandard.java b/src/Java/powercrystals/minefactoryreloaded/farmables/harvestables/HarvestableStandard.java deleted file mode 100644 index eeab615ed8..0000000000 --- a/src/Java/powercrystals/minefactoryreloaded/farmables/harvestables/HarvestableStandard.java +++ /dev/null @@ -1,71 +0,0 @@ -package powercrystals.minefactoryreloaded.farmables.harvestables; - -import java.util.*; - -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import powercrystals.minefactoryreloaded.api.HarvestType; -import powercrystals.minefactoryreloaded.api.IFactoryHarvestable; - -public class HarvestableStandard implements IFactoryHarvestable -{ - private Block _block; - private HarvestType _harvestType; - - public HarvestableStandard(Block block, HarvestType harvestType) - { - if (block == Blocks.air) - throw new IllegalArgumentException("Passed air FactoryHarvestableStandard"); - - _block = block; - _harvestType = harvestType; - } - - public HarvestableStandard(Block block) - { - this(block, HarvestType.Normal); - } - - @Override - public Block getPlant() - { - return _block; - } - - @Override - public HarvestType getHarvestType() - { - return _harvestType; - } - - @Override - public boolean breakBlock() - { - return true; - } - - @Override - public boolean canBeHarvested(World world, Map<String, Boolean> harvesterSettings, int x, int y, int z) - { - return true; - } - - @Override - public List<ItemStack> getDrops(World world, Random rand, Map<String, Boolean> harvesterSettings, int x, int y, int z) - { - return world.getBlock(x, y, z).getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), 0); - } - - @Override - public void preHarvest(World world, int x, int y, int z) - { - } - - @Override - public void postHarvest(World world, int x, int y, int z) - { - world.notifyBlocksOfNeighborChange(x, y, z, getPlant()); - } -} diff --git a/src/Java/powercrystals/minefactoryreloaded/farmables/harvestables/HarvestableTreeLeaves.java b/src/Java/powercrystals/minefactoryreloaded/farmables/harvestables/HarvestableTreeLeaves.java deleted file mode 100644 index eaa23bd847..0000000000 --- a/src/Java/powercrystals/minefactoryreloaded/farmables/harvestables/HarvestableTreeLeaves.java +++ /dev/null @@ -1,33 +0,0 @@ -package powercrystals.minefactoryreloaded.farmables.harvestables; - -import net.minecraft.block.Block; -import net.minecraft.world.World; -import powercrystals.minefactoryreloaded.api.HarvestType; - -public class HarvestableTreeLeaves extends HarvestableShearable -{ - public HarvestableTreeLeaves(Block block) - { - super(block, HarvestType.TreeLeaf); - } - - @Override - public void postHarvest(World world, int x, int y, int z) - { - Block id = getPlant(); - - notifyBlock(world, x, y - 1, z, id); - notifyBlock(world, x - 1, y, z, id); - notifyBlock(world, x + 1, y, z, id); - notifyBlock(world, x, y, z - 1, id); - notifyBlock(world, x, y, z + 1, id); - notifyBlock(world, x, y + 1, z, id); - } - - protected void notifyBlock(World world, int x, int y, int z, Block id) - { - Block block = world.getBlock(x, y, z); - if (!block.isLeaves(world, x, y, z)) - world.notifyBlockOfNeighborChange(x, y, z, id); - } -} diff --git a/src/Java/powercrystals/minefactoryreloaded/farmables/plantables/PlantableStandard.java b/src/Java/powercrystals/minefactoryreloaded/farmables/plantables/PlantableStandard.java deleted file mode 100644 index 022d947150..0000000000 --- a/src/Java/powercrystals/minefactoryreloaded/farmables/plantables/PlantableStandard.java +++ /dev/null @@ -1,116 +0,0 @@ -package powercrystals.minefactoryreloaded.farmables.plantables; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import net.minecraftforge.common.IPlantable; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.oredict.OreDictionary; -import powercrystals.minefactoryreloaded.api.IFactoryPlantable; -import powercrystals.minefactoryreloaded.api.ReplacementBlock; - -/* - * Used for directly placing blocks (ie saplings) and items (ie sugarcane). Pass in source ID to constructor, - * so one instance per source ID. - */ - -public class PlantableStandard implements IFactoryPlantable -{ - public static final int WILDCARD = OreDictionary.WILDCARD_VALUE; - - protected Item _seed; - protected Block _block; - protected ReplacementBlock _plantedBlock; - protected int _validMeta; - - public PlantableStandard(Block block) - { - this(Item.getItemFromBlock(block), block); - } - - public PlantableStandard(Block block, Block plantedBlock) - { - this(Item.getItemFromBlock(block), plantedBlock); - } - - public PlantableStandard(Item block, Block plantedBlock) - { - this(block, plantedBlock, WILDCARD); - } - - public PlantableStandard(Block block, int meta) - { - this(Item.getItemFromBlock(block), block, meta); - } - - public PlantableStandard(Block block, Block plantedBlock, int meta) - { - this(Item.getItemFromBlock(block), plantedBlock, meta); - } - - public PlantableStandard(Item block, Block plantedBlock, int validMeta) - { - this(block, plantedBlock, validMeta, new ReplacementBlock(plantedBlock)); - } - - public PlantableStandard(Item block, Block plantedBlock, int validMeta, int plantedMeta) - { - this(block, plantedBlock, validMeta, new ReplacementBlock(plantedBlock).setMeta(plantedMeta)); - } - - public PlantableStandard(Item block, Block plantedBlock, int validMeta, boolean useItemMeta) - { - this(block, plantedBlock, validMeta, new ReplacementBlock(plantedBlock).setMeta(useItemMeta)); - } - - public PlantableStandard(Item block, Block plantedBlock, int validMeta, ReplacementBlock repl) - { - _seed = block; - _block = plantedBlock; - _validMeta = validMeta; - _plantedBlock = repl; - } - - @Override - public boolean canBePlanted(ItemStack stack, boolean forFermenting) - { - return _validMeta == WILDCARD || stack.getItemDamage() == _validMeta; - } - - @Override - public boolean canBePlantedHere(World world, int x, int y, int z, ItemStack stack) - { - if (!world.isAirBlock(x, y, z)) - return false; - - Block groundId = world.getBlock(x, y - 1, z); - return (_block.canPlaceBlockAt(world, x, y, z) && _block.canReplace(world, x, y, z, 0, stack)) || - (_block instanceof IPlantable && groundId != null && - groundId.canSustainPlant(world, x, y, z, ForgeDirection.UP, (IPlantable)_block)); - } - - @Override - public void prePlant(World world, int x, int y, int z, ItemStack stack) - { - return; - } - - @Override - public void postPlant(World world, int x, int y, int z, ItemStack stack) - { - return; - } - - @Override - public ReplacementBlock getPlantedBlock(World world, int x, int y, int z, ItemStack stack) - { - return _plantedBlock; - } - - @Override - public Item getSeed() - { - return _seed; - } -} |