package com.hbm.items.gear; import java.util.List; import java.util.Random; import com.google.common.collect.Multimap; import com.hbm.entity.effect.EntityNukeCloudSmall; import com.hbm.entity.logic.EntityNukeExplosionMK4; import com.hbm.entity.projectile.EntityRubble; import com.hbm.items.ModItems; import com.hbm.lib.Library; import com.hbm.main.MainRegistry; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.Vec3; import net.minecraft.world.World; public class WeaponSpecial extends ItemSword { Random rand = new Random(); public WeaponSpecial(ToolMaterial p_i45356_1_) { super(p_i45356_1_); } @Override public EnumRarity getRarity(ItemStack p_77613_1_) { if(this == ModItems.schrabidium_hammer) { return EnumRarity.rare; } if(this == ModItems.ullapool_caber) { return EnumRarity.uncommon; } if(this == ModItems.shimmer_sledge || this == ModItems.shimmer_axe) { return EnumRarity.epic; } return EnumRarity.common; } @Override public boolean hitEntity(ItemStack stack, EntityLivingBase entity, EntityLivingBase entityPlayer) { World world = entity.worldObj; if(this == ModItems.schrabidium_hammer) { if (!world.isRemote) { entity.setHealth(0.0F); } world.playSoundAtEntity(entity, "random.anvil_land", 3.0F, 0.1F); } if(this == ModItems.bottle_opener) { if (!world.isRemote) { int i = rand.nextInt(7); if(i == 0) entity.addPotionEffect(new PotionEffect(Potion.blindness.id, 5 * 60 * 20, 0)); if(i == 1) entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 5 * 60 * 20, 2)); if(i == 2) entity.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 5 * 60 * 20, 2)); if(i == 3) entity.addPotionEffect(new PotionEffect(Potion.confusion.id, 1 * 60 * 20, 0)); } world.playSoundAtEntity(entity, "random.anvil_land", 3.0F, 1.F); } if(this == ModItems.ullapool_caber) { if (!world.isRemote) { world.createExplosion(null, entity.posX, entity.posY, entity.posZ, 7.5F, true); } stack.damageItem(505, entityPlayer); } if(this == ModItems.shimmer_sledge) { Vec3 vec = entityPlayer.getLookVec(); double dX = vec.xCoord * 5; double dY = vec.yCoord * 5; double dZ = vec.zCoord * 5; entity.motionX += dX; entity.motionY += dY; entity.motionZ += dZ; world.playSoundAtEntity(entity, "hbm:weapon.bang", 3.0F, 1.F); } if(this == ModItems.shimmer_axe) { entity.setHealth(entity.getHealth() / 2); world.playSoundAtEntity(entity, "hbm:weapon.slice", 3.0F, 1.F); } if(this == ModItems.wrench) { Vec3 vec = entityPlayer.getLookVec(); double dX = vec.xCoord * 0.5; double dY = vec.yCoord * 0.5; double dZ = vec.zCoord * 0.5; entity.motionX += dX; entity.motionY += dY; entity.motionZ += dZ; world.playSoundAtEntity(entity, "random.anvil_land", 3.0F, 0.75F); } if(this == ModItems.memespoon) { if(entityPlayer.fallDistance >= 2) { world.playSoundAtEntity(entity, "hbm:weapon.bang", 3.0F, 0.75F); entity.setHealth(0); } if(!(entityPlayer instanceof EntityPlayer)) return false; if(entityPlayer.fallDistance >= 20 && !((EntityPlayer)entityPlayer).capabilities.isCreativeMode) { if(!world.isRemote) { world.spawnEntityInWorld(EntityNukeExplosionMK4.statFac(world, 100, entity.posX, entity.posY, entity.posZ)); EntityNukeCloudSmall entity2 = new EntityNukeCloudSmall(world, 1000, 100 * 0.005F); entity2.posX = entity.posX; entity2.posY = entity.posY; entity2.posZ = entity.posZ; world.spawnEntityInWorld(entity2); } } } return false; } @Override public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int i, float f1, float f2, float f3) { if(this == ModItems.shimmer_sledge) { if(world.getBlock(x, y, z) != Blocks.air) { EntityRubble rubble = new EntityRubble(world); rubble.posX = x + 0.5F; rubble.posY = y; rubble.posZ = z + 0.5F; rubble.setMetaBasedOnBlock(world.getBlock(x, y, z), world.getBlockMetadata(x, y, z)); Vec3 vec = player.getLookVec(); double dX = vec.xCoord * 5; double dY = vec.yCoord * 5; double dZ = vec.zCoord * 5; rubble.motionX += dX; rubble.motionY += dY; rubble.motionZ += dZ; world.playSoundAtEntity(rubble, "hbm:weapon.bang", 3.0F, 1.0F); if(!world.isRemote) { world.spawnEntityInWorld(rubble); world.func_147480_a(x, y, z, false); } } return true; } if(this == ModItems.shimmer_axe) { world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "hbm:weapon.kapeng", 3.0F, 1.0F); if(!world.isRemote) { if(world.getBlock(x, y, z) != Blocks.air) { world.func_147480_a(x, y, z, false); } if(world.getBlock(x, y + 1, z) != Blocks.air) { world.func_147480_a(x, y + 1, z, false); } if(world.getBlock(x, y - 1, z) != Blocks.air) { world.func_147480_a(x, y - 1, z, false); } } return true; } return false; } @Override public Multimap getItemAttributeModifiers() { Multimap multimap = super.getItemAttributeModifiers(); if(this == ModItems.schrabidium_hammer) { multimap.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", -0.5, 1)); } if(this == ModItems.shimmer_sledge || this == ModItems.shimmer_axe) { multimap.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", -0.2, 1)); } if(this == ModItems.wrench || this == ModItems.wrench_flipped) { multimap.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", -0.1, 1)); } return multimap; } @Override public void onUpdate(ItemStack stack, World world, Entity entity, int i, boolean b) { if(entity instanceof EntityPlayer) { if(Library.checkForFiend((EntityPlayer) entity)) { ((EntityPlayer) entity).triggerAchievement(MainRegistry.achFiend); } else if(Library.checkForFiend2((EntityPlayer) entity)) { ((EntityPlayer) entity).triggerAchievement(MainRegistry.achFiend2); } } } @Override public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool) { if(this == ModItems.schrabidium_hammer) { list.add("Even though it says \"+1000000000"); list.add("damage\", it's actually \"onehit anything\""); } if(this == ModItems.ullapool_caber) { list.add("High-yield Scottish face removal."); list.add("A sober person would throw it..."); } if(this == ModItems.bottle_opener) { list.add("My very own bottle opener."); list.add("Use with caution!"); } if(this == ModItems.shimmer_sledge) { if(MainRegistry.polaroidID == 11) { list.add("shimmer no"); list.add("drop that hammer"); list.add("you're going to hurt somebody"); list.add("shimmer no"); list.add("shimmer pls"); } else { list.add("Breaks everything, even portals."); } } if(this == ModItems.shimmer_axe) { if(MainRegistry.polaroidID == 11) { list.add("shim's toolbox does an e-x-p-a-n-d"); } else { list.add("Timber!"); } } if(this == ModItems.wrench) { list.add("Mechanic Richard"); } if(this == ModItems.wrench_flipped) { list.add("Wrench 2: The Wrenchening"); } if(this == ModItems.memespoon) { list.add(EnumChatFormatting.DARK_GRAY + "Level 10 Shovel"); list.add(EnumChatFormatting.AQUA + "Deals crits while the wielder is rocket jumping"); list.add(EnumChatFormatting.RED + "20% slower firing speed"); list.add(EnumChatFormatting.RED + "No random critical hits"); } } }