@Override public void collide(net.minecraft.server.v1_6_R2.Entity entity) { // this method is called by both the entities involved - cancelling // it will not stop the NPC from moving. super.collide(entity); if (npc != null) Util.callCollisionEvent(npc, entity.getBukkitEntity()); }
@Override public void g(double x, double y, double z) { if (npc == null) { super.g(x, y, z); return; } if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) { if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) super.g(x, y, z); return; } Vector vector = new Vector(x, y, z); NPCPushEvent event = Util.callPushEvent(npc, vector); if (!event.isCancelled()) { vector = event.getCollisionVector(); super.g(vector.getX(), vector.getY(), vector.getZ()); } // when another entity collides, this method is called to push the // NPC so we prevent it from doing anything if the event is // cancelled. }
@Override public void c() { if (npc != null) { npc.update(); if (motX != 0 || motY != 0 || motZ != 0) { motX *= 0.98; motY *= 0.98; motZ *= 0.98; yaw = getCorrectYaw(locX + motX, locZ + motZ); setPosition(locX + motX, locY + motY, locZ + motZ); } } else super.c(); }
@Override public void bk() { if (npc == null) { super.bk(); } }