mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Fixed placed spells not reflecting their correct location in the dismiss spell screen
This commit is contained in:
parent
e9114f9e12
commit
7937604c41
2 changed files with 22 additions and 13 deletions
|
@ -139,8 +139,8 @@ public class PlacementControlSpell extends AbstractSpell implements OrientedSpel
|
||||||
super.fromNBT(compound);
|
super.fromNBT(compound);
|
||||||
delegate = Spell.readNbt(compound.getCompound("spell"));
|
delegate = Spell.readNbt(compound.getCompound("spell"));
|
||||||
placedEntityId = compound.containsUuid("placedEntityId") ? compound.getUuid("placedEntityId") : null;
|
placedEntityId = compound.containsUuid("placedEntityId") ? compound.getUuid("placedEntityId") : null;
|
||||||
position = compound.contains("position") ? Optional.of(NbtSerialisable.readVector(compound.getList("position", 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.FLOAT_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)) {
|
if (compound.contains("dimension", NbtElement.STRING_TYPE)) {
|
||||||
dimension = Optional.ofNullable(Identifier.tryParse(compound.getString("dimension"))).map(id -> RegistryKey.of(RegistryKeys.WORLD, id));
|
dimension = Optional.ofNullable(Identifier.tryParse(compound.getString("dimension"))).map(id -> RegistryKey.of(RegistryKeys.WORLD, id));
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,15 +57,16 @@ public class DismissSpellScreen extends GameGui {
|
||||||
}
|
}
|
||||||
|
|
||||||
double minimalDistance = 75 * (ring - 1) - 25;
|
double minimalDistance = 75 * (ring - 1) - 25;
|
||||||
Vec3d origin = pony.getOriginVector();
|
Vec3d origin = pony.asEntity().getPos();
|
||||||
|
|
||||||
placeableSpells.forEach(placeable -> {
|
placeableSpells.forEach(placeable -> {
|
||||||
placeable.getPosition().ifPresent(position -> {
|
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
|
Vec3d cartesian = relativePos
|
||||||
.normalize()
|
.normalize()
|
||||||
.multiply(minimalDistance + relativePos.length())
|
.multiply(minimalDistance + relativePos.horizontalLength())
|
||||||
.rotateY((pony.asEntity().getYaw() - 180) * MathHelper.RADIANS_PER_DEGREE);
|
.rotateY((180 + yaw) * MathHelper.RADIANS_PER_DEGREE);
|
||||||
addDrawableChild(new Entry(placeable).ofCartesian(cartesian));
|
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);
|
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.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;
|
int color = type.type().getColor() << 2;
|
||||||
|
|
||||||
matrices.push();
|
matrices.push();
|
||||||
matrices.translate(x, y, 0);
|
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);
|
DrawableUtil.drawArc(matrices, 0, 8, 0, DrawableUtil.TAU, color | 0x000000FF, false);
|
||||||
|
|
||||||
List<Text> tooltip = new ArrayList<>();
|
List<Text> tooltip = new ArrayList<>();
|
||||||
|
|
Loading…
Reference in a new issue