Fix npc path block updates (#1611)

* Fix npc path block updates

* Only update pathfind blocks in debug mode
This commit is contained in:
mergu 2018-11-05 06:05:28 -05:00 committed by fullwall
parent ae31173ac4
commit f47912f001
3 changed files with 7 additions and 6 deletions

View File

@ -471,7 +471,7 @@ public class NMSImpl implements NMSBridge {
@Override @Override
public void stop() { public void stop() {
if (navigation.k() != null) { if (params.debug() && navigation.k() != null) {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
for (int i = 0; i < navigation.k().d(); i++) { for (int i = 0; i < navigation.k().d(); i++) {
PathPoint pp = navigation.k().a(i); PathPoint pp = navigation.k().a(i);

View File

@ -474,7 +474,7 @@ public class NMSImpl implements NMSBridge {
@Override @Override
public void stop() { public void stop() {
if (navigation.l() != null) { if (params.debug() && navigation.l() != null) {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
for (int i = 0; i < navigation.l().d(); i++) { for (int i = 0; i < navigation.l().d(); i++) {
PathPoint pp = navigation.l().a(i); PathPoint pp = navigation.l().a(i);

View File

@ -19,6 +19,7 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.data.BlockData;
import org.bukkit.boss.BarColor; import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle; import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar; import org.bukkit.boss.BossBar;
@ -486,13 +487,13 @@ public class NMSImpl implements NMSBridge {
@Override @Override
public void stop() { public void stop() {
if (navigation.m() != null) { if (params.debug() && navigation.m() != null) {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
for (int i = 0; i < navigation.m().d(); i++) { for (int i = 0; i < navigation.m().d(); i++) {
PathPoint pp = navigation.m().a(i); PathPoint pp = navigation.m().a(i);
org.bukkit.block.Block block = new Vector(pp.a, pp.b, pp.c).toLocation(player.getWorld()) org.bukkit.block.Block block = new Vector(pp.a, pp.b, pp.c).toLocation(player.getWorld())
.getBlock(); .getBlock();
player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); player.sendBlockChange(block.getLocation(), block.getBlockData());
} }
} }
} }
@ -519,11 +520,11 @@ public class NMSImpl implements NMSBridge {
lastSpeed = params.speed(); lastSpeed = params.speed();
} }
if (params.debug() && !NMSImpl.isNavigationFinished(navigation)) { if (params.debug() && !NMSImpl.isNavigationFinished(navigation)) {
BlockData data = Material.DANDELION.createBlockData();
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
for (int i = 0; i < navigation.m().d(); i++) { for (int i = 0; i < navigation.m().d(); i++) {
PathPoint pp = navigation.m().a(i); PathPoint pp = navigation.m().a(i);
player.sendBlockChange(new Vector(pp.a, pp.b, pp.c).toLocation(player.getWorld()), player.sendBlockChange(new Vector(pp.a, pp.b, pp.c).toLocation(player.getWorld()), data);
Material.SUNFLOWER, (byte) 0);
} }
} }
} }