Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package wop.items;
- import wop.lib.Constants;
- import cpw.mods.fml.common.registry.GameRegistry;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.init.Items;
- import net.minecraft.item.ItemStack;
- import net.minecraft.world.World;
- import net.minecraftforge.common.MinecraftForge;
- import net.minecraftforge.event.entity.player.ArrowNockEvent;
- public class ItemBlastingWand extends ModItems {
- private String name = "blastingWand";
- int damageItem = 1;
- private boolean isactive = false;
- public ItemBlastingWand()
- {
- setMaxStackSize(18);
- setMaxDamage(200);
- setUnlocalizedName(Constants.MODID + "_" + name);
- setCreativeTab(CreativeTabs.tabCombat);
- GameRegistry.registerItem(this, name);
- }
- public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
- {
- if (par1ItemStack.getItemDamage() < par1ItemStack.getMaxDamage())
- {
- par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() - 1);
- //System.out.println(par1ItemStack.getItemDamage());
- }
- if (par5 && (par3Entity instanceof EntityPlayer))
- {
- EntityPlayer entityplayer = (EntityPlayer)par3Entity;
- if (!par2World.isRemote && !entityplayer.capabilities.isCreativeMode)
- {
- if (entityplayer.getCurrentEquippedItem().getItem() == ModItems.MagicBlaster)
- {
- if (par1ItemStack.getItemDamage() > 0)
- {
- entityplayer.fallDistance = 0.0F;
- }
- }
- }
- }
- if (par1ItemStack.getItemDamage() < par1ItemStack.getMaxDamage())
- {
- if (par3Entity instanceof EntityPlayer)
- {
- EntityPlayer entityplayer = (EntityPlayer)par3Entity;
- if (this.isactive)
- {
- for (int cp = 0; cp <= 10; cp++)
- {
- double d0 = itemRand.nextGaussian() * 0.02D;
- double d1 = itemRand.nextGaussian() * 0.02D;
- double d2 = itemRand.nextGaussian() * 0.02D;
- double dx = entityplayer.posX;
- double dy = entityplayer.posY - 1.8;
- double dz = entityplayer.posZ;
- par2World.spawnParticle("cloud", dx, dy, dz, d0, d1, d2);
- }
- }
- }
- }
- }
- public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
- if (player.capabilities.isCreativeMode || player.inventory.hasItem(Items.arrow))
- {
- if(stack.getItemDamage() == 0){
- player.inventory.consumeInventoryItem(Items.arrow);
- //stack.attemptDamageItem(damageItem, itemRand);
- stack.damageItem(199, player);
- this.isactive = true;
- }
- return stack;
- }
- ArrowNockEvent event = new ArrowNockEvent(player, stack);
- MinecraftForge.EVENT_BUS.post(event);
- if (event.isCanceled())
- {
- return event.result;
- }
- world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
- if (!world.isRemote) {
- world.spawnEntityInWorld(new EntityWandBolt(world, player));
- }
- return stack;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement