2019-01-08 21:23:22 +01:00
|
|
|
package com.minelittlepony.unicopia.item;
|
|
|
|
|
|
|
|
import com.minelittlepony.unicopia.block.BlockTomatoPlant;
|
|
|
|
|
2019-01-10 08:45:05 +01:00
|
|
|
import net.minecraft.block.Block;
|
2019-01-08 21:23:22 +01:00
|
|
|
import net.minecraft.block.state.IBlockState;
|
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.util.EnumActionResult;
|
|
|
|
import net.minecraft.util.EnumFacing;
|
|
|
|
import net.minecraft.util.EnumHand;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
|
|
|
public class ItemTomatoSeeds extends Item {
|
|
|
|
|
|
|
|
public ItemTomatoSeeds(String domain, String name) {
|
|
|
|
setTranslationKey(name);
|
|
|
|
setRegistryName(domain, name);
|
|
|
|
setCreativeTab(CreativeTabs.MATERIALS);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
|
|
|
|
|
|
|
IBlockState state = world.getBlockState(pos);
|
|
|
|
|
2019-01-10 08:45:05 +01:00
|
|
|
Block block = state.getBlock();
|
|
|
|
|
|
|
|
if (block instanceof BlockTomatoPlant) {
|
|
|
|
if (((BlockTomatoPlant)block).plant(world, pos, state)) {
|
2019-01-10 10:34:32 +01:00
|
|
|
if (!player.capabilities.isCreativeMode) {
|
|
|
|
player.getHeldItem(hand).shrink(1);
|
|
|
|
}
|
2019-01-10 08:45:05 +01:00
|
|
|
|
2019-01-08 21:23:22 +01:00
|
|
|
return EnumActionResult.SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return EnumActionResult.PASS;
|
|
|
|
}
|
|
|
|
}
|