Misc bugfixes

This commit is contained in:
fullwall 2024-11-28 19:37:49 +08:00
parent 8b4a4dd48c
commit 2773304f47
16 changed files with 100 additions and 88 deletions

View File

@ -96,7 +96,7 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
Location loc = npc.getEntity().getLocation(); Location loc = npc.getEntity().getLocation();
Location dest = Util.getCenterLocation(vector.toLocation(loc.getWorld()).getBlock()); Location dest = Util.getCenterLocation(vector.toLocation(loc.getWorld()).getBlock());
/* Proper door movement - gets stuck on corners at times /* Proper door movement - gets stuck on corners at times
Block block = loc.getWorld().getBlockAt(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()); Block block = loc.getWorld().getBlockAt(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
if (MinecraftBlockExaminer.isDoor(block.getType())) { if (MinecraftBlockExaminer.isDoor(block.getType())) {
Door door = (Door) block.getState().getData(); Door door = (Door) block.getState().getData();
@ -121,7 +121,7 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
npc.getEntity().getWorld().playEffect(dest, Effect.ENDER_SIGNAL, 0); npc.getEntity().getWorld().playEffect(dest, Effect.ENDER_SIGNAL, 0);
} }
if (npc.getEntity() instanceof LivingEntity && npc.getEntity().getType() != EntityType.ARMOR_STAND) { if (npc.getEntity() instanceof LivingEntity && npc.getEntity().getType() != EntityType.ARMOR_STAND) {
NMS.setDestination(npc.getEntity(), dest.getX(), dest.getY(), dest.getZ(), params.speed()); NMS.setDestination(npc.getEntity(), dest.getX(), dest.getY(), dest.getZ(), params.speedModifier());
} else { } else {
Vector dir = dest.toVector().subtract(npc.getEntity().getLocation().toVector()).normalize().multiply(0.2); Vector dir = dest.toVector().subtract(npc.getEntity().getLocation().toVector()).normalize().multiply(0.2);
boolean liquidOrInLiquid = MinecraftBlockExaminer.isLiquidOrInLiquid(loc.getBlock()); boolean liquidOrInLiquid = MinecraftBlockExaminer.isLiquidOrInLiquid(loc.getBlock());

View File

@ -370,7 +370,7 @@ public class ShopTrait extends Trait {
@Persist @Persist
private int timesPurchasable = 0; private int timesPurchasable = 0;
public List<Transaction> apply(List<NPCShopAction> actions, Function<NPCShopAction, Transaction> func) { private List<Transaction> apply(List<NPCShopAction> actions, Function<NPCShopAction, Transaction> func) {
List<Transaction> pending = Lists.newArrayList(); List<Transaction> pending = Lists.newArrayList();
for (NPCShopAction action : actions) { for (NPCShopAction action : actions) {
Transaction take = func.apply(action); Transaction take = func.apply(action);
@ -402,11 +402,11 @@ public class ShopTrait extends Trait {
} }
} }
public void changeCost(Function<NPCShopAction, Boolean> filter, NPCShopAction cost) { private void changeCost(Function<NPCShopAction, Boolean> filter, NPCShopAction cost) {
changeAction(this.cost, filter, cost); changeAction(this.cost, filter, cost);
} }
public void changeResult(Function<NPCShopAction, Boolean> filter, NPCShopAction result) { private void changeResult(Function<NPCShopAction, Boolean> filter, NPCShopAction result) {
changeAction(this.result, filter, result); changeAction(this.result, filter, result);
} }
@ -428,6 +428,10 @@ public class ShopTrait extends Trait {
} }
} }
public List<NPCShopAction> getCost() {
return cost;
}
public ItemStack getDisplayItem(Player player) { public ItemStack getDisplayItem(Player player) {
if (display == null) if (display == null)
return null; return null;
@ -457,6 +461,10 @@ public class ShopTrait extends Trait {
return stack; return stack;
} }
public List<NPCShopAction> getResult() {
return result;
}
@Override @Override
public void load(DataKey key) { public void load(DataKey key) {
if (key.keyExists("message")) { if (key.keyExists("message")) {
@ -469,7 +477,7 @@ public class ShopTrait extends Trait {
} }
} }
public void onClick(NPCShop shop, Player player, InventoryMultiplexer inventory, boolean shiftClick, private void onClick(NPCShop shop, Player player, InventoryMultiplexer inventory, boolean shiftClick,
boolean secondClick) { boolean secondClick) {
// TODO: InventoryMultiplexer could be lifted up to transact in apply(), which would be cleaner. // TODO: InventoryMultiplexer could be lifted up to transact in apply(), which would be cleaner.
// if this is done, it should probably refresh after every transaction application // if this is done, it should probably refresh after every transaction application
@ -675,8 +683,12 @@ public class ShopTrait extends Trait {
: "Unset"), : "Unset"),
description -> { description -> {
ItemMeta meta = modified.display.getItemMeta(); ItemMeta meta = modified.display.getItemMeta();
meta.setLore( if (description.isEmpty()) {
Lists.newArrayList(Splitter.on('\n').split(Messaging.parseComponents(description)))); meta.setLore(Lists.newArrayList());
} else {
meta.setLore(Lists
.newArrayList(Splitter.on('\n').split(Messaging.parseComponents(description))));
}
modified.display.setItemMeta(meta); modified.display.setItemMeta(meta);
}); });
} }

View File

@ -129,8 +129,8 @@ public class NMS {
if (npc.getEntity() == null) if (npc.getEntity() == null)
return; return;
if (SUPPORTS_ATTRIBUTABLE && npc.getEntity() instanceof Attributable) { if (SUPPORTS_ATTRIBUTABLE && npc.getEntity() instanceof Attributable) {
AttributeInstance attribute = ((Attributable) npc.getEntity()) AttributeInstance attribute = ((Attributable) npc.getEntity()).getAttribute(
.getAttribute(Util.getRegistryValue(Registry.ATTRIBUTE, "generic.knockback_resistance", "knockback_resistance")); Util.getRegistryValue(Registry.ATTRIBUTE, "generic.knockback_resistance", "knockback_resistance"));
if (attribute != null) { if (attribute != null) {
strength *= 1 - attribute.getValue(); strength *= 1 - attribute.getValue();
} }

View File

@ -596,14 +596,14 @@ public class NMSImpl implements NMSBridge {
Iterables.transform(dest, Iterables.transform(dest,
input -> new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ())), input -> new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ())),
PathPoint.class)); PathPoint.class));
return getTargetNavigator(entity, params, input -> input.a(path, params.speed())); return getTargetNavigator(entity, params, input -> input.a(path, params.speedModifier()));
} }
@Override @Override
public MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final Location dest, public MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final Location dest,
final NavigatorParameters params) { final NavigatorParameters params) {
return getTargetNavigator(entity, params, return getTargetNavigator(entity, params,
input -> input.a(dest.getX(), dest.getY(), dest.getZ(), params.speed())); input -> input.a(dest.getX(), dest.getY(), dest.getZ(), params.speedModifier()));
} }
private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params, private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params,
@ -652,7 +652,7 @@ public class NMSImpl implements NMSBridge {
@Override @Override
public boolean update() { public boolean update() {
if (params.speed() != lastSpeed && lastSpeed > 0) { if (params.speedModifier() != lastSpeed && lastSpeed > 0) {
Entity handle = getHandle(entity); Entity handle = getHandle(entity);
float oldWidth = handle.width; float oldWidth = handle.width;
if (handle instanceof EntityHorse) { if (handle instanceof EntityHorse) {
@ -663,9 +663,9 @@ public class NMSImpl implements NMSBridge {
} }
handle.width = oldWidth; // minecraft requires that an entity fit onto both blocks if width >= 1f, handle.width = oldWidth; // minecraft requires that an entity fit onto both blocks if width >= 1f,
// but we'd prefer to make it just fit on 1 so hack around it a bit. // but we'd prefer to make it just fit on 1 so hack around it a bit.
lastSpeed = params.speed(); lastSpeed = params.speedModifier();
} }
navigation.a(params.speed()); navigation.a(params.speedModifier());
return NMSImpl.isNavigationFinished(navigation); return NMSImpl.isNavigationFinished(navigation);
} }
}; };
@ -1542,7 +1542,7 @@ public class NMSImpl implements NMSBridge {
Location location = parameters.entityTargetLocationMapper().apply(target); Location location = parameters.entityTargetLocationMapper().apply(target);
if (location == null) if (location == null)
throw new IllegalStateException("mapper should not return null"); throw new IllegalStateException("mapper should not return null");
navigation.a(location.getX(), location.getY(), location.getZ(), parameters.speed()); navigation.a(location.getX(), location.getY(), location.getZ(), parameters.speedModifier());
} }
@Override @Override

View File

@ -616,14 +616,14 @@ public class NMSImpl implements NMSBridge {
Iterables.transform(dest, Iterables.transform(dest,
input -> new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ())), input -> new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ())),
PathPoint.class)); PathPoint.class));
return getTargetNavigator(entity, params, input -> input.a(path, params.speed())); return getTargetNavigator(entity, params, input -> input.a(path, params.speedModifier()));
} }
@Override @Override
public MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final Location dest, public MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final Location dest,
final NavigatorParameters params) { final NavigatorParameters params) {
return getTargetNavigator(entity, params, return getTargetNavigator(entity, params,
input -> input.a(dest.getX(), dest.getY(), dest.getZ(), params.speed())); input -> input.a(dest.getX(), dest.getY(), dest.getZ(), params.speedModifier()));
} }
private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params, private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params,
@ -685,7 +685,7 @@ public class NMSImpl implements NMSBridge {
@Override @Override
public boolean update() { public boolean update() {
if (params.speed() != lastSpeed && lastSpeed > 0) { if (params.speedModifier() != lastSpeed && lastSpeed > 0) {
Entity handle = getHandle(entity); Entity handle = getHandle(entity);
float oldWidth = handle.width; float oldWidth = handle.width;
if (handle instanceof EntityHorse) { if (handle instanceof EntityHorse) {
@ -696,12 +696,12 @@ public class NMSImpl implements NMSBridge {
} }
handle.width = oldWidth; // minecraft requires that an entity fit onto both blocks if width >= 1f, handle.width = oldWidth; // minecraft requires that an entity fit onto both blocks if width >= 1f,
// but we'd prefer to make it just fit on 1 so hack around it a bit. // but we'd prefer to make it just fit on 1 so hack around it a bit.
lastSpeed = params.speed(); lastSpeed = params.speedModifier();
} }
if (params.debug() && !NMSImpl.isNavigationFinished(navigation)) { if (params.debug() && !NMSImpl.isNavigationFinished(navigation)) {
Util.sendBlockChanges(getBlocks(entity, navigation), Material.YELLOW_FLOWER); Util.sendBlockChanges(getBlocks(entity, navigation), Material.YELLOW_FLOWER);
} }
navigation.a(params.speed()); navigation.a(params.speedModifier());
return NMSImpl.isNavigationFinished(navigation); return NMSImpl.isNavigationFinished(navigation);
} }
}; };
@ -1601,7 +1601,7 @@ public class NMSImpl implements NMSBridge {
Location location = parameters.entityTargetLocationMapper().apply(target); Location location = parameters.entityTargetLocationMapper().apply(target);
if (location == null) if (location == null)
throw new IllegalStateException("mapper should not return null"); throw new IllegalStateException("mapper should not return null");
navigation.a(location.getX(), location.getY(), location.getZ(), parameters.speed()); navigation.a(location.getX(), location.getY(), location.getZ(), parameters.speedModifier());
} }
@Override @Override

View File

@ -617,14 +617,14 @@ public class NMSImpl implements NMSBridge {
Iterables.transform(dest, Iterables.transform(dest,
input -> new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ())), input -> new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ())),
PathPoint.class)); PathPoint.class));
return getTargetNavigator(entity, params, input -> input.a(path, params.speed())); return getTargetNavigator(entity, params, input -> input.a(path, params.speedModifier()));
} }
@Override @Override
public MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final Location dest, public MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final Location dest,
final NavigatorParameters params) { final NavigatorParameters params) {
return getTargetNavigator(entity, params, return getTargetNavigator(entity, params,
input -> input.a(dest.getX(), dest.getY(), dest.getZ(), params.speed())); input -> input.a(dest.getX(), dest.getY(), dest.getZ(), params.speedModifier()));
} }
private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params, private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params,
@ -687,7 +687,7 @@ public class NMSImpl implements NMSBridge {
@Override @Override
public boolean update() { public boolean update() {
if (params.speed() != lastSpeed) { if (params.speedModifier() != lastSpeed) {
Entity handle = getHandle(entity); Entity handle = getHandle(entity);
float oldWidth = handle.width; float oldWidth = handle.width;
if (handle instanceof EntityHorse) { if (handle instanceof EntityHorse) {
@ -698,12 +698,12 @@ public class NMSImpl implements NMSBridge {
} }
handle.width = oldWidth; // minecraft requires that an entity fit onto both blocks if width >= 1f, handle.width = oldWidth; // minecraft requires that an entity fit onto both blocks if width >= 1f,
// but we'd prefer to make it just fit on 1 so hack around it a bit. // but we'd prefer to make it just fit on 1 so hack around it a bit.
lastSpeed = params.speed(); lastSpeed = params.speedModifier();
} }
if (params.debug() && !NMSImpl.isNavigationFinished(navigation)) { if (params.debug() && !NMSImpl.isNavigationFinished(navigation)) {
Util.sendBlockChanges(getBlocks(entity, navigation), Material.YELLOW_FLOWER); Util.sendBlockChanges(getBlocks(entity, navigation), Material.YELLOW_FLOWER);
} }
navigation.a(params.speed()); navigation.a(params.speedModifier());
return NMSImpl.isNavigationFinished(navigation); return NMSImpl.isNavigationFinished(navigation);
} }
}; };
@ -1609,7 +1609,7 @@ public class NMSImpl implements NMSBridge {
Location location = parameters.entityTargetLocationMapper().apply(target); Location location = parameters.entityTargetLocationMapper().apply(target);
if (location == null) if (location == null)
throw new IllegalStateException("mapper should not return null"); throw new IllegalStateException("mapper should not return null");
navigation.a(location.getX(), location.getY(), location.getZ(), parameters.speed()); navigation.a(location.getX(), location.getY(), location.getZ(), parameters.speedModifier());
} }
@Override @Override

View File

@ -646,14 +646,14 @@ public class NMSImpl implements NMSBridge {
Iterables.transform(dest, Iterables.transform(dest,
input -> new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ())), input -> new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ())),
PathPoint.class)); PathPoint.class));
return getTargetNavigator(entity, params, input -> input.a(path, params.speed())); return getTargetNavigator(entity, params, input -> input.a(path, params.speedModifier()));
} }
@Override @Override
public MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final Location dest, public MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final Location dest,
final NavigatorParameters params) { final NavigatorParameters params) {
return getTargetNavigator(entity, params, return getTargetNavigator(entity, params,
input -> input.a(dest.getX(), dest.getY(), dest.getZ(), params.speed())); input -> input.a(dest.getX(), dest.getY(), dest.getZ(), params.speedModifier()));
} }
private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params, private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params,
@ -716,7 +716,7 @@ public class NMSImpl implements NMSBridge {
@Override @Override
public boolean update() { public boolean update() {
if (params.speed() != lastSpeed) { if (params.speedModifier() != lastSpeed) {
Entity handle = getHandle(entity); Entity handle = getHandle(entity);
float oldWidth = handle.width; float oldWidth = handle.width;
if (handle instanceof EntityHorse) { if (handle instanceof EntityHorse) {
@ -727,12 +727,12 @@ public class NMSImpl implements NMSBridge {
} }
handle.width = oldWidth; // minecraft requires that an entity fit onto both blocks if width >= 1f, handle.width = oldWidth; // minecraft requires that an entity fit onto both blocks if width >= 1f,
// but we'd prefer to make it just fit on 1 so hack around it a bit. // but we'd prefer to make it just fit on 1 so hack around it a bit.
lastSpeed = params.speed(); lastSpeed = params.speedModifier();
} }
if (params.debug() && !NMSImpl.isNavigationFinished(navigation)) { if (params.debug() && !NMSImpl.isNavigationFinished(navigation)) {
Util.sendBlockChanges(getBlocks(entity, navigation), Material.DANDELION); Util.sendBlockChanges(getBlocks(entity, navigation), Material.DANDELION);
} }
navigation.a(params.speed()); navigation.a(params.speedModifier());
return NMSImpl.isNavigationFinished(navigation); return NMSImpl.isNavigationFinished(navigation);
} }
}; };
@ -1657,7 +1657,7 @@ public class NMSImpl implements NMSBridge {
Location location = parameters.entityTargetLocationMapper().apply(target); Location location = parameters.entityTargetLocationMapper().apply(target);
if (location == null) if (location == null)
throw new IllegalStateException("mapper should not return null"); throw new IllegalStateException("mapper should not return null");
navigation.a(location.getX(), location.getY(), location.getZ(), parameters.speed()); navigation.a(location.getX(), location.getY(), location.getZ(), parameters.speedModifier());
} }
@Override @Override

View File

@ -686,14 +686,14 @@ public class NMSImpl implements NMSBridge {
PathPoint last = list.size() > 0 ? list.get(list.size() - 1) : null; PathPoint last = list.size() > 0 ? list.get(list.size() - 1) : null;
final PathEntity path = new PathEntity(list, last != null ? new BlockPosition(last.a, last.b, last.c) : null, final PathEntity path = new PathEntity(list, last != null ? new BlockPosition(last.a, last.b, last.c) : null,
true); true);
return getTargetNavigator(entity, params, input -> input.a(path, params.speed())); return getTargetNavigator(entity, params, input -> input.a(path, params.speedModifier()));
} }
@Override @Override
public MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final Location dest, public MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final Location dest,
final NavigatorParameters params) { final NavigatorParameters params) {
return getTargetNavigator(entity, params, return getTargetNavigator(entity, params,
input -> input.a(dest.getX(), dest.getY(), dest.getZ(), params.speed())); input -> input.a(dest.getX(), dest.getY(), dest.getZ(), params.speedModifier()));
} }
private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params, private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params,
@ -756,7 +756,7 @@ public class NMSImpl implements NMSBridge {
@Override @Override
public boolean update() { public boolean update() {
if (params.speed() != lastSpeed) { if (params.speedModifier() != lastSpeed) {
Entity handle = getHandle(entity); Entity handle = getHandle(entity);
EntitySize size = null; EntitySize size = null;
try { try {
@ -778,12 +778,12 @@ public class NMSImpl implements NMSBridge {
// minecraft requires that an entity fit onto both blocks if width >= 1f, but we'd prefer to // minecraft requires that an entity fit onto both blocks if width >= 1f, but we'd prefer to
// make it just fit on 1 so hack around it a bit. // make it just fit on 1 so hack around it a bit.
} }
lastSpeed = params.speed(); lastSpeed = params.speedModifier();
} }
if (params.debug() && !NMSImpl.isNavigationFinished(navigation)) { if (params.debug() && !NMSImpl.isNavigationFinished(navigation)) {
Util.sendBlockChanges(getBlocks(entity, navigation), Material.DANDELION); Util.sendBlockChanges(getBlocks(entity, navigation), Material.DANDELION);
} }
navigation.a(params.speed()); navigation.a(params.speedModifier());
return NMSImpl.isNavigationFinished(navigation); return NMSImpl.isNavigationFinished(navigation);
} }
}; };
@ -1754,7 +1754,7 @@ public class NMSImpl implements NMSBridge {
Location location = parameters.entityTargetLocationMapper().apply(target); Location location = parameters.entityTargetLocationMapper().apply(target);
if (location == null) if (location == null)
throw new IllegalStateException("mapper should not return null"); throw new IllegalStateException("mapper should not return null");
navigation.a(location.getX(), location.getY(), location.getZ(), parameters.speed()); navigation.a(location.getX(), location.getY(), location.getZ(), parameters.speedModifier());
} }
@Override @Override

View File

@ -701,14 +701,14 @@ public class NMSImpl implements NMSBridge {
PathPoint last = list.size() > 0 ? list.get(list.size() - 1) : null; PathPoint last = list.size() > 0 ? list.get(list.size() - 1) : null;
final PathEntity path = new PathEntity(list, last != null ? new BlockPosition(last.a, last.b, last.c) : null, final PathEntity path = new PathEntity(list, last != null ? new BlockPosition(last.a, last.b, last.c) : null,
true); true);
return getTargetNavigator(entity, params, input -> input.a(path, params.speed())); return getTargetNavigator(entity, params, input -> input.a(path, params.speedModifier()));
} }
@Override @Override
public MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final Location dest, public MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final Location dest,
final NavigatorParameters params) { final NavigatorParameters params) {
return getTargetNavigator(entity, params, return getTargetNavigator(entity, params,
input -> input.a(dest.getX(), dest.getY(), dest.getZ(), params.speed())); input -> input.a(dest.getX(), dest.getY(), dest.getZ(), params.speedModifier()));
} }
private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params, private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params,
@ -771,7 +771,7 @@ public class NMSImpl implements NMSBridge {
@Override @Override
public boolean update() { public boolean update() {
if (params.speed() != lastSpeed) { if (params.speedModifier() != lastSpeed) {
Entity handle = getHandle(entity); Entity handle = getHandle(entity);
EntitySize size = null; EntitySize size = null;
try { try {
@ -793,12 +793,12 @@ public class NMSImpl implements NMSBridge {
// minecraft requires that an entity fit onto both blocks if width >= 1f, but we'd prefer to // minecraft requires that an entity fit onto both blocks if width >= 1f, but we'd prefer to
// make it just fit on 1 so hack around it a bit. // make it just fit on 1 so hack around it a bit.
} }
lastSpeed = params.speed(); lastSpeed = params.speedModifier();
} }
if (params.debug() && !NMSImpl.isNavigationFinished(navigation)) { if (params.debug() && !NMSImpl.isNavigationFinished(navigation)) {
Util.sendBlockChanges(getBlocks(entity, navigation), Material.DANDELION); Util.sendBlockChanges(getBlocks(entity, navigation), Material.DANDELION);
} }
navigation.a((double) params.speed()); navigation.a((double) params.speedModifier());
return NMSImpl.isNavigationFinished(navigation); return NMSImpl.isNavigationFinished(navigation);
} }
}; };
@ -1803,7 +1803,7 @@ public class NMSImpl implements NMSBridge {
Location location = parameters.entityTargetLocationMapper().apply(target); Location location = parameters.entityTargetLocationMapper().apply(target);
if (location == null) if (location == null)
throw new IllegalStateException("mapper should not return null"); throw new IllegalStateException("mapper should not return null");
navigation.a(location.getX(), location.getY(), location.getZ(), parameters.speed()); navigation.a(location.getX(), location.getY(), location.getZ(), parameters.speedModifier());
} }
@Override @Override

View File

@ -722,14 +722,14 @@ public class NMSImpl implements NMSBridge {
PathPoint last = list.size() > 0 ? list.get(list.size() - 1) : null; PathPoint last = list.size() > 0 ? list.get(list.size() - 1) : null;
final PathEntity path = new PathEntity(list, last != null ? new BlockPosition(last.a, last.b, last.c) : null, final PathEntity path = new PathEntity(list, last != null ? new BlockPosition(last.a, last.b, last.c) : null,
true); true);
return getTargetNavigator(entity, params, input -> input.a(path, params.speed())); return getTargetNavigator(entity, params, input -> input.a(path, params.speedModifier()));
} }
@Override @Override
public MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final Location dest, public MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final Location dest,
final NavigatorParameters params) { final NavigatorParameters params) {
return getTargetNavigator(entity, params, return getTargetNavigator(entity, params,
input -> input.a(dest.getX(), dest.getY(), dest.getZ(), params.speed())); input -> input.a(dest.getX(), dest.getY(), dest.getZ(), params.speedModifier()));
} }
private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params, private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params,
@ -792,7 +792,7 @@ public class NMSImpl implements NMSBridge {
@Override @Override
public boolean update() { public boolean update() {
if (params.speed() != lastSpeed) { if (params.speedModifier() != lastSpeed) {
Entity handle = getHandle(entity); Entity handle = getHandle(entity);
EntitySize size = null; EntitySize size = null;
try { try {
@ -814,12 +814,12 @@ public class NMSImpl implements NMSBridge {
// minecraft requires that an entity fit onto both blocks if width >= 1f, but we'd prefer to // minecraft requires that an entity fit onto both blocks if width >= 1f, but we'd prefer to
// make it just fit on 1 so hack around it a bit. // make it just fit on 1 so hack around it a bit.
} }
lastSpeed = params.speed(); lastSpeed = params.speedModifier();
} }
if (params.debug() && !NMSImpl.isNavigationFinished(navigation)) { if (params.debug() && !NMSImpl.isNavigationFinished(navigation)) {
Util.sendBlockChanges(getBlocks(entity, navigation), Material.DANDELION); Util.sendBlockChanges(getBlocks(entity, navigation), Material.DANDELION);
} }
navigation.a((double) params.speed()); navigation.a((double) params.speedModifier());
return NMSImpl.isNavigationFinished(navigation); return NMSImpl.isNavigationFinished(navigation);
} }
}; };
@ -1823,7 +1823,7 @@ public class NMSImpl implements NMSBridge {
Location location = parameters.entityTargetLocationMapper().apply(target); Location location = parameters.entityTargetLocationMapper().apply(target);
if (location == null) if (location == null)
throw new IllegalStateException("mapper should not return null"); throw new IllegalStateException("mapper should not return null");
navigation.a(location.getX(), location.getY(), location.getZ(), parameters.speed()); navigation.a(location.getX(), location.getY(), location.getZ(), parameters.speedModifier());
} }
@Override @Override

View File

@ -724,14 +724,14 @@ public class NMSImpl implements NMSBridge {
input -> new Node(input.getBlockX(), input.getBlockY(), input.getBlockZ()))); input -> new Node(input.getBlockX(), input.getBlockY(), input.getBlockZ())));
Node last = list.size() > 0 ? list.get(list.size() - 1) : null; Node last = list.size() > 0 ? list.get(list.size() - 1) : null;
final Path path = new Path(list, last != null ? new BlockPos(last.x, last.y, last.z) : null, true); final Path path = new Path(list, last != null ? new BlockPos(last.x, last.y, last.z) : null, true);
return getTargetNavigator(entity, params, input -> input.moveTo(path, params.speed())); return getTargetNavigator(entity, params, input -> input.moveTo(path, params.speedModifier()));
} }
@Override @Override
public MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final Location dest, public MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final Location dest,
final NavigatorParameters params) { final NavigatorParameters params) {
return getTargetNavigator(entity, params, return getTargetNavigator(entity, params,
input -> input.moveTo(dest.getX(), dest.getY(), dest.getZ(), params.speed())); input -> input.moveTo(dest.getX(), dest.getY(), dest.getZ(), params.speedModifier()));
} }
private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params, private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params,
@ -794,7 +794,7 @@ public class NMSImpl implements NMSBridge {
@Override @Override
public boolean update() { public boolean update() {
if (params.speed() != lastSpeed) { if (params.speedModifier() != lastSpeed) {
Entity handle = getHandle(entity); Entity handle = getHandle(entity);
EntityDimensions size = null; EntityDimensions size = null;
try { try {
@ -816,13 +816,13 @@ public class NMSImpl implements NMSBridge {
// minecraft requires that an entity fit onto both blocks if width >= 1f, but we'd prefer to // minecraft requires that an entity fit onto both blocks if width >= 1f, but we'd prefer to
// make it just fit on 1 so hack around it a bit. // make it just fit on 1 so hack around it a bit.
} }
lastSpeed = params.speed(); lastSpeed = params.speedModifier();
} }
Path path = getPathEntity(navigation); Path path = getPathEntity(navigation);
if (params.debug() && !path.isDone()) { if (params.debug() && !path.isDone()) {
Util.sendBlockChanges(getBlocks(entity, path), Material.DANDELION); Util.sendBlockChanges(getBlocks(entity, path), Material.DANDELION);
} }
navigation.setSpeedModifier(params.speed()); navigation.setSpeedModifier(params.speedModifier());
return navigation.isDone(); return navigation.isDone();
} }
}; };
@ -1818,7 +1818,7 @@ public class NMSImpl implements NMSBridge {
Location location = parameters.entityTargetLocationMapper().apply(target); Location location = parameters.entityTargetLocationMapper().apply(target);
if (location == null) if (location == null)
throw new IllegalStateException("mapper should not return null"); throw new IllegalStateException("mapper should not return null");
navigation.moveTo(location.getX(), location.getY(), location.getZ(), parameters.speed()); navigation.moveTo(location.getX(), location.getY(), location.getZ(), parameters.speedModifier());
} }
@Override @Override

View File

@ -731,14 +731,14 @@ public class NMSImpl implements NMSBridge {
input -> new Node(input.getBlockX(), input.getBlockY(), input.getBlockZ()))); input -> new Node(input.getBlockX(), input.getBlockY(), input.getBlockZ())));
Node last = list.size() > 0 ? list.get(list.size() - 1) : null; Node last = list.size() > 0 ? list.get(list.size() - 1) : null;
final Path path = new Path(list, last != null ? new BlockPos(last.x, last.y, last.z) : null, true); final Path path = new Path(list, last != null ? new BlockPos(last.x, last.y, last.z) : null, true);
return getTargetNavigator(entity, params, input -> input.moveTo(path, params.speed())); return getTargetNavigator(entity, params, input -> input.moveTo(path, params.speedModifier()));
} }
@Override @Override
public MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final Location dest, public MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final Location dest,
final NavigatorParameters params) { final NavigatorParameters params) {
return getTargetNavigator(entity, params, return getTargetNavigator(entity, params,
input -> input.moveTo(dest.getX(), dest.getY(), dest.getZ(), params.speed())); input -> input.moveTo(dest.getX(), dest.getY(), dest.getZ(), params.speedModifier()));
} }
private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params, private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params,
@ -801,7 +801,7 @@ public class NMSImpl implements NMSBridge {
@Override @Override
public boolean update() { public boolean update() {
if (params.speed() != lastSpeed) { if (params.speedModifier() != lastSpeed) {
Entity handle = getHandle(entity); Entity handle = getHandle(entity);
EntityDimensions size = null; EntityDimensions size = null;
try { try {
@ -823,12 +823,12 @@ public class NMSImpl implements NMSBridge {
// minecraft requires that an entity fit onto both blocks if width >= 1f, but we'd prefer to // minecraft requires that an entity fit onto both blocks if width >= 1f, but we'd prefer to
// make it just fit on 1 so hack around it a bit. // make it just fit on 1 so hack around it a bit.
} }
lastSpeed = params.speed(); lastSpeed = params.speedModifier();
} }
if (params.debug() && !navigation.isDone()) { if (params.debug() && !navigation.isDone()) {
Util.sendBlockChanges(getBlocks(entity, getPathEntity(navigation)), Material.DANDELION); Util.sendBlockChanges(getBlocks(entity, getPathEntity(navigation)), Material.DANDELION);
} }
navigation.setSpeedModifier(params.speed()); navigation.setSpeedModifier(params.speedModifier());
return navigation.isDone(); return navigation.isDone();
} }
}; };
@ -1826,7 +1826,7 @@ public class NMSImpl implements NMSBridge {
Location location = parameters.entityTargetLocationMapper().apply(target); Location location = parameters.entityTargetLocationMapper().apply(target);
if (location == null) if (location == null)
throw new IllegalStateException("mapper should not return null"); throw new IllegalStateException("mapper should not return null");
navigation.moveTo(location.getX(), location.getY(), location.getZ(), parameters.speed()); navigation.moveTo(location.getX(), location.getY(), location.getZ(), parameters.speedModifier());
} }
@Override @Override

View File

@ -780,14 +780,14 @@ public class NMSImpl implements NMSBridge {
input -> new Node(input.getBlockX(), input.getBlockY(), input.getBlockZ()))); input -> new Node(input.getBlockX(), input.getBlockY(), input.getBlockZ())));
Node last = list.size() > 0 ? list.get(list.size() - 1) : null; Node last = list.size() > 0 ? list.get(list.size() - 1) : null;
final Path path = new Path(list, last != null ? new BlockPos(last.x, last.y, last.z) : null, true); final Path path = new Path(list, last != null ? new BlockPos(last.x, last.y, last.z) : null, true);
return getTargetNavigator(entity, params, input -> input.moveTo(path, params.speed())); return getTargetNavigator(entity, params, input -> input.moveTo(path, params.speedModifier()));
} }
@Override @Override
public MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final Location dest, public MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final Location dest,
final NavigatorParameters params) { final NavigatorParameters params) {
return getTargetNavigator(entity, params, return getTargetNavigator(entity, params,
input -> input.moveTo(dest.getX(), dest.getY(), dest.getZ(), params.speed())); input -> input.moveTo(dest.getX(), dest.getY(), dest.getZ(), params.speedModifier()));
} }
private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params, private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params,
@ -850,7 +850,7 @@ public class NMSImpl implements NMSBridge {
@Override @Override
public boolean update() { public boolean update() {
if (params.speed() != lastSpeed) { if (params.speedModifier() != lastSpeed) {
Entity handle = getHandle(entity); Entity handle = getHandle(entity);
EntityDimensions size = null; EntityDimensions size = null;
try { try {
@ -875,9 +875,9 @@ public class NMSImpl implements NMSBridge {
if (params.debug() && getPathEntity(navigation) != null) { if (params.debug() && getPathEntity(navigation) != null) {
Util.sendBlockChanges(getBlocks(entity, getPathEntity(navigation)), Material.DANDELION); Util.sendBlockChanges(getBlocks(entity, getPathEntity(navigation)), Material.DANDELION);
} }
lastSpeed = params.speed(); lastSpeed = params.speedModifier();
} }
navigation.setSpeedModifier(params.speed()); navigation.setSpeedModifier(params.speedModifier());
return navigation.isDone(); return navigation.isDone();
} }
}; };
@ -2030,7 +2030,7 @@ public class NMSImpl implements NMSBridge {
Location location = parameters.entityTargetLocationMapper().apply(target); Location location = parameters.entityTargetLocationMapper().apply(target);
if (location == null) if (location == null)
throw new IllegalStateException("mapper should not return null"); throw new IllegalStateException("mapper should not return null");
navigation.moveTo(location.getX(), location.getY(), location.getZ(), parameters.speed()); navigation.moveTo(location.getX(), location.getY(), location.getZ(), parameters.speedModifier());
} }
@Override @Override

View File

@ -809,14 +809,14 @@ public class NMSImpl implements NMSBridge {
input -> new Node(input.getBlockX(), input.getBlockY(), input.getBlockZ()))); input -> new Node(input.getBlockX(), input.getBlockY(), input.getBlockZ())));
Node last = list.size() > 0 ? list.get(list.size() - 1) : null; Node last = list.size() > 0 ? list.get(list.size() - 1) : null;
final Path path = new Path(list, last != null ? new BlockPos(last.x, last.y, last.z) : null, true); final Path path = new Path(list, last != null ? new BlockPos(last.x, last.y, last.z) : null, true);
return getTargetNavigator(entity, params, input -> input.moveTo(path, params.speed())); return getTargetNavigator(entity, params, input -> input.moveTo(path, params.speedModifier()));
} }
@Override @Override
public MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final Location dest, public MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final Location dest,
final NavigatorParameters params) { final NavigatorParameters params) {
return getTargetNavigator(entity, params, return getTargetNavigator(entity, params,
input -> input.moveTo(dest.getX(), dest.getY(), dest.getZ(), params.speed())); input -> input.moveTo(dest.getX(), dest.getY(), dest.getZ(), params.speedModifier()));
} }
private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params, private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params,
@ -879,7 +879,7 @@ public class NMSImpl implements NMSBridge {
@Override @Override
public boolean update() { public boolean update() {
if (params.speed() != lastSpeed) { if (params.speedModifier() != lastSpeed) {
Entity handle = getHandle(entity); Entity handle = getHandle(entity);
EntityDimensions size = null; EntityDimensions size = null;
try { try {
@ -904,9 +904,9 @@ public class NMSImpl implements NMSBridge {
if (params.debug() && getPathEntity(navigation) != null) { if (params.debug() && getPathEntity(navigation) != null) {
Util.sendBlockChanges(getBlocks(entity, getPathEntity(navigation)), Material.DANDELION); Util.sendBlockChanges(getBlocks(entity, getPathEntity(navigation)), Material.DANDELION);
} }
lastSpeed = params.speed(); lastSpeed = params.speedModifier();
} }
navigation.setSpeedModifier(params.speed()); navigation.setSpeedModifier(params.speedModifier());
return navigation.isDone(); return navigation.isDone();
} }
}; };
@ -2070,7 +2070,7 @@ public class NMSImpl implements NMSBridge {
Location location = parameters.entityTargetLocationMapper().apply(target); Location location = parameters.entityTargetLocationMapper().apply(target);
if (location == null) if (location == null)
throw new IllegalStateException("mapper should not return null"); throw new IllegalStateException("mapper should not return null");
navigation.moveTo(location.getX(), location.getY(), location.getZ(), parameters.speed()); navigation.moveTo(location.getX(), location.getY(), location.getZ(), parameters.speedModifier());
} }
@Override @Override

View File

@ -797,14 +797,14 @@ public class NMSImpl implements NMSBridge {
input -> new Node(input.getBlockX(), input.getBlockY(), input.getBlockZ()))); input -> new Node(input.getBlockX(), input.getBlockY(), input.getBlockZ())));
Node last = list.size() > 0 ? list.get(list.size() - 1) : null; Node last = list.size() > 0 ? list.get(list.size() - 1) : null;
final Path path = new Path(list, last != null ? new BlockPos(last.x, last.y, last.z) : null, true); final Path path = new Path(list, last != null ? new BlockPos(last.x, last.y, last.z) : null, true);
return getTargetNavigator(entity, params, input -> input.moveTo(path, params.speed())); return getTargetNavigator(entity, params, input -> input.moveTo(path, params.speedModifier()));
} }
@Override @Override
public MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final Location dest, public MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final Location dest,
final NavigatorParameters params) { final NavigatorParameters params) {
return getTargetNavigator(entity, params, return getTargetNavigator(entity, params,
input -> input.moveTo(dest.getX(), dest.getY(), dest.getZ(), params.speed())); input -> input.moveTo(dest.getX(), dest.getY(), dest.getZ(), params.speedModifier()));
} }
private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params, private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params,
@ -867,7 +867,7 @@ public class NMSImpl implements NMSBridge {
@Override @Override
public boolean update() { public boolean update() {
if (params.speed() != lastSpeed) { if (params.speedModifier() != lastSpeed) {
Entity handle = getHandle(entity); Entity handle = getHandle(entity);
EntityDimensions size = null; EntityDimensions size = null;
try { try {
@ -892,9 +892,9 @@ public class NMSImpl implements NMSBridge {
if (params.debug() && getPathEntity(navigation) != null) { if (params.debug() && getPathEntity(navigation) != null) {
Util.sendBlockChanges(getBlocks(entity, getPathEntity(navigation)), Material.DANDELION); Util.sendBlockChanges(getBlocks(entity, getPathEntity(navigation)), Material.DANDELION);
} }
lastSpeed = params.speed(); lastSpeed = params.speedModifier();
} }
navigation.setSpeedModifier(params.speed()); navigation.setSpeedModifier(params.speedModifier());
return navigation.isDone(); return navigation.isDone();
} }
}; };
@ -2086,7 +2086,7 @@ public class NMSImpl implements NMSBridge {
Location location = parameters.entityTargetLocationMapper().apply(target); Location location = parameters.entityTargetLocationMapper().apply(target);
if (location == null) if (location == null)
throw new IllegalStateException("mapper should not return null"); throw new IllegalStateException("mapper should not return null");
navigation.moveTo(location.getX(), location.getY(), location.getZ(), parameters.speed()); navigation.moveTo(location.getX(), location.getY(), location.getZ(), parameters.speedModifier());
} }
@Override @Override

View File

@ -551,14 +551,14 @@ public class NMSImpl implements NMSBridge {
Iterables.transform(dest, Iterables.transform(dest,
input -> new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ())), input -> new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ())),
PathPoint.class)); PathPoint.class));
return getTargetNavigator(entity, params, input -> input.a(path, params.speed())); return getTargetNavigator(entity, params, input -> input.a(path, params.speedModifier()));
} }
@Override @Override
public MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final Location dest, public MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final Location dest,
final NavigatorParameters params) { final NavigatorParameters params) {
return getTargetNavigator(entity, params, return getTargetNavigator(entity, params,
input -> input.a(dest.getX(), dest.getY(), dest.getZ(), params.speed())); input -> input.a(dest.getX(), dest.getY(), dest.getZ(), params.speedModifier()));
} }
private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params, private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params,
@ -597,7 +597,7 @@ public class NMSImpl implements NMSBridge {
@Override @Override
public boolean update() { public boolean update() {
if (params.speed() != lastSpeed) { if (params.speedModifier() != lastSpeed) {
Entity handle = getHandle(entity); Entity handle = getHandle(entity);
float oldWidth = handle.width; float oldWidth = handle.width;
if (handle instanceof EntityHorse) { if (handle instanceof EntityHorse) {
@ -608,9 +608,9 @@ public class NMSImpl implements NMSBridge {
} }
handle.width = oldWidth; // minecraft requires that an entity fit onto both blocks if width >= 1f, handle.width = oldWidth; // minecraft requires that an entity fit onto both blocks if width >= 1f,
// but we'd prefer to make it just fit on 1 so hack around it a bit. // but we'd prefer to make it just fit on 1 so hack around it a bit.
lastSpeed = params.speed(); lastSpeed = params.speedModifier();
} }
navigation.a(params.speed()); navigation.a(params.speedModifier());
return NMSImpl.isNavigationFinished(navigation); return NMSImpl.isNavigationFinished(navigation);
} }
}; };
@ -1473,7 +1473,7 @@ public class NMSImpl implements NMSBridge {
Location location = parameters.entityTargetLocationMapper().apply(target); Location location = parameters.entityTargetLocationMapper().apply(target);
if (location == null) if (location == null)
throw new IllegalStateException("mapper should not return null"); throw new IllegalStateException("mapper should not return null");
navigation.a(location.getX(), location.getY(), location.getZ(), parameters.speed()); navigation.a(location.getX(), location.getY(), location.getZ(), parameters.speedModifier());
} }
@Override @Override