mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
151 lines
4.4 KiB
Java
151 lines
4.4 KiB
Java
package com.hbm.items.weapon;
|
|
|
|
import java.util.List;
|
|
|
|
import com.google.common.collect.Multimap;
|
|
import com.hbm.entity.projectile.EntityBaleflare;
|
|
import com.hbm.items.ModItems;
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
import net.minecraft.enchantment.Enchantment;
|
|
import net.minecraft.enchantment.EnchantmentHelper;
|
|
import net.minecraft.entity.SharedMonsterAttributes;
|
|
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.item.EnumAction;
|
|
import net.minecraft.item.Item;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.util.IIcon;
|
|
import net.minecraft.world.World;
|
|
import net.minecraftforge.common.MinecraftForge;
|
|
import net.minecraftforge.event.entity.player.ArrowLooseEvent;
|
|
import net.minecraftforge.event.entity.player.ArrowNockEvent;
|
|
|
|
public class GunBaleFlare extends Item {
|
|
public static final String[] bowPullIconNameArray = new String[] { "pulling_0", "pulling_1", "pulling_2" };
|
|
@SideOnly(Side.CLIENT)
|
|
private IIcon[] iconArray;
|
|
private static final String __OBFID = "CL_00001777";
|
|
|
|
public GunBaleFlare() {
|
|
this.maxStackSize = 1;
|
|
this.setMaxDamage(2500);
|
|
}
|
|
|
|
/**
|
|
* called when the player releases the use item button. Args: itemstack,
|
|
* world, entityplayer, itemInUseCount
|
|
*/
|
|
@Override
|
|
public void onPlayerStoppedUsing(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_) {
|
|
int j = this.getMaxItemUseDuration(p_77615_1_) - p_77615_4_;
|
|
|
|
ArrowLooseEvent event = new ArrowLooseEvent(p_77615_3_, p_77615_1_, j);
|
|
MinecraftForge.EVENT_BUS.post(event);
|
|
j = event.charge;
|
|
|
|
boolean flag = p_77615_3_.capabilities.isCreativeMode
|
|
|| EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, p_77615_1_) > 0;
|
|
|
|
if (flag || p_77615_3_.inventory.hasItem(ModItems.gun_bf_ammo)) {
|
|
float f = j / 20.0F;
|
|
f = (f * f + f * 2.0F) / 3.0F;
|
|
|
|
if (j < 25.0D) {
|
|
return;
|
|
}
|
|
|
|
if (j > 25.0F) {
|
|
f = 25.0F;
|
|
}
|
|
|
|
EntityBaleflare entityarrow = new EntityBaleflare(p_77615_2_, p_77615_3_, 3.0F * 0.25F);
|
|
|
|
entityarrow.setIsCritical(true);
|
|
entityarrow.gravity = 0.3;
|
|
entityarrow.setDamage(1000);
|
|
|
|
p_77615_1_.damageItem(1, p_77615_3_);
|
|
// p_77615_2_.playSoundAtEntity(p_77615_3_, "tile.piston.out", 1.0F,
|
|
// 0.5F);
|
|
p_77615_2_.playSoundAtEntity(p_77615_3_, "hbm:weapon.fatmanShoot", 1.0F, 1F);
|
|
|
|
if (!flag) {
|
|
p_77615_3_.inventory.consumeInventoryItem(ModItems.gun_bf_ammo);
|
|
}
|
|
|
|
if (!p_77615_2_.isRemote) {
|
|
p_77615_2_.spawnEntityInWorld(entityarrow);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public ItemStack onEaten(ItemStack p_77654_1_, World p_77654_2_, EntityPlayer p_77654_3_) {
|
|
return p_77654_1_;
|
|
}
|
|
|
|
/**
|
|
* How long it takes to use or consume an item
|
|
*/
|
|
@Override
|
|
public int getMaxItemUseDuration(ItemStack p_77626_1_) {
|
|
return 72000;
|
|
}
|
|
|
|
/**
|
|
* returns the action that specifies what animation to play when the items
|
|
* is being used
|
|
*/
|
|
@Override
|
|
public EnumAction getItemUseAction(ItemStack p_77661_1_) {
|
|
return EnumAction.bow;
|
|
}
|
|
|
|
/**
|
|
* Called whenever this item is equipped and the right mouse button is
|
|
* pressed. Args: itemStack, world, entityPlayer
|
|
*/
|
|
@Override
|
|
public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) {
|
|
ArrowNockEvent event = new ArrowNockEvent(p_77659_3_, p_77659_1_);
|
|
|
|
p_77659_3_.setItemInUse(p_77659_1_, this.getMaxItemUseDuration(p_77659_1_));
|
|
|
|
return p_77659_1_;
|
|
}
|
|
|
|
/**
|
|
* Return the enchantability factor of the item, most of the time is based
|
|
* on material.
|
|
*/
|
|
@Override
|
|
public int getItemEnchantability() {
|
|
return 0;
|
|
}
|
|
|
|
@Override
|
|
public Multimap getItemAttributeModifiers() {
|
|
Multimap multimap = super.getItemAttributeModifiers();
|
|
multimap.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(),
|
|
new AttributeModifier(field_111210_e, "Weapon modifier", -0.3, 1));
|
|
multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(),
|
|
new AttributeModifier(field_111210_e, "Weapon modifier", 4, 0));
|
|
return multimap;
|
|
}
|
|
|
|
@Override
|
|
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool) {
|
|
|
|
list.add("These bombs were meant for artillery, but");
|
|
list.add("this makeshift launcher works just fine!");
|
|
list.add("");
|
|
list.add("Ammo: Mk.V AMAT Shell");
|
|
list.add("Damage: 1000");
|
|
list.add("Creates small nuclear explosion.");
|
|
list.add("");
|
|
list.add("[LEGENDARY WEAPON]");
|
|
}
|
|
}
|