fix: backport of #3172 (#3180)

* fix: partial backport of #3172

MC ver <= 1.16.5 is not considered as they are no longer supported officially. Fork devs pls do your own backport.

* fix: different way to get level in different MC version

* fix: finished missing backport for all other MC versions we support
This commit is contained in:
ZX夏夜之风 2024-11-08 23:53:33 +08:00 committed by GitHub
parent 7cc2b0658d
commit 080bf9ce3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
24 changed files with 240 additions and 0 deletions

View File

@ -279,6 +279,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
}
updateAI();
cs();
NMSImpl.callNPCMoveEvent(this);
if (npc.useMinecraftAI()) {
foodData.a(this);
}

View File

@ -18,6 +18,7 @@ import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import net.citizensnpcs.api.event.NPCMoveEvent;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -1589,6 +1590,24 @@ public class NMSImpl implements NMSBridge {
}
}
public static <T extends Entity & NPCHolder> void callNPCMoveEvent(T what) {
final NPC npc = what.getNPC();
if (npc != null && NPCMoveEvent.getHandlerList().getRegisteredListeners().length > 0) {
if (what.lastX != what.locX || what.lastY != what.locY || what.lastZ != what.locZ || what.lastYaw != what.yaw || what.lastPitch != what.pitch) {
Location from = new Location(what.world.getWorld(), what.lastX, what.lastY, what.lastZ, what.lastYaw, what.lastPitch);
Location to = new Location (what.world.getWorld(), what.locX, what.locY, what.locZ, what.yaw, what.pitch);
final NPCMoveEvent event = new NPCMoveEvent(npc, from, to.clone());
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
final Location eventFrom = event.getFrom();
what.setLocation(eventFrom.getX(), eventFrom.getY(), eventFrom.getZ(), eventFrom.getYaw(), eventFrom.getPitch());
} else if (!to.equals(event.getTo())) {
what.setLocation(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch());
}
}
}
}
public static void checkAndUpdateHeight(EntityLiving living, boolean flag, Consumer<Boolean> cb) {
float oldw = living.width;
float oldl = living.length;

View File

@ -343,6 +343,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
}
updateAI();
ct();
NMSImpl.callNPCMoveEvent(this);
if (npc.useMinecraftAI()) {
foodData.a(this);
}

View File

@ -18,6 +18,7 @@ import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import net.citizensnpcs.api.event.NPCMoveEvent;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -1648,6 +1649,24 @@ public class NMSImpl implements NMSBridge {
}
}
public static <T extends Entity & NPCHolder> void callNPCMoveEvent(T what) {
final NPC npc = what.getNPC();
if (npc != null && NPCMoveEvent.getHandlerList().getRegisteredListeners().length > 0) {
if (what.lastX != what.locX || what.lastY != what.locY || what.lastZ != what.locZ || what.lastYaw != what.yaw || what.lastPitch != what.pitch) {
Location from = new Location(what.world.getWorld(), what.lastX, what.lastY, what.lastZ, what.lastYaw, what.lastPitch);
Location to = new Location (what.world.getWorld(), what.locX, what.locY, what.locZ, what.yaw, what.pitch);
final NPCMoveEvent event = new NPCMoveEvent(npc, from, to.clone());
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
final Location eventFrom = event.getFrom();
what.setLocation(eventFrom.getX(), eventFrom.getY(), eventFrom.getZ(), eventFrom.getYaw(), eventFrom.getPitch());
} else if (!to.equals(event.getTo())) {
what.setLocation(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch());
}
}
}
}
public static void checkAndUpdateHeight(EntityLiving living, boolean flag, Consumer<Boolean> cb) {
float oldw = living.width;
float oldl = living.length;

View File

@ -352,6 +352,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
}
updateAI();
cB();
NMSImpl.callNPCMoveEvent(this);
if (npc.useMinecraftAI()) {
foodData.a(this);
}

View File

