SHARE
TWEET

ItemRevolver.java

Camellias_ Jul 5th, 2017 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package camellias_.fallout;
  2.  
  3. import net.minecraft.world.World;
  4. import net.minecraft.util.MathHelper;
  5. import net.minecraft.item.ItemStack;
  6. import net.minecraft.item.Item;
  7. import net.minecraft.item.EnumAction;
  8. import net.minecraft.init.Items;
  9. import net.minecraft.init.Blocks;
  10. import net.minecraft.entity.projectile.EntityArrow;
  11. import net.minecraft.entity.player.EntityPlayer;
  12. import net.minecraft.entity.EntityLivingBase;
  13. import net.minecraft.entity.Entity;
  14. import net.minecraft.enchantment.EnchantmentHelper;
  15. import net.minecraft.enchantment.Enchantment;
  16. import net.minecraft.creativetab.CreativeTabs;
  17. import net.minecraft.client.renderer.entity.RenderSnowball;
  18.  
  19. import java.util.Random;
  20.  
  21. import cpw.mods.fml.common.registry.EntityRegistry;
  22. import cpw.mods.fml.common.event.FMLServerStartingEvent;
  23. import cpw.mods.fml.common.event.FMLPreInitializationEvent;
  24. import cpw.mods.fml.client.registry.RenderingRegistry;
  25.  
  26. public class ItemRevolver extends Item{
  27.  
  28.     public ItemRevolver() {
  29.     }
  30.  
  31.     public static Item block;
  32.     public static Object instance;
  33.  
  34.     static {
  35.         block = (new ItemgGUN());
  36.     }
  37.  
  38.     static class ItemgGUN extends Item {
  39.  
  40.         public ItemgGUN() {
  41.             super();
  42.             setMaxDamage(0);
  43.             maxStackSize = 1;
  44.             setFull3D();
  45.             setTextureName("revolver");
  46.             setCreativeTab(CreativeTabs.tabCombat);
  47.         }
  48.  
  49.         public int getMaxItemUseDuration(ItemStack par1ItemStack) {
  50.             return 72000;
  51.         }
  52.  
  53.         public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, final EntityPlayer par3EntityPlayer) {
  54.  
  55.             boolean flag = par3EntityPlayer.capabilities.isCreativeMode
  56.                     || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0;
  57.  
  58.             if (flag || par3EntityPlayer.inventory.hasItem(FalloutMain.itemIronNugget)) {
  59.                 float f = 3.9999999999999996F;
  60.  
  61.                 EntityArrowCustom entityarrow = new EntityArrowCustom(par2World, par3EntityPlayer, f * 2.0F) {
  62.  
  63.                     public void onCollideWithPlayer(EntityPlayer entity) {
  64.                         super.onCollideWithPlayer(entity);
  65.                         int i = MathHelper.floor_double(this.boundingBox.minX + 0.001D);
  66.                         int j = MathHelper.floor_double(this.boundingBox.minY + 0.001D);
  67.                         int k = MathHelper.floor_double(this.boundingBox.minZ + 0.001D);
  68.                         World world = this.worldObj;
  69.  
  70.                     }
  71.  
  72.                     public void onUpdate() {
  73.                         super.onUpdate();
  74.                         int i = MathHelper.floor_double(this.boundingBox.minX + 0.001D);
  75.                         int j = MathHelper.floor_double(this.boundingBox.minY + 0.001D);
  76.                         int k = MathHelper.floor_double(this.boundingBox.minZ + 0.001D);
  77.                         World world = this.worldObj;
  78.                         Entity entity = (Entity) par3EntityPlayer;
  79.  
  80.                         if (this.worldObj.getBlock(i, j, k) != Blocks.air || this.worldObj.getBlock(i, j - 1, k) != Blocks.air
  81.                                 || this.worldObj.getBlock(i, j + 1, k) != Blocks.air || this.worldObj.getBlock(i + 1, j, k) != Blocks.air
  82.                                 || this.worldObj.getBlock(i - 1, j, k) != Blocks.air || this.worldObj.getBlock(i, j, k + 1) != Blocks.air
  83.                                 || this.worldObj.getBlock(i, j, k - 1) != Blocks.air) {
  84.  
  85.                             this.kill();
  86.                         }
  87.  
  88.                     }
  89.  
  90.                 };
  91.  
  92.                 entityarrow.setIsCritical(false);
  93.                 entityarrow.setDamage(5.0);
  94.                 entityarrow.setKnockbackStrength(1);
  95.  
  96.                 par1ItemStack.damageItem(1, par3EntityPlayer);
  97.                 par2World.playSoundAtEntity(par3EntityPlayer, "fireworks.blast", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
  98.  
  99.                 if (flag) {
  100.                     entityarrow.canBePickedUp = 2;
  101.                 } else {
  102.                     Item itemIronNugget;
  103.                     par3EntityPlayer.inventory.consumeInventoryItem(FalloutMain.itemIronNugget);
  104.                 }
  105.  
  106.                 if (!par2World.isRemote) {
  107.                     par2World.spawnEntityInWorld(entityarrow);
  108.                 }
  109.                 World world = par2World;
  110.                 EntityPlayer entity = par3EntityPlayer;
  111.                 int i = (int) entity.posX;
  112.                 int j = (int) entity.posY;
  113.                 int k = (int) entity.posZ;
  114.  
  115.             }
  116.  
  117.             return par1ItemStack;
  118.         }
  119.  
  120.         /**
  121.          * returns the action that specifies what animation to play when the
  122.          * items is being used
  123.          */
  124.         public EnumAction getItemUseAction(ItemStack par1ItemStack) {
  125.             return EnumAction.bow;
  126.         }
  127.  
  128.     }
  129.  
  130.     public static class EntityArrowCustom extends EntityArrow {
  131.         public EntityArrowCustom(World a) {
  132.             super(a);
  133.         }
  134.  
  135.         public EntityArrowCustom(World a, EntityLivingBase b, float c) {
  136.             super(a, b, c);
  137.         }
  138.     }
  139.  
  140.     public Item setUnlocalizedName(String string) {
  141.         return null;
  142.     }
  143. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top