Add AgriCraft cropstick plants to Orchard

This commit is contained in:
Nirek-K authored and mezz committed 2015-04-09 21:37:59 -07:00
1 parent f4d671ba2a
commit 4be4606854
4 files changed
+169

No files matched your search

@@ -0,0 +1,56 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.farming.logic;
import java.util.ArrayList;
import java.util.Collection;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import forestry.core.config.Defaults;
import forestry.core.proxy.Proxies;
import forestry.core.vect.Vect;
public class CropBasicAgriCraft extends Crop {
protected final Block block;
protected final int meta;
public CropBasicAgriCraft(World world, Block block, int meta, Vect position) {
super(world, position);
this.block = block;
this.meta = meta;
}
@Override
protected boolean isCrop(Vect pos) {
return getBlock(pos) == block && getBlockMeta(pos) == meta;
}
@Override
protected Collection<ItemStack> harvestBlock(Vect pos) {
ArrayList<ItemStack> harvest = block.getDrops(world, pos.x, pos.y, pos.z, meta, 0);
if (harvest.size() > 1) {
harvest.remove(1); //AgriCraft returns cropsticks in 0, seeds in 1 in getDrops, removing since harvesting doesn't return them.
}
harvest.remove(0);
Proxies.common.addBlockDestroyEffects(world, pos.x, pos.y, pos.z, block, 0);
world.setBlockMetadataWithNotify(pos.x, pos.y, pos.z, 0, Defaults.FLAG_BLOCK_SYNCH);
return harvest;
}
@Override
public String toString() {
return String.format("CropBasicAgriCraft [ position: [ %s ]; block: %s; meta: %s ]", position.toString(), block.getUnlocalizedName(), meta);
}
}
@@ -0,0 +1,65 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.farming.logic;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmable;
import forestry.core.config.Defaults;
import forestry.core.utils.StackUtils;
import forestry.core.vect.Vect;
public class FarmableBasicAgricraft implements IFarmable {
private final Block block;
private final int matureMeta;
public FarmableBasicAgricraft(Block block, int matureMeta) {
this.block = block;
this.matureMeta = matureMeta;
}
@Override
public boolean isSaplingAt(World world, int x, int y, int z) {
return world.getBlock(x, y, z) == block;
}
@Override
public ICrop getCropAt(World world, int x, int y, int z) {
if (world.getBlock(x, y, z) != block) {
return null;
}
if (world.getBlockMetadata(x, y, z) != matureMeta) {
return null;
}
return new CropBasicAgriCraft(world, block, matureMeta, new Vect(x, y, z));
}
@Override
public boolean isGermling(ItemStack itemstack) {
return StackUtils.equals(block, itemstack);
}
@Override
public boolean isWindfall(ItemStack itemstack) {
return false;
}
@Override
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
return world.setBlock(x, y, z, block, 0, Defaults.FLAG_BLOCK_SYNCH);
}
}
@@ -0,0 +1,47 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.plugins;
import net.minecraft.block.Block;
import cpw.mods.fml.common.registry.GameRegistry;
import forestry.api.farming.Farmables;
import forestry.core.config.Defaults;
import forestry.core.proxy.Proxies;
import forestry.farming.logic.FarmableBasicAgricraft;
@Plugin(pluginID = "AgriCraft", name = "AgriCraft", author = "Nirek", url = Defaults.URL, unlocalizedDescription = "for.plugin.agricraft.description")
public class PluginAgriCraft extends ForestryPlugin {
private static final String AgriCraft = "AgriCraft";
@Override
public boolean isAvailable() {
return Proxies.common.isModLoaded(AgriCraft);
}
@Override
public String getFailMessage() {
return "AgriCraft";
}
@Override
protected void registerRecipes() {
Block cropBlock = GameRegistry.findBlock(AgriCraft, "crops");
if (cropBlock != null) {
Farmables.farmables.get("farmOrchard").add(new FarmableBasicAgricraft(cropBlock, 7));
}
}
}
@@ -85,6 +85,7 @@ public class PluginManager {
BUILDCRAFT_TRANSPORT(new PluginBuildCraftTransport()),
PROPOLIS_PIPE(new PluginPropolisPipe()),
AGRICRAFT(new PluginAgriCraft()),
BIOMESOPLENTY(new PluginBiomesOPlenty()),
CHISEL(new PluginChisel()),
EXTRAUTILITIES(new PluginExtraUtilities()),