mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-05 04:49:10 +01:00
make the hoe give you seeds randomly
This commit is contained in:
parent
be83a96487
commit
897ce41ac2
1 changed files with 38 additions and 0 deletions
|
@ -1,9 +1,20 @@
|
|||
package de.ellpeck.naturesaura.items.tools;
|
||||
|
||||
import de.ellpeck.naturesaura.items.ModItems;
|
||||
import de.ellpeck.naturesaura.reg.IModItem;
|
||||
import de.ellpeck.naturesaura.reg.IModelProvider;
|
||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemHoe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
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;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
|
@ -18,6 +29,33 @@ public class ItemHoeNA extends ItemHoe implements IModItem, IModelProvider {
|
|||
ModRegistry.addItemOrBlock(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
EnumActionResult result = super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ);
|
||||
if (!worldIn.isRemote && result == EnumActionResult.SUCCESS && this == ModItems.INFUSED_HOE) {
|
||||
ItemStack seed = ItemStack.EMPTY;
|
||||
|
||||
if (worldIn.rand.nextInt(5) == 0) {
|
||||
seed = ForgeHooks.getGrassSeed(worldIn.rand, 0);
|
||||
} else if (worldIn.rand.nextInt(10) == 0) {
|
||||
int rand = worldIn.rand.nextInt(3);
|
||||
if (rand == 0) {
|
||||
seed = new ItemStack(Items.MELON_SEEDS);
|
||||
} else if (rand == 1) {
|
||||
seed = new ItemStack(Items.PUMPKIN_SEEDS);
|
||||
} else if (rand == 2) {
|
||||
seed = new ItemStack(Items.BEETROOT_SEEDS);
|
||||
}
|
||||
}
|
||||
|
||||
if (!seed.isEmpty()) {
|
||||
EntityItem item = new EntityItem(worldIn, pos.getX() + worldIn.rand.nextFloat(), pos.getY() + 1F, pos.getZ() + worldIn.rand.nextFloat(), seed);
|
||||
worldIn.spawnEntity(item);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBaseName() {
|
||||
return this.baseName;
|
||||
|
|
Loading…
Reference in a new issue