From 9454302f4a86c4760227276c48f475e490d7ef54 Mon Sep 17 00:00:00 2001 From: Ka0rX Date: Tue, 12 Jul 2022 22:13:32 +0200 Subject: [PATCH] 3D Gui enhancements --- .../gui/api/adaptor/ThreeDimAdaptor.java | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/main/java/net/Indyuce/mmocore/gui/api/adaptor/ThreeDimAdaptor.java b/src/main/java/net/Indyuce/mmocore/gui/api/adaptor/ThreeDimAdaptor.java index 641c430d..fbc7cbf2 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/api/adaptor/ThreeDimAdaptor.java +++ b/src/main/java/net/Indyuce/mmocore/gui/api/adaptor/ThreeDimAdaptor.java @@ -212,7 +212,7 @@ public class ThreeDimAdaptor extends Adaptor { Vector xAxis=initalLocation.clone().toVector().subtract(generated.getPlayer().getLocation().toVector()).setY(0).normalize(); Vector yAxis = new Vector(0, 1, 0); - Vector zAxis = xAxis.rotateAroundAxis(yAxis, -Math.PI / 2); + Vector zAxis = xAxis.clone().rotateAroundAxis(yAxis, -Math.PI / 2); //Empiric height of a line: 0.25 @@ -246,25 +246,29 @@ public class ThreeDimAdaptor extends Adaptor { double totalHeight=lineHeight*itemStack.getItemMeta().getLore().size(); double totalLength=max*charSize; - Location topCorner=getLocation(n, 1).add(yAxis.clone().multiply(2 +totalHeight/2)); + Location topCorner=getLocation(n, 1).add(yAxis.clone().multiply(armorStand.getHeight()*0.25 +totalHeight/2)); //We remove the items that can be in the field of vision - for(ArmorStand otherArmorStand:armorStands.values()) { + for(int slot:armorStands.keySet()) { + ArmorStand otherArmorStand = armorStands.get(slot); if(!otherArmorStand.equals(armorStand)) { //Calculates the direction between the player and otherArmorStand - Vector direction=otherArmorStand.getLocation().add(new Vector(0,0.25*otherArmorStand.getHeight(),0)).subtract(generated.getPlayer().getLocation()).toVector(); + Vector direction=otherArmorStand.getLocation().add(new Vector(0,0.25*otherArmorStand.getHeight(),0)).subtract(generated.getPlayer().getLocation()).toVector().normalize(); //The vector between the plan and the player. - Vector vector=initalLocation.clone().toVector().subtract(generated.getPlayer().getLocation().toVector()).setY(0); - //The intersection between 'direction' and the plane - Vector projection=generated.getPlayer().getLocation().toVector().add(xAxis.clone().multiply(vector.dot(direction))); - Vector relativeProjection=projection.subtract(topCorner.toVector()); - double z=zAxis.dot(relativeProjection); - double y=-yAxis.dot(relativeProjection); - Bukkit.broadcastMessage(otherArmorStand.getName()+" z:"+z+" y:"+y); - if(z>0&&z0&&y0&&z0&&y