Guest User

Untitled

a guest
Apr 5th, 2015
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.96 KB | None | 0 0
  1. package skymine.redenergy.sow.items;
  2.  
  3. import net.minecraft.entity.player.EntityPlayer;
  4. import net.minecraft.item.ItemStack;
  5. import net.minecraft.nbt.NBTTagCompound;
  6. import net.minecraft.world.World;
  7. import skymine.redenergy.sow.entities.EntityFlame;
  8. import skymine.redenergy.sow.utils.LogHelper;
  9.  
  10. public class ItemScreamPistol extends ItemWeapon{
  11.    
  12.     public ItemScreamPistol(){
  13.         super();
  14.         this.setMaxDamage(100);
  15.         this.setMaxStackSize(1);
  16.     }
  17.  
  18.    
  19.     public int getMaxItemUseDuration(ItemStack itemStack) {
  20.         return 72000;
  21.     }
  22.        
  23.     @Override
  24.     public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
  25.         checkNBT(stack);
  26.         player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
  27.         stack.stackTagCompound.setBoolean("isShooting", true);
  28.         return stack;
  29.     }
  30.  
  31.    
  32.     @Override
  33.     public void onPlayerStoppedUsing(ItemStack stack, World world,EntityPlayer player, int ticks) {
  34.         stack.stackTagCompound.setBoolean("isShooting", false);
  35.     }
  36.  
  37.     public void onUsingTick(ItemStack stack, EntityPlayer player, int ticksInUse) {
  38.         if(!player.worldObj.isRemote){
  39.             shootFire(stack, player.worldObj, player);
  40.         }
  41.     }
  42.    
  43.     private ItemStack shootFire(ItemStack stack, World world, EntityPlayer player){
  44.         if(!world.isRemote && stack.getItemDamage() != 100 && stack.stackTagCompound.getBoolean("isShooting")){
  45.             for(int i = 0; i < 8; i++){
  46.                 EntityFlame flame = new EntityFlame(world, player);
  47.                 world.spawnEntityInWorld(flame);
  48.             }
  49.             stack.damageItem(1, player);
  50.         }
  51.         return stack;
  52.     }
  53.    
  54.  
  55.     @Override
  56.     public void switchWeaponMode(ItemStack stack, EntityPlayer player) {}
  57.  
  58.    
  59.     @Override
  60.     public void reloadWeapon(ItemStack stack, EntityPlayer player) {
  61.         stack.setItemDamage(0);
  62.         LogHelper.dLog("weapon reloaded");
  63.     }
  64.  
  65.  
  66.     private void checkNBT(ItemStack stack){
  67.         if(stack.stackTagCompound == null){
  68.             stack.stackTagCompound = new NBTTagCompound();
  69.             stack.stackTagCompound.setBoolean("isShooting", false);
  70.         }
  71.     }
  72.    
  73.    
  74. }
Advertisement
Add Comment
Please, Sign In to add comment