From 2691f168bb609ba190dbcb2bbc02d5308a66cb09 Mon Sep 17 00:00:00 2001 From: John Yorke Date: Fri, 28 Jul 2017 15:32:29 -0300 Subject: [PATCH] Bug fixes, closes #50 --- .../common/items/ItemFlyteCharm.java | 57 ++++++++++--------- .../assets/taintedmagic/lang/en_US.lang | 2 +- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/main/java/taintedmagic/common/items/ItemFlyteCharm.java b/src/main/java/taintedmagic/common/items/ItemFlyteCharm.java index c975d6a..270c5d0 100644 --- a/src/main/java/taintedmagic/common/items/ItemFlyteCharm.java +++ b/src/main/java/taintedmagic/common/items/ItemFlyteCharm.java @@ -40,13 +40,16 @@ public class ItemFlyteCharm extends Item implements IWarpingGear { boolean isFlying = false; - final int burstCooldown = 40; - final AspectList cost = new AspectList().add(Aspect.AIR, 10); + static final int burstCooldown = 40; + static final AspectList cost = new AspectList().add(Aspect.AIR, 10); + + static final String TAG_SPRINTING = "isSprinting"; + static final String TAG_COOLDOWN = "cooldown"; // Flight manager List playersWithFlight = new ArrayList(); - private static ResourceLocation circle = new ResourceLocation("taintedmagic:textures/misc/circle.png"); + private static final ResourceLocation circle = new ResourceLocation("taintedmagic:textures/misc/circle.png"); public ItemFlyteCharm () { @@ -109,14 +112,12 @@ public class ItemFlyteCharm extends Item implements IWarpingGear } ItemStack s = null; - boolean b = false; for (int i = 0; i < p.inventory.getSizeInventory(); i++) { if (p.inventory.getStackInSlot(i) != null && p.inventory.getStackInSlot(i).getItem() instanceof ItemFlyteCharm) { s = p.inventory.getStackInSlot(i); - b = true; break; } else s = null; @@ -124,11 +125,15 @@ public class ItemFlyteCharm extends Item implements IWarpingGear if (s != null) { - // Burst CD - if (getBurstCooldown(s) > 0.0F) setBurstCooldown(s, (int) Math.max(getBurstCooldown(s) - 1, 0)); + if (s.stackTagCompound == null) s.stackTagCompound = new NBTTagCompound(); + + // Sprint stuff + boolean wasSprinting = s.stackTagCompound.getBoolean(TAG_SPRINTING); + boolean isSprinting = p.isSprinting(); + if (isSprinting != wasSprinting) s.stackTagCompound.setBoolean(TAG_SPRINTING, isSprinting); - // Negate fall dmg - if (p.fallDistance > 3.0F) p.fallDistance = 0.0F; + // Burst CD + if (getBurstCooldown(s) > 0) setBurstCooldown(s, (int) Math.max(getBurstCooldown(s) - 1, 0)); // Speed boost if (p.moveForward > 0.0F) @@ -144,20 +149,21 @@ public class ItemFlyteCharm extends Item implements IWarpingGear if (isFlying) { if (!p.capabilities.isCreativeMode) TaintedMagicHelper.consumeVisFromInventory(p, cost, true); - if (getBurstCooldown(s) == 0 && p.worldObj.isRemote && Minecraft.getMinecraft().gameSettings.keyBindSprint.getIsKeyPressed()) - { - if (p.onGround) Minecraft.getMinecraft().gameSettings.keyBindSprint.unPressAllKeys(); - else if (!p.onGround) - { - p.worldObj.playSound(p.posX, p.posY, p.posZ, "taintedmagic:burst", 5.0F, 1.0F + (float) Math.random() * 0.1F, true); - p.motionX += look.x * 1.5D; - p.motionZ += look.z * 1.5D; - p.moveFlying(0.0F, 1.0F, 5.0F); - setBurstCooldown(s, this.burstCooldown); - } + // Burst + if (!wasSprinting && isSprinting && getBurstCooldown(s) == 0 && TaintedMagicHelper.consumeVisFromInventory(p, new AspectList().add(Aspect.FIRE, 500), true)) + { + p.worldObj.playSound(p.posX, p.posY, p.posZ, "taintedmagic:burst", 5.0F, 1.0F + (float) Math.random() * 0.1F, true); + p.motionX += look.x * 1.5D; + p.motionZ += look.z * 1.5D; + + setBurstCooldown(s, this.burstCooldown); + } + else if (getBurstCooldown(s) > 0) + { + if (this.burstCooldown - getBurstCooldown(s) < 2) p.moveFlying(0F, 1.0F, 5.0F); + else if (this.burstCooldown - getBurstCooldown(s) < 10) p.setSprinting(false); } - if (getBurstCooldown(s) < this.burstCooldown / 2) p.setSprinting(false); } else { @@ -172,11 +178,6 @@ public class ItemFlyteCharm extends Item implements IWarpingGear } } } - else - { - if (!p.capabilities.isCreativeMode) p.capabilities.isFlying = false; - b = false; - } } } @@ -205,13 +206,13 @@ public class ItemFlyteCharm extends Item implements IWarpingGear public void setBurstCooldown (ItemStack s, int cooldown) { if (s.stackTagCompound == null) s.stackTagCompound = new NBTTagCompound(); - s.getTagCompound().setInteger("cooldown", cooldown); + s.getTagCompound().setInteger(TAG_COOLDOWN, cooldown); } public float getBurstCooldown (ItemStack s) { if (s.stackTagCompound == null) s.stackTagCompound = new NBTTagCompound(); - return s.stackTagCompound.getInteger("cooldown"); + return s.stackTagCompound.getInteger(TAG_COOLDOWN); } @SideOnly (Side.CLIENT) diff --git a/src/main/resources/assets/taintedmagic/lang/en_US.lang b/src/main/resources/assets/taintedmagic/lang/en_US.lang index e7fae67..746fd83 100644 --- a/src/main/resources/assets/taintedmagic/lang/en_US.lang +++ b/src/main/resources/assets/taintedmagic/lang/en_US.lang @@ -419,4 +419,4 @@ tm.text.FOCUSLUMOS.1=After having studied foci and aspects you had an amazing id #FLYTECHARM tm.name.FLYTECHARM=Flyte Charm tm.tag.FLYTECHARM=The spiders of Aurum -tm.text.FLYTECHARM.1=By infusing an Air Arrow with a Shard of Creation - and some other magical objects - you have created a powerful charm which allows the user to fly. While you have the charm stored in your inventory, you will be granted Flyte at the cost of some Aer vis. About 0.1 per tick while flying.
While flying, press your Sprint key to burst forward and while falling, press your Sneak key to glide gently to the ground. \ No newline at end of file +tm.text.FLYTECHARM.1=By infusing an Air Arrow with a Shard of Creation - and some other magical objects - you have created a powerful charm which allows the user to fly.
While you have the charm stored in your inventory, you will be granted Flyte at the cost of some Aer vis from your inventory. About 0.1 per tick while flying.
Furthermore, while flying, you can press your Sprint key to burst forward every 2 seconds. At the cost of some Ignis vis, that is. While falling, press your Sneak key to glide gently to the ground. \ No newline at end of file