mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-19 19:59:58 +00:00
Cleaned up farmers seed handling, now works with Harvest Craft crops with no special handling.
This commit is contained in:
1 parent
a1b12f75c6
commit
513c009f62
11 files changed
+287
-67
No files matched your search
@@ -249,8 +249,9 @@ public final class Config {
|
||||
public static void syncConfig() {
|
||||
try {
|
||||
Config.processConfig(config);
|
||||
} catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
Log.error("EnderIO has a problem loading it's configuration");
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if(config.hasChanged()) {
|
||||
config.save();
|
||||
@@ -609,7 +610,7 @@ public final class Config {
|
||||
useModMetals = config.get(sectionRecipe.name, "useModMetals", useModMetals,
|
||||
"If true copper and tin will be used in recipes when registered in the ore dictionary").getBoolean(useModMetals);
|
||||
|
||||
nutrientFoodBoostDelay = config.get(sectionFluid.name, "nutrientFluidFoodBoostDelay", nutrientFoodBoostDelay, "The delay in ticks between when nutrient distillation boosts your food value.").getInt();
|
||||
nutrientFoodBoostDelay = config.get(sectionFluid.name, "nutrientFluidFoodBoostDelay", nutrientFoodBoostDelay, "The delay in ticks between when nutrient distillation boosts your food value.").getInt((int)nutrientFoodBoostDelay);
|
||||
}
|
||||
|
||||
private Config() {
|
||||
|
||||
+5
-5
@@ -12,7 +12,7 @@ import net.minecraftforge.common.IPlantable;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
public class SeedFarmer implements IFarmerJoe {
|
||||
public class CustomSeedFarmer implements IFarmerJoe {
|
||||
|
||||
protected Block plantedBlock;
|
||||
protected int plantedBlockMeta;
|
||||
@@ -22,15 +22,15 @@ public class SeedFarmer implements IFarmerJoe {
|
||||
protected List<Block> tilledBlocks = new ArrayList<Block>();
|
||||
protected boolean ignoreSustainCheck = false;
|
||||
|
||||
public SeedFarmer(Block plantedBlock, ItemStack seeds) {
|
||||
public CustomSeedFarmer(Block plantedBlock, ItemStack seeds) {
|
||||
this(plantedBlock, 0, 7, seeds);
|
||||
}
|
||||
|
||||
public SeedFarmer(Block plantedBlock, int grownBlockMeta, ItemStack seeds) {
|
||||
public CustomSeedFarmer(Block plantedBlock, int grownBlockMeta, ItemStack seeds) {
|
||||
this(plantedBlock, 0, grownBlockMeta, seeds);
|
||||
}
|
||||
|
||||
public SeedFarmer(Block plantedBlock, int plantedBlockMeta, int grownBlockMeta, ItemStack seeds) {
|
||||
public CustomSeedFarmer(Block plantedBlock, int plantedBlockMeta, int grownBlockMeta, ItemStack seeds) {
|
||||
this.plantedBlock = plantedBlock;
|
||||
this.plantedBlockMeta = plantedBlockMeta;
|
||||
this.grownBlockMeta = grownBlockMeta;
|
||||
@@ -109,7 +109,7 @@ public class SeedFarmer implements IFarmerJoe {
|
||||
|
||||
protected boolean plantFromInventory(TileFarmStation farm, BlockCoord bc) {
|
||||
World worldObj = farm.getWorldObj();
|
||||
if(canPlant(worldObj, bc) && farm.getSeedFromSupplies(getSeeds(), bc) != null) {
|
||||
if(canPlant(worldObj, bc) && farm.takeSeedFromSupplies(getSeeds(), bc) != null) {
|
||||
return plant(farm, worldObj, bc);
|
||||
}
|
||||
return false;
|
||||
@@ -1,60 +1,37 @@
|
||||
package crazypants.enderio.machine.farm;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockCrops;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import crazypants.enderio.Log;
|
||||
|
||||
public final class FarmersRegistry {
|
||||
|
||||
public static void addFarmers() {
|
||||
//vanilla
|
||||
FarmersCommune.instance.joinCommune(new MelonFarmer(Blocks.melon_stem, Blocks.melon_block, new ItemStack(Items.melon_seeds)));
|
||||
FarmersCommune.instance.joinCommune(new MelonFarmer(Blocks.pumpkin_stem, Blocks.pumpkin, new ItemStack(Items.pumpkin_seeds)));
|
||||
FarmersCommune.instance.joinCommune(new SeedFarmer(Blocks.potatoes, new ItemStack(Items.potato)));
|
||||
FarmersCommune.instance.joinCommune(new SeedFarmer(Blocks.wheat, new ItemStack(Items.wheat_seeds)));
|
||||
FarmersCommune.instance.joinCommune(new SeedFarmer(Blocks.carrots, new ItemStack(Items.carrot)));
|
||||
FarmersCommune.instance.joinCommune(new NetherWartFarmer());
|
||||
FarmersCommune.instance.joinCommune(new StemFarmer(Blocks.reeds, new ItemStack(Items.reeds)));
|
||||
FarmersCommune.instance.joinCommune(new StemFarmer(Blocks.cactus, new ItemStack(Blocks.cactus)));
|
||||
FarmersCommune.instance.joinCommune(new TreeFarmer(Blocks.sapling, Blocks.log));
|
||||
FarmersCommune.instance.joinCommune(new TreeFarmer(Blocks.sapling, Blocks.log2));
|
||||
|
||||
addExtraUtilities();
|
||||
addNutura();
|
||||
addTiC();
|
||||
addStillHungry();
|
||||
addIC2();
|
||||
|
||||
FarmersCommune.instance.joinCommune(new StemFarmer(Blocks.reeds, new ItemStack(Items.reeds)));
|
||||
FarmersCommune.instance.joinCommune(new StemFarmer(Blocks.cactus, new ItemStack(Blocks.cactus)));
|
||||
FarmersCommune.instance.joinCommune(new TreeFarmer(Blocks.sapling, Blocks.log));
|
||||
FarmersCommune.instance.joinCommune(new TreeFarmer(Blocks.sapling, Blocks.log2));
|
||||
//special case of plantables to get spacing correct
|
||||
FarmersCommune.instance.joinCommune(new MelonFarmer(Blocks.melon_stem, Blocks.melon_block, new ItemStack(Items.melon_seeds)));
|
||||
FarmersCommune.instance.joinCommune(new MelonFarmer(Blocks.pumpkin_stem, Blocks.pumpkin, new ItemStack(Items.pumpkin_seeds)));
|
||||
//Handles all 'vanilla' style crops
|
||||
FarmersCommune.instance.joinCommune(new PlantableFarmer());
|
||||
}
|
||||
|
||||
private static void addIC2() {
|
||||
RubberTreeFarmerIC2 rtf = new RubberTreeFarmerIC2();
|
||||
if(rtf.isValid()) {
|
||||
FarmersCommune.instance.joinCommune(rtf);
|
||||
}
|
||||
}
|
||||
|
||||
private static void addStillHungry() {
|
||||
String mod = "stillhungry";
|
||||
addSeed(mod, "strawberryBlock", "StillHungry_strawberrySeed");
|
||||
addPickable(mod, "grapeBlock", "StillHungry_grapeSeed");
|
||||
addSeed(mod, "riceBlock", "StillHungry_riceSeed");
|
||||
}
|
||||
|
||||
|
||||
private static void addExtraUtilities() {
|
||||
String mod = "ExtraUtilities";
|
||||
String name = "plant/ender_lilly";
|
||||
|
||||
SeedFarmer farmer = addSeed(mod, name, name, Blocks.end_stone, GameRegistry.findBlock(mod, "decorativeBlock1"));
|
||||
if(farmer != null) {
|
||||
farmer.setIgnoreGroundCanSustainCheck(true);
|
||||
}
|
||||
}
|
||||
|
||||
private static void addPickable(String mod, String blockName, String itemName) {
|
||||
public static void addPickable(String mod, String blockName, String itemName) {
|
||||
Block cropBlock = GameRegistry.findBlock(mod, blockName);
|
||||
if(cropBlock != null) {
|
||||
Item seedItem = GameRegistry.findItem(mod, itemName);
|
||||
@@ -63,15 +40,15 @@ public final class FarmersRegistry {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static SeedFarmer addSeed(String mod, String blockName, String itemName, Block... extraFarmland) {
|
||||
|
||||
public static CustomSeedFarmer addSeed(String mod, String blockName, String itemName, Block... extraFarmland) {
|
||||
Block cropBlock = GameRegistry.findBlock(mod, blockName);
|
||||
if(cropBlock != null) {
|
||||
Item seedItem = GameRegistry.findItem(mod, itemName);
|
||||
if(seedItem != null) {
|
||||
SeedFarmer farmer = new SeedFarmer(cropBlock, new ItemStack(seedItem));
|
||||
CustomSeedFarmer farmer = new CustomSeedFarmer(cropBlock, new ItemStack(seedItem));
|
||||
if(extraFarmland != null) {
|
||||
for(Block farmland : extraFarmland) {
|
||||
for (Block farmland : extraFarmland) {
|
||||
if(farmland != null) {
|
||||
farmer.addTilledBlock(farmland);
|
||||
}
|
||||
@@ -124,7 +101,7 @@ public final class FarmersRegistry {
|
||||
Item seedItem = GameRegistry.findItem(mod, "barley.seed");
|
||||
if(seedItem != null) {
|
||||
//barley
|
||||
FarmersCommune.instance.joinCommune(new SeedFarmer(cropBlock, 3, new ItemStack(seedItem)));
|
||||
FarmersCommune.instance.joinCommune(new CustomSeedFarmer(cropBlock, 3, new ItemStack(seedItem)));
|
||||
// cotton
|
||||
FarmersCommune.instance.joinCommune(new PickableFarmer(cropBlock, 4, 8, new ItemStack(seedItem, 1, 1)));
|
||||
}
|
||||
@@ -142,21 +119,43 @@ public final class FarmersRegistry {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
blockName = "florasapling";
|
||||
Block saplingBlock = GameRegistry.findBlock(mod, blockName);
|
||||
if(saplingBlock != null) {
|
||||
FarmersCommune.instance.joinCommune(new TreeFarmer(saplingBlock,
|
||||
GameRegistry.findBlock(mod, "tree"),
|
||||
if(saplingBlock != null) {
|
||||
FarmersCommune.instance.joinCommune(new TreeFarmer(saplingBlock,
|
||||
GameRegistry.findBlock(mod, "tree"),
|
||||
GameRegistry.findBlock(mod, "willow"),
|
||||
GameRegistry.findBlock(mod, "Dark Tree")));
|
||||
GameRegistry.findBlock(mod, "Dark Tree")));
|
||||
}
|
||||
blockName = "Rare Sapling";
|
||||
saplingBlock = GameRegistry.findBlock(mod, blockName);
|
||||
if(saplingBlock != null) {
|
||||
FarmersCommune.instance.joinCommune(new TreeFarmer(saplingBlock, GameRegistry.findBlock(mod, "Rare Tree")));
|
||||
if(saplingBlock != null) {
|
||||
FarmersCommune.instance.joinCommune(new TreeFarmer(saplingBlock, GameRegistry.findBlock(mod, "Rare Tree")));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void addIC2() {
|
||||
RubberTreeFarmerIC2 rtf = new RubberTreeFarmerIC2();
|
||||
if(rtf.isValid()) {
|
||||
FarmersCommune.instance.joinCommune(rtf);
|
||||
}
|
||||
}
|
||||
|
||||
private static void addStillHungry() {
|
||||
String mod = "stillhungry";
|
||||
addPickable(mod, "grapeBlock", "StillHungry_grapeSeed");
|
||||
}
|
||||
|
||||
private static void addExtraUtilities() {
|
||||
String mod = "ExtraUtilities";
|
||||
String name = "plant/ender_lilly";
|
||||
|
||||
CustomSeedFarmer farmer = addSeed(mod, name, name, Blocks.end_stone, GameRegistry.findBlock(mod, "decorativeBlock1"));
|
||||
if(farmer != null) {
|
||||
farmer.setIgnoreGroundCanSustainCheck(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private FarmersRegistry() {
|
||||
|
||||
@@ -5,7 +5,7 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class MelonFarmer extends SeedFarmer {
|
||||
public class MelonFarmer extends CustomSeedFarmer {
|
||||
|
||||
private Block grownBlock;
|
||||
|
||||
@@ -19,7 +19,9 @@ public class MelonFarmer extends SeedFarmer {
|
||||
int xVal = farm.getLocation().x % 2;
|
||||
int zVal = farm.getLocation().z % 2;
|
||||
if(bc.x % 2 != xVal || bc.z % 2 != zVal) {
|
||||
return false;
|
||||
//if we have melon seeds, we still want ot return true here so they are not planted by the default plantable
|
||||
//handlers
|
||||
return canPlant(farm.getSeedTypeInSuppliesFor(bc));
|
||||
}
|
||||
return super.prepareBlock(farm, bc, block, meta);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
public class NetherWartFarmer extends SeedFarmer {
|
||||
public class NetherWartFarmer extends CustomSeedFarmer {
|
||||
|
||||
public NetherWartFarmer() {
|
||||
super(Blocks.nether_wart, 3, new ItemStack(Items.nether_wart));
|
||||
|
||||
@@ -10,7 +10,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
public class PickableFarmer extends SeedFarmer {
|
||||
public class PickableFarmer extends CustomSeedFarmer {
|
||||
|
||||
public PickableFarmer(Block plantedBlock, int plantedBlockMeta, int grownBlockMeta, ItemStack seeds) {
|
||||
super(plantedBlock, plantedBlockMeta, grownBlockMeta, seeds);
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
package crazypants.enderio.machine.farm;
|
||||
|
||||
import static net.minecraftforge.common.EnumPlantType.Cave;
|
||||
import static net.minecraftforge.common.EnumPlantType.Crop;
|
||||
import static net.minecraftforge.common.EnumPlantType.Desert;
|
||||
import static net.minecraftforge.common.EnumPlantType.Nether;
|
||||
import static net.minecraftforge.common.EnumPlantType.Plains;
|
||||
import static net.minecraftforge.common.EnumPlantType.Water;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockStem;
|
||||
import net.minecraft.block.IGrowable;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
public class PlantableFarmer implements IFarmerJoe {
|
||||
|
||||
@Override
|
||||
public boolean canPlant(ItemStack stack) {
|
||||
if(stack == null) {
|
||||
return false;
|
||||
}
|
||||
return stack.getItem() instanceof IPlantable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean prepareBlock(TileFarmStation farm, BlockCoord bc, Block block, int meta) {
|
||||
if(block == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemStack seedStack = farm.getSeedTypeInSuppliesFor(bc);
|
||||
if(seedStack == null) {
|
||||
return false;
|
||||
}
|
||||
if(!(seedStack.getItem() instanceof IPlantable)) {
|
||||
return false;
|
||||
|
||||
}
|
||||
IPlantable plantable = (IPlantable) seedStack.getItem();
|
||||
EnumPlantType type = plantable.getPlantType(farm.getWorld(), bc.x, bc.y, bc.z);
|
||||
if(type == null) {
|
||||
return false;
|
||||
}
|
||||
Block ground = farm.getBlock(bc.getLocation(ForgeDirection.DOWN));
|
||||
if(type == EnumPlantType.Nether) {
|
||||
if(ground != Blocks.soul_sand) {
|
||||
return false;
|
||||
}
|
||||
return plantFromInventory(farm, bc, plantable);
|
||||
}
|
||||
|
||||
if(type == EnumPlantType.Crop) {
|
||||
if(!farm.tillBlock(bc)) {
|
||||
return false;
|
||||
}
|
||||
return plantFromInventory(farm, bc, plantable);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
// From BlockBush, as a reference
|
||||
// @Override
|
||||
// public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z)
|
||||
// {
|
||||
// if (this == Blocks.wheat) return Crop;
|
||||
// if (this == Blocks.carrots) return Crop;
|
||||
// if (this == Blocks.potatoes) return Crop;
|
||||
// if (this == Blocks.melon_stem) return Crop;
|
||||
// if (this == Blocks.pumpkin_stem) return Crop;
|
||||
// if (this == Blocks.deadbush) return Desert;
|
||||
// if (this == Blocks.waterlily) return Water;
|
||||
// if (this == Blocks.red_mushroom) return Cave;
|
||||
// if (this == Blocks.brown_mushroom) return Cave;
|
||||
// if (this == Blocks.nether_wart) return Nether;
|
||||
// if (this == Blocks.sapling) return Plains;
|
||||
// if (this == Blocks.tallgrass) return Plains;
|
||||
// if (this == Blocks.double_plant) return Plains;
|
||||
// if (this == Blocks.red_flower) return Plains;
|
||||
// if (this == Blocks.yellow_flower) return Plains;
|
||||
// return Plains;
|
||||
// }
|
||||
|
||||
protected boolean plantFromInventory(TileFarmStation farm, BlockCoord bc, IPlantable plantable) {
|
||||
World worldObj = farm.getWorldObj();
|
||||
if(canPlant(worldObj, bc, plantable) && farm.takeSeedFromSupplies(bc) != null) {
|
||||
return plant(farm, worldObj, bc, plantable);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean plant(TileFarmStation farm, World worldObj, BlockCoord bc, IPlantable plantable) {
|
||||
worldObj.setBlock(bc.x, bc.y, bc.z, Blocks.air, 0, 1 | 2);
|
||||
Block target = plantable.getPlant(null, 0, 0, 0);
|
||||
int meta = plantable.getPlantMetadata(null, 0, 0, 0);
|
||||
worldObj.setBlock(bc.x, bc.y, bc.z, target, meta, 1 | 2);
|
||||
farm.actionPerformed();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean canPlant(World worldObj, BlockCoord bc, IPlantable plantable) {
|
||||
Block target = plantable.getPlant(null, 0, 0, 0);
|
||||
Block ground = worldObj.getBlock(bc.x, bc.y - 1, bc.z);
|
||||
if(target.canPlaceBlockAt(worldObj, bc.x, bc.y, bc.z) &&
|
||||
target.canBlockStay(worldObj, bc.x, bc.y, bc.z) &&
|
||||
ground.canSustainPlant(worldObj, bc.x, bc.y - 1, bc.z, ForgeDirection.UP, plantable)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHarvest(TileFarmStation farm, BlockCoord bc, Block block, int meta) {
|
||||
if(block instanceof IGrowable && !(block instanceof BlockStem)) {
|
||||
return !((IGrowable)block).func_149851_a(farm.getWorldObj(), bc.x, bc.y, bc.z, true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IHarvestResult harvestBlock(TileFarmStation farm, BlockCoord bc, Block block, int meta) {
|
||||
if(!canHarvest(farm, bc, block, meta) || !farm.hasDefaultHarvestTool()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
World worldObj = farm.getWorldObj();
|
||||
List<EntityItem> result = new ArrayList<EntityItem>();
|
||||
|
||||
ItemStack removedPlantable = null;
|
||||
|
||||
ArrayList<ItemStack> drops = block.getDrops(worldObj, bc.x, bc.y, bc.z, meta, farm.getMaxLootingValue());
|
||||
farm.damageMaxLootingItem(1, bc, block);
|
||||
farm.actionPerformed();
|
||||
boolean removed = false;
|
||||
if(drops != null) {
|
||||
for (ItemStack stack : drops) {
|
||||
if(stack != null && !removed && isPlantableForBlock(stack, block)) {
|
||||
stack.stackSize--;
|
||||
removed = true;
|
||||
removedPlantable = stack.copy();
|
||||
if(stack.stackSize > 0) {
|
||||
result.add(new EntityItem(worldObj, bc.x + 0.5, bc.y + 0.5, bc.z + 0.5, stack.copy()));
|
||||
}
|
||||
} else {
|
||||
result.add(new EntityItem(worldObj, bc.x + 0.5, bc.y + 0.5, bc.z + 0.5, stack.copy()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(removed) {
|
||||
if(!plant(farm, worldObj, bc, (IPlantable)removedPlantable.getItem())) {
|
||||
result.add(new EntityItem(worldObj, bc.x + 0.5, bc.y + 0.5, bc.z + 0.5, removedPlantable.copy()));
|
||||
worldObj.setBlock(bc.x, bc.y, bc.z, Blocks.air, 0, 1 | 2);
|
||||
}
|
||||
} else {
|
||||
worldObj.setBlock(bc.x, bc.y, bc.z, Blocks.air, 0, 1 | 2);
|
||||
}
|
||||
|
||||
return new HarvestResult(result, bc);
|
||||
}
|
||||
|
||||
private boolean isPlantableForBlock(ItemStack stack, Block block) {
|
||||
if(!(stack.getItem() instanceof IPlantable)) {
|
||||
return false;
|
||||
}
|
||||
IPlantable plantable = (IPlantable)stack.getItem();
|
||||
return plantable.getPlant(null, 0, 0, 0) == block;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
public class StemFarmer extends SeedFarmer {
|
||||
public class StemFarmer extends CustomSeedFarmer {
|
||||
|
||||
|
||||
public StemFarmer(Block plantedBlock, ItemStack seeds) {
|
||||
@@ -68,7 +68,7 @@ public class StemFarmer extends SeedFarmer {
|
||||
@Override
|
||||
protected boolean plantFromInventory(TileFarmStation farm, BlockCoord bc) {
|
||||
World worldObj = farm.getWorldObj();
|
||||
if(canPlant(worldObj, bc) && farm.getSeedFromSupplies(seeds, bc) != null) {
|
||||
if(canPlant(worldObj, bc) && farm.takeSeedFromSupplies(seeds, bc) != null) {
|
||||
return plant(farm, worldObj, bc);
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -9,12 +9,15 @@ import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemAxe;
|
||||
import net.minecraft.item.ItemHoe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import crazypants.enderio.EnderIO;
|
||||
@@ -74,6 +77,22 @@ public class TileFarmStation extends AbstractPoweredTaskEntity /*implements IEnt
|
||||
usePower(Config.farmActionEnergyUse * (getUpgradeDist() * upgradeBonusSize));
|
||||
}
|
||||
|
||||
public boolean tillBlock(BlockCoord plantingLocation) {
|
||||
BlockCoord dirtLoc = plantingLocation.getLocation(ForgeDirection.DOWN);
|
||||
Block dirtBlock = getBlock(dirtLoc);
|
||||
if((dirtBlock == Blocks.dirt || dirtBlock == Blocks.grass) && hasHoe()) {
|
||||
damageHoe(1, dirtLoc);
|
||||
worldObj.setBlock(dirtLoc.x, dirtLoc.y, dirtLoc.z, Blocks.farmland);
|
||||
worldObj.playSoundEffect(dirtLoc.x + 0.5F, dirtLoc.y + 0.5F, dirtLoc.z + 0.5F, Blocks.farmland.stepSound.getStepResourcePath(),
|
||||
(Blocks.farmland.stepSound.getVolume() + 1.0F) / 2.0F, Blocks.farmland.stepSound.getPitch() * 0.8F);
|
||||
actionPerformed();
|
||||
return true;
|
||||
} else if(dirtBlock == Blocks.farmland) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getMaxLootingValue() {
|
||||
int result = 0;
|
||||
for (int i = minToolSlot; i <= maxToolSlot; i++) {
|
||||
@@ -298,11 +317,11 @@ public class TileFarmStation extends AbstractPoweredTaskEntity /*implements IEnt
|
||||
return false;
|
||||
}
|
||||
|
||||
public ItemStack getSeedFromSupplies(ItemStack stack, BlockCoord forBlock) {
|
||||
return getSeedFromSupplies(stack, forBlock, true);
|
||||
public ItemStack takeSeedFromSupplies(ItemStack stack, BlockCoord forBlock) {
|
||||
return takeSeedFromSupplies(stack, forBlock, true);
|
||||
}
|
||||
|
||||
public ItemStack getSeedFromSupplies(ItemStack stack, BlockCoord forBlock, boolean matchMetadata) {
|
||||
public ItemStack takeSeedFromSupplies(ItemStack stack, BlockCoord forBlock, boolean matchMetadata) {
|
||||
if(stack == null || forBlock == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -323,6 +342,19 @@ public class TileFarmStation extends AbstractPoweredTaskEntity /*implements IEnt
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack takeSeedFromSupplies(BlockCoord bc) {
|
||||
return takeSeedFromSupplies(getSeedTypeInSuppliesFor(bc), bc);
|
||||
}
|
||||
|
||||
public ItemStack getSeedTypeInSuppliesFor(BlockCoord bc) {
|
||||
int slot = getSupplySlotForCoord(bc);
|
||||
ItemStack inv = inventory[slot];
|
||||
if(inv != null) {
|
||||
return inv.copy();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected int getSupplySlotForCoord(BlockCoord forBlock) {
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ public class TreeFarmer implements IFarmerJoe {
|
||||
protected boolean plantFromInventory(TileFarmStation farm, BlockCoord bc, Block block, int meta) {
|
||||
World worldObj = farm.getWorldObj();
|
||||
if(canPlant(worldObj, bc)) {
|
||||
ItemStack seed = farm.getSeedFromSupplies(saplingItem, bc, false);
|
||||
ItemStack seed = farm.takeSeedFromSupplies(saplingItem, bc, false);
|
||||
if(seed != null) {
|
||||
return plant(farm, worldObj, bc, seed);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.text.NumberFormat;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -46,6 +47,11 @@ public class ItemConduitProbe extends Item implements IResourceTooltipProvider {
|
||||
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float par8,
|
||||
float par9, float par10) {
|
||||
|
||||
Block blk = world.getBlock(x, y, z);
|
||||
if(blk != null) {
|
||||
System.out.println("ItemConduitProbe.onItemUse: " + blk.getUnlocalizedName());
|
||||
}
|
||||
|
||||
if(player.isSneaking()) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
Reference in new issue
Block a user