From 8f598ab6b8087145a8839276369d38ef1529d7a2 Mon Sep 17 00:00:00 2001 From: Zeshan Aslam Date: Thu, 23 Mar 2017 20:10:10 -0400 Subject: [PATCH] New features and bug fixes Bug fixes: - Showing health message when player hurts itself. New features: - Added an option to blacklist certain entities from being shown in the health action bar. - Added option to show the health action bar when looking at an entity. - Added the ability to customize the message when using /actionhealth toggle. --- config.yml | 14 +- .../actionhealth/HealthListeners.class | Bin 4187 -> 4586 bytes .../actionhealth/HealthUtil$1.class | Bin 1248 -> 1314 bytes .../zeshanaslam/actionhealth/HealthUtil.class | Bin 7586 -> 7565 bytes .../zeshanaslam/actionhealth/LookThread.class | Bin 0 -> 2575 bytes .../com/zeshanaslam/actionhealth/Main.class | Bin 2149 -> 2189 bytes .../actionhealth/SettingsManager.class | Bin 3151 -> 5302 bytes .../actionhealth/TargetHelper.class | Bin 0 -> 6534 bytes plugin.yml | 2 +- .../actionhealth/HealthListeners.java | 14 +- .../zeshanaslam/actionhealth/HealthUtil.java | 24 +- .../zeshanaslam/actionhealth/LookThread.java | 46 +++ src/com/zeshanaslam/actionhealth/Main.java | 3 +- .../actionhealth/SettingsManager.java | 38 ++- .../actionhealth/TargetHelper.java | 288 ++++++++++++++++++ 15 files changed, 416 insertions(+), 13 deletions(-) create mode 100644 out/production/ActionHealth/com/zeshanaslam/actionhealth/LookThread.class create mode 100644 out/production/ActionHealth/com/zeshanaslam/actionhealth/TargetHelper.class create mode 100644 src/com/zeshanaslam/actionhealth/LookThread.java create mode 100644 src/com/zeshanaslam/actionhealth/TargetHelper.java diff --git a/config.yml b/config.yml index 33d5a52..7d37126 100644 --- a/config.yml +++ b/config.yml @@ -6,6 +6,10 @@ Health Message: '&7&l{name}: {usestyle}' +# The message the player is sent to the player if they have actionhealth disabled. +# {name} shows the name of the player. +Toggle Message: '' + # Strip Name. Strip Name: true @@ -51,4 +55,12 @@ Region PvP: true Limit Health: true # Saves players /actionhealth toggle state. -Remember Toggle: false \ No newline at end of file +Remember Toggle: false + +# Blacklist by entity name or entity display name. +Blacklist: +- 'CCPD Officer' + +# Show the health of the entity that the player is looking at. +Show On Look: false +Look Distance: 10 \ No newline at end of file diff --git a/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthListeners.class b/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthListeners.class index edfd2af0a4983590d40f61e96cbb157565948a5b..40bf094262699c6ce6cdff132c8dfea132d3f345 100644 GIT binary patch delta 1938 zcmZ{jX;hR|7{`B?nc*E~-l+sZ5h;*RKo&KX5;GJ{O+^z@DJ@4F5yepf7c?C$wZ+Qv zZNnC|($F#`Xbdre7Pl5@Uu@q#cuwE?Qdy_x&HySW&wJi`pZl!;XFHR0HYITC-y*pd(Ep}7E5*L1!YUwilT<)flDmT@v(7csSR%!NX ztzV<5H3nuKHh{5yozTD@Ysuh}fk{M)I7=2=WY`H+g|Q2766jq|RWU$$nlkd6@$y zuW-;{x5**u4PG^ApwZ+tf+mM~-Jr?j2+amZP2QlzCLI|`pa^Psw>O=WqFD#y7MH8Z}|#uMU}#+^ewCKmWt`vvfk1nk)U+N#@tyJWsS#1$93DYXPHNMIVeRbeVpV4qO>WE6rl_gMI zCx3))yljSD=#gA6=P0YqoiOeO;a!GJ&S;Uv5JgY&{2L>_Ph^ghcrdo+9%xa>iqK(*E8p3odu_Npv?h#`4 zu-eU@0b3)zc8GmOBN2`Cj<+`vuV}&(A=5K1%oUwJ$H+bZh)xL7cL%9qPGr3O0#TxN zait>2RY8*KGuue6B_*?!bnEg~7odD{k>Na$L_LE^9@C*oKuz`VW zB%7_|U@@4T3=!!t8W}Ey&6V}blLZ<{yV(6kzH%^H4WK}!F<#{`K@DS~no6N6VXE>n zT`i_at)^JjFjH+}mfFm0wVgT2Vy>#gtM=hjhghJ3l&RAJ7KKJ*I!LGpr7{FWE`7O`+d?Z=+*tv^J&D-@*&&(h>V+%d zM4h8Zvi#rt0?gs|js&;Jt(P`i5**f%U>IfRs$2wJn8PnZu9qFwO8j-w$@OH(Xypqh dDeSciXSU$HBZM=ZLEV66T?#03#Zv^{{{X5YoyPzG delta 1555 zcmZXTS#(rI5Qe{=B|S@z9EOn0kf4D;0!bz)L{J0-LKGFkYGQ)2C?p6ZEC$((6I>7x zH?E3XW|VIUZkq(N{f)R^P!Wc;-xZbys!OU;khCm*Vq9$#WNv zp9ZS9=a13J^r+LBfA}?w78eS%)*=Kl#R}HW6y5S8vHG2&Ec~kS2;cebAyvqT@d%Umt z!0;glHHQp`=`wso${Fa7g}XUo=%G_l=(KwZ1BPBcR>YjXa4gr5CS^Ekmt8j1F*42p zfAPrUoG_fU%PCGPytQ+y4WDpC(`Putr-siY|F8b$soTE$gjp19moOQa$=~DxGGC5wa^HXr4b23=mqr=D4&@rOD;yU?z zEGIG$KC!E~Ue@u>kEWnzg4|t&SJtTb1`!mMZje)+ynqllGEsJG+4o9*H!(?k?}{C`-s*iG7M7ETW*TBtldZMM4z|^x|ajXdhzt)?Pc&jeBI7( zk=$f{+?OGy$Pn?6lG}kqrtp7pKEgX5VZ0@7Pi47=C zma~}(I;do~e0+O_zx~4CVPU^Z7(OY?o)RX%XEHx9jq^G zyOf!ZSHcUV=oEZXWS#33`BjGia-|llni(Q=tBO*?Eh6@if$0W^|MahI$f8vX`M3?Ezo diff --git a/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthUtil$1.class b/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthUtil$1.class index f3c4e1d2562e756712665c55e75fc9c83a639385..dea40fc29e84a34a754f77698e00503648db408b 100644 GIT binary patch delta 393 zcmZ8dO-lk{5PsfWb9H?;zYEQ>FSXR#)U2RWoecuLc6c)pOIEQp2!evn5zF3!F8zZd zqB?Z!(5e1Gf1!Isv(>4Ad6S*x3^j5}lgP-hz=!4;Wx@f_u0t zxo7zQ8glLq$~7@%gb72W14acf;p5k#C=3<=6SV4p}Sq>xDg VVkYAlr@%#ToFpmeP)4*L`v&nrMf(5% delta 281 zcmXYsyH3MU42HjR0!?#j3KBN~<gc+7Xy22j&LXT9)=o>ozH7?F=V&c-g z*{`}g&GWP2u$`r;;l#fj6`#TA;+P6X?`tLZ7)|@H!2^?qn`8owF@E7Je~ diff --git a/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthUtil.class b/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthUtil.class index b22d536a3b760bdf63ebd66c09f9f39b273bafbd..5871788ddbb2febc8d78e0da39a0641c81195ab1 100644 GIT binary patch delta 3547 zcma)833yaj75>k>nY=e|UcxX*NFMthm?VUqWD-Ky30r}%rG?f60)&Qu5VlenY_Zq^ zt>G0RwTohHD5A0sTNl(?Y%R4EwNRCc;#TWct5yoc|GvpWzRIUr?mPF~bME=?xo5e1 z^LOM&U%z?kB>;nEzKNNrH<5>Zep1i-u^->?;{d*?<69;Y@NG35R8ofmIE*7|II4zY zYKSS(;{lw&NkyG9aT+fu>O~VT;bk?P(eWL{`L2QQnMlPe2EHFv#H$9*8u)=CUo-G} zLQzj5;!i@6`vG+P&_oaHQ^Ol-i*t&4Q&B%s!&}PQc>`~&$pr&HHZcr8QNvFSykp>^ zflF%XT?0Qe@N)yd&~aHUzZccj9jamK)Q9e*(~0e@A#`kRRl@pls+;U6aciGKy~G5#IEHGHCm>pE^I1UF4g zM}sa9SjE-V6-U-d2k|doU9)0!jUeO<&{CY8o>NYlHp)*aU4%|Ma!gw<`ej0;!6QR_ z<>E9XbWU7~do9crpM}|&s7j+v5WNjAzY>8Fh6D5}322FO6C z!06axklHV~Uqy9IWzG72qgR$Ks+m?*w!UJeC4*&%B}1jBv%$!dVa_pQl$I-b&NU;W zYs8X#DbQuOC56~v$p|S@wnyqR%97DC#u@2Pn>$veLHBsvcS+B+`<_UD#Yl`Xips&W-?G&tF{y1J&aDrYh|`GTa@9C~lT^6Hwh z%IZ}+6Wco#)>BUV#KWEreVmPn_K^=0`}v~2#T7Nh3(<|Km&c3{c+`!n1R*^ar5x|% zY#jL>e$DW4c*2>-pdI4OgS$8;LE{*L7s>D=1@ky-7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a7BU z3Yg7LAr{hV6AO_?YXJ*rvx$colp{N}W><&=Nr(0j9qiVcTOCrGq&3MnbZYE!*rV|_ zhi;9xJKUl1PKUcR-tCap*dut47WO*q(|E7Leuw*X!21h%fCmeCh==v@h|K|qM?;kJ zn6Bw@hl37Jgz$M%7yeX;r+FsCv-Ijfha8^Mcc0hC3l1-8e97TuZG6SyRh{BBAr7zG zykYZZe~;R){QCU81y-glo>t6U?f+_5`W4n>6%xS<5Q%ayiU9ilHmKXd=@VZt&9SXw0*D*X2FlcUixxJ&^Y0Rtsk~5xjWN+xnZR?6zZViC2i66n5V*6xg1CN(5Bzz7z5Hhmw=C4j&s7VA3Vm{ z%t@Dz`NZEbc#16Ar!J>B?eZC)+njOvf-h~pa`~EXT$*$aHPhu=zH>Rt_X@jfR`dMk zrdcjOa6~ak=)7i^b^2LFO9a-bdfK}qftcJtIIA(Z;Ye7+@NAT z8|21~5}_GOJ{45jKVDp(ogPq75(+3Bz>OF(Bw*+OMLAMz$gmtKF=Tj-Tw%zSIWoeK zkvTHTkkT9(Z9v9<+VbxB<^J7CTsdA~N#6}cDN>ch$(V4f*&e!$heT+{{fPos+a%WEt}H zz`2>NazjhE&@Ah)O?;#x`vPakw~5-c*ldTtnei8!M6pDE7sMkkXEdnFEOFhTwRryl D7dA*G diff --git a/out/production/ActionHealth/com/zeshanaslam/actionhealth/TargetHelper.class b/out/production/ActionHealth/com/zeshanaslam/actionhealth/TargetHelper.class new file mode 100644 index 0000000000000000000000000000000000000000..2f2f47ca1189b5c4b313becae053b7db354fa89e GIT binary patch literal 6534 zcmcIp3wTt;75*ptxcj)-O~`{?5H+IY0U;GoNI*nLfRrR4K_IpjZ#GME$!0g~-k`+R z`oLn9`oflnf>vwMmI_i0L|d!2wpJ~+YHMw+itksewQmH{f9~Dg?2=g2@2keSXJ*cv zIrIPLoSDSOkKF$tfGI+FFasN$v+~&EKORiSH@wKhH43ivz=;jAbDam*;|32l;zlpN ziEnwa37ciJMZs3Nbefa+iFx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BPef<9OJ|4WJxO1y`6qD+NES zUms!4L0Wa=Ypj+QsxMfm^3weTs8;OGK(&cQB8BSd_DX+|-NN;_EohNy@?nsLWl@oR zyDa)#H)+{A`@oKY1H1vKGkJX>riA)%y49VU>`t?~)%Nq(_n}7Kf entities = TargetHelper.getLivingTargets(player, plugin.settingsManager.lookDistance); + + if (!entities.isEmpty()) { + LivingEntity livingEntity = entities.get(0); + String name; + + if (livingEntity.getCustomName() == null) { + name = livingEntity.getName(); + } else { + name = livingEntity.getCustomName(); + } + + if (!plugin.settingsManager.blacklist.contains(name)) { + plugin.healthUtil.sendHealth(player, livingEntity, livingEntity.getHealth()); + } + } + } + } +} diff --git a/src/com/zeshanaslam/actionhealth/Main.java b/src/com/zeshanaslam/actionhealth/Main.java index ac8a282..7de17cd 100644 --- a/src/com/zeshanaslam/actionhealth/Main.java +++ b/src/com/zeshanaslam/actionhealth/Main.java @@ -14,6 +14,7 @@ public class Main extends JavaPlugin { public SettingsManager settingsManager; public WorldGuardPlugin worldGuardPlugin; public HealthUtil healthUtil; + public int taskID = -1; public List toggle = new ArrayList<>(); @@ -33,7 +34,7 @@ public class Main extends JavaPlugin { // Register listeners getServer().getPluginManager().registerEvents(new HealthListeners(this), this); - + // Register command getCommand("Actionhealth").setExecutor(new HealthCommand(this)); diff --git a/src/com/zeshanaslam/actionhealth/SettingsManager.java b/src/com/zeshanaslam/actionhealth/SettingsManager.java index 3594587..3b2d685 100644 --- a/src/com/zeshanaslam/actionhealth/SettingsManager.java +++ b/src/com/zeshanaslam/actionhealth/SettingsManager.java @@ -1,10 +1,13 @@ package com.zeshanaslam.actionhealth; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.scheduler.BukkitTask; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.stream.Collectors; public class SettingsManager { @@ -22,11 +25,22 @@ public class SettingsManager { public List worlds = new ArrayList<>(); public HashMap translate = new HashMap<>(); public List regions = new ArrayList<>(); - public String mcVersion; public boolean useOldMethods; + public boolean showOnLook; + public double lookDistance; + public List blacklist = new ArrayList<>(); + public String toggleMessage; public SettingsManager(Main plugin) { + // Clear settings for reloads + worlds.clear(); + regions.clear(); + blacklist.clear(); + + if (plugin.taskID != -1) Bukkit.getScheduler().cancelTask(plugin.taskID); + + // Get settings from config healthMessage = plugin.getConfig().getString("Health Message"); usePerms = plugin.getConfig().getBoolean("Use Permissions"); showMobs = plugin.getConfig().getBoolean("Show Mob"); @@ -60,5 +74,27 @@ public class SettingsManager { } else { rememberToggle = false; } + + // New options + if (plugin.getConfig().contains("Blacklist")) { + blacklist.addAll(plugin.getConfig().getStringList("Blacklist").stream().map(s -> ChatColor.translateAlternateColorCodes('&', s)).collect(Collectors.toList())); + } + + if (plugin.getConfig().contains("Show On Look")) { + showOnLook = plugin.getConfig().getBoolean("Show On Look"); + lookDistance = plugin.getConfig().getDouble("Look Distance"); + + if (showOnLook) { + BukkitTask bukkitTask = new LookThread(plugin).runTaskTimerAsynchronously(plugin, 0, 20); + plugin.taskID = bukkitTask.getTaskId(); + } + } else { + plugin.taskID = -1; + showOnLook = false; + } + + if (plugin.getConfig().contains("Toggle Message")) { + toggleMessage = plugin.getConfig().getString("Toggle Message"); + } } } diff --git a/src/com/zeshanaslam/actionhealth/TargetHelper.java b/src/com/zeshanaslam/actionhealth/TargetHelper.java new file mode 100644 index 0000000..80f105b --- /dev/null +++ b/src/com/zeshanaslam/actionhealth/TargetHelper.java @@ -0,0 +1,288 @@ +package com.zeshanaslam.actionhealth; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.util.Vector; + +import java.util.ArrayList; +import java.util.List; + +/** + *

