mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-20 04:09:43 +00:00
Farm cleanup/refactor.
This commit is contained in:
1 parent
70db4f38e8
commit
6bb86a2e89
4 files changed
+78
-73
No files matched your search
@@ -49,7 +49,7 @@ import crazypants.enderio.machine.alloy.BlockAlloySmelter;
|
||||
import crazypants.enderio.machine.crusher.BlockCrusher;
|
||||
import crazypants.enderio.machine.crusher.CrusherRecipeManager;
|
||||
import crazypants.enderio.machine.farm.BlockFarmStation;
|
||||
import crazypants.enderio.machine.farm.ModdedCrops;
|
||||
import crazypants.enderio.machine.farm.FarmersRegistry;
|
||||
import crazypants.enderio.machine.generator.BlockCombustionGenerator;
|
||||
import crazypants.enderio.machine.generator.BlockStirlingGenerator;
|
||||
import crazypants.enderio.machine.hypercube.BlockHyperCube;
|
||||
@@ -371,7 +371,7 @@ public class EnderIO {
|
||||
CrusherRecipeManager.getInstance().loadRecipesFromConfig();
|
||||
AlloyRecipeManager.getInstance().loadRecipesFromConfig();
|
||||
VatRecipeManager.getInstance().loadRecipesFromConfig();
|
||||
ModdedCrops.addModdedFarmers();
|
||||
FarmersRegistry.addFarmers();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
||||
@@ -20,20 +20,8 @@ public class FarmersComune implements IFarmerJoe {
|
||||
instance.farmers.add(joe);
|
||||
}
|
||||
|
||||
public static void leaveComune(IFarmerJoe joe) {
|
||||
//instance.farmers.remove(joe);
|
||||
throw new UnsupportedOperationException("As if this would be implemented.");
|
||||
}
|
||||
|
||||
static {
|
||||
joinComune(new SeedFarmer(Blocks.potatoes, new ItemStack(Items.potato)));
|
||||
joinComune(new SeedFarmer(Blocks.wheat, new ItemStack(Items.wheat_seeds)));
|
||||
joinComune(new SeedFarmer(Blocks.carrots, new ItemStack(Items.carrot)));
|
||||
joinComune(new NetherWartFarmer());
|
||||
joinComune(new StemFarmer(Blocks.reeds, new ItemStack(Items.reeds)));
|
||||
joinComune(new StemFarmer(Blocks.cactus, new ItemStack(Blocks.cactus)));
|
||||
joinComune(new TreeFarmer(Blocks.sapling, Blocks.log));
|
||||
joinComune(new TreeFarmer(Blocks.sapling, Blocks.log2));
|
||||
public static void leaveComune(IFarmerJoe joe) {
|
||||
throw new UnsupportedOperationException("As if this would be implemented. The comune is for life!");
|
||||
}
|
||||
|
||||
private List<IFarmerJoe> farmers = new ArrayList<IFarmerJoe>();
|
||||
|
||||
+15
-57
@@ -1,19 +1,26 @@
|
||||
package crazypants.enderio.machine.farm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
public final class ModdedCrops {
|
||||
public final class FarmersRegistry {
|
||||
|
||||
public static void addModdedFarmers() {
|
||||
public static void addFarmers() {
|
||||
//vanilla
|
||||
FarmersComune.instance.joinComune(new SeedFarmer(Blocks.potatoes, new ItemStack(Items.potato)));
|
||||
FarmersComune.instance.joinComune(new SeedFarmer(Blocks.wheat, new ItemStack(Items.wheat_seeds)));
|
||||
FarmersComune.instance.joinComune(new SeedFarmer(Blocks.carrots, new ItemStack(Items.carrot)));
|
||||
FarmersComune.instance.joinComune(new NetherWartFarmer());
|
||||
FarmersComune.instance.joinComune(new StemFarmer(Blocks.reeds, new ItemStack(Items.reeds)));
|
||||
FarmersComune.instance.joinComune(new StemFarmer(Blocks.cactus, new ItemStack(Blocks.cactus)));
|
||||
FarmersComune.instance.joinComune(new TreeFarmer(Blocks.sapling, Blocks.log));
|
||||
FarmersComune.instance.joinComune(new TreeFarmer(Blocks.sapling, Blocks.log2));
|
||||
|
||||
addNutura();
|
||||
addTiC();
|
||||
}
|
||||
@@ -78,56 +85,7 @@ public final class ModdedCrops {
|
||||
}
|
||||
}
|
||||
|
||||
private ModdedCrops() {
|
||||
}
|
||||
|
||||
private static class NaturaBerryFarmer extends PickableFarmer {
|
||||
|
||||
public NaturaBerryFarmer(Block plantedBlock, int plantedBlockMeta, int grownBlockMeta, ItemStack seeds) {
|
||||
super(plantedBlock, plantedBlockMeta, grownBlockMeta, seeds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IHarvestResult harvestBlock(TileFarmStation farm, BlockCoord bc, Block block, int meta) {
|
||||
|
||||
if(block != getPlantedBlock()) {
|
||||
return null;
|
||||
}
|
||||
BlockCoord upLoc = bc.getLocation(ForgeDirection.UP);
|
||||
Block aboveBlock = farm.getBlock(upLoc);
|
||||
ArrayList<ItemStack> drops = null;
|
||||
|
||||
if(aboveBlock == getPlantedBlock()) {
|
||||
drops = block.getDrops(farm.getWorld(), upLoc.x, upLoc.y, upLoc.z, meta, farm.getMaxLootingValue());
|
||||
farm.damageMaxLootingItem();
|
||||
farm.actionPerformed();
|
||||
farm.getWorld().setBlockToAir(upLoc.x, upLoc.y, upLoc.z);
|
||||
|
||||
}
|
||||
IHarvestResult res = super.harvestBlock(farm, bc, block, meta);
|
||||
if(drops != null) {
|
||||
if(res == null) {
|
||||
res = new HarvestResult();
|
||||
}
|
||||
res.getHarvestedBlocks().add(upLoc);
|
||||
List<EntityItem> addToDrops = res.getDrops();
|
||||
for(ItemStack stack : drops) {
|
||||
addToDrops.add(new EntityItem(farm.getWorld(), upLoc.x + 0.5, upLoc.y + 1, upLoc.z + 0.5, stack.copy()));
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHarvest(TileFarmStation farm, BlockCoord bc, Block block, int meta) {
|
||||
BlockCoord upLoc = bc.getLocation(ForgeDirection.UP);
|
||||
Block aboveBlock = farm.getBlock(upLoc);
|
||||
if(aboveBlock == getPlantedBlock()) {
|
||||
return true;
|
||||
}
|
||||
return super.canHarvest(farm, bc, block, meta);
|
||||
}
|
||||
|
||||
private FarmersRegistry() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package crazypants.enderio.machine.farm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
public class NaturaBerryFarmer extends PickableFarmer {
|
||||
|
||||
public NaturaBerryFarmer(Block plantedBlock, int plantedBlockMeta, int grownBlockMeta, ItemStack seeds) {
|
||||
super(plantedBlock, plantedBlockMeta, grownBlockMeta, seeds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IHarvestResult harvestBlock(TileFarmStation farm, BlockCoord bc, Block block, int meta) {
|
||||
|
||||
if(block != getPlantedBlock()) {
|
||||
return null;
|
||||
}
|
||||
BlockCoord upLoc = bc.getLocation(ForgeDirection.UP);
|
||||
Block aboveBlock = farm.getBlock(upLoc);
|
||||
ArrayList<ItemStack> drops = null;
|
||||
|
||||
if(aboveBlock == getPlantedBlock()) {
|
||||
drops = block.getDrops(farm.getWorld(), upLoc.x, upLoc.y, upLoc.z, meta, farm.getMaxLootingValue());
|
||||
farm.damageMaxLootingItem();
|
||||
farm.actionPerformed();
|
||||
farm.getWorld().setBlockToAir(upLoc.x, upLoc.y, upLoc.z);
|
||||
|
||||
}
|
||||
IHarvestResult res = super.harvestBlock(farm, bc, block, meta);
|
||||
if(drops != null) {
|
||||
if(res == null) {
|
||||
res = new HarvestResult();
|
||||
}
|
||||
res.getHarvestedBlocks().add(upLoc);
|
||||
List<EntityItem> addToDrops = res.getDrops();
|
||||
for(ItemStack stack : drops) {
|
||||
addToDrops.add(new EntityItem(farm.getWorld(), upLoc.x + 0.5, upLoc.y + 1, upLoc.z + 0.5, stack.copy()));
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHarvest(TileFarmStation farm, BlockCoord bc, Block block, int meta) {
|
||||
BlockCoord upLoc = bc.getLocation(ForgeDirection.UP);
|
||||
Block aboveBlock = farm.getBlock(upLoc);
|
||||
if(aboveBlock == getPlantedBlock()) {
|
||||
return true;
|
||||
}
|
||||
return super.canHarvest(farm, bc, block, meta);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user