Remove unnecessary empty itemstack checks, see comments on d0fda72

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