@ -19,6 +19,7 @@ import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import net.citizensnpcs.api.event.NPCMoveEvent;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -1656,6 +1657,24 @@ public class NMSImpl implements NMSBridge {
}
}
public static <T extends Entity & NPCHolder> void callNPCMoveEvent(T what) {
final NPC npc = what.getNPC();
if (npc != null && NPCMoveEvent.getHandlerList().getRegisteredListeners().length > 0) {
if (what.lastX != what.locX || what.lastY != what.locY || what.lastZ != what.locZ || what.lastYaw != what.yaw || what.lastPitch != what.pitch) {
Location from = new Location(what.world.getWorld(), what.lastX, what.lastY, what.lastZ, what.lastYaw, what.lastPitch);
Location to = new Location (what.world.getWorld(), what.locX, what.locY, what.locZ, what.yaw, what.pitch);
final NPCMoveEvent event = new NPCMoveEvent(npc, from, to.clone());
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
final Location eventFrom = event.getFrom();
what.setLocation(eventFrom.getX(), eventFrom.getY(), eventFrom.getZ(), eventFrom.getYaw(), eventFrom.getPitch());
} else if (!to.equals(event.getTo())) {
what.setLocation(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch());
}
}
}
}
public static void checkAndUpdateHeight(EntityLiving living, boolean flag, Consumer<Boolean> cb) {
float oldw = living.width;
float oldl = living.length;

View File

@ -334,6 +334,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
}
updateAI();
cN();
NMSImpl.callNPCMoveEvent(this);
if (npc.useMinecraftAI()) {
foodData.a(this);
}

View File

@ -18,6 +18,7 @@ import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import net.citizensnpcs.api.event.NPCMoveEvent;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -1704,6 +1705,24 @@ public class NMSImpl implements NMSBridge {
}
}
public static <T extends Entity & NPCHolder> void callNPCMoveEvent(T what) {
final NPC npc = what.getNPC();
if (npc != null && NPCMoveEvent.getHandlerList().getRegisteredListeners().length > 0) {
if (what.lastX != what.locX || what.lastY != what.locY || what.lastZ != what.locZ || what.lastYaw != what.yaw || what.lastPitch != what.pitch) {
Location from = new Location(what.world.getWorld(), what.lastX, what.lastY, what.lastZ, what.lastYaw, what.lastPitch);
Location to = new Location (what.world.getWorld(), what.locX, what.locY, what.locZ, what.yaw, what.pitch);
final NPCMoveEvent event = new NPCMoveEvent(npc, from, to.clone());
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
final Location eventFrom = event.getFrom();
what.setLocation(eventFrom.getX(), eventFrom.getY(), eventFrom.getZ(), eventFrom.getYaw(), eventFrom.getPitch());
} else if (!to.equals(event.getTo())) {
what.setLocation(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch());
}
}
}
}
public static void checkAndUpdateHeight(EntityLiving living, boolean flag, Consumer<Boolean> cb) {
float oldw = living.width;
float oldl = living.length;

View File

@ -345,6 +345,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
}
updateAI();
collideNearby();
NMSImpl.callNPCMoveEvent(this);
if (npc.useMinecraftAI()) {
foodData.a(this);
}

View File

