This commit is contained in:
HbmMods 2017-04-18 20:53:30 +02:00
parent 1ec84ff294
commit 23fea92fc4

View File

@ -1,165 +1,238 @@
package com.hbm.items; package com.hbm.items.weapon;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import com.hbm.entity.EntityBullet; import com.google.common.collect.Multimap;
import com.hbm.lib.ModDamageSource; import com.hbm.entity.projectile.EntityBullet;
import com.hbm.items.ModItems;
import cpw.mods.fml.relauncher.Side; import com.hbm.lib.ModDamageSource;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.enchantment.Enchantment; import cpw.mods.fml.relauncher.Side;
import net.minecraft.enchantment.EnchantmentHelper; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.enchantment.Enchantment;
import net.minecraft.item.EnumAction; import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.item.EnumRarity; import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.item.Item; import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.item.ItemStack; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion; import net.minecraft.item.EnumAction;
import net.minecraft.potion.PotionEffect; import net.minecraft.item.EnumRarity;
import net.minecraft.util.IIcon; import net.minecraft.item.Item;
import net.minecraft.world.World; import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge; import net.minecraft.potion.Potion;
import net.minecraftforge.event.entity.player.ArrowLooseEvent; import net.minecraft.potion.PotionEffect;
import net.minecraftforge.event.entity.player.ArrowNockEvent; import net.minecraft.util.IIcon;
import net.minecraft.world.World;
public class GunSuicide extends Item { import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.ArrowLooseEvent;
public static final String[] bowPullIconNameArray = new String[] {"pulling_0", "pulling_1", "pulling_2"}; import net.minecraftforge.event.entity.player.ArrowNockEvent;
@SideOnly(Side.CLIENT)
private IIcon[] iconArray; public class GunSuicide extends Item {
private static final String __OBFID = "CL_00001777";
private Item ammo; public static final String[] bowPullIconNameArray = new String[] {"pulling_0", "pulling_1", "pulling_2"};
Random rand = new Random(); @SideOnly(Side.CLIENT)
private IIcon[] iconArray;
public GunSuicide() private static final String __OBFID = "CL_00001777";
{ private Item ammo;
this.maxStackSize = 1; Random rand = new Random();
//if(this == ModItems.gun_revolver)
{ public GunSuicide()
this.setMaxDamage(500); {
} this.maxStackSize = 1;
//if(this == ModItems.gun_revolver)
this.ammo = ModItems.gun_revolver_ammo; {
} this.setMaxDamage(500);
}
@Override
public EnumRarity getRarity(ItemStack p_77613_1_) { this.ammo = ModItems.gun_revolver_ammo;
}
return EnumRarity.uncommon;
} @Override
public EnumRarity getRarity(ItemStack p_77613_1_) {
/**
* called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount if (this == ModItems.gun_revolver_schrabidium) {
*/ return EnumRarity.rare;
@Override }
public void onPlayerStoppedUsing(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_)
{ if (this == ModItems.gun_revolver_cursed) {
int j = this.getMaxItemUseDuration(p_77615_1_) - p_77615_4_; return EnumRarity.uncommon;
}
ArrowLooseEvent event = new ArrowLooseEvent(p_77615_3_, p_77615_1_, j);
MinecraftForge.EVENT_BUS.post(event); return EnumRarity.common;
j = event.charge; }
boolean flag = p_77615_3_.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, p_77615_1_) > 0; /**
* called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount
*/
if (flag || p_77615_3_.inventory.hasItem(ammo)) @Override
{ public void onPlayerStoppedUsing(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_)
float f = j / 20.0F; {
f = (f * f + f * 2.0F) / 3.0F; int j = this.getMaxItemUseDuration(p_77615_1_) - p_77615_4_;
if (j < 10.0D) ArrowLooseEvent event = new ArrowLooseEvent(p_77615_3_, p_77615_1_, j);
{ MinecraftForge.EVENT_BUS.post(event);
return; j = event.charge;
}
boolean flag = p_77615_3_.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, p_77615_1_) > 0;
if (j > 10.0F)
{
f = 10.0F; if (flag || p_77615_3_.inventory.hasItem(ammo))
} {
float f = j / 20.0F;
p_77615_1_.damageItem(1, p_77615_3_); f = (f * f + f * 2.0F) / 3.0F;
//if(this == ModItems.gun_revolver || this == ModItems.gun_revolver_iron || this == ModItems.gun_revolver_gold || this == ModItems.gun_revolver_lead)
{ if (j < 10.0D)
//p_77615_2_.playSoundAtEntity(p_77615_3_, "random.explode", 1.0F, 3.0F); {
p_77615_2_.playSoundAtEntity(p_77615_3_, "hbm:weapon.revolverShoot", 1.0F, 1.0F); return;
} }
if (flag) if (j > 10.0F)
{ } {
else f = 10.0F;
{ }
p_77615_3_.inventory.consumeInventoryItem(ammo);
} p_77615_1_.damageItem(1, p_77615_3_);
//if(this == ModItems.gun_revolver || this == ModItems.gun_revolver_iron || this == ModItems.gun_revolver_gold || this == ModItems.gun_revolver_lead)
if (!p_77615_2_.isRemote) {
{ //p_77615_2_.playSoundAtEntity(p_77615_3_, "random.explode", 1.0F, 3.0F);
p_77615_3_.attackEntityFrom(ModDamageSource.suicide, Float.POSITIVE_INFINITY); p_77615_2_.playSoundAtEntity(p_77615_3_, "hbm:weapon.revolverShoot", 1.0F, 1.0F);
} }
} if(this == ModItems.gun_revolver || this == ModItems.gun_revolver_iron || this == ModItems.gun_revolver_gold || this == ModItems.gun_revolver_lead)
} {
//p_77615_2_.playSoundAtEntity(p_77615_3_, "random.explode", 1.0F, 3.0F);
@Override p_77615_2_.playSoundAtEntity(p_77615_3_, "hbm:weapon.revolverShoot", 1.0F, 1.0F);
public ItemStack onEaten(ItemStack p_77654_1_, World p_77654_2_, EntityPlayer p_77654_3_) }
{ if(this == ModItems.gun_revolver_cursed)
return p_77654_1_; {
} //p_77615_2_.playSoundAtEntity(p_77615_3_, "random.explode", 3.0F, 1.5F);
p_77615_2_.playSoundAtEntity(p_77615_3_, "hbm:weapon.heavyShoot", 3.0F, 1.0F);
/** }
* How long it takes to use or consume an item if(this == ModItems.gun_revolver_schrabidium)
*/ {
@Override //p_77615_2_.playSoundAtEntity(p_77615_3_, "random.explode", 1.0F, 3.0F);
public int getMaxItemUseDuration(ItemStack p_77626_1_) p_77615_2_.playSoundAtEntity(p_77615_3_, "hbm:weapon.schrabidiumShoot", 1.0F, 1.0F);
{ }
return 72000;
} if (flag)
{ }
/** else
* returns the action that specifies what animation to play when the items is being used {
*/ p_77615_3_.inventory.consumeInventoryItem(ammo);
@Override }
public EnumAction getItemUseAction(ItemStack p_77661_1_)
{ if (!p_77615_2_.isRemote)
return EnumAction.bow; {
} p_77615_3_.attackEntityFrom(ModDamageSource.suicide, Float.POSITIVE_INFINITY);
}
/** }
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer }
*/
@Override @Override
public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) public ItemStack onEaten(ItemStack p_77654_1_, World p_77654_2_, EntityPlayer p_77654_3_)
{ {
ArrowNockEvent event = new ArrowNockEvent(p_77659_3_, p_77659_1_); return p_77654_1_;
MinecraftForge.EVENT_BUS.post(event); }
if (p_77659_3_.capabilities.isCreativeMode || p_77659_3_.inventory.hasItem(ammo)) /**
{ * How long it takes to use or consume an item
p_77659_3_.setItemInUse(p_77659_1_, this.getMaxItemUseDuration(p_77659_1_)); */
} @Override
public int getMaxItemUseDuration(ItemStack p_77626_1_)
return p_77659_1_; {
} return 72000;
}
/**
* Return the enchantability factor of the item, most of the time is based on material. /**
*/ * returns the action that specifies what animation to play when the items is being used
@Override */
public int getItemEnchantability() @Override
{ public EnumAction getItemUseAction(ItemStack p_77661_1_)
return 1; {
} return EnumAction.bow;
}
@Override
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool) { /**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
//if(this == ModItems.gun_revolver) */
{ @Override
list.add("I've seen things..."); public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_)
list.add("...I shouldn't have seen."); {
list.add(""); ArrowNockEvent event = new ArrowNockEvent(p_77659_3_, p_77659_1_);
list.add("Ammo: Lead Bullets"); MinecraftForge.EVENT_BUS.post(event);
list.add("Damage: ∞");
} if (p_77659_3_.capabilities.isCreativeMode || p_77659_3_.inventory.hasItem(ammo))
} {
} 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 1;
}
@Override
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool) {
//if(this == ModItems.gun_revolver)
{
list.add("I've seen things...");
list.add("...I shouldn't have seen.");
list.add("");
list.add("Ammo: Lead Bullets");
list.add("Damage: infinite");
}
if (this == ModItems.gun_revolver_iron) {
list.add("Cheap.");
list.add("");
list.add("Ammo: Iron Bullets");
list.add("Damage: 5 - 15");
}
if (this == ModItems.gun_revolver) {
list.add("I feel like a cowboy!");
list.add("");
list.add("Ammo: Lead Bullets");
list.add("Damage: 10 - 25");
}
if (this == ModItems.gun_revolver_gold) {
list.add("GoldenEye would be proud!");
list.add("");
list.add("Ammo: Golden Bullets");
list.add("Damage: 20 - 30");
}
if (this == ModItems.gun_revolver_lead) {
list.add("Made from lead for your safety!");
list.add("");
list.add("Ammo: Atomic Bullets");
list.add("Damage: 5 - 15");
list.add("Bullets are radioactive.");
}
if (this == ModItems.gun_revolver_schrabidium) {
list.add("Kills everyone and everything.");
list.add("");
list.add("Ammo: Schrabidium Bullets");
list.add("Damage: 10000 - 100000");
list.add("Sets enemy's health to zero.");
}
if (this == ModItems.gun_revolver_cursed) {
list.add("You're dead.");
list.add("");
list.add("Ammo: Steel Bullets");
list.add("Damage: 25 - 40");
list.add("33% chance of user being withered.");
}
}
public Multimap getItemAttributeModifiers() {
Multimap multimap = super.getItemAttributeModifiers();
multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(),
new AttributeModifier(field_111210_e, "Weapon modifier", (double) 2.5, 0));
return multimap;
}
}