Use given variables to condense code

This commit is contained in:
GotoLink 2013-10-28 20:41:41 +01:00
commit 578051b530
13 changed files with 27 additions and 74 deletions

View file

@ -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);

View file

@ -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);
}
}

View file

@ -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);
}
}
}

View file

@ -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);
}
}
}

View file

@ -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);
}
}
}

View file

@ -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;

View file

@ -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);
}
}

View file

@ -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);
}
}
}

View file

@ -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);
}
}
}

View file

@ -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]);
}
}
}

View file

@ -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]);
}
}
}

View file

@ -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);
}
}
}

View file

@ -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");
}
}