@ -17,6 +17,7 @@ import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import net.citizensnpcs.api.event.NPCMoveEvent;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -1801,6 +1802,24 @@ public class NMSImpl implements NMSBridge {
}
}
public static <T extends Entity & NPCHolder> void callNPCMoveEvent(T what) {
final NPC npc = what.getNPC();
if (npc != null && NPCMoveEvent.getHandlerList().getRegisteredListeners().length > 0) {
if (what.lastX != what.locX || what.lastY != what.locY || what.lastZ != what.locZ || what.lastYaw != what.yaw || what.lastPitch != what.pitch) {
Location from = new Location(what.world.getWorld(), what.lastX, what.lastY, what.lastZ, what.lastYaw, what.lastPitch);
Location to = new Location (what.world.getWorld(), what.locX, what.locY, what.locZ, what.yaw, what.pitch);
final NPCMoveEvent event = new NPCMoveEvent(npc, from, to.clone());
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
final Location eventFrom = event.getFrom();
what.setLocation(eventFrom.getX(), eventFrom.getY(), eventFrom.getZ(), eventFrom.getYaw(), eventFrom.getPitch());
} else if (!to.equals(event.getTo())) {
what.setLocation(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch());
}
}
}
}
public static void checkAndUpdateHeight(EntityLiving living, DataWatcherObject<?> datawatcherobject,
Consumer<DataWatcherObject<?>> cb) {
EntitySize size;

View File

@ -344,6 +344,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
}
updateAI();
collideNearby();
NMSImpl.callNPCMoveEvent(this);
}
public void setMoveDestination(double x, double y, double z, double speed) {

View File

@ -17,6 +17,7 @@ import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import net.citizensnpcs.api.event.NPCMoveEvent;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -1850,6 +1851,24 @@ public class NMSImpl implements NMSBridge {
}
}
public static <T extends Entity & NPCHolder> void callNPCMoveEvent(T what) {
final NPC npc = what.getNPC();
if (npc != null && NPCMoveEvent.getHandlerList().getRegisteredListeners().length > 0) {
if (what.lastX != what.locX() || what.lastY != what.locY() || what.lastZ != what.locZ() || what.lastYaw != what.yaw || what.lastPitch != what.pitch) {
Location from = new Location(what.world.getWorld(), what.lastX, what.lastY, what.lastZ, what.lastYaw, what.lastPitch);
Location to = new Location (what.world.getWorld(), what.locX(), what.locY(), what.locZ(), what.yaw, what.pitch);
final NPCMoveEvent event = new NPCMoveEvent(npc, from, to.clone());
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
final Location eventFrom = event.getFrom();
what.setLocation(eventFrom.getX(), eventFrom.getY(), eventFrom.getZ(), eventFrom.getYaw(), eventFrom.getPitch());
} else if (!to.equals(event.getTo())) {
what.setLocation(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch());
}
}
}
}
public static void checkAndUpdateHeight(EntityLiving living, DataWatcherObject<?> datawatcherobject,
Consumer<DataWatcherObject<?>> cb) {
EntitySize size;

View File

@ -318,6 +318,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
ai.getMoveControl().a();
ai.getJumpControl().b();
collideNearby();
NMSImpl.callNPCMoveEvent(this);
}
@Override

View File

@ -17,6 +17,7 @@ import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import net.citizensnpcs.api.event.NPCMoveEvent;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -1870,6 +1871,24 @@ public class NMSImpl implements NMSBridge {
}
}
public static <T extends Entity & NPCHolder> void callNPCMoveEvent(T what) {
final NPC npc = what.getNPC();
if (npc != null && NPCMoveEvent.getHandlerList().getRegisteredListeners().length > 0) {
if (what.lastX != what.locX() || what.lastY != what.locY() || what.lastZ != what.locZ() || what.lastYaw != what.yaw || what.lastPitch != what.pitch) {
Location from = new Location(what.world.getWorld(), what.lastX, what.lastY, what.lastZ, what.lastYaw, what.lastPitch);
Location to = new Location (what.world.getWorld(), what.locX(), what.locY(), what.locZ(), what.yaw, what.pitch);
final NPCMoveEvent event = new NPCMoveEvent(npc, from, to.clone());
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
final Location eventFrom = event.getFrom();
what.setLocation(eventFrom.getX(), eventFrom.getY(), eventFrom.getZ(), eventFrom.getYaw(), eventFrom.getPitch());
} else if (!to.equals(event.getTo())) {
what.setLocation(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch());
}
}
}
}
public static void checkAndUpdateHeight(EntityLiving living, DataWatcherObject<?> datawatcherobject,
Consumer<DataWatcherObject<?>> cb) {
EntitySize size;

View File

@ -143,6 +143,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
this.onGround = false;
}
pushEntities();
NMSImpl.callNPCMoveEvent(this);
if (npc.useMinecraftAI()) {
foodData.tick(this);
}

View File

