diff --git a/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java index 354476d0..12f702d9 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java @@ -73,7 +73,8 @@ public class UnicornCastingAbility implements Ability { return Math.min(manaLevel, ((AmuletItem)amulet.getValue().getItem()).getChargeRemainder(amulet.getValue())); } - TypedActionResult> spell = player.getCharms().getSpellInHand(Hand.MAIN_HAND); + Hand hand = player.asEntity().isSneaking() ? Hand.OFF_HAND : Hand.MAIN_HAND; + TypedActionResult> spell = player.getCharms().getSpellInHand(hand); return !spell.getResult().isAccepted() || spell.getValue().isOn(player) ? 2 : 4; } @@ -100,7 +101,8 @@ public class UnicornCastingAbility implements Ability { } } } else { - TypedActionResult> newSpell = player.getCharms().getSpellInHand(Hand.MAIN_HAND); + Hand hand = player.asEntity().isSneaking() ? Hand.OFF_HAND : Hand.MAIN_HAND; + TypedActionResult> newSpell = player.getCharms().getSpellInHand(hand); if (newSpell.getResult() != ActionResult.FAIL) { CustomisedSpellType spell = newSpell.getValue(); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/UnicornProjectileAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/UnicornProjectileAbility.java index 019b9f18..32261a02 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/UnicornProjectileAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/UnicornProjectileAbility.java @@ -12,7 +12,6 @@ import com.minelittlepony.unicopia.util.TraceHelper; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; -import net.minecraft.util.Identifier; import net.minecraft.util.TypedActionResult; /** @@ -22,13 +21,6 @@ import net.minecraft.util.TypedActionResult; * 2. If the player is holding a gem, consumes it and casts whatever spell is contained within onto a projectile. */ public class UnicornProjectileAbility implements Ability { - - @Override - public Identifier getIcon(Pony player, boolean swap) { - Identifier id = Abilities.REGISTRY.getId(this); - return new Identifier(id.getNamespace(), "textures/gui/ability/" + id.getPath() + (swap ? "_focused" : "_unfocused") + ".png"); - } - @Override public int getWarmupTime(Pony player) { return 8; @@ -63,7 +55,8 @@ public class UnicornProjectileAbility implements Ability { public boolean onQuickAction(Pony player, ActivationType type) { if (type == ActivationType.DOUBLE_TAP) { if (!player.isClient()) { - TypedActionResult> thrown = player.getCharms().getSpellInHand(Hand.OFF_HAND); + Hand hand = player.asEntity().isSneaking() ? Hand.MAIN_HAND : Hand.OFF_HAND; + TypedActionResult> thrown = player.getCharms().getSpellInHand(hand); if (thrown.getResult() != ActionResult.FAIL) { thrown.getValue().create().toThrowable().throwProjectile(player).ifPresent(projectile -> { @@ -80,11 +73,10 @@ public class UnicornProjectileAbility implements Ability { @Override public void apply(Pony player, Hit data) { - TypedActionResult> thrown = player.getCharms().getSpellInHand(Hand.OFF_HAND); + Hand hand = player.asEntity().isSneaking() ? Hand.MAIN_HAND : Hand.OFF_HAND; + TypedActionResult> thrown = player.getCharms().getSpellInHand(hand); if (thrown.getResult() != ActionResult.FAIL) { - - Spell spell = thrown.getValue().create(); spell.toThrowable().throwProjectile(player).ifPresent(projectile -> { diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java b/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java index 89909c21..3ea7d257 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java @@ -4,14 +4,12 @@ import java.util.List; import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.*; -import com.minelittlepony.unicopia.ability.AbilityDispatcher; -import com.minelittlepony.unicopia.ability.AbilitySlot; +import com.minelittlepony.unicopia.ability.*; import com.minelittlepony.unicopia.ability.magic.SpellPredicate; import com.minelittlepony.unicopia.ability.magic.spell.AbstractDisguiseSpell; import com.minelittlepony.unicopia.ability.magic.spell.TimedSpell; import com.minelittlepony.unicopia.ability.magic.spell.effect.CustomisedSpellType; import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType; -import com.minelittlepony.unicopia.client.KeyBindingsHandler; import com.minelittlepony.unicopia.client.sound.*; import com.minelittlepony.unicopia.entity.AmuletSelectors; import com.minelittlepony.unicopia.entity.ItemTracker; @@ -21,6 +19,9 @@ import com.minelittlepony.unicopia.entity.effect.UEffects; import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.item.GlassesItem; import com.minelittlepony.unicopia.item.UItems; +import com.mojang.blaze3d.platform.GlStateManager; +import com.mojang.blaze3d.platform.GlStateManager.DstFactor; +import com.mojang.blaze3d.platform.GlStateManager.SrcFactor; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; @@ -120,13 +121,36 @@ public class UHud extends DrawableHelper { boolean swap = client.options.sneakKey.isPressed(); slots.forEach(slot -> slot.renderBackground(matrices, abilities, swap, tickDelta)); + + if (pony.getObservedSpecies().canCast()) { + + Ability ability = pony.getAbilities().getStat(AbilitySlot.PRIMARY) + .getAbility(Unicopia.getConfig().hudPage.get()) + .orElse(null); + + if (ability == Abilities.CAST || ability == Abilities.SHOOT) { + matrices.push(); + matrices.translate(PRIMARY_SLOT_SIZE / 2F, PRIMARY_SLOT_SIZE / 2F, 0); + boolean first = ability == Abilities.CAST; + if (pony.asEntity().isSneaking()) { + first = !first; + } + matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(first ? 37 : 63)); + matrices.translate(-23, 0, 0); + matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(-26)); + matrices.scale(0.8F, 0.8F, 1); + UHud.drawTexture(matrices, 0, 0, 3, 120, 15, 7, 128, 128); + matrices.pop(); + } + } + slots.forEach(slot -> slot.renderLabel(matrices, abilities, tickDelta)); matrices.pop(); - if (pony.getActualSpecies().canCast() || AmuletSelectors.ALICORN_AMULET.test(pony.asEntity())) { - renderSpell(pony.getCharms().getEquippedSpell(Hand.MAIN_HAND), hudX + 15 - xDirection * 13, hudY + 3); - renderSpell(pony.getCharms().getEquippedSpell(Hand.OFF_HAND), hudX + 15 - xDirection * 2, hudY - 3); + if (pony.getObservedSpecies().canCast()) { + renderSpell(pony.getCharms().getEquippedSpell(Hand.MAIN_HAND), hudX + 10 - xDirection * 13, hudY + 2); + renderSpell(pony.getCharms().getEquippedSpell(Hand.OFF_HAND), hudX + 8 - xDirection * 2, hudY - 6); } RenderSystem.disableBlend(); diff --git a/src/main/resources/assets/unicopia/textures/gui/ability/disguise_original.png b/src/main/resources/assets/unicopia/textures/gui/ability/disguise_original.png deleted file mode 100644 index a2fe153a..00000000 Binary files a/src/main/resources/assets/unicopia/textures/gui/ability/disguise_original.png and /dev/null differ diff --git a/src/main/resources/assets/unicopia/textures/gui/ability/shoot.png b/src/main/resources/assets/unicopia/textures/gui/ability/shoot.png new file mode 100644 index 00000000..bbf65511 Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/gui/ability/shoot.png differ diff --git a/src/main/resources/assets/unicopia/textures/gui/hud.png b/src/main/resources/assets/unicopia/textures/gui/hud.png index 2ef3b7ad..97a2beeb 100644 Binary files a/src/main/resources/assets/unicopia/textures/gui/hud.png and b/src/main/resources/assets/unicopia/textures/gui/hud.png differ