diff --git a/src/main/java/net/aufdemrand/denizen/objects/dEntity.java b/src/main/java/net/aufdemrand/denizen/objects/dEntity.java index 1a5f947d95..c4b05a8832 100644 --- a/src/main/java/net/aufdemrand/denizen/objects/dEntity.java +++ b/src/main/java/net/aufdemrand/denizen/objects/dEntity.java @@ -1394,9 +1394,10 @@ else if (attribute.startsWith("equipment")) { // TODO: meta if (attribute.startsWith("map_trace")) { Location location = Rotation.mapTrace(getLivingEntity(), 200); - if (location != null) + if (location != null) { // TODO: make this return the point (between 0,0 and 128,128) on the map - return new dLocation(null, location.getX(), location.getY()).getAttribute(attribute.fulfill(1)); + return new dLocation(location).getAttribute(attribute.fulfill(1)); + } } // <--[tag] diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/PlayEffectCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/PlayEffectCommand.java index ffc6b737e3..5cd13daf96 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/PlayEffectCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/PlayEffectCommand.java @@ -168,6 +168,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { radius.debug() + data.debug() + qty.debug() + + offset.debug() + (effect != null ? "" : offset.debug())); for (dLocation location: locations) { diff --git a/src/main/java/net/aufdemrand/denizen/utilities/entity/Rotation.java b/src/main/java/net/aufdemrand/denizen/utilities/entity/Rotation.java index e83624bdf4..a06b869373 100644 --- a/src/main/java/net/aufdemrand/denizen/utilities/entity/Rotation.java +++ b/src/main/java/net/aufdemrand/denizen/utilities/entity/Rotation.java @@ -98,6 +98,7 @@ public static Location mapTrace(LivingEntity from, double range) { Vector endVec = startVec.clone().add(new Vector(nx, -ny, nz).multiply(range)); MovingObjectPosition l = rayTrace(start.getWorld(), startVec, endVec); if (l == null || l.pos == null) return null; + Vector finalVec = new Vector(l.pos.a, l.pos.b, l.pos.c); double yaw = start.getYaw(); double angleX = -1; double angleY = 0; @@ -115,9 +116,9 @@ public static Location mapTrace(LivingEntity from, double range) { angleX = -yaw+90; break; } - if (angleX < 0 || angleY < 0) return null; - // TODO: calculate and return the actual location of the map (should be distance between original start/end minus 0.072) - Vector hit = startVec.normalize().multiply((0.072/angleX)*(180-angleX)); + // wallPosition - ((end - start).normalize() * 0.072) + // TODO: Increase accuracy using trigonometry (forward.norm*length is imperfect) + Vector hit = finalVec.clone().subtract((endVec.clone().subtract(startVec)).normalize().multiply(0.072)); return new Location(start.getWorld(), hit.getX(), hit.getY(), hit.getZ()); }