Helper class for getting targets using various methods

+ */ +public class TargetHelper { + + /** + *

Number of pixels that end up displaying about 1 degree of vision in the client window

+ *

Not really useful since you can't get the client's window size, but I added it in case + * it becomes useful sometime

+ */ + private static final int PIXELS_PER_DEGREE = 35; + + /** + *

Gets all entities the player is looking at within the range

+ *

Has a little bit of tolerance to make targeting easier

+ * + * @param source living entity to get the targets of + * @param range maximum range to check + * @return all entities in the player's vision line + */ + public static List getLivingTargets(LivingEntity source, double range) { + return getLivingTargets(source, range, 4); + } + + /** + *

Gets all entities the player is looking at within the range using + * the given tolerance.

+ * + * @param source living entity to get the targets of + * @param range maximum range to check + * @param tolerance tolerance of the line calculation + * @return all entities in the player's vision line + */ + public static List getLivingTargets(LivingEntity source, double range, double tolerance) { + List list = source.getNearbyEntities(range, range, range); + List targets = new ArrayList(); + + Vector facing = source.getLocation().getDirection(); + double fLengthSq = facing.lengthSquared(); + + for (Entity entity : list) { + if (!isInFront(source, entity) || !(entity instanceof LivingEntity)) continue; + + Vector relative = entity.getLocation().subtract(source.getLocation()).toVector(); + double dot = relative.dot(facing); + double rLengthSq = relative.lengthSquared(); + double cosSquared = (dot * dot) / (rLengthSq * fLengthSq); + double sinSquared = 1 - cosSquared; + double dSquared = rLengthSq * sinSquared; + + // If close enough to vision line, return the entity + if (dSquared < tolerance) targets.add((LivingEntity) entity); + } + + return targets; + } + + /** + *

Gets the entity the player is looking at

+ *

Has a little bit of tolerance to make targeting easier

+ * + * @param source living entity to get the target of + * @param range maximum range to check + * @return entity player is looing at or null if not found + */ + public static LivingEntity getLivingTarget(LivingEntity source, double range) { + return getLivingTarget(source, range, 4); + } + + /** + *

Gets the entity the player is looking at

+ *

Has a little bit of tolerance to make targeting easier

+ * + * @param source living entity to get the target of + * @param range maximum range to check + * @param tolerance tolerance of the line calculation + * @return entity player is looking at or null if not found + */ + public static LivingEntity getLivingTarget(LivingEntity source, double range, double tolerance) { + List targets = getLivingTargets(source, range, tolerance); + if (targets.size() == 0) return null; + LivingEntity target = targets.get(0); + double minDistance = target.getLocation().distanceSquared(source.getLocation()); + for (LivingEntity entity : targets) { + double distance = entity.getLocation().distanceSquared(source.getLocation()); + if (distance < minDistance) { + minDistance = distance; + target = entity; + } + } + return target; + } + + /** + * Gets the targets in a cone + * + * @param source entity to get the targets for + * @param arc arc angle of the cone + * @param range range of the cone + * @return list of targets + */ + public static List getConeTargets(LivingEntity source, double arc, double range) { + List targets = new ArrayList(); + List list = source.getNearbyEntities(range, range, range); + if (arc <= 0) return targets; + + // Initialize values + Vector dir = source.getLocation().getDirection(); + dir.setY(0); + double cos = Math.cos(arc * Math.PI / 180); + double cosSq = cos * cos; + + // Get the targets in the cone + for (Entity entity : list) { + if (entity instanceof LivingEntity) { + + // Greater than 360 degrees is all targets + if (arc >= 360) { + targets.add((LivingEntity) entity); + } + + // Otherwise, select targets based on dot product + else { + Vector relative = entity.getLocation().subtract(source.getLocation()).toVector(); + relative.setY(0); + double dot = relative.dot(dir); + double value = dot * dot / relative.lengthSquared(); + if (arc < 180 && dot > 0 && value >= cosSq) targets.add((LivingEntity) entity); + else if (arc >= 180 && (dot > 0 || dot <= cosSq)) targets.add((LivingEntity) entity); + } + } + } + + return targets; + } + + /** + * Checks if the entity is in front of the entity + * + * @param entity entity to check for + * @param target target to check against + * @return true if the target is in front of the entity + */ + public static boolean isInFront(Entity entity, Entity target) { + + // Get the necessary vectors + Vector facing = entity.getLocation().getDirection(); + Vector relative = target.getLocation().subtract(entity.getLocation()).toVector(); + + // If the dot product is positive, the target is in front + return facing.dot(relative) >= 0; + } + + /** + * Checks if the entity is in front of the entity restricted to the given angle + * + * @param entity entity to check for + * @param target target to check against + * @param angle angle to restrict it to (0-360) + * @return true if the target is in front of the entity + */ + public static boolean isInFront(Entity entity, Entity target, double angle) { + if (angle <= 0) return false; + if (angle >= 360) return true; + + // Get the necessary data + double dotTarget = Math.cos(angle); + Vector facing = entity.getLocation().getDirection(); + Vector relative = target.getLocation().subtract(entity.getLocation()).toVector().normalize(); + + // Compare the target dot product with the actual result + return facing.dot(relative) >= dotTarget; + } + + /** + * Checks if the target is behind the entity + * + * @param entity entity to check for + * @param target target to check against + * @return true if the target is behind the entity + */ + public static boolean isBehind(Entity entity, Entity target) { + return !isInFront(entity, target); + } + + /** + * Checks if the entity is behind the player restricted to the given angle + * + * @param entity entity to check for + * @param target target to check against + * @param angle angle to restrict it to (0-360) + * @return true if the target is behind the entity + */ + public static boolean isBehind(Entity entity, Entity target, double angle) { + if (angle <= 0) return false; + if (angle >= 360) return true; + + // Get the necessary data + double dotTarget = Math.cos(angle); + Vector facing = entity.getLocation().getDirection(); + Vector relative = entity.getLocation().subtract(target.getLocation()).toVector().normalize(); + + // Compare the target dot product and the actual result + return facing.dot(relative) >= dotTarget; + } + + /** + * Checks whether or not the line between the two points is obstructed + * + * @param loc1 first location + * @param loc2 second location + * @return the location of obstruction or null if not obstructed + */ + public static boolean isObstructed(Location loc1, Location loc2) { + if (loc1.getX() == loc2.getX() && loc1.getY() == loc2.getY() && loc1.getZ() == loc2.getZ()) { + return false; + } + Vector slope = loc2.clone().subtract(loc1).toVector(); + int steps = (int) (slope.length() * 4) + 1; + slope.multiply(1.0 / steps); + Location temp = loc1.clone(); + for (int i = 0; i < steps; i++) { + temp.add(slope); + if (temp.getBlock().getType().isSolid() && temp.getBlock().getType() != Material.IRON_FENCE && !temp.getBlock().getType().toString().contains("GLASS")) { + return true; + } + } + return false; + } + + /** + * Retrieves an open location along the line for teleporting or linear targeting + * + * @param loc1 start location of the path + * @param loc2 end location of the path + * @param throughWall whether or not going through walls is allowed + * @return the farthest open location along the path + */ + public static Location getOpenLocation(Location loc1, Location loc2, boolean throughWall) { + // Special case + if (loc1.getX() == loc2.getX() && loc1.getY() == loc2.getY() && loc1.getZ() == loc2.getZ()) { + return loc1; + } + + // Common data + Vector slope = loc2.clone().subtract(loc1).toVector(); + int steps = (int) (slope.length() * 4) + 1; + slope.multiply(1.0 / steps); + + // Going through walls starts at the end and traverses backwards + if (throughWall) { + Location temp = loc2.clone(); + while (temp.getBlock().getType().isSolid() && steps > 0) { + temp.subtract(slope); + steps--; + } + temp.setX(temp.getBlockX() + 0.5); + temp.setZ(temp.getBlockZ() + 0.5); + temp.setY(temp.getBlockY() + 1); + return temp; + } + + // Not going through walls starts at the beginning and traverses forward + else { + Location temp = loc1.clone(); + while (!temp.getBlock().getType().isSolid() && steps > 0) { + temp.add(slope); + steps--; + } + temp.subtract(slope); + temp.setX(temp.getBlockX() + 0.5); + temp.setZ(temp.getBlockZ() + 0.5); + temp.setY(temp.getBlockY() + 1); + return temp; + } + } +} \ No newline at end of file