@ -16,6 +16,7 @@ import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import net.citizensnpcs.api.event.NPCMoveEvent;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -2036,6 +2037,24 @@ public class NMSImpl implements NMSBridge {
entity.calculateEntityAnimation(entity, entity instanceof net.minecraft.world.entity.animal.FlyingAnimal);
}
public static <T extends Entity & NPCHolder> void callNPCMoveEvent(T what) {
final NPC npc = what.getNPC();
if (npc != null && NPCMoveEvent.getHandlerList().getRegisteredListeners().length > 0) {
if (what.xo != what.getX() || what.yo != what.getY() || what.zo != what.getZ() || what.yRotO != what.getYRot() || what.xRotO != what.getXRot()) {
Location from = new Location(what.level.getWorld(), what.xo, what.yo, what.zo, what.yRotO, what.xRotO);
Location to = new Location(what.level.getWorld(), what.getX(), what.getY(), what.getZ(), what.getYRot(), what.getXRot());
final NPCMoveEvent event = new NPCMoveEvent(npc, from, to.clone());
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
final Location eventFrom = event.getFrom();
what.absMoveTo(eventFrom.getX(), eventFrom.getY(), eventFrom.getZ(), eventFrom.getYaw(), eventFrom.getPitch());
} else if (!to.equals(event.getTo())) {
what.absMoveTo(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch());
}
}
}
}
public static TreeMap<?, ?> getBehaviorMap(LivingEntity entity) {
try {
return (TreeMap<?, ?>) BEHAVIOR_MAP.invoke(entity.getBrain());

View File

@ -144,6 +144,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
this.onGround = false;
}
pushEntities();
NMSImpl.callNPCMoveEvent(this);
if (npc.useMinecraftAI()) {
foodData.tick(this);
}

View File

@ -15,6 +15,7 @@ import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import net.citizensnpcs.api.event.NPCMoveEvent;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -2044,6 +2045,24 @@ public class NMSImpl implements NMSBridge {
entity.calculateEntityAnimation(entity, entity instanceof net.minecraft.world.entity.animal.FlyingAnimal);
}
public static <T extends Entity & NPCHolder> void callNPCMoveEvent(T what) {
final NPC npc = what.getNPC();
if (npc != null && NPCMoveEvent.getHandlerList().getRegisteredListeners().length > 0) {
if (what.xo != what.getX() || what.yo != what.getY() || what.zo != what.getZ() || what.yRotO != what.getYRot() || what.xRotO != what.getXRot()) {
Location from = new Location(what.level.getWorld(), what.xo, what.yo, what.zo, what.yRotO, what.xRotO);
Location to = new Location(what.level.getWorld(), what.getX(), what.getY(), what.getZ(), what.getYRot(), what.getXRot());
final NPCMoveEvent event = new NPCMoveEvent(npc, from, to.clone());
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
final Location eventFrom = event.getFrom();
what.absMoveTo(eventFrom.getX(), eventFrom.getY(), eventFrom.getZ(), eventFrom.getYaw(), eventFrom.getPitch());
} else if (!to.equals(event.getTo())) {
what.absMoveTo(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch());
}
}
}
}
public static TreeMap<?, ?> getBehaviorMap(LivingEntity entity) {
try {
return (TreeMap<?, ?>) BEHAVIOR_TREE_MAP.invoke(entity.getBrain());

View File

@ -147,6 +147,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
this.onGround = false;
}
pushEntities();
NMSImpl.callNPCMoveEvent(this);
if (npc.useMinecraftAI()) {
foodData.tick(this);
}

View File

@ -20,6 +20,7 @@ import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import net.citizensnpcs.api.event.NPCMoveEvent;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -2244,6 +2245,24 @@ public class NMSImpl implements NMSBridge {
entity.calculateEntityAnimation(entity instanceof net.minecraft.world.entity.animal.FlyingAnimal);
}
public static <T extends Entity & NPCHolder> void callNPCMoveEvent(T what) {
final NPC npc = what.getNPC();
if (npc != null && NPCMoveEvent.getHandlerList().getRegisteredListeners().length > 0) {
if (what.xo != what.getX() || what.yo != what.getY() || what.zo != what.getZ() || what.yRotO != what.getYRot() || what.xRotO != what.getXRot()) {
Location from = new Location(what.level.getWorld(), what.xo, what.yo, what.zo, what.yRotO, what.xRotO);
Location to = new Location(what.level.getWorld(), what.getX(), what.getY(), what.getZ(), what.getYRot(), what.getXRot());
final NPCMoveEvent event = new NPCMoveEvent(npc, from, to.clone());
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
final Location eventFrom = event.getFrom();
what.absMoveTo(eventFrom.getX(), eventFrom.getY(), eventFrom.getZ(), eventFrom.getYaw(), eventFrom.getPitch());
} else if (!to.equals(event.getTo())) {
what.absMoveTo(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch());
}
}
}
}
public static TreeMap<?, ?> getBehaviorMap(LivingEntity entity) {
try {
return (TreeMap<?, ?>) BEHAVIOR_TREE_MAP.invoke(entity.getBrain());

View File

@ -150,6 +150,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
onGround = false;
}
pushEntities();
NMSImpl.callNPCMoveEvent(this);
if (npc.useMinecraftAI()) {
foodData.tick(this);
}

View File

@ -18,6 +18,7 @@ import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import net.citizensnpcs.api.event.NPCMoveEvent;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -2320,6 +2321,24 @@ public class NMSImpl implements NMSBridge {
entity.calculateEntityAnimation(entity instanceof net.minecraft.world.entity.animal.FlyingAnimal);
}
public static <T extends Entity & NPCHolder> void callNPCMoveEvent(T what) {
final NPC npc = what.getNPC();
if (npc != null && NPCMoveEvent.getHandlerList().getRegisteredListeners().length > 0) {
if (what.xo != what.getX() || what.yo != what.getY() || what.zo != what.getZ() || what.yRotO != what.getYRot() || what.xRotO != what.getXRot()) {
Location from = new Location(what.level().getWorld(), what.xo, what.yo, what.zo, what.yRotO, what.xRotO);
Location to = new Location(what.level().getWorld(), what.getX(), what.getY(), what.getZ(), what.getYRot(), what.getXRot());
final NPCMoveEvent event = new NPCMoveEvent(npc, from, to.clone());
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
final Location eventFrom = event.getFrom();
what.absMoveTo(eventFrom.getX(), eventFrom.getY(), eventFrom.getZ(), eventFrom.getYaw(), eventFrom.getPitch());
} else if (!to.equals(event.getTo())) {
what.absMoveTo(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch());
}
}
}
}
public static TreeMap<?, ?> getBehaviorMap(LivingEntity entity) {
try {
return (TreeMap<?, ?>) AVAILABLE_BEHAVIORS_BY_PRIORITY.invoke(entity.getBrain());

View File

@ -281,6 +281,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
}
updateAI();
bL();
NMSImpl.callNPCMoveEvent(this);
if (npc.useMinecraftAI()) {
foodData.a(this);
}

View File

@ -19,6 +19,7 @@ import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import net.citizensnpcs.api.event.NPCMoveEvent;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -1520,6 +1521,24 @@ public class NMSImpl implements NMSBridge {
}
}
public static <T extends Entity & NPCHolder> void callNPCMoveEvent(T what) {
final NPC npc = what.getNPC();
if (npc != null && NPCMoveEvent.getHandlerList().getRegisteredListeners().length > 0) {
if (what.lastX != what.locX || what.lastY != what.locY || what.lastZ != what.locZ || what.lastYaw != what.yaw || what.lastPitch != what.pitch) {
Location from = new Location(what.world.getWorld(), what.lastX, what.lastY, what.lastZ, what.lastYaw, what.lastPitch);
Location to = new Location (what.world.getWorld(), what.locX, what.locY, what.locZ, what.yaw, what.pitch);
final NPCMoveEvent event = new NPCMoveEvent(npc, from, to.clone());
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
final Location eventFrom = event.getFrom();
what.setLocation(eventFrom.getX(), eventFrom.getY(), eventFrom.getZ(), eventFrom.getYaw(), eventFrom.getPitch());
} else if (!to.equals(event.getTo())) {
what.setLocation(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch());
}
}
}
}
public static void checkAndUpdateHeight(EntityLiving living, boolean flag, Consumer<Boolean> cb) {
float oldw = living.width;
float oldl = living.length;