From 3be254a2476e538a47ba1a86a3129fc709055abe Mon Sep 17 00:00:00 2001 From: Electroblob <35599699+Electroblob77@users.noreply.github.com> Date: Fri, 16 Feb 2018 22:28:00 +0000 Subject: [PATCH] Remove unnecessary empty itemstack checks, see comments on d0fda72 --- .../wizardry/WizardryEventHandler.java | 3 +- .../wizardry/WizardryGuiHandler.java | 17 +-- .../wizardry/client/ClientProxy.java | 20 ++-- .../wizardry/client/GuiSpellDisplay.java | 19 ++-- .../client/WizardryClientEventHandler.java | 104 ++++++++---------- .../wizardry/enchantment/Imbuement.java | 6 +- .../wizardry/entity/EntityShield.java | 3 +- .../wizardry/item/ItemWizardArmour.java | 2 +- .../wizardry/packet/PacketControlInput.java | 6 +- .../wizardry/spell/Clairvoyance.java | 43 +++----- .../wizardry/spell/ShadowWard.java | 16 +-- 11 files changed, 98 insertions(+), 141 deletions(-) diff --git a/src/main/java/electroblob/wizardry/WizardryEventHandler.java b/src/main/java/electroblob/wizardry/WizardryEventHandler.java index 2230f83b..10e1a95f 100644 --- a/src/main/java/electroblob/wizardry/WizardryEventHandler.java +++ b/src/main/java/electroblob/wizardry/WizardryEventHandler.java @@ -400,8 +400,7 @@ public final class WizardryEventHandler { * @param player */ private static void hackilyFixContinuousSpellCasting(EntityPlayer player){ - if(player.isHandActive() && !player.getHeldItem(player.getActiveHand()).isEmpty() - && player.getHeldItem(player.getActiveHand()).getItem() instanceof ItemWand + if(player.isHandActive() && player.getHeldItem(player.getActiveHand()).getItem() instanceof ItemWand && WandHelper.getCurrentSpell(player.getHeldItem(player.getActiveHand())).isContinuous){ if(player.getActiveItemStack() != player.getHeldItem(player.getActiveHand())){ player.setHeldItem(player.getActiveHand(), player.getActiveItemStack()); diff --git a/src/main/java/electroblob/wizardry/WizardryGuiHandler.java b/src/main/java/electroblob/wizardry/WizardryGuiHandler.java index bd5e5423..f3dffaa6 100644 --- a/src/main/java/electroblob/wizardry/WizardryGuiHandler.java +++ b/src/main/java/electroblob/wizardry/WizardryGuiHandler.java @@ -43,19 +43,14 @@ public class WizardryGuiHandler implements IGuiHandler { return new electroblob.wizardry.client.GuiArcaneWorkbench(player.inventory, (TileEntityArcaneWorkbench)tileEntity); } - }else if(id == WIZARD_HANDBOOK && ((!player.getHeldItemMainhand().isEmpty() - && player.getHeldItemMainhand().getItem() instanceof ItemWizardHandbook) - || (!player.getHeldItemOffhand().isEmpty() - && player.getHeldItemOffhand().getItem() instanceof ItemWizardHandbook))){ + }else if(id == WIZARD_HANDBOOK && (player.getHeldItemMainhand().getItem() instanceof ItemWizardHandbook + || player.getHeldItemOffhand().getItem() instanceof ItemWizardHandbook)){ return new electroblob.wizardry.client.GuiWizardHandbook(); }else if(id == SPELL_BOOK){ - if(!player.getHeldItemMainhand().isEmpty() && player.getHeldItemMainhand().getItem() instanceof ItemSpellBook){ - return new electroblob.wizardry.client.GuiSpellBook( - Spell.get(player.getHeldItemMainhand().getItemDamage())); - }else if(!player.getHeldItemOffhand().isEmpty() - && player.getHeldItemOffhand().getItem() instanceof ItemSpellBook){ - return new electroblob.wizardry.client.GuiSpellBook( - Spell.get(player.getHeldItemOffhand().getItemDamage())); + if(player.getHeldItemMainhand().getItem() instanceof ItemSpellBook){ + return new electroblob.wizardry.client.GuiSpellBook(Spell.get(player.getHeldItemMainhand().getItemDamage())); + }else if(player.getHeldItemOffhand().getItem() instanceof ItemSpellBook){ + return new electroblob.wizardry.client.GuiSpellBook(Spell.get(player.getHeldItemOffhand().getItemDamage())); } }else if(id == PORTABLE_CRAFTING){ return new electroblob.wizardry.client.GuiPortableCrafting(player.inventory, world, new BlockPos(x, y, z)); diff --git a/src/main/java/electroblob/wizardry/client/ClientProxy.java b/src/main/java/electroblob/wizardry/client/ClientProxy.java index d85d350a..ab59450e 100644 --- a/src/main/java/electroblob/wizardry/client/ClientProxy.java +++ b/src/main/java/electroblob/wizardry/client/ClientProxy.java @@ -363,13 +363,12 @@ public class ClientProxy extends CommonProxy { Source source = Source.OTHER; - if(!((EntityPlayer)caster).getHeldItem(message.hand).isEmpty()){ - Item item = ((EntityPlayer)caster).getHeldItem(message.hand).getItem(); - if(item instanceof ItemWand){ - source = Source.WAND; - }else if(item instanceof ItemScroll){ - source = Source.SCROLL; - } + Item item = ((EntityPlayer)caster).getHeldItem(message.hand).getItem(); + + if(item instanceof ItemWand){ + source = Source.WAND; + }else if(item instanceof ItemScroll){ + source = Source.SCROLL; } // No need to check if the spell succeeded, because the packet is only ever sent when it succeeds. @@ -516,10 +515,9 @@ public class ClientProxy extends CommonProxy { // SECTION Rendering // =============================================================================================================== - private static final ResourceLocation ICE_WRAITH_TEXTURE = new ResourceLocation(Wizardry.MODID, - "textures/entity/ice_wraith.png"); - private static final ResourceLocation LIGHTNING_WRAITH_TEXTURE = new ResourceLocation(Wizardry.MODID, - "textures/entity/lightning_wraith.png"); + private static final ResourceLocation ICE_WRAITH_TEXTURE = new ResourceLocation(Wizardry.MODID, "textures/entity/ice_wraith.png"); + private static final ResourceLocation LIGHTNING_WRAITH_TEXTURE = new ResourceLocation(Wizardry.MODID, "textures/entity/lightning_wraith.png"); + /** Static instance of the statue renderer, used to access the block breaking texture. */ public static RenderStatue renderStatue; diff --git a/src/main/java/electroblob/wizardry/client/GuiSpellDisplay.java b/src/main/java/electroblob/wizardry/client/GuiSpellDisplay.java index 6b613a6f..8a52dbb4 100644 --- a/src/main/java/electroblob/wizardry/client/GuiSpellDisplay.java +++ b/src/main/java/electroblob/wizardry/client/GuiSpellDisplay.java @@ -30,8 +30,7 @@ public class GuiSpellDisplay extends Gui { private Minecraft mc; - private static final ResourceLocation hudTexture = new ResourceLocation(Wizardry.MODID, - "textures/gui/spell_hud.png"); + private static final ResourceLocation hudTexture = new ResourceLocation(Wizardry.MODID, "textures/gui/spell_hud.png"); public GuiSpellDisplay(Minecraft par1Minecraft){ super(); @@ -47,10 +46,10 @@ public class GuiSpellDisplay extends Gui { ItemStack wand = player.getHeldItemMainhand(); - if(wand.isEmpty() || !(wand.getItem() instanceof ItemWand)){ + if(!(wand.getItem() instanceof ItemWand)){ wand = player.getHeldItemOffhand(); // If the player isn't holding a wand, then nothing else needs to be done. - if(wand.isEmpty() || !(wand.getItem() instanceof ItemWand)) return; + if(!(wand.getItem() instanceof ItemWand)) return; } int width = event.getResolution().getScaledWidth(); @@ -59,8 +58,7 @@ public class GuiSpellDisplay extends Gui { Spell spell = WandHelper.getCurrentSpell(wand); int cooldown = WandHelper.getCurrentCooldown(wand); - float cooldownMultiplier = 1.0f - WandHelper.getUpgradeLevel(wand, WizardryItems.cooldown_upgrade) - * Constants.COOLDOWN_REDUCTION_PER_LEVEL; + float cooldownMultiplier = 1.0f - WandHelper.getUpgradeLevel(wand, WizardryItems.cooldown_upgrade) * Constants.COOLDOWN_REDUCTION_PER_LEVEL; if(player.isPotionActive(WizardryPotions.font_of_mana)){ // Dividing by this rather than setting it takes upgrades and font of mana into account simultaneously @@ -97,8 +95,7 @@ public class GuiSpellDisplay extends Gui { if(event.getType() == RenderGameOverlayEvent.ElementType.TEXT){ // Makes spells greyed out if they are in cooldown or if the player has the arcane jammer effect - String colour = cooldown > 0 || player.isPotionActive(WizardryPotions.arcane_jammer) ? "\u00A78" - : spell.element.getFormattingCode(); + String colour = cooldown > 0 || player.isPotionActive(WizardryPotions.arcane_jammer) ? "\u00A78" : spell.element.getFormattingCode(); if(!discovered) colour = "\u00A79"; String spellName = discovered ? spell.getDisplayName() : SpellGlyphData.getGlyphName(spell, player.world); FontRenderer font = discovered ? this.mc.fontRenderer : this.mc.standardGalacticFontRenderer; @@ -117,8 +114,7 @@ public class GuiSpellDisplay extends Gui { for(Object line : lines){ if(line instanceof String){ - font.drawStringWithShadow(colour + (String)line, mirror ? left + 5 : left + 41, - top + 6 + 11 * lineNumber, 0xffffffff); + font.drawStringWithShadow(colour + (String)line, mirror ? left + 5 : left + 41, top + 6 + 11 * lineNumber, 0xffffffff); } lineNumber++; } @@ -141,8 +137,7 @@ public class GuiSpellDisplay extends Gui { if(cooldown > 0){ this.drawTexturedModalRect(mirror ? left + 5 : left + 41, height - 8, 128, 6, 82, 6); - int l = (int)(((double)(spell.cooldown * cooldownMultiplier - cooldown) - / (double)(spell.cooldown * cooldownMultiplier)) * 82); + int l = (int)(((double)(spell.cooldown * cooldownMultiplier - cooldown) / (double)(spell.cooldown * cooldownMultiplier)) * 82); this.drawTexturedModalRect(mirror ? left + 5 : left + 41, height - 8, 128, 0, l, 6); } diff --git a/src/main/java/electroblob/wizardry/client/WizardryClientEventHandler.java b/src/main/java/electroblob/wizardry/client/WizardryClientEventHandler.java index 964b3691..182d2636 100644 --- a/src/main/java/electroblob/wizardry/client/WizardryClientEventHandler.java +++ b/src/main/java/electroblob/wizardry/client/WizardryClientEventHandler.java @@ -49,22 +49,14 @@ import net.minecraftforge.fml.relauncher.Side; @Mod.EventBusSubscriber(Side.CLIENT) public final class WizardryClientEventHandler { - private static final ResourceLocation shieldTexture = new ResourceLocation(Wizardry.MODID, - "textures/entity/shield.png"); - private static final ResourceLocation wingTexture = new ResourceLocation(Wizardry.MODID, - "textures/entity/wing.png"); - private static final ResourceLocation shadowWardTexture = new ResourceLocation(Wizardry.MODID, - "textures/entity/shadow_ward.png"); - private static final ResourceLocation sixthSenseTexture = new ResourceLocation(Wizardry.MODID, - "textures/entity/sixth_sense.png"); - private static final ResourceLocation sixthSenseOverlayTexture = new ResourceLocation(Wizardry.MODID, - "textures/gui/sixth_sense_overlay.png"); - private static final ResourceLocation frostOverlayTexture = new ResourceLocation(Wizardry.MODID, - "textures/gui/frost_overlay.png"); - private static final ResourceLocation pointerTexture = new ResourceLocation(Wizardry.MODID, - "textures/entity/pointer.png"); - private static final ResourceLocation targetPointerTexture = new ResourceLocation(Wizardry.MODID, - "textures/entity/target_pointer.png"); + private static final ResourceLocation shieldTexture = new ResourceLocation(Wizardry.MODID, "textures/entity/shield.png"); + private static final ResourceLocation wingTexture = new ResourceLocation(Wizardry.MODID, "textures/entity/wing.png"); + private static final ResourceLocation shadowWardTexture = new ResourceLocation(Wizardry.MODID, "textures/entity/shadow_ward.png"); + private static final ResourceLocation sixthSenseTexture = new ResourceLocation(Wizardry.MODID, "textures/entity/sixth_sense.png"); + private static final ResourceLocation sixthSenseOverlayTexture = new ResourceLocation(Wizardry.MODID, "textures/gui/sixth_sense_overlay.png"); + private static final ResourceLocation frostOverlayTexture = new ResourceLocation(Wizardry.MODID, "textures/gui/frost_overlay.png"); + private static final ResourceLocation pointerTexture = new ResourceLocation(Wizardry.MODID, "textures/entity/pointer.png"); + private static final ResourceLocation targetPointerTexture = new ResourceLocation(Wizardry.MODID, "textures/entity/target_pointer.png"); @SubscribeEvent public static void onTextureStitchEvent(TextureStitchEvent.Pre event){ @@ -79,10 +71,10 @@ public final class WizardryClientEventHandler { EntityPlayer player = Minecraft.getMinecraft().player; ItemStack wand = player.getHeldItemMainhand(); - if(wand.isEmpty() || !(wand.getItem() instanceof ItemWand)){ + if(!(wand.getItem() instanceof ItemWand)){ wand = player.getHeldItemOffhand(); // If the player isn't holding a wand, then nothing else needs to be done. - if(wand.isEmpty() || !(wand.getItem() instanceof ItemWand)) return; + if(!(wand.getItem() instanceof ItemWand)) return; } if(Minecraft.getMinecraft().inGameHasFocus && !wand.isEmpty() && event.getDwheel() != 0 && player.isSneaking() @@ -107,8 +99,7 @@ public final class WizardryClientEventHandler { public static void onFOVUpdateEvent(FOVUpdateEvent event){ // Bow zoom. Taken directly from AbstractClientPlayer so it works exactly like vanilla. - if(event.getEntity().isHandActive() && !event.getEntity().getActiveItemStack().isEmpty() - && event.getEntity().getActiveItemStack().getItem() instanceof ItemSpectralBow){ + if(event.getEntity().isHandActive() && event.getEntity().getActiveItemStack().getItem() instanceof ItemSpectralBow){ int maxUseTicks = event.getEntity().getItemInUseMaxCount(); @@ -174,14 +165,14 @@ public final class WizardryClientEventHandler { * * Timer timer = ReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getMinecraft(), "timer"); * - * // Chooses the appropriate zombie model, normal or villager // Fixed by moving before the model fields are - * accessed if(render instanceof RenderZombie && event.entity instanceof EntityZombie){ // The second argument - * is never used... ReflectionHelper.findMethod(RenderZombie.class, (RenderZombie)render, new - * String[]{"func_82427_a"}, EntityZombie.class) .invoke(renderliving, (EntityZombie)event.entity); } + * // Chooses the appropriate zombie model, normal or villager // Fixed by moving before the model fields are accessed + * if(render instanceof RenderZombie && event.entity instanceof EntityZombie){ // The second argument is never used... + * ReflectionHelper.findMethod(RenderZombie.class, (RenderZombie)render, new String[]{"func_82427_a"}, + * EntityZombie.class) .invoke(renderliving, (EntityZombie)event.entity); } * - * // Turns out that java automatically infers the type parameter T in this method from the type // I am - * assigning the returned value to. Neat! ModelBase mainModel = - * ReflectionHelper.getPrivateValue(RenderLiving.class, renderliving, "mainModel"); + * // Turns out that java automatically infers the type parameter T in this method from the type // I am assigning the + * returned value to. Neat! ModelBase mainModel = ReflectionHelper.getPrivateValue(RenderLiving.class, renderliving, + * "mainModel"); * * mainModel.isRiding = event.entity.isRiding(); mainModel.isChild = event.entity.isChild(); * @@ -193,9 +184,9 @@ public final class WizardryClientEventHandler { * * // Why is this -1.5f? No idea! GlStateManager.translate(0, -1.5f, 0); * - * float f6 = event.entity.prevLimbSwingAmount + (event.entity.limbSwingAmount - - * event.entity.prevLimbSwingAmount) * timer.renderPartialTicks; float f7 = event.entity.limbSwing - - * event.entity.limbSwingAmount * (1.0F - timer.renderPartialTicks); + * float f6 = event.entity.prevLimbSwingAmount + (event.entity.limbSwingAmount - event.entity.prevLimbSwingAmount) * + * timer.renderPartialTicks; float f7 = event.entity.limbSwing - event.entity.limbSwingAmount * (1.0F - + * timer.renderPartialTicks); * * if (event.entity.isChild()) { f7 *= 3.0F; } * @@ -223,14 +214,13 @@ public final class WizardryClientEventHandler { ItemStack wand = mc.player.getHeldItemMainhand(); - if(wand.isEmpty() || !(wand.getItem() instanceof ItemWand)){ + if(!(wand.getItem() instanceof ItemWand)){ wand = mc.player.getHeldItemOffhand(); } // Target selection pointer - if(mc.player.isSneaking() && !wand.isEmpty() && wand.getItem() instanceof ItemWand && rayTrace != null - && rayTrace.entityHit instanceof EntityLivingBase && rayTrace.entityHit == event.getEntity() - && properties != null && properties.selectedMinion != null){ + if(mc.player.isSneaking() && wand.getItem() instanceof ItemWand && rayTrace != null && rayTrace.entityHit instanceof EntityLivingBase + && rayTrace.entityHit == event.getEntity() && properties != null && properties.selectedMinion != null){ Tessellator tessellator = Tessellator.getInstance(); VertexBuffer buffer = tessellator.getBuffer(); @@ -271,8 +261,7 @@ public final class WizardryClientEventHandler { } // Summoned creature selection pointer - if(properties != null && properties.selectedMinion != null - && properties.selectedMinion.get() == event.getEntity()){ + if(properties != null && properties.selectedMinion != null && properties.selectedMinion.get() == event.getEntity()){ Tessellator tessellator = Tessellator.getInstance(); VertexBuffer buffer = tessellator.getBuffer(); @@ -314,10 +303,8 @@ public final class WizardryClientEventHandler { // Sixth sense if(mc.player.isPotionActive(WizardryPotions.sixth_sense) && event.getEntity() != mc.player - && mc.player.getActivePotionEffect(WizardryPotions.sixth_sense) != null - && event.getEntity().getDistanceToEntity(mc.player) < 20 - * (1 + mc.player.getActivePotionEffect(WizardryPotions.sixth_sense).getAmplifier() - * Constants.RANGE_INCREASE_PER_LEVEL)){ + && mc.player.getActivePotionEffect(WizardryPotions.sixth_sense) != null && event.getEntity().getDistanceToEntity(mc.player) < 20 + * (1 + mc.player.getActivePotionEffect(WizardryPotions.sixth_sense).getAmplifier() * Constants.RANGE_INCREASE_PER_LEVEL)){ Tessellator tessellator = Tessellator.getInstance(); VertexBuffer buffer = tessellator.getBuffer(); @@ -380,8 +367,8 @@ public final class WizardryClientEventHandler { buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); buffer.pos(0.0D, (double)event.getResolution().getScaledHeight(), -90.0D).tex(0.0D, 1.0D).endVertex(); - buffer.pos((double)event.getResolution().getScaledWidth(), (double)event.getResolution().getScaledHeight(), - -90.0D).tex(1.0D, 1.0D).endVertex(); + buffer.pos((double)event.getResolution().getScaledWidth(), (double)event.getResolution().getScaledHeight(), -90.0D).tex(1.0D, 1.0D) + .endVertex(); buffer.pos((double)event.getResolution().getScaledWidth(), 0.0D, -90.0D).tex(1.0D, 0.0D).endVertex(); buffer.pos(0.0D, 0.0D, -90.0D).tex(0.0D, 0.0D).endVertex(); tessellator.draw(); @@ -394,8 +381,7 @@ public final class WizardryClientEventHandler { GlStateManager.popMatrix(); } - if(event.getType() == RenderGameOverlayEvent.ElementType.HELMET - && Minecraft.getMinecraft().player.isPotionActive(WizardryPotions.frost)){ + if(event.getType() == RenderGameOverlayEvent.ElementType.HELMET && Minecraft.getMinecraft().player.isPotionActive(WizardryPotions.frost)){ GlStateManager.pushMatrix(); @@ -411,8 +397,8 @@ public final class WizardryClientEventHandler { buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); buffer.pos(0.0D, (double)event.getResolution().getScaledHeight(), -90.0D).tex(0.0D, 1.0D).endVertex(); - buffer.pos((double)event.getResolution().getScaledWidth(), (double)event.getResolution().getScaledHeight(), - -90.0D).tex(1.0D, 1.0D).endVertex(); + buffer.pos((double)event.getResolution().getScaledWidth(), (double)event.getResolution().getScaledHeight(), -90.0D).tex(1.0D, 1.0D) + .endVertex(); buffer.pos((double)event.getResolution().getScaledWidth(), 0.0D, -90.0D).tex(1.0D, 0.0D).endVertex(); buffer.pos(0.0D, 0.0D, -90.0D).tex(0.0D, 0.0D).endVertex(); @@ -430,8 +416,7 @@ public final class WizardryClientEventHandler { private static void renderShadowWardFirstPerson(EntityPlayer entityplayer){ ItemStack wand = entityplayer.getActiveItemStack(); if(WizardData.get(entityplayer) != null && WizardData.get(entityplayer).currentlyCasting() instanceof ShadowWard - || (entityplayer.isHandActive() && !wand.isEmpty() && wand.getItemDamage() < wand.getMaxDamage() - && wand.getItem() instanceof ItemWand + || (entityplayer.isHandActive() && wand.getItemDamage() < wand.getMaxDamage() && wand.getItem() instanceof ItemWand && WandHelper.getCurrentSpell(wand) instanceof ShadowWard)){ GlStateManager.pushMatrix(); @@ -489,9 +474,9 @@ public final class WizardryClientEventHandler { private static void renderShadowWardIfActive(EntityPlayer entityplayer){ ItemStack wand = entityplayer.getActiveItemStack(); - if(WizardData.get(entityplayer).currentlyCasting() instanceof ShadowWard || (entityplayer.isHandActive() - && !wand.isEmpty() && wand.getItemDamage() < wand.getMaxDamage() && wand.getItem() instanceof ItemWand - && WandHelper.getCurrentSpell(wand) instanceof ShadowWard)){ + if(WizardData.get(entityplayer).currentlyCasting() instanceof ShadowWard + || (entityplayer.isHandActive() && wand.getItemDamage() < wand.getMaxDamage() && wand.getItem() instanceof ItemWand + && WandHelper.getCurrentSpell(wand) instanceof ShadowWard)){ GlStateManager.pushMatrix(); @@ -541,8 +526,8 @@ public final class WizardryClientEventHandler { private static void renderWingsIfActive(EntityPlayer entityplayer, float partialTickTime){ ItemStack wand = entityplayer.getActiveItemStack(); if(WizardData.get(entityplayer).currentlyCasting() instanceof Flight - || (entityplayer.isHandActive() && !wand.isEmpty() && wand.getItemDamage() < wand.getMaxDamage() - && wand.getItem() instanceof ItemWand && WandHelper.getCurrentSpell(wand) instanceof Flight)){ + || (entityplayer.isHandActive() && wand.getItemDamage() < wand.getMaxDamage() && wand.getItem() instanceof ItemWand + && WandHelper.getCurrentSpell(wand) instanceof Flight)){ GlStateManager.pushMatrix(); @@ -619,9 +604,9 @@ public final class WizardryClientEventHandler { private static void renderShieldFirstPerson(EntityPlayer entityplayer){ ItemStack wand = entityplayer.getActiveItemStack(); if(WizardData.get(entityplayer) != null && WizardData.get(entityplayer).shield != null - && (WizardData.get(entityplayer).currentlyCasting() instanceof Shield || (entityplayer.isHandActive() - && !wand.isEmpty() && wand.getItemDamage() < wand.getMaxDamage() - && wand.getItem() instanceof ItemWand && WandHelper.getCurrentSpell(wand) instanceof Shield))){ + && (WizardData.get(entityplayer).currentlyCasting() instanceof Shield + || (entityplayer.isHandActive() && wand.getItemDamage() < wand.getMaxDamage() && wand.getItem() instanceof ItemWand + && WandHelper.getCurrentSpell(wand) instanceof Shield))){ GlStateManager.pushMatrix(); @@ -658,10 +643,9 @@ public final class WizardryClientEventHandler { private static void renderShieldIfActive(EntityPlayer entityplayer){ ItemStack wand = entityplayer.getActiveItemStack(); - if(WizardData.get(entityplayer).shield != null - && (WizardData.get(entityplayer).currentlyCasting() instanceof Shield || (entityplayer.isHandActive() - && !wand.isEmpty() && wand.getItemDamage() < wand.getMaxDamage() - && wand.getItem() instanceof ItemWand && WandHelper.getCurrentSpell(wand) instanceof Shield))){ + if(WizardData.get(entityplayer).shield != null && (WizardData.get(entityplayer).currentlyCasting() instanceof Shield + || (entityplayer.isHandActive() && wand.getItemDamage() < wand.getMaxDamage() && wand.getItem() instanceof ItemWand + && WandHelper.getCurrentSpell(wand) instanceof Shield))){ GlStateManager.pushMatrix(); diff --git a/src/main/java/electroblob/wizardry/enchantment/Imbuement.java b/src/main/java/electroblob/wizardry/enchantment/Imbuement.java index 52e9efaf..959e73fe 100644 --- a/src/main/java/electroblob/wizardry/enchantment/Imbuement.java +++ b/src/main/java/electroblob/wizardry/enchantment/Imbuement.java @@ -70,7 +70,7 @@ public interface Imbuement { // Still not sure if it's better to set stacks in slots or modify the itemstack list directly, but I would // imagine it's the former. for(Slot slot : event.getContainer().inventorySlots){ - if(!slot.getStack().isEmpty() && slot.getStack().getItem() instanceof ItemEnchantedBook){ + if(slot.getStack().getItem() instanceof ItemEnchantedBook){ // We don't care about the level of the enchantments Map enchantments = EnchantmentHelper.getEnchantments(slot.getStack()); // Removes all imbuements @@ -104,9 +104,9 @@ public interface Imbuement { ItemStack bow = archer.getHeldItemMainhand(); - if(bow.isEmpty() || !(bow.getItem() instanceof ItemBow)){ + if(!(bow.getItem() instanceof ItemBow)){ bow = archer.getHeldItemOffhand(); - if(bow.isEmpty() || !(bow.getItem() instanceof ItemBow)) return; + if(!(bow.getItem() instanceof ItemBow)) return; } // Taken directly from ItemBow, so it works exactly the same as the power enchantment. diff --git a/src/main/java/electroblob/wizardry/entity/EntityShield.java b/src/main/java/electroblob/wizardry/entity/EntityShield.java index 5f6b988f..0f483493 100644 --- a/src/main/java/electroblob/wizardry/entity/EntityShield.java +++ b/src/main/java/electroblob/wizardry/entity/EntityShield.java @@ -46,8 +46,7 @@ public class EntityShield extends Entity { entityplayer.posY + 1 + entityplayer.getLookVec().y * 0.3, entityplayer.posZ + entityplayer.getLookVec().z * 0.3, entityplayer.rotationYawHead, entityplayer.rotationPitch); - if(!entityplayer.isHandActive() || entityplayer.getHeldItem(entityplayer.getActiveHand()).isEmpty() - || !(entityplayer.getHeldItem(entityplayer.getActiveHand()).getItem() instanceof ItemWand)){ + if(!entityplayer.isHandActive() || !(entityplayer.getHeldItem(entityplayer.getActiveHand()).getItem() instanceof ItemWand)){ WizardData.get(entityplayer).shield = null; this.setDead(); } diff --git a/src/main/java/electroblob/wizardry/item/ItemWizardArmour.java b/src/main/java/electroblob/wizardry/item/ItemWizardArmour.java index 781f0ead..4594a6f5 100644 --- a/src/main/java/electroblob/wizardry/item/ItemWizardArmour.java +++ b/src/main/java/electroblob/wizardry/item/ItemWizardArmour.java @@ -232,7 +232,7 @@ public class ItemWizardArmour extends ItemArmor implements ISpecialArmor { EntityPlayer player = (EntityPlayer)event.getEntityLiving(); for(ItemStack stack : player.getArmorInventoryList()){ - if(stack.isEmpty() || !(stack.getItem() instanceof ItemWizardArmour)){ + if(!(stack.getItem() instanceof ItemWizardArmour)){ return; // If any of the armour slots doesn't contain wizard armour, don't trigger the achievement. } } diff --git a/src/main/java/electroblob/wizardry/packet/PacketControlInput.java b/src/main/java/electroblob/wizardry/packet/PacketControlInput.java index 212d72cd..c0f3132d 100644 --- a/src/main/java/electroblob/wizardry/packet/PacketControlInput.java +++ b/src/main/java/electroblob/wizardry/packet/PacketControlInput.java @@ -28,7 +28,7 @@ public class PacketControlInput implements IMessageHandler { ItemStack wand = player.getHeldItemMainhand(); - if(wand.isEmpty() || !(wand.getItem() instanceof ItemWand)){ + if(!(wand.getItem() instanceof ItemWand)){ wand = player.getHeldItemOffhand(); } @@ -41,7 +41,7 @@ public class PacketControlInput implements IMessageHandler { case NEXT_SPELL_KEY: - if(!wand.isEmpty() && wand.getItem() instanceof ItemWand){ + if(wand.getItem() instanceof ItemWand){ WandHelper.selectNextSpell(wand); // This line fixes the bug with continuous spells casting when they shouldn't be @@ -52,7 +52,7 @@ public class PacketControlInput implements IMessageHandler { case PREVIOUS_SPELL_KEY: - if(!wand.isEmpty() && wand.getItem() instanceof ItemWand){ + if(wand.getItem() instanceof ItemWand){ WandHelper.selectPreviousSpell(wand); // This line fixes the bug with continuous spells casting when they shouldn't be diff --git a/src/main/java/electroblob/wizardry/spell/Clairvoyance.java b/src/main/java/electroblob/wizardry/spell/Clairvoyance.java index 320bd9a7..f3d2b70e 100644 --- a/src/main/java/electroblob/wizardry/spell/Clairvoyance.java +++ b/src/main/java/electroblob/wizardry/spell/Clairvoyance.java @@ -57,8 +57,7 @@ public class Clairvoyance extends Spell { if(caster.dimension == properties.getClairvoyanceDimension()){ if(properties.getClairvoyanceLocation() != null){ - if(!world.isRemote) - caster.sendMessage(new TextComponentTranslation("spell.clairvoyance.searching")); + if(!world.isRemote) caster.sendMessage(new TextComponentTranslation("spell.clairvoyance.searching")); EntityZombie arbitraryZombie = new EntityZombie(world){ @Override @@ -74,14 +73,12 @@ public class Clairvoyance extends Spell { BlockPos destination = properties.getClairvoyanceLocation(); - WizardryPathFinder pathfinder = new WizardryPathFinder( - arbitraryZombie.getNavigator().getNodeProcessor()); + WizardryPathFinder pathfinder = new WizardryPathFinder(arbitraryZombie.getNavigator().getNodeProcessor()); - Path path = pathfinder.findPath(world, arbitraryZombie, destination, - 256 * modifiers.get(WizardryItems.range_upgrade)); + Path path = pathfinder.findPath(world, arbitraryZombie, destination, 256 * modifiers.get(WizardryItems.range_upgrade)); if(path != null && path.getFinalPathPoint() != null){ - + int x = path.getFinalPathPoint().x; int y = path.getFinalPathPoint().y; int z = path.getFinalPathPoint().z; @@ -91,24 +88,21 @@ public class Clairvoyance extends Spell { WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0f, 1.0f); if(!world.isRemote && caster instanceof EntityPlayerMP){ - WizardryPacketHandler.net.sendTo(new PacketClairvoyance.Message(path, - modifiers.get(WizardryItems.duration_upgrade)), (EntityPlayerMP)caster); + WizardryPacketHandler.net.sendTo(new PacketClairvoyance.Message(path, modifiers.get(WizardryItems.duration_upgrade)), + (EntityPlayerMP)caster); } return true; } } - if(!world.isRemote) - caster.sendMessage(new TextComponentTranslation("spell.clairvoyance.outofrange")); + if(!world.isRemote) caster.sendMessage(new TextComponentTranslation("spell.clairvoyance.outofrange")); }else{ - if(!world.isRemote) - caster.sendMessage(new TextComponentTranslation("spell.clairvoyance.undefined")); + if(!world.isRemote) caster.sendMessage(new TextComponentTranslation("spell.clairvoyance.undefined")); } }else{ - if(!world.isRemote) - caster.sendMessage(new TextComponentTranslation("spell.clairvoyance.wrongdimension")); + if(!world.isRemote) caster.sendMessage(new TextComponentTranslation("spell.clairvoyance.wrongdimension")); } } @@ -129,11 +123,9 @@ public class Clairvoyance extends Spell { nextPoint = path.getCurrentPathLength() - path.getCurrentPathIndex() <= 2 ? path.getFinalPathPoint() : path.getPathPointFromIndex(path.getCurrentPathIndex() + 2); - Wizardry.proxy.spawnParticle(WizardryParticleType.PATH, world, point.x + 0.5, point.y + 0.5, - point.z + 0.5, (nextPoint.x - point.x) / (float)PARTICLE_MOVEMENT_INTERVAL, - (nextPoint.y - point.y) / (float)PARTICLE_MOVEMENT_INTERVAL, - (nextPoint.z - point.z) / (float)PARTICLE_MOVEMENT_INTERVAL, - (int)(1800 * durationMultiplier), 0, 1, 0.3f); + Wizardry.proxy.spawnParticle(WizardryParticleType.PATH, world, point.x + 0.5, point.y + 0.5, point.z + 0.5, + (nextPoint.x - point.x) / (float)PARTICLE_MOVEMENT_INTERVAL, (nextPoint.y - point.y) / (float)PARTICLE_MOVEMENT_INTERVAL, + (nextPoint.z - point.z) / (float)PARTICLE_MOVEMENT_INTERVAL, (int)(1800 * durationMultiplier), 0, 1, 0.3f); path.incrementPathIndex(); path.incrementPathIndex(); @@ -141,8 +133,8 @@ public class Clairvoyance extends Spell { point = path.getFinalPathPoint(); - Wizardry.proxy.spawnParticle(WizardryParticleType.PATH, world, point.x + 0.5, point.y + 0.5, - point.z + 0.5, 0, 0, 0, (int)(1800 * durationMultiplier), 1, 1, 1); + Wizardry.proxy.spawnParticle(WizardryParticleType.PATH, world, point.x + 0.5, point.y + 0.5, point.z + 0.5, 0, 0, 0, + (int)(1800 * durationMultiplier), 1, 1, 1); } @SubscribeEvent @@ -153,8 +145,7 @@ public class Clairvoyance extends Spell { // The event now has an ItemStack, which greatly simplifies hand-related stuff. ItemStack wand = event.getItemStack(); - if(!wand.isEmpty() && wand.getItem() instanceof ItemWand - && WandHelper.getCurrentSpell(wand) instanceof Clairvoyance){ + if(wand.getItem() instanceof ItemWand && WandHelper.getCurrentSpell(wand) instanceof Clairvoyance){ WizardData properties = WizardData.get(event.getEntityPlayer()); @@ -165,8 +156,8 @@ public class Clairvoyance extends Spell { properties.setClairvoyancePoint(pos, event.getWorld().provider.getDimension()); if(!event.getWorld().isRemote){ - event.getEntityPlayer().sendMessage(new TextComponentTranslation("spell.clairvoyance.confirm", - Spells.clairvoyance.getNameForTranslationFormatted())); + event.getEntityPlayer().sendMessage( + new TextComponentTranslation("spell.clairvoyance.confirm", Spells.clairvoyance.getNameForTranslationFormatted())); } event.setCanceled(true); diff --git a/src/main/java/electroblob/wizardry/spell/ShadowWard.java b/src/main/java/electroblob/wizardry/spell/ShadowWard.java index d04bb2fe..12267d2a 100644 --- a/src/main/java/electroblob/wizardry/spell/ShadowWard.java +++ b/src/main/java/electroblob/wizardry/spell/ShadowWard.java @@ -36,8 +36,7 @@ public class ShadowWard extends Spell { double dx = -1 + 2 * world.rand.nextFloat(); double dy = -1 + world.rand.nextFloat(); double dz = -1 + 2 * world.rand.nextFloat(); - world.spawnParticle(EnumParticleTypes.PORTAL, caster.posX, WizardryUtilities.getPlayerEyesPos(caster), - caster.posZ, dx, dy, dz); + world.spawnParticle(EnumParticleTypes.PORTAL, caster.posX, WizardryUtilities.getPlayerEyesPos(caster), caster.posZ, dx, dy, dz); } if(ticksInUse % 50 == 0){ @@ -53,19 +52,16 @@ public class ShadowWard extends Spell { // There used to be a check that the target was a player here, but I don't see any reason for it. ItemStack wand = event.getEntityLiving().getActiveItemStack(); - if(!wand.isEmpty() && wand.getItemDamage() < wand.getMaxDamage() && wand.getItem() instanceof ItemWand + if(wand.getItemDamage() < wand.getMaxDamage() && wand.getItem() instanceof ItemWand && WandHelper.getCurrentSpell(wand) instanceof ShadowWard && !event.getSource().isUnblockable() - && !(event.getSource() instanceof IElementalDamage - && ((IElementalDamage)event.getSource()).isRetaliatory())){ + && !(event.getSource() instanceof IElementalDamage && ((IElementalDamage)event.getSource()).isRetaliatory())){ event.setCanceled(true); // Now we can preserve the original daage source (sort of) as long as we make it retaliatory. event.getEntityLiving().attackEntityFrom( - MagicDamage.causeDirectMagicDamage(event.getSource().getTrueSource(), DamageType.MAGIC, true), - event.getAmount() / 2); - ((EntityLivingBase)event.getSource().getTrueSource()).attackEntityFrom( - MagicDamage.causeDirectMagicDamage(event.getEntityLiving(), DamageType.MAGIC, true), - event.getAmount() / 2); + MagicDamage.causeDirectMagicDamage(event.getSource().getTrueSource(), DamageType.MAGIC, true), event.getAmount() / 2); + ((EntityLivingBase)event.getSource().getTrueSource()) + .attackEntityFrom(MagicDamage.causeDirectMagicDamage(event.getEntityLiving(), DamageType.MAGIC, true), event.getAmount() / 2); } } }