base mod created
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package net.minecraft.item;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemFireball extends Item
|
||||
{
|
||||
public ItemFireball()
|
||||
{
|
||||
this.setCreativeTab(CreativeTabs.MISC);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a Block is right-clicked with this Item
|
||||
*/
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (worldIn.isRemote)
|
||||
{
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = pos.offset(facing);
|
||||
ItemStack itemstack = player.getHeldItem(hand);
|
||||
|
||||
if (!player.canPlayerEdit(pos, facing, itemstack))
|
||||
{
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (worldIn.getBlockState(pos).getMaterial() == Material.AIR)
|
||||
{
|
||||
worldIn.playSound((EntityPlayer)null, pos, SoundEvents.ITEM_FIRECHARGE_USE, SoundCategory.BLOCKS, 1.0F, (itemRand.nextFloat() - itemRand.nextFloat()) * 0.2F + 1.0F);
|
||||
worldIn.setBlockState(pos, Blocks.FIRE.getDefaultState());
|
||||
}
|
||||
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
itemstack.shrink(1);
|
||||
}
|
||||
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user