Skip to content

Commit

Permalink
Add back right click harvesting on cotton crops #400
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbegt committed Oct 21, 2017
1 parent 36f2d65 commit ef28578
Showing 1 changed file with 57 additions and 0 deletions.
Expand Up @@ -6,7 +6,15 @@
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.util.FakePlayer;

public class BlockNaturaCotton extends BlockOverworldCrops
{
Expand Down Expand Up @@ -47,4 +55,53 @@ protected ItemStack getCrop()
return NaturaCommons.cotton.copy();
}

@Override
public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn)
{
if (!worldIn.isRemote)
{
int age = worldIn.getBlockState(pos).getValue(AGE).intValue();

if (age == 4)
{
worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, Integer.valueOf(2)), 3);

EntityItem entityitem = new EntityItem(worldIn, playerIn.posX, playerIn.posY - 1.0D, playerIn.posZ, NaturaCommons.cotton.copy());

worldIn.spawnEntity(entityitem);

if (!(playerIn instanceof FakePlayer))
{
entityitem.onCollideWithPlayer(playerIn);
}
}
}
}

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
int age = state.getValue(AGE).intValue();

if (age == 4)
{
if (worldIn.isRemote)
return true;

worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, Integer.valueOf(2)), 3);

EntityItem entityitem = new EntityItem(worldIn, playerIn.posX, playerIn.posY - 1.0D, playerIn.posZ, NaturaCommons.cotton.copy());

worldIn.spawnEntity(entityitem);

if (!(playerIn instanceof FakePlayer))
{
entityitem.onCollideWithPlayer(playerIn);
}
return true;
}

return false;
}

}

0 comments on commit ef28578

Please sign in to comment.