mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-28 15:56:07 +00:00
Added flower support to farming station
* Farming station will now pick flowers (not plant!) * Supported flowers: Vanilla single block, BoP, Botany, Botania
This commit is contained in:
1 parent
172c7a1342
commit
7f9270affc
2 files changed
+86
No files matched your search
@@ -22,6 +22,7 @@ public final class FarmersRegistry {
|
||||
addIC2();
|
||||
addMFR();
|
||||
addThaumcraft();
|
||||
addFlowers();
|
||||
|
||||
FarmersCommune.joinCommune(new StemFarmer(Blocks.reeds, new ItemStack(Items.reeds)));
|
||||
FarmersCommune.joinCommune(new StemFarmer(Blocks.cactus, new ItemStack(Blocks.cactus)));
|
||||
@@ -191,6 +192,16 @@ public final class FarmersRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
private static void addFlowers() {
|
||||
FarmersCommune.joinCommune(new FlowerPicker().add(
|
||||
GameRegistry.findBlock("minecraft", "yellow_flower"),
|
||||
GameRegistry.findBlock("minecraft", "red_flower"),
|
||||
GameRegistry.findBlock("BiomesOPlenty", "flowers"),
|
||||
GameRegistry.findBlock("BiomesOPlenty", "flowers2"),
|
||||
GameRegistry.findBlock("Botany", "flower"),
|
||||
GameRegistry.findBlock("Botania", "flower") ) );
|
||||
}
|
||||
|
||||
private FarmersRegistry() {
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package crazypants.enderio.machine.farm.farmers;
|
||||
|
||||
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.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import crazypants.enderio.machine.farm.TileFarmStation;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
public class FlowerPicker implements IFarmerJoe {
|
||||
|
||||
protected List<Block> flowers = new ArrayList<Block>();
|
||||
|
||||
public FlowerPicker() {
|
||||
}
|
||||
|
||||
public FlowerPicker add(Block... flowers) {
|
||||
for (Block block : flowers) {
|
||||
if (block != null) {
|
||||
this.flowers.add(block);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean prepareBlock(TileFarmStation farm, BlockCoord bc, Block block, int meta) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHarvest(TileFarmStation farm, BlockCoord bc, Block block, int meta) {
|
||||
for (Block flower : flowers) {
|
||||
if (block == flower) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlant(ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IHarvestResult harvestBlock(TileFarmStation farm, BlockCoord bc, Block block, int meta) {
|
||||
|
||||
if(!farm.hasHoe()) {
|
||||
farm.setNotification(TileFarmStation.NOTIFICATION_NO_HOE);
|
||||
return null;
|
||||
}
|
||||
|
||||
World worldObj = farm.getWorldObj();
|
||||
List<EntityItem> result = new ArrayList<EntityItem>();
|
||||
|
||||
ArrayList<ItemStack> drops = block.getDrops(worldObj, bc.x, bc.y, bc.z, meta, farm.getMaxLootingValue());
|
||||
farm.damageHoe(1, bc);
|
||||
farm.actionPerformed(false);
|
||||
if(drops != null) {
|
||||
for (ItemStack stack : drops) {
|
||||
result.add(new EntityItem(worldObj, bc.x + 0.5, bc.y + 0.5, bc.z + 0.5, stack.copy()));
|
||||
}
|
||||
}
|
||||
|
||||
worldObj.setBlockToAir(bc.x, bc.y, bc.z);
|
||||
|
||||
return new HarvestResult(result, bc);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user