Unicopia/src/main/java/com/minelittlepony/unicopia/item/ItemTomatoSeeds.java

44 lines
1.3 KiB
Java
Raw Normal View History

2019-01-08 21:23:22 +01:00
package com.minelittlepony.unicopia.item;
import com.minelittlepony.unicopia.block.BlockTomatoPlant;
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);
Block block = state.getBlock();
if (block instanceof BlockTomatoPlant) {
if (((BlockTomatoPlant)block).plant(world, pos, state)) {
if (!player.capabilities.isCreativeMode) {
player.getHeldItem(hand).shrink(1);
}
2019-01-08 21:23:22 +01:00
return EnumActionResult.SUCCESS;
}
}
return EnumActionResult.PASS;
}
}