mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-28 15:36:18 +00:00
50 lines
1.8 KiB
Java
Executable File
50 lines
1.8 KiB
Java
Executable File
/*******************************************************************************
|
|
* 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 forestry.api.genetics.IFruitBearer;
|
|
import forestry.core.network.packets.PacketFXSignal;
|
|
import forestry.core.tiles.TileUtil;
|
|
import forestry.core.utils.NetworkUtil;
|
|
import net.minecraft.block.state.IBlockState;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.tileentity.TileEntity;
|
|
import net.minecraft.util.NonNullList;
|
|
import net.minecraft.util.math.BlockPos;
|
|
import net.minecraft.world.World;
|
|
|
|
public class CropFruit extends Crop {
|
|
|
|
public CropFruit(World world, BlockPos position) {
|
|
super(world, position);
|
|
}
|
|
|
|
@Override
|
|
protected boolean isCrop(World world, BlockPos pos) {
|
|
IFruitBearer bearer = TileUtil.getTile(world, pos, IFruitBearer.class);
|
|
return bearer != null && bearer.hasFruit() && bearer.getRipeness() >= 0.9f;
|
|
}
|
|
|
|
@Override
|
|
protected NonNullList<ItemStack> harvestBlock(World world, BlockPos pos) {
|
|
IFruitBearer tile = TileUtil.getTile(world, pos, IFruitBearer.class);
|
|
if (tile == null) {
|
|
return NonNullList.create();
|
|
}
|
|
|
|
IBlockState blockState = world.getBlockState(pos);
|
|
PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.VisualFXType.BLOCK_BREAK, PacketFXSignal.SoundFXType.BLOCK_BREAK, pos, blockState);
|
|
NetworkUtil.sendNetworkPacket(packet, pos, world);
|
|
return tile.pickFruit(ItemStack.EMPTY);
|
|
}
|
|
|
|
}
|