From 578051b530c6901743fe3685bc52564d772f54cf Mon Sep 17 00:00:00 2001 From: GotoLink Date: Mon, 28 Oct 2013 20:41:41 +0100 Subject: [PATCH] Use given variables to condense code --- common/MysticWorld/Items/ItemOrbAir.java | 6 +++--- common/MysticWorld/Items/ItemOrbEarth.java | 9 ++------- common/MysticWorld/Items/ItemOrbEnergy.java | 10 +++------- common/MysticWorld/Items/ItemOrbFire.java | 19 +++---------------- common/MysticWorld/Items/ItemOrbWater.java | 9 ++------- common/MysticWorld/Items/ItemStaffAir.java | 2 +- common/MysticWorld/Items/ItemStaffEarth.java | 9 ++------- common/MysticWorld/Items/ItemStaffEnegy.java | 11 +++-------- common/MysticWorld/Items/ItemStaffFire.java | 11 +++-------- common/MysticWorld/Items/ItemStaffParts.java | 2 +- common/MysticWorld/Items/ItemStaffPower.java | 2 +- common/MysticWorld/Items/ItemStaffWater.java | 9 ++------- common/MysticWorld/Items/ItemVoidShard.java | 2 +- 13 files changed, 27 insertions(+), 74 deletions(-) diff --git a/common/MysticWorld/Items/ItemOrbAir.java b/common/MysticWorld/Items/ItemOrbAir.java index e5249eb..9a6868b 100644 --- a/common/MysticWorld/Items/ItemOrbAir.java +++ b/common/MysticWorld/Items/ItemOrbAir.java @@ -19,7 +19,7 @@ public class ItemOrbAir extends ItemOrb { public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { if (itemStack.stackTagCompound == null) itemStack.setTagCompound(new NBTTagCompound()); - if (itemStack.stackTagCompound.getBoolean("charging") == false) { + if (!itemStack.stackTagCompound.getBoolean("charging")) { itemStack.stackTagCompound.setBoolean("charging", true); } return itemStack; @@ -33,7 +33,7 @@ public class ItemOrbAir extends ItemOrb { ItemStack currentItem = player.inventory.getCurrentItem(); itemStack.stackTagCompound.setInteger("maxChargeTime", 5 * 20); if (currentItem != null) { - if (currentItem.itemID == itemStack.itemID) { + if (par5) { player.fallDistance = 0.0F; chargeEffect(itemStack, world, player); if (!Mouse.isButtonDown(1)) { @@ -46,7 +46,7 @@ public class ItemOrbAir extends ItemOrb { } resetData(itemStack); } else { - if (itemStack.stackTagCompound.getBoolean("charging") == true) { + if (itemStack.stackTagCompound.getBoolean("charging")) { incrementData(itemStack); } spiralEffect(itemStack, world, player); diff --git a/common/MysticWorld/Items/ItemOrbEarth.java b/common/MysticWorld/Items/ItemOrbEarth.java index 77b6da5..c796ce0 100644 --- a/common/MysticWorld/Items/ItemOrbEarth.java +++ b/common/MysticWorld/Items/ItemOrbEarth.java @@ -41,13 +41,8 @@ public class ItemOrbEarth extends ItemOrb { @Override public void onUpdate(ItemStack itemStack, World world, Entity entity, int par4, boolean par5) { EntityPlayer player = (EntityPlayer) entity; - ItemStack currentItem = player.inventory.getCurrentItem(); - if (!world.isRemote) { - if (currentItem != null) { - if (currentItem.itemID == itemStack.itemID) { - MysticWorld.proxy.earthFX(world, (player.posX - 0.5D) + rand.nextDouble(), player.posY, (player.posZ - 0.5D) + rand.nextDouble(), 1.0F); - } - } + if (!world.isRemote && par5) { + MysticWorld.proxy.earthFX(world, (player.posX - 0.5D) + rand.nextDouble(), player.posY, (player.posZ - 0.5D) + rand.nextDouble(), 1.0F); } } diff --git a/common/MysticWorld/Items/ItemOrbEnergy.java b/common/MysticWorld/Items/ItemOrbEnergy.java index 83f3b6f..1a9bae3 100644 --- a/common/MysticWorld/Items/ItemOrbEnergy.java +++ b/common/MysticWorld/Items/ItemOrbEnergy.java @@ -51,13 +51,9 @@ public class ItemOrbEnergy extends ItemOrb { public void onUpdate(ItemStack itemStack, World world, Entity entity, int par4, boolean par5) { EntityPlayer player = (EntityPlayer) entity; ItemStack currentItem = player.inventory.getCurrentItem(); - if (!world.isRemote) { - if (currentItem != null) { - if (currentItem.itemID == itemStack.itemID) { - player.addPotionEffect(new PotionEffect(Potion.moveSpeed.getId(), 20, 2)); - MysticWorld.proxy.energyFX(world, (player.posX - 0.5D) + rand.nextDouble(), player.posY, (player.posZ - 0.5D) + rand.nextDouble(), 1.0F); - } - } + if (!world.isRemote && par5) { + player.addPotionEffect(new PotionEffect(Potion.moveSpeed.getId(), 20, 2)); + MysticWorld.proxy.energyFX(world, (player.posX - 0.5D) + rand.nextDouble(), player.posY, (player.posZ - 0.5D) + rand.nextDouble(), 1.0F); } } } diff --git a/common/MysticWorld/Items/ItemOrbFire.java b/common/MysticWorld/Items/ItemOrbFire.java index 405f85b..8d76490 100644 --- a/common/MysticWorld/Items/ItemOrbFire.java +++ b/common/MysticWorld/Items/ItemOrbFire.java @@ -3,7 +3,6 @@ package mysticworld.items; import mysticworld.MysticWorld; import net.minecraft.block.Block; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; @@ -16,13 +15,6 @@ public class ItemOrbFire extends ItemOrb { super(id); } - public boolean itemInteractionForEntity(ItemStack itemStack, EntityLiving entityLiving) { - entityLiving.setFire(5); - entityLiving.attackEntityFrom(DamageSource.magic, 7); - itemStack.damageItem(1, entityLiving); - return true; - } - @Override public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { if (par7 == 0) { @@ -66,14 +58,9 @@ public class ItemOrbFire extends ItemOrb { @Override public void onUpdate(ItemStack itemStack, World world, Entity entity, int par4, boolean par5) { EntityPlayer player = (EntityPlayer) entity; - ItemStack currentItem = player.inventory.getCurrentItem(); - if (!world.isRemote) { - if (currentItem != null) { - if (currentItem.itemID == itemStack.itemID) { - player.addPotionEffect(new PotionEffect(Potion.fireResistance.getId(), 20, 0)); - MysticWorld.proxy.fireFX(world, (player.posX - 0.5D) + rand.nextDouble(), player.posY, (player.posZ - 0.5D) + rand.nextDouble(), 1.0F); - } - } + if (!world.isRemote && par5) { + player.addPotionEffect(new PotionEffect(Potion.fireResistance.getId(), 20, 0)); + MysticWorld.proxy.fireFX(world, (player.posX - 0.5D) + rand.nextDouble(), player.posY, (player.posZ - 0.5D) + rand.nextDouble(), 1.0F); } } } diff --git a/common/MysticWorld/Items/ItemOrbWater.java b/common/MysticWorld/Items/ItemOrbWater.java index 8ea45e7..dad06f5 100644 --- a/common/MysticWorld/Items/ItemOrbWater.java +++ b/common/MysticWorld/Items/ItemOrbWater.java @@ -75,13 +75,8 @@ public class ItemOrbWater extends ItemOrb { @Override public void onUpdate(ItemStack itemStack, World world, Entity entity, int par4, boolean par5) { EntityPlayer player = (EntityPlayer) entity; - ItemStack currentItem = player.inventory.getCurrentItem(); - if (itemStack != null) { - if (currentItem != null) { - if (currentItem.itemID == itemStack.itemID) { - MysticWorld.proxy.waterFX(world, (player.posX - 0.5D) + rand.nextDouble(), player.posY, (player.posZ - 0.5D) + rand.nextDouble(), 1.0F); - } - } + if (!world.isRemote && par5) { + MysticWorld.proxy.waterFX(world, (player.posX - 0.5D) + rand.nextDouble(), player.posY, (player.posZ - 0.5D) + rand.nextDouble(), 1.0F); } } } diff --git a/common/MysticWorld/Items/ItemStaffAir.java b/common/MysticWorld/Items/ItemStaffAir.java index 10a856d..85b3da2 100644 --- a/common/MysticWorld/Items/ItemStaffAir.java +++ b/common/MysticWorld/Items/ItemStaffAir.java @@ -19,7 +19,7 @@ public class ItemStaffAir extends ItemStaff { public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { if (itemStack.stackTagCompound == null) itemStack.setTagCompound(new NBTTagCompound()); - if (itemStack.stackTagCompound.getBoolean("charging") == false) { + if (!itemStack.stackTagCompound.getBoolean("charging")) { itemStack.stackTagCompound.setBoolean("charging", true); } return itemStack; diff --git a/common/MysticWorld/Items/ItemStaffEarth.java b/common/MysticWorld/Items/ItemStaffEarth.java index e744c47..4798e1e 100644 --- a/common/MysticWorld/Items/ItemStaffEarth.java +++ b/common/MysticWorld/Items/ItemStaffEarth.java @@ -68,13 +68,8 @@ public class ItemStaffEarth extends ItemStaff { @Override public void onUpdate(ItemStack itemStack, World world, Entity entity, int par4, boolean par5) { EntityPlayer player = (EntityPlayer) entity; - ItemStack currentItem = player.inventory.getCurrentItem(); - if (!world.isRemote) { - if (currentItem != null) { - if (currentItem.itemID == itemStack.itemID) { - MysticWorld.proxy.earthFX(world, (player.posX - 0.5D) + rand.nextDouble(), player.posY, (player.posZ - 0.5D) + rand.nextDouble(), 1.0F); - } - } + if (!world.isRemote && par5) { + MysticWorld.proxy.earthFX(world, (player.posX - 0.5D) + rand.nextDouble(), player.posY, (player.posZ - 0.5D) + rand.nextDouble(), 1.0F); } } diff --git a/common/MysticWorld/Items/ItemStaffEnegy.java b/common/MysticWorld/Items/ItemStaffEnegy.java index 47c5544..54f3edc 100644 --- a/common/MysticWorld/Items/ItemStaffEnegy.java +++ b/common/MysticWorld/Items/ItemStaffEnegy.java @@ -81,14 +81,9 @@ public class ItemStaffEnegy extends ItemStaff { @Override public void onUpdate(ItemStack itemStack, World world, Entity entity, int par4, boolean par5) { EntityPlayer player = (EntityPlayer) entity; - ItemStack currentItem = player.inventory.getCurrentItem(); - if (!world.isRemote) { - if (currentItem != null) { - if (currentItem.itemID == itemStack.itemID) { - player.addPotionEffect(new PotionEffect(Potion.moveSpeed.getId(), 20, 2)); - MysticWorld.proxy.energyFX(world, (player.posX - 0.5D) + rand.nextDouble(), player.posY, (player.posZ - 0.5D) + rand.nextDouble(), 1.0F); - } - } + if (!world.isRemote && par5) { + player.addPotionEffect(new PotionEffect(Potion.moveSpeed.getId(), 20, 2)); + MysticWorld.proxy.energyFX(world, (player.posX - 0.5D) + rand.nextDouble(), player.posY, (player.posZ - 0.5D) + rand.nextDouble(), 1.0F); } } } diff --git a/common/MysticWorld/Items/ItemStaffFire.java b/common/MysticWorld/Items/ItemStaffFire.java index adf3916..2079ae0 100644 --- a/common/MysticWorld/Items/ItemStaffFire.java +++ b/common/MysticWorld/Items/ItemStaffFire.java @@ -83,14 +83,9 @@ public class ItemStaffFire extends ItemStaff { @Override public void onUpdate(ItemStack itemStack, World world, Entity entity, int par4, boolean par5) { EntityPlayer player = (EntityPlayer) entity; - ItemStack currentItem = player.inventory.getCurrentItem(); - if (!world.isRemote) { - if (currentItem != null) { - if (currentItem.itemID == itemStack.itemID) { - player.addPotionEffect(new PotionEffect(Potion.fireResistance.getId(), 20, 0)); - MysticWorld.proxy.fireFX(world, (player.posX - 0.5D) + rand.nextDouble(), player.posY, (player.posZ - 0.5D) + rand.nextDouble(), 1.0F); - } - } + if (!world.isRemote && par5) { + player.addPotionEffect(new PotionEffect(Potion.fireResistance.getId(), 20, 0)); + MysticWorld.proxy.fireFX(world, (player.posX - 0.5D) + rand.nextDouble(), player.posY, (player.posZ - 0.5D) + rand.nextDouble(), 1.0F); } } } diff --git a/common/MysticWorld/Items/ItemStaffParts.java b/common/MysticWorld/Items/ItemStaffParts.java index 0ce6633..caff955 100644 --- a/common/MysticWorld/Items/ItemStaffParts.java +++ b/common/MysticWorld/Items/ItemStaffParts.java @@ -54,7 +54,7 @@ public class ItemStaffParts extends Item { public void registerIcons(IconRegister iconRegister) { icons = new Icon[STAFF_PARTS.length]; for (int i = 0; i < STAFF_PARTS.length; ++i) { - icons[i] = iconRegister.registerIcon("MysticMods:StaffPart_" + STAFF_PARTS[i]); + icons[i] = iconRegister.registerIcon("mysticmods:StaffPart_" + STAFF_PARTS[i]); } } } diff --git a/common/MysticWorld/Items/ItemStaffPower.java b/common/MysticWorld/Items/ItemStaffPower.java index 86736ca..01ba740 100644 --- a/common/MysticWorld/Items/ItemStaffPower.java +++ b/common/MysticWorld/Items/ItemStaffPower.java @@ -37,7 +37,7 @@ public class ItemStaffPower extends Item { public void registerIcons(IconRegister iconRegister) { icons = new Icon[CHARGE_NAMES.length]; for (int i = 0; i < CHARGE_NAMES.length; ++i) { - icons[i] = iconRegister.registerIcon("MysticMods:Charge" + CHARGE_NAMES[i]); + icons[i] = iconRegister.registerIcon("mysticmods:Charge" + CHARGE_NAMES[i]); } } } diff --git a/common/MysticWorld/Items/ItemStaffWater.java b/common/MysticWorld/Items/ItemStaffWater.java index 1f2264f..84b3b21 100644 --- a/common/MysticWorld/Items/ItemStaffWater.java +++ b/common/MysticWorld/Items/ItemStaffWater.java @@ -90,13 +90,8 @@ public class ItemStaffWater extends ItemStaff { @Override public void onUpdate(ItemStack itemStack, World world, Entity entity, int par4, boolean par5) { EntityPlayer player = (EntityPlayer) entity; - ItemStack currentItem = player.inventory.getCurrentItem(); - if (!world.isRemote) { - if (currentItem != null) { - if (currentItem.itemID == itemStack.itemID) { - MysticWorld.proxy.waterFX(world, (player.posX - 0.5D) + rand.nextDouble(), player.posY, (player.posZ - 0.5D) + rand.nextDouble(), 1.0F); - } - } + if (!world.isRemote && par5) { + MysticWorld.proxy.waterFX(world, (player.posX - 0.5D) + rand.nextDouble(), player.posY, (player.posZ - 0.5D) + rand.nextDouble(), 1.0F); } } } \ No newline at end of file diff --git a/common/MysticWorld/Items/ItemVoidShard.java b/common/MysticWorld/Items/ItemVoidShard.java index efeae6f..fc4e7bc 100644 --- a/common/MysticWorld/Items/ItemVoidShard.java +++ b/common/MysticWorld/Items/ItemVoidShard.java @@ -67,6 +67,6 @@ public class ItemVoidShard extends Item { @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister iconRegister) { - itemIcon = iconRegister.registerIcon("MysticMods:ShardVoid"); + itemIcon = iconRegister.registerIcon("mysticmods:ShardVoid"); } }