package com.hbm.items.special; import java.util.List; import java.util.Random; import com.hbm.items.ModItems; import com.hbm.items.gear.JetpackBooster; import com.hbm.items.gear.JetpackBreak; import com.hbm.items.gear.JetpackRegular; import com.hbm.items.gear.JetpackVectorized; import com.hbm.lib.ModDamageSource; import com.hbm.potion.HbmPotion; import com.hbm.saveddata.RadEntitySavedData; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; public class ItemSyringe extends Item { Random rand = new Random(); @Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { if(this == ModItems.syringe_antidote) { if (!world.isRemote) { player.clearActivePotions(); stack.stackSize--; world.playSoundAtEntity(player, "hbm:item.syringe", 1.0F, 1.0F); if (stack.stackSize <= 0) { return new ItemStack(ModItems.syringe_empty); } if (!player.inventory.addItemStackToInventory(new ItemStack(ModItems.syringe_empty))) { player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.syringe_empty, 1, 0), false); } } } if(this == ModItems.syringe_awesome) { if (!world.isRemote) { player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 50 * 20, 9)); player.addPotionEffect(new PotionEffect(Potion.resistance.id, 50 * 20, 9)); player.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 50 * 20, 0)); player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 50 * 20, 24)); player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 50 * 20, 9)); player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 50 * 20, 6)); player.addPotionEffect(new PotionEffect(Potion.jump.id, 50 * 20, 9)); player.addPotionEffect(new PotionEffect(Potion.field_76434_w.id, 50 * 20, 9)); player.addPotionEffect(new PotionEffect(Potion.field_76444_x.id, 50 * 20, 4)); player.addPotionEffect(new PotionEffect(Potion.confusion.id, 5 * 20, 4)); stack.stackSize--; world.playSoundAtEntity(player, "hbm:item.syringe", 1.0F, 1.0F); if (stack.stackSize <= 0) { return new ItemStack(ModItems.syringe_empty); } if (!player.inventory.addItemStackToInventory(new ItemStack(ModItems.syringe_empty))) { player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.syringe_empty, 1, 0), false); } } } if(this == ModItems.syringe_poison) { if (!world.isRemote) { if(rand.nextInt(2) == 0) player.attackEntityFrom(ModDamageSource.euthanizedSelf, 30); else player.attackEntityFrom(ModDamageSource.euthanizedSelf2, 30); stack.stackSize--; world.playSoundAtEntity(player, "hbm:item.syringe", 1.0F, 1.0F); if (stack.stackSize <= 0) { return new ItemStack(ModItems.syringe_empty); } if (!player.inventory.addItemStackToInventory(new ItemStack(ModItems.syringe_empty))) { player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.syringe_empty, 1, 0), false); } } } if(this == ModItems.syringe_metal_stimpak) { if (!world.isRemote) { player.heal(5); stack.stackSize--; world.playSoundAtEntity(player, "hbm:item.syringe", 1.0F, 1.0F); if (stack.stackSize <= 0) { return new ItemStack(ModItems.syringe_metal_empty); } if (!player.inventory.addItemStackToInventory(new ItemStack(ModItems.syringe_metal_empty))) { player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.syringe_metal_empty, 1, 0), false); } } } if(this == ModItems.syringe_metal_medx) { if (!world.isRemote) { player.addPotionEffect(new PotionEffect(Potion.resistance.id, 4 * 60 * 20, 2)); stack.stackSize--; world.playSoundAtEntity(player, "hbm:item.syringe", 1.0F, 1.0F); if (stack.stackSize <= 0) { return new ItemStack(ModItems.syringe_metal_empty); } if (!player.inventory.addItemStackToInventory(new ItemStack(ModItems.syringe_metal_empty))) { player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.syringe_metal_empty, 1, 0), false); } } } if(this == ModItems.syringe_metal_psycho) { if (!world.isRemote) { player.addPotionEffect(new PotionEffect(Potion.resistance.id, 2 * 60 * 20, 0)); player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 2 * 60 * 20, 0)); stack.stackSize--; world.playSoundAtEntity(player, "hbm:item.syringe", 1.0F, 1.0F); if (stack.stackSize <= 0) { return new ItemStack(ModItems.syringe_metal_empty); } if (!player.inventory.addItemStackToInventory(new ItemStack(ModItems.syringe_metal_empty))) { player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.syringe_metal_empty, 1, 0), false); } } } if(this == ModItems.syringe_metal_super) { if (!world.isRemote) { player.heal(25); player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 10 * 20, 0)); stack.stackSize--; world.playSoundAtEntity(player, "hbm:item.syringe", 1.0F, 1.0F); if (stack.stackSize <= 0) { return new ItemStack(ModItems.syringe_metal_empty); } if (!player.inventory.addItemStackToInventory(new ItemStack(ModItems.syringe_metal_empty))) { player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.syringe_metal_empty, 1, 0), false); } } } if(this == ModItems.med_bag) { if (!world.isRemote) { player.setHealth(player.getMaxHealth()); player.removePotionEffect(Potion.blindness.id); player.removePotionEffect(Potion.confusion.id); player.removePotionEffect(Potion.digSlowdown.id); player.removePotionEffect(Potion.hunger.id); player.removePotionEffect(Potion.moveSlowdown.id); player.removePotionEffect(Potion.poison.id); player.removePotionEffect(Potion.weakness.id); player.removePotionEffect(Potion.wither.id); player.removePotionEffect(HbmPotion.radiation.id); stack.stackSize--; } } if(this == ModItems.radaway) { if (!world.isRemote) { //player.removePotionEffect(HbmPotion.radiation.id); RadEntitySavedData entityData = RadEntitySavedData.getData(world); float rad = entityData.getRadFromEntity(player); rad -= 140F; if(rad < 0) rad = 0; entityData.setRadForEntity(player, rad); stack.stackSize--; world.playSoundAtEntity(player, "hbm:item.radaway", 1.0F, 1.0F); } } if(this == ModItems.radaway_strong) { if (!world.isRemote) { RadEntitySavedData entityData = RadEntitySavedData.getData(world); float rad = entityData.getRadFromEntity(player); rad -= 350F; if(rad < 0) rad = 0; entityData.setRadForEntity(player, rad); stack.stackSize--; world.playSoundAtEntity(player, "hbm:item.radaway", 1.0F, 1.0F); } } if(this == ModItems.radaway_flush) { if (!world.isRemote) { RadEntitySavedData entityData = RadEntitySavedData.getData(world); float rad = entityData.getRadFromEntity(player); rad -= 1000F; if(rad < 0) rad = 0; entityData.setRadForEntity(player, rad); stack.stackSize--; world.playSoundAtEntity(player, "hbm:item.radaway", 1.0F, 1.0F); } } if(this == ModItems.syringe_taint) { if (!world.isRemote) { player.addPotionEffect(new PotionEffect(HbmPotion.taint.id, 60 * 20, 0)); player.addPotionEffect(new PotionEffect(Potion.confusion.id, 5 * 20, 0)); stack.stackSize--; world.playSoundAtEntity(player, "hbm:item.syringe", 1.0F, 1.0F); } if (!player.inventory.addItemStackToInventory(new ItemStack(ModItems.syringe_metal_empty))) { player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.syringe_metal_empty, 1, 0), false); } if (!player.inventory.addItemStackToInventory(new ItemStack(ModItems.bottle2_empty))) { player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.bottle2_empty, 1, 0), false); } } if(this == ModItems.gas_mask_filter && player.inventory.armorInventory[3] != null && (player.inventory.armorInventory[3].getItem() == ModItems.gas_mask || player.inventory.armorInventory[3].getItem() == ModItems.gas_mask_m65)) { if (!world.isRemote) { if(player.inventory.armorInventory[3].getItemDamage() == 0) return stack; player.inventory.armorInventory[3].setItemDamage(0); world.playSoundAtEntity(player, "hbm:item.gasmaskScrew", 1.0F, 1.0F); stack.stackSize--; } } if(this == ModItems.jetpack_tank && player.inventory.armorInventory[2] != null && (player.inventory.armorInventory[2].getItem() == ModItems.jetpack_boost || player.inventory.armorInventory[2].getItem() == ModItems.jetpack_break || player.inventory.armorInventory[2].getItem() == ModItems.jetpack_fly || player.inventory.armorInventory[2].getItem() == ModItems.jetpack_vector)) { if (!world.isRemote) { ItemStack jetpack = player.inventory.armorInventory[2]; int fill = JetpackRegular.getFuel(jetpack) + 1000; if(jetpack.getItem() == ModItems.jetpack_boost && fill > JetpackBooster.maxFuel) fill = JetpackBooster.maxFuel; if(jetpack.getItem() == ModItems.jetpack_break && fill > JetpackBreak.maxFuel) fill = JetpackBreak.maxFuel; if(jetpack.getItem() == ModItems.jetpack_fly && fill > JetpackRegular.maxFuel) fill = JetpackRegular.maxFuel; if(jetpack.getItem() == ModItems.jetpack_vector && fill > JetpackVectorized.maxFuel) fill = JetpackVectorized.maxFuel; if(JetpackRegular.getFuel(jetpack) == fill) return stack; JetpackRegular.setFuel(jetpack, fill); world.playSoundAtEntity(player, "hbm:item.jetpackTank", 1.0F, 1.0F); stack.stackSize--; } } return stack; } @Override @SideOnly(Side.CLIENT) public boolean hasEffect(ItemStack p_77636_1_) { if(this == ModItems.syringe_awesome) { return true; } return false; } @Override public EnumRarity getRarity(ItemStack p_77613_1_) { if(this == ModItems.syringe_awesome) { return EnumRarity.uncommon; } if(this == ModItems.euphemium_stopper) { return EnumRarity.epic; } return EnumRarity.common; } @Override public boolean hitEntity(ItemStack stack, EntityLivingBase entity, EntityLivingBase entityPlayer) { World world = entity.worldObj; if(this == ModItems.syringe_antidote) { if (!world.isRemote) { entity.clearActivePotions(); stack.stackSize--; world.playSoundAtEntity(entity, "hbm:item.syringe", 1.0F, 1.0F); if(entityPlayer instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)entityPlayer; if (!player.inventory.addItemStackToInventory(new ItemStack(ModItems.syringe_empty))) { player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.syringe_empty, 1, 0), false); } } } } if(this == ModItems.syringe_awesome) { if (!world.isRemote) { entity.addPotionEffect(new PotionEffect(Potion.regeneration.id, 50 * 20, 9)); entity.addPotionEffect(new PotionEffect(Potion.resistance.id, 50 * 20, 9)); entity.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 50 * 20, 0)); entity.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 50 * 20, 24)); entity.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 50 * 20, 9)); entity.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 50 * 20, 6)); entity.addPotionEffect(new PotionEffect(Potion.jump.id, 50 * 20, 9)); entity.addPotionEffect(new PotionEffect(Potion.field_76434_w.id, 50 * 20, 9)); entity.addPotionEffect(new PotionEffect(Potion.field_76444_x.id, 50 * 20, 4)); entity.addPotionEffect(new PotionEffect(Potion.confusion.id, 5 * 20, 4)); stack.stackSize--; world.playSoundAtEntity(entity, "hbm:item.syringe", 1.0F, 1.0F); if(entityPlayer instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)entityPlayer; if (!player.inventory.addItemStackToInventory(new ItemStack(ModItems.syringe_empty))) { player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.syringe_empty, 1, 0), false); } } } } if(this == ModItems.syringe_poison) { if (!world.isRemote) { entity.attackEntityFrom(ModDamageSource.euthanized(entityPlayer, entityPlayer), 30); stack.stackSize--; world.playSoundAtEntity(entity, "hbm:item.syringe", 1.0F, 1.0F); if(entityPlayer instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)entityPlayer; if (!player.inventory.addItemStackToInventory(new ItemStack(ModItems.syringe_empty))) { player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.syringe_empty, 1, 0), false); } } } } if(this == ModItems.syringe_metal_stimpak) { if (!world.isRemote) { entity.heal(5); stack.stackSize--; world.playSoundAtEntity(entity, "hbm:item.syringe", 1.0F, 1.0F); if(entityPlayer instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)entityPlayer; if (!player.inventory.addItemStackToInventory(new ItemStack(ModItems.syringe_metal_empty))) { player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.syringe_metal_empty, 1, 0), false); } } } } if(this == ModItems.syringe_metal_medx) { if (!world.isRemote) { entity.addPotionEffect(new PotionEffect(Potion.resistance.id, 4 * 60 * 20, 2)); stack.stackSize--; world.playSoundAtEntity(entity, "hbm:item.syringe", 1.0F, 1.0F); if(entityPlayer instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)entityPlayer; if (!player.inventory.addItemStackToInventory(new ItemStack(ModItems.syringe_metal_empty))) { player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.syringe_metal_empty, 1, 0), false); } } } } if(this == ModItems.syringe_metal_psycho) { if (!world.isRemote) { entity.addPotionEffect(new PotionEffect(Potion.resistance.id, 2 * 60 * 20, 0)); entity.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 2 * 60 * 20, 0)); stack.stackSize--; world.playSoundAtEntity(entity, "hbm:item.syringe", 1.0F, 1.0F); if(entityPlayer instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)entityPlayer; if (!player.inventory.addItemStackToInventory(new ItemStack(ModItems.syringe_metal_empty))) { player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.syringe_metal_empty, 1, 0), false); } } } } if(this == ModItems.syringe_metal_super) { if (!world.isRemote) { entity.heal(25); entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 10 * 20, 0)); stack.stackSize--; world.playSoundAtEntity(entity, "hbm:item.syringe", 1.0F, 1.0F); if(entityPlayer instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)entityPlayer; if (!player.inventory.addItemStackToInventory(new ItemStack(ModItems.syringe_metal_empty))) { player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.syringe_metal_empty, 1, 0), false); } } } } if(this == ModItems.syringe_taint) { if (!world.isRemote) { entity.addPotionEffect(new PotionEffect(HbmPotion.taint.id, 60 * 20, 0)); entity.addPotionEffect(new PotionEffect(Potion.confusion.id, 5 * 20, 0)); stack.stackSize--; world.playSoundAtEntity(entity, "hbm:item.syringe", 1.0F, 1.0F); if(entityPlayer instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)entityPlayer; if (!player.inventory.addItemStackToInventory(new ItemStack(ModItems.syringe_metal_empty))) { player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.syringe_metal_empty, 1, 0), false); } if (!player.inventory.addItemStackToInventory(new ItemStack(ModItems.bottle2_empty))) { player.dropPlayerItemWithRandomChoice(new ItemStack(ModItems.bottle2_empty, 1, 0), false); } } } } if(this == ModItems.euphemium_stopper) { if (!world.isRemote) { entity.addPotionEffect(new PotionEffect(Potion.weakness.id, 30 * 20, 9)); entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 30 * 20, 9)); entity.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 30 * 20, 9)); } } return false; } @Override public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool) { if(this == ModItems.syringe_antidote) { list.add("Removes all potion effects"); } if(this == ModItems.syringe_awesome) { list.add("Every good effect for 50 seconds"); } if(this == ModItems.syringe_metal_medx) { list.add("Resistance III for 4 minutes"); } if(this == ModItems.syringe_metal_psycho) { list.add("Resistance I for 2 minutes"); list.add("Strength I for 2 minutes"); } if(this == ModItems.syringe_metal_stimpak) { list.add("Heals 2.5 hearts"); } if(this == ModItems.syringe_metal_super) { list.add("Heals 25 hearts"); list.add("Slowness I for 10 seconds"); } if(this == ModItems.syringe_poison) { list.add("Deadly"); } if(this == ModItems.med_bag) { list.add("Full heal, regardless of max health"); list.add("Removes negative effects"); } if(this == ModItems.radaway) { list.add("Removes 140 RAD"); } if(this == ModItems.radaway_strong) { list.add("Removes 350 RAD"); } if(this == ModItems.radaway_flush) { list.add("Removes 1000 RAD"); } if(this == ModItems.syringe_taint) { list.add("Tainted I for 60 seconds"); list.add("Nausea I for 5 seconds"); list.add("Cloud damage + taint = tainted heart effect"); } if(this == ModItems.gas_mask_filter) { list.add("Repairs worn gas mask"); } if(this == ModItems.jetpack_tank) { list.add("Fills worn jetpack with up to 1000mB of kerosene"); } } }