mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-18 11:19:28 +00:00
61 lines
2.1 KiB
Java
61 lines
2.1 KiB
Java
/*******************************************************************************
|
|
* 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.init.Blocks;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.util.math.BlockPos;
|
|
import net.minecraft.world.World;
|
|
|
|
import forestry.api.farming.ICrop;
|
|
import forestry.core.config.Constants;
|
|
import forestry.core.proxy.Proxies;
|
|
import forestry.core.utils.BlockUtil;
|
|
import forestry.core.utils.ItemStackUtil;
|
|
import forestry.core.utils.vect.Vect;
|
|
import forestry.farming.PluginFarming;
|
|
|
|
public class FarmableVanillaMushroom extends FarmableGenericSapling {
|
|
|
|
public FarmableVanillaMushroom(Block sapling, int saplingMeta) {
|
|
super(sapling, saplingMeta);
|
|
}
|
|
|
|
@Override
|
|
public ICrop getCropAt(World world, BlockPos pos) {
|
|
Block block = BlockUtil.getBlock(world, pos);
|
|
|
|
if (block != Blocks.BROWN_MUSHROOM_BLOCK && block != Blocks.RED_MUSHROOM_BLOCK) {
|
|
return null;
|
|
}
|
|
|
|
return new CropBlock(world, block, BlockUtil.getBlockMetadata(world, pos), new Vect(pos));
|
|
}
|
|
|
|
@Override
|
|
public boolean isGermling(ItemStack itemstack) {
|
|
return ItemStackUtil.equals(sapling, itemstack);
|
|
}
|
|
|
|
@Override
|
|
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
|
|
int meta = 0;
|
|
if (ItemStackUtil.equals(Blocks.RED_MUSHROOM, germling)) {
|
|
meta = 1;
|
|
}
|
|
|
|
Proxies.common.addBlockPlaceEffects(world, pos, Blocks.BROWN_MUSHROOM.getDefaultState());
|
|
return world.setBlockState(pos, PluginFarming.blocks.mushroom.getStateFromMeta(meta), Constants.FLAG_BLOCK_SYNCH_AND_UPDATE);
|
|
}
|
|
}
|