From 7937604c41e870453bba0f36ee949ccd896fb883 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 25 May 2024 21:01:33 +0100 Subject: [PATCH] Fixed placed spells not reflecting their correct location in the dismiss spell screen --- .../magic/spell/PlacementControlSpell.java | 4 +-- .../client/gui/DismissSpellScreen.java | 31 ++++++++++++------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/PlacementControlSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/PlacementControlSpell.java index a42cd9a3..f486c0d4 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/PlacementControlSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/PlacementControlSpell.java @@ -139,8 +139,8 @@ public class PlacementControlSpell extends AbstractSpell implements OrientedSpel super.fromNBT(compound); delegate = Spell.readNbt(compound.getCompound("spell")); placedEntityId = compound.containsUuid("placedEntityId") ? compound.getUuid("placedEntityId") : null; - position = compound.contains("position") ? Optional.of(NbtSerialisable.readVector(compound.getList("position", NbtElement.FLOAT_TYPE))) : Optional.empty(); - orientation = compound.contains("orientation") ? Optional.of(NbtSerialisable.readVector(compound.getList("orientation", NbtElement.FLOAT_TYPE))) : Optional.empty(); + position = compound.contains("position") ? Optional.of(NbtSerialisable.readVector(compound.getList("position", NbtElement.DOUBLE_TYPE))) : Optional.empty(); + orientation = compound.contains("orientation") ? Optional.of(NbtSerialisable.readVector(compound.getList("orientation", NbtElement.DOUBLE_TYPE))) : Optional.empty(); if (compound.contains("dimension", NbtElement.STRING_TYPE)) { dimension = Optional.ofNullable(Identifier.tryParse(compound.getString("dimension"))).map(id -> RegistryKey.of(RegistryKeys.WORLD, id)); } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/DismissSpellScreen.java b/src/main/java/com/minelittlepony/unicopia/client/gui/DismissSpellScreen.java index bad720d8..d73091c0 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/DismissSpellScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/DismissSpellScreen.java @@ -57,15 +57,16 @@ public class DismissSpellScreen extends GameGui { } double minimalDistance = 75 * (ring - 1) - 25; - Vec3d origin = pony.getOriginVector(); + Vec3d origin = pony.asEntity().getPos(); placeableSpells.forEach(placeable -> { placeable.getPosition().ifPresent(position -> { - Vec3d relativePos = position.subtract(origin); + Vec3d relativePos = position.subtract(origin).multiply(1, 0, 1); + float yaw = client.gameRenderer.getCamera().getYaw(); Vec3d cartesian = relativePos .normalize() - .multiply(minimalDistance + relativePos.length()) - .rotateY((pony.asEntity().getYaw() - 180) * MathHelper.RADIANS_PER_DEGREE); + .multiply(minimalDistance + relativePos.horizontalLength()) + .rotateY((180 + yaw) * MathHelper.RADIANS_PER_DEGREE); addDrawableChild(new Entry(placeable).ofCartesian(cartesian)); }); }); @@ -167,20 +168,28 @@ public class DismissSpellScreen extends GameGui { copy.set(mouseX - width * 0.5F - x * 0.5F, mouseY - height * 0.5F - y * 0.5F, 0, 0); DrawableUtil.drawLine(matrices, 0, 0, (int)x, (int)y, actualSpell.getAffinity().getColor().getColorValue()); - DrawableUtil.renderItemIcon(context, actualSpell.isDead() ? UItems.BOTCHED_GEM.getDefaultStack() : type.getDefaultStack(), - x - 8 - copy.x * 0.2F, - y - 8 - copy.y * 0.2F, - 1 - ); + int color = type.type().getColor() << 2; matrices.push(); matrices.translate(x, y, 0); - DrawableUtil.drawArc(matrices, 7, 8, 0, DrawableUtil.TAU, color | 0x00000088, false); + matrices.push(); + matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(((MinecraftClient.getInstance().player.age + tickDelta) * 2) % 360)); + DrawableUtil.renderItemIcon(context, actualSpell.isDead() ? UItems.BOTCHED_GEM.getDefaultStack() : type.getDefaultStack(), + -8, + -8, + 1 + ); + matrices.pop(); - if (isMouseOver(relativeMouseX, relativeMouseY)) { + boolean hovered = isMouseOver(relativeMouseX, relativeMouseY); + double radius = (hovered ? 9 + MathHelper.sin((MinecraftClient.getInstance().player.age + tickDelta) / 9F) : 7); + + DrawableUtil.drawArc(matrices, radius, radius + 1, 0, DrawableUtil.TAU, color | 0x00000088, false); + + if (hovered) { DrawableUtil.drawArc(matrices, 0, 8, 0, DrawableUtil.TAU, color | 0x000000FF, false); List tooltip = new ArrayList<>();