mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-16 12:21:25 +01:00
Implement new AI API for Minecraft 1.15.2, fix Squids
This commit is contained in:
parent
725adb009f
commit
0531fe859e
@ -87,6 +87,7 @@ public class Messages {
|
||||
public static final String ERROR_GETTING_METHOD = "citizens.nms-errors.getting-method";
|
||||
public static final String ERROR_INITALISING_SUB_PLUGIN = "citizens.sub-plugins.error-on-load";
|
||||
public static final String ERROR_LOADING_ECONOMY = "citizens.economy.error-loading";
|
||||
public static final String ERROR_RESTORING_GOALS = "citizens.nms-errors.restoring-goals";
|
||||
public static final String ERROR_SETTING_ENTITY_PERSISTENT = "citizens.nms-errors.error-setting-persistent";
|
||||
public static final String ERROR_SETTING_LOOKCLOSE_RANGE = "citizens.commands.npc.lookclose.error-random-range";
|
||||
public static final String ERROR_SETTING_SKIN_URL = "citizens.commands.npc.skin.error-setting-url";
|
||||
|
@ -335,6 +335,7 @@ citizens.editors.waypoints.triggers.teleport.prompt=Enter the destination in the
|
||||
citizens.limits.over-npc-limit=Over the NPC limit of {0}.
|
||||
citizens.load-task-error=NPC load task couldn''t be scheduled, disabling...
|
||||
citizens.nms-errors.clearing-goals=Could not clear goals: {0}.
|
||||
citizens.nms-errors.restoring-goals=Could not restore goals: {0}.
|
||||
citizens.nms-errors.error-setting-persistent=Could not set NPC as persistent: {0}. NPC entity may despawn.
|
||||
citizens.nms-errors.getting-field=Could not fetch NMS field {0}: [[{1}.
|
||||
citizens.nms-errors.getting-method=Could not fetch NMS method {0}: [[{1}.
|
||||
|
@ -172,6 +172,14 @@ public class SquidController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void n() {
|
||||
super.n();
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float f, float f1) {
|
||||
if (npc == null) {
|
||||
|
@ -172,6 +172,14 @@ public class SquidController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void n() {
|
||||
super.n();
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float f, float f1) {
|
||||
if (npc == null) {
|
||||
|
@ -41,8 +41,8 @@ public class VexController extends MobEntityController {
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
setNoGravity(true);
|
||||
}
|
||||
setNoGravity(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -175,6 +175,14 @@ public class SquidController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void n() {
|
||||
super.n();
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float f, float f1) {
|
||||
if (npc == null) {
|
||||
|
@ -42,8 +42,8 @@ public class VexController extends MobEntityController {
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
setNoGravity(true);
|
||||
}
|
||||
setNoGravity(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -64,8 +64,10 @@ public class EvokerController extends MobEntityController {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect cs() {
|
||||
return NMSImpl.getSoundEffect(npc, super.cs(), NPC.DEATH_SOUND_METADATA);
|
||||
public void c(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.c(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -78,6 +80,11 @@ public class EvokerController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect cs() {
|
||||
return NMSImpl.getSoundEffect(npc, super.cs(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect d(DamageSource damagesource) {
|
||||
return NMSImpl.getSoundEffect(npc, super.d(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
@ -89,10 +96,8 @@ public class EvokerController extends MobEntityController {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void c(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.c(f, f1);
|
||||
}
|
||||
protected SoundEffect D() {
|
||||
return NMSImpl.getSoundEffect(npc, super.D(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -130,11 +135,6 @@ public class EvokerController extends MobEntityController {
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect D() {
|
||||
return NMSImpl.getSoundEffect(npc, super.D(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(bukkitEntity instanceof NPCHolder)) {
|
||||
@ -148,6 +148,13 @@ public class EvokerController extends MobEntityController {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void I() {
|
||||
if (npc == null) {
|
||||
super.I();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
@ -161,13 +168,6 @@ public class EvokerController extends MobEntityController {
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void I() {
|
||||
if (npc == null) {
|
||||
super.I();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
|
@ -64,8 +64,10 @@ public class SquidController extends MobEntityController {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect cs() {
|
||||
return NMSImpl.getSoundEffect(npc, super.cs(), NPC.DEATH_SOUND_METADATA);
|
||||
public void c(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.c(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -77,6 +79,11 @@ public class SquidController extends MobEntityController {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect cs() {
|
||||
return NMSImpl.getSoundEffect(npc, super.cs(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect d(DamageSource damagesource) {
|
||||
return NMSImpl.getSoundEffect(npc, super.d(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
@ -88,10 +95,8 @@ public class SquidController extends MobEntityController {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void c(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.c(f, f1);
|
||||
}
|
||||
protected SoundEffect D() {
|
||||
return NMSImpl.getSoundEffect(npc, super.D(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -129,11 +134,6 @@ public class SquidController extends MobEntityController {
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect D() {
|
||||
return NMSImpl.getSoundEffect(npc, super.D(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(bukkitEntity instanceof NPCHolder))
|
||||
@ -146,6 +146,13 @@ public class SquidController extends MobEntityController {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void I() {
|
||||
if (npc == null) {
|
||||
super.I();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
@ -160,18 +167,10 @@ public class SquidController extends MobEntityController {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void I() {
|
||||
if (npc == null) {
|
||||
super.I();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean z_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.z_();
|
||||
} else {
|
||||
return false;
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,6 +182,15 @@ public class SquidController extends MobEntityController {
|
||||
NMSImpl.setSize(this, f, f1, justCreated);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean z_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.z_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class SquidNPC extends CraftSquid implements NPCHolder {
|
||||
|
@ -42,13 +42,8 @@ public class VexController extends MobEntityController {
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
setNoGravity(true);
|
||||
}
|
||||
setNoGravity(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect cs() {
|
||||
return NMSImpl.getSoundEffect(npc, super.cs(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -61,6 +56,11 @@ public class VexController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect cs() {
|
||||
return NMSImpl.getSoundEffect(npc, super.cs(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect d(DamageSource damagesource) {
|
||||
return NMSImpl.getSoundEffect(npc, super.d(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
@ -71,6 +71,11 @@ public class VexController extends MobEntityController {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect D() {
|
||||
return NMSImpl.getSoundEffect(npc, super.D(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null) {
|
||||
@ -106,11 +111,6 @@ public class VexController extends MobEntityController {
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect D() {
|
||||
return NMSImpl.getSoundEffect(npc, super.D(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(bukkitEntity instanceof NPCHolder))
|
||||
@ -123,6 +123,13 @@ public class VexController extends MobEntityController {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void I() {
|
||||
if (npc == null) {
|
||||
super.I();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null) {
|
||||
@ -137,13 +144,6 @@ public class VexController extends MobEntityController {
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void I() {
|
||||
if (npc == null) {
|
||||
super.I();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
|
@ -48,11 +48,8 @@ public class HorseZombieController extends MobEntityController {
|
||||
|
||||
public static class EntityHorseZombieNPC extends EntityHorseZombie implements NPCHolder {
|
||||
private double baseMovementSpeed;
|
||||
|
||||
boolean calledNMSHeight = false;
|
||||
|
||||
private final CitizensNPC npc;
|
||||
|
||||
private boolean riding;
|
||||
|
||||
public EntityHorseZombieNPC(EntityTypes<? extends EntityHorseZombie> types, World world) {
|
||||
|
@ -1,7 +1,5 @@
|
||||
package net.citizensnpcs.nms.v1_14_R1.entity;
|
||||
|
||||
import net.minecraft.server.v1_14_R1.Vec3D;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity;
|
||||
@ -23,6 +21,7 @@ import net.minecraft.server.v1_14_R1.EntityTypes;
|
||||
import net.minecraft.server.v1_14_R1.IBlockData;
|
||||
import net.minecraft.server.v1_14_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_14_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_14_R1.Vec3D;
|
||||
import net.minecraft.server.v1_14_R1.World;
|
||||
|
||||
public class SquidController extends MobEntityController {
|
||||
@ -57,15 +56,6 @@ public class SquidController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(Vec3D vec3d) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(vec3d);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, vec3d);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -94,6 +84,15 @@ public class SquidController extends MobEntityController {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(Vec3D vec3d) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(vec3d);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, vec3d);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null) {
|
||||
@ -157,6 +156,15 @@ public class SquidController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.isClimbing();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
@ -170,6 +178,14 @@ public class SquidController extends MobEntityController {
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSize() {
|
||||
if (npc == null) {
|
||||
@ -178,15 +194,6 @@ public class SquidController extends MobEntityController {
|
||||
NMSImpl.setSize(this, justCreated);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.isClimbing();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class SquidNPC extends CraftSquid implements NPCHolder {
|
||||
|
@ -212,8 +212,8 @@ public class TraderLlamaController extends MobEntityController {
|
||||
super.mobTick();
|
||||
} else {
|
||||
try {
|
||||
if (bJ != null) {
|
||||
bJ.invoke(this, 10); // DespawnDelay
|
||||
if (bI != null) {
|
||||
bI.invoke(this, 10); // DespawnDelay
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
@ -222,7 +222,7 @@ public class TraderLlamaController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
private static final MethodHandle bJ = NMS.getSetter(EntityLlamaTrader.class, "bJ");
|
||||
private static final MethodHandle bI = NMS.getSetter(EntityLlamaTrader.class, "bI");
|
||||
}
|
||||
|
||||
public static class TraderLlamaNPC extends CraftTraderLlama implements NPCHolder {
|
||||
|
@ -1,7 +1,5 @@
|
||||
package net.citizensnpcs.nms.v1_14_R1.entity;
|
||||
|
||||
import net.minecraft.server.v1_14_R1.Vec3D;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity;
|
||||
@ -45,8 +43,8 @@ public class VexController extends MobEntityController {
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
setNoGravity(true);
|
||||
}
|
||||
setNoGravity(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,7 +56,7 @@ public class BatController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
setFlying(false);
|
||||
}
|
||||
}
|
||||
@ -165,7 +165,10 @@ public class BatController extends MobEntityController {
|
||||
if (npc == null) {
|
||||
super.mobTick();
|
||||
} else {
|
||||
NMSImpl.updateAI(this);
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
if (!npc.useMinecraftAI()) {
|
||||
NMSImpl.updateAI(this);
|
||||
}
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class BeeController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,6 +164,10 @@ public class BeeController extends MobEntityController {
|
||||
if (npc == null) {
|
||||
super.mobTick();
|
||||
} else {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
if (!npc.useMinecraftAI()) {
|
||||
NMSImpl.updateAI(this);
|
||||
}
|
||||
NMSImpl.updateAI(this);
|
||||
npc.update();
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package net.citizensnpcs.nms.v1_15_R1.entity;
|
||||
|
||||
import net.minecraft.server.v1_15_R1.Vec3D;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftBlaze;
|
||||
@ -58,7 +56,7 @@ public class BlazeController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,29 +95,6 @@ public class BlazeController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) {
|
||||
super.h(x, y, z);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -148,6 +123,29 @@ public class BlazeController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) {
|
||||
super.h(x, y, z);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isLeashed() {
|
||||
if (npc == null)
|
||||
@ -164,6 +162,7 @@ public class BlazeController extends MobEntityController {
|
||||
@Override
|
||||
public void mobTick() {
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -61,8 +61,7 @@ public class CatController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,28 +134,6 @@ public class CatController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -185,6 +162,28 @@ public class CatController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -211,6 +210,7 @@ public class CatController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public class CaveSpiderController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,28 +122,6 @@ public class CaveSpiderController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -172,6 +150,28 @@ public class CaveSpiderController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -200,6 +200,7 @@ public class CaveSpiderController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,6 @@ public class ChickenController extends MobEntityController {
|
||||
|
||||
public static class EntityChickenNPC extends EntityChicken implements NPCHolder {
|
||||
boolean calledNMSHeight = false;
|
||||
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityChickenNPC(EntityTypes<? extends EntityChicken> types, World world) {
|
||||
@ -62,7 +61,7 @@ public class ChickenController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,28 +135,6 @@ public class ChickenController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -186,6 +163,28 @@ public class ChickenController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -212,6 +211,7 @@ public class ChickenController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_15_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.nms.v1_15_R1.util.PlayerControllerMove;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
@ -51,6 +52,7 @@ public class CodController extends MobEntityController {
|
||||
|
||||
public static class EntityCodNPC extends EntityCod implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
private ControllerMove oldMoveController;
|
||||
|
||||
public EntityCodNPC(EntityTypes<? extends EntityCod> types, World world) {
|
||||
this(types, world, null);
|
||||
@ -60,7 +62,8 @@ public class CodController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
this.oldMoveController = this.moveController;
|
||||
this.moveController = new ControllerMove(this);
|
||||
}
|
||||
}
|
||||
@ -123,28 +126,6 @@ public class CodController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -173,6 +154,28 @@ public class CodController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -198,7 +201,16 @@ public class CodController extends MobEntityController {
|
||||
@Override
|
||||
public void mobTick() {
|
||||
if (npc != null) {
|
||||
NMSImpl.setNotInSchool(this);
|
||||
if (!npc.useMinecraftAI()) {
|
||||
NMSImpl.setNotInSchool(this);
|
||||
}
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
if (npc.useMinecraftAI() && this.moveController != this.oldMoveController) {
|
||||
this.moveController = this.oldMoveController;
|
||||
}
|
||||
if (!npc.useMinecraftAI() && this.moveController == this.oldMoveController) {
|
||||
this.moveController = new PlayerControllerMove(this);
|
||||
}
|
||||
}
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
|
@ -61,7 +61,7 @@ public class CowController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,28 +134,6 @@ public class CowController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -184,6 +162,28 @@ public class CowController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -210,6 +210,7 @@ public class CowController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class CreeperController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,29 +123,6 @@ public class CreeperController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) {
|
||||
super.h(x, y, z);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -174,6 +151,29 @@ public class CreeperController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) {
|
||||
super.h(x, y, z);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -200,6 +200,7 @@ public class CreeperController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_15_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.nms.v1_15_R1.util.PlayerControllerMove;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
@ -53,6 +54,7 @@ public class DolphinController extends MobEntityController {
|
||||
|
||||
public static class EntityDolphinNPC extends EntityDolphin implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
private ControllerMove oldMoveController;
|
||||
|
||||
public EntityDolphinNPC(EntityTypes<? extends EntityDolphin> types, World world) {
|
||||
this(types, world, null);
|
||||
@ -62,7 +64,8 @@ public class DolphinController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
this.oldMoveController = this.moveController;
|
||||
this.moveController = new ControllerMove(this);
|
||||
}
|
||||
}
|
||||
@ -135,28 +138,6 @@ public class DolphinController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -185,6 +166,28 @@ public class DolphinController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -216,6 +219,13 @@ public class DolphinController extends MobEntityController {
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
if (npc.useMinecraftAI() && this.moveController != this.oldMoveController) {
|
||||
this.moveController = this.oldMoveController;
|
||||
}
|
||||
if (!npc.useMinecraftAI() && this.moveController == this.oldMoveController) {
|
||||
this.moveController = new PlayerControllerMove(this);
|
||||
}
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public class DrownedController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,28 +121,6 @@ public class DrownedController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -171,6 +149,28 @@ public class DrownedController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -197,6 +197,7 @@ public class DrownedController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class EnderDragonController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,28 +95,6 @@ public class EnderDragonController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -154,6 +132,28 @@ public class EnderDragonController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isLeashed() {
|
||||
if (npc == null)
|
||||
@ -171,6 +171,9 @@ public class EnderDragonController extends MobEntityController {
|
||||
public void movementTick() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
}
|
||||
if (npc != null && !npc.useMinecraftAI()) {
|
||||
Vec3D mot = getMot();
|
||||
if (mot.getX() != 0 || mot.getY() != 0 || mot.getZ() != 0) {
|
||||
mot = mot.d(0.98, 0.98, 0.98);
|
||||
|
@ -59,7 +59,7 @@ public class EndermanController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,28 +129,6 @@ public class EndermanController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -179,6 +157,28 @@ public class EndermanController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -205,6 +205,7 @@ public class EndermanController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public class EndermiteController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,28 +121,6 @@ public class EndermiteController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -171,6 +149,28 @@ public class EndermiteController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -197,7 +197,8 @@ public class EndermiteController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,7 +45,7 @@ public class EvokerController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,28 +108,6 @@ public class EvokerController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -158,6 +136,28 @@ public class EvokerController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -184,6 +184,7 @@ public class EvokerController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -47,8 +47,7 @@ public class FoxController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,28 +120,6 @@ public class FoxController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -171,6 +148,28 @@ public class FoxController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -197,6 +196,7 @@ public class FoxController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package net.citizensnpcs.nms.v1_15_R1.entity;
|
||||
|
||||
import net.minecraft.server.v1_15_R1.Vec3D;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
|
||||
@ -44,7 +42,7 @@ public class GhastController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,28 +81,6 @@ public class GhastController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -133,6 +109,28 @@ public class GhastController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isLeashed() {
|
||||
if (npc == null)
|
||||
@ -155,6 +153,10 @@ public class GhastController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
if (!npc.useMinecraftAI()) {
|
||||
NMSImpl.updateAI(this);
|
||||
}
|
||||
}
|
||||
super.mobTick();
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class GiantController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,28 +107,6 @@ public class GiantController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -157,6 +135,28 @@ public class GiantController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -183,6 +183,7 @@ public class GiantController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class GuardianController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,28 +108,6 @@ public class GuardianController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -158,6 +136,28 @@ public class GuardianController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -185,7 +185,12 @@ public class GuardianController extends MobEntityController {
|
||||
if (npc == null) {
|
||||
super.movementTick();
|
||||
} else {
|
||||
NMSImpl.updateAI(this);
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
if (!npc.useMinecraftAI()) {
|
||||
NMSImpl.updateAI(this);
|
||||
} else {
|
||||
super.movementTick();
|
||||
}
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class GuardianElderController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,28 +108,6 @@ public class GuardianElderController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -158,6 +136,28 @@ public class GuardianElderController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -185,7 +185,12 @@ public class GuardianElderController extends MobEntityController {
|
||||
if (npc == null) {
|
||||
super.movementTick();
|
||||
} else {
|
||||
NMSImpl.updateAI(this);
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
if (!npc.useMinecraftAI()) {
|
||||
NMSImpl.updateAI(this);
|
||||
} else {
|
||||
super.movementTick();
|
||||
}
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public class HorseController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
Horse horse = (Horse) getBukkitEntity();
|
||||
horse.setDomestication(horse.getMaxDomestication());
|
||||
baseMovementSpeed = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue() * 0.8;
|
||||
@ -220,6 +220,7 @@ public class HorseController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||
|
@ -62,7 +62,7 @@ public class HorseDonkeyController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
((Donkey) getBukkitEntity()).setDomestication(((Donkey) getBukkitEntity()).getMaxDomestication());
|
||||
baseMovementSpeed = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue();
|
||||
}
|
||||
@ -94,6 +94,13 @@ public class HorseDonkeyController extends MobEntityController {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkDespawn() {
|
||||
if (npc == null) {
|
||||
super.checkDespawn();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cj() {
|
||||
if (npc != null && riding) {
|
||||
@ -102,13 +109,6 @@ public class HorseDonkeyController extends MobEntityController {
|
||||
return super.cj();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkDespawn() {
|
||||
if (npc == null) {
|
||||
super.checkDespawn();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_15_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
@ -146,28 +146,6 @@ public class HorseDonkeyController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -196,6 +174,28 @@ public class HorseDonkeyController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -222,6 +222,7 @@ public class HorseDonkeyController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||
|
@ -60,7 +60,7 @@ public class HorseMuleController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
((Mule) getBukkitEntity()).setDomestication(((Mule) getBukkitEntity()).getMaxDomestication());
|
||||
baseMovementSpeed = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue();
|
||||
}
|
||||
@ -92,6 +92,13 @@ public class HorseMuleController extends MobEntityController {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkDespawn() {
|
||||
if (npc == null) {
|
||||
super.checkDespawn();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cj() {
|
||||
if (npc != null && riding) {
|
||||
@ -100,13 +107,6 @@ public class HorseMuleController extends MobEntityController {
|
||||
return super.cj();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkDespawn() {
|
||||
if (npc == null) {
|
||||
super.checkDespawn();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_15_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
@ -144,28 +144,6 @@ public class HorseMuleController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -194,6 +172,28 @@ public class HorseMuleController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -220,6 +220,7 @@ public class HorseMuleController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||
|
@ -63,7 +63,7 @@ public class HorseSkeletonController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
((SkeletonHorse) getBukkitEntity())
|
||||
.setDomestication(((SkeletonHorse) getBukkitEntity()).getMaxDomestication());
|
||||
baseMovementSpeed = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue();
|
||||
@ -96,6 +96,13 @@ public class HorseSkeletonController extends MobEntityController {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkDespawn() {
|
||||
if (npc == null) {
|
||||
super.checkDespawn();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cj() {
|
||||
if (npc != null && riding) {
|
||||
@ -104,13 +111,6 @@ public class HorseSkeletonController extends MobEntityController {
|
||||
return super.cj();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkDespawn() {
|
||||
if (npc == null) {
|
||||
super.checkDespawn();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_15_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
@ -148,28 +148,6 @@ public class HorseSkeletonController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -198,6 +176,28 @@ public class HorseSkeletonController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -224,6 +224,7 @@ public class HorseSkeletonController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||
|
@ -60,7 +60,7 @@ public class HorseZombieController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
((ZombieHorse) getBukkitEntity())
|
||||
.setDomestication(((ZombieHorse) getBukkitEntity()).getMaxDomestication());
|
||||
baseMovementSpeed = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue();
|
||||
@ -221,6 +221,7 @@ public class HorseZombieController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||
|
@ -45,7 +45,7 @@ public class IllusionerController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,28 +108,6 @@ public class IllusionerController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -158,6 +136,28 @@ public class IllusionerController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -184,6 +184,7 @@ public class IllusionerController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class IronGolemController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,28 +107,6 @@ public class IronGolemController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -157,6 +135,28 @@ public class IronGolemController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -183,6 +183,7 @@ public class IronGolemController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,6 @@ public class LlamaController extends MobEntityController {
|
||||
|
||||
public static class EntityLlamaNPC extends EntityLlama implements NPCHolder {
|
||||
boolean calledNMSHeight = false;
|
||||
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityLlamaNPC(EntityTypes<? extends EntityLlama> types, World world) {
|
||||
@ -57,7 +56,7 @@ public class LlamaController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
((Llama) getBukkitEntity()).setDomestication(((Llama) getBukkitEntity()).getMaxDomestication());
|
||||
}
|
||||
}
|
||||
@ -132,28 +131,6 @@ public class LlamaController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -182,6 +159,28 @@ public class LlamaController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -209,6 +208,10 @@ public class LlamaController extends MobEntityController {
|
||||
if (npc == null) {
|
||||
super.mobTick();
|
||||
} else {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
if (npc.useMinecraftAI()) {
|
||||
super.mobTick();
|
||||
}
|
||||
NMS.setStepHeight(getBukkitEntity(), 1);
|
||||
npc.update();
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_15_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_15_R1.ControllerMove;
|
||||
import net.minecraft.server.v1_15_R1.DamageSource;
|
||||
import net.minecraft.server.v1_15_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_15_R1.EntityMagmaCube;
|
||||
@ -38,6 +39,7 @@ public class MagmaCubeController extends MobEntityController {
|
||||
|
||||
public static class EntityMagmaCubeNPC extends EntityMagmaCube implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
private ControllerMove oldMoveController;
|
||||
|
||||
public EntityMagmaCubeNPC(EntityTypes<? extends EntityMagmaCube> types, World world) {
|
||||
this(types, world, null);
|
||||
@ -48,7 +50,8 @@ public class MagmaCubeController extends MobEntityController {
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
setSize(3, true);
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
this.oldMoveController = this.moveController;
|
||||
this.moveController = new PlayerControllerMove(this);
|
||||
}
|
||||
}
|
||||
@ -111,28 +114,6 @@ public class MagmaCubeController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -161,6 +142,28 @@ public class MagmaCubeController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -194,6 +197,13 @@ public class MagmaCubeController extends MobEntityController {
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
if (npc.useMinecraftAI() && this.moveController != this.oldMoveController) {
|
||||
this.moveController = this.oldMoveController;
|
||||
}
|
||||
if (!npc.useMinecraftAI() && this.moveController == this.oldMoveController) {
|
||||
this.moveController = new PlayerControllerMove(this);
|
||||
}
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class MushroomCowController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,28 +122,6 @@ public class MushroomCowController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -172,6 +150,28 @@ public class MushroomCowController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -197,8 +197,10 @@ public class MushroomCowController extends MobEntityController {
|
||||
@Override
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null)
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class OcelotController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,28 +121,6 @@ public class OcelotController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -171,6 +149,28 @@ public class OcelotController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -197,6 +197,7 @@ public class OcelotController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -47,8 +47,7 @@ public class PandaController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -197,6 +196,7 @@ public class PandaController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class ParrotController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,28 +92,6 @@ public class ParrotController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -142,6 +120,28 @@ public class ParrotController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isLeashed() {
|
||||
if (npc == null) {
|
||||
@ -161,7 +161,12 @@ public class ParrotController extends MobEntityController {
|
||||
if (npc == null) {
|
||||
super.mobTick();
|
||||
} else {
|
||||
NMSImpl.updateAI(this);
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
if (!npc.useMinecraftAI()) {
|
||||
NMSImpl.updateAI(this);
|
||||
} else {
|
||||
super.mobTick();
|
||||
}
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_15_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.nms.v1_15_R1.util.PlayerControllerMove;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
@ -39,6 +40,8 @@ public class PhantomController extends MobEntityController {
|
||||
|
||||
public static class EntityPhantomNPC extends EntityPhantom implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
private ControllerLook oldLookController;
|
||||
private ControllerMove oldMoveController;
|
||||
|
||||
public EntityPhantomNPC(EntityTypes<? extends EntityPhantom> types, World world) {
|
||||
this(types, world, null);
|
||||
@ -48,8 +51,10 @@ public class PhantomController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
setNoAI(true);
|
||||
this.oldMoveController = this.moveController;
|
||||
this.oldLookController = this.lookController;
|
||||
this.moveController = new ControllerMove(this);
|
||||
this.lookController = new ControllerLook(this);
|
||||
// TODO: phantom pitch reversed
|
||||
@ -121,28 +126,6 @@ public class PhantomController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -171,6 +154,28 @@ public class PhantomController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -197,6 +202,17 @@ public class PhantomController extends MobEntityController {
|
||||
public void movementTick() {
|
||||
super.movementTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
if (npc.useMinecraftAI() && this.moveController != this.oldMoveController) {
|
||||
this.moveController = this.oldMoveController;
|
||||
this.lookController = this.oldLookController;
|
||||
setNoAI(false);
|
||||
}
|
||||
if (!npc.useMinecraftAI() && this.moveController == this.oldMoveController) {
|
||||
this.moveController = new PlayerControllerMove(this);
|
||||
this.lookController = new ControllerLook(this);
|
||||
setNoAI(true);
|
||||
}
|
||||
if (npc.isProtected()) {
|
||||
this.setOnFire(0);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class PigController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,28 +128,6 @@ public class PigController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -178,6 +156,28 @@ public class PigController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -204,6 +204,7 @@ public class PigController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class PigZombieController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,29 +108,6 @@ public class PigZombieController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) {
|
||||
super.h(x, y, z);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -159,6 +136,29 @@ public class PigZombieController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) {
|
||||
super.h(x, y, z);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -185,6 +185,7 @@ public class PigZombieController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -47,8 +47,7 @@ public class PillagerController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,28 +120,6 @@ public class PillagerController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -171,6 +148,28 @@ public class PillagerController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -197,6 +196,7 @@ public class PillagerController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class PolarBearController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,28 +95,6 @@ public class PolarBearController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -145,6 +123,28 @@ public class PolarBearController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isLeashed() {
|
||||
if (npc == null) {
|
||||
@ -163,6 +163,7 @@ public class PolarBearController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_15_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.nms.v1_15_R1.util.PlayerControllerMove;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
@ -37,6 +38,7 @@ public class PufferFishController extends MobEntityController {
|
||||
|
||||
public static class EntityPufferFishNPC extends EntityPufferFish implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
private ControllerMove oldMoveController;
|
||||
|
||||
public EntityPufferFishNPC(EntityTypes<? extends EntityPufferFish> types, World world) {
|
||||
this(types, world, null);
|
||||
@ -46,7 +48,8 @@ public class PufferFishController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
this.oldMoveController = this.moveController;
|
||||
this.moveController = new ControllerMove(this);
|
||||
}
|
||||
}
|
||||
@ -109,28 +112,6 @@ public class PufferFishController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -159,6 +140,28 @@ public class PufferFishController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -185,6 +188,13 @@ public class PufferFishController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
if (npc.useMinecraftAI() && this.moveController != this.oldMoveController) {
|
||||
this.moveController = this.oldMoveController;
|
||||
}
|
||||
if (!npc.useMinecraftAI() && this.moveController == this.oldMoveController) {
|
||||
this.moveController = new PlayerControllerMove(this);
|
||||
}
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class RabbitController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,28 +124,6 @@ public class RabbitController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -179,6 +157,28 @@ public class RabbitController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -203,14 +203,13 @@ public class RabbitController extends MobEntityController {
|
||||
|
||||
@Override
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
super.mobTick();
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
if (npc.getNavigator().isNavigating()) {
|
||||
NMS.setShouldJump(getBukkitEntity());
|
||||
}
|
||||
npc.update();
|
||||
} else {
|
||||
super.mobTick();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,8 +47,7 @@ public class RavagerController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,28 +120,6 @@ public class RavagerController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -171,6 +148,28 @@ public class RavagerController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -197,6 +196,7 @@ public class RavagerController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_15_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.nms.v1_15_R1.util.PlayerControllerMove;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
@ -37,6 +38,7 @@ public class SalmonController extends MobEntityController {
|
||||
|
||||
public static class EntitySalmonNPC extends EntitySalmon implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
private ControllerMove oldMoveController;
|
||||
|
||||
public EntitySalmonNPC(EntityTypes<? extends EntitySalmon> types, World world) {
|
||||
this(types, world, null);
|
||||
@ -46,7 +48,8 @@ public class SalmonController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
this.oldMoveController = this.moveController;
|
||||
this.moveController = new ControllerMove(this);
|
||||
}
|
||||
}
|
||||
@ -109,28 +112,6 @@ public class SalmonController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -159,6 +140,28 @@ public class SalmonController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -185,6 +188,13 @@ public class SalmonController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
if (npc != null) {
|
||||
NMSImpl.setNotInSchool(this);
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
if (npc.useMinecraftAI() && this.moveController != this.oldMoveController) {
|
||||
this.moveController = this.oldMoveController;
|
||||
}
|
||||
if (!npc.useMinecraftAI() && this.moveController == this.oldMoveController) {
|
||||
this.moveController = new PlayerControllerMove(this);
|
||||
}
|
||||
}
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
|
@ -48,7 +48,7 @@ public class SheepController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,28 +121,6 @@ public class SheepController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -171,6 +149,28 @@ public class SheepController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -196,8 +196,10 @@ public class SheepController extends MobEntityController {
|
||||
@Override
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null)
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class ShulkerController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,28 +108,6 @@ public class ShulkerController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -158,6 +136,28 @@ public class ShulkerController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -182,7 +182,7 @@ public class ShulkerController extends MobEntityController {
|
||||
|
||||
@Override
|
||||
public void movementTick() {
|
||||
if (npc == null) {
|
||||
if (npc == null || npc.useMinecraftAI()) {
|
||||
super.movementTick();
|
||||
}
|
||||
}
|
||||
@ -195,6 +195,10 @@ public class ShulkerController extends MobEntityController {
|
||||
@Override
|
||||
public void tick() {
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
if (npc.useMinecraftAI()) {
|
||||
super.tick();
|
||||
}
|
||||
npc.update();
|
||||
} else {
|
||||
super.tick();
|
||||
|
@ -45,7 +45,7 @@ public class SilverfishController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,28 +105,6 @@ public class SilverfishController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -155,6 +133,28 @@ public class SilverfishController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -180,8 +180,10 @@ public class SilverfishController extends MobEntityController {
|
||||
@Override
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null)
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,7 +45,7 @@ public class SkeletonController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,28 +107,6 @@ public class SkeletonController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -157,6 +135,28 @@ public class SkeletonController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -183,6 +183,7 @@ public class SkeletonController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class SkeletonStrayController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,28 +107,6 @@ public class SkeletonStrayController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -157,6 +135,28 @@ public class SkeletonStrayController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -183,6 +183,7 @@ public class SkeletonStrayController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class SkeletonWitherController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,28 +107,6 @@ public class SkeletonWitherController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -157,6 +135,28 @@ public class SkeletonWitherController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -183,6 +183,7 @@ public class SkeletonWitherController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_15_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_15_R1.ControllerMove;
|
||||
import net.minecraft.server.v1_15_R1.DamageSource;
|
||||
import net.minecraft.server.v1_15_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_15_R1.EntitySlime;
|
||||
@ -38,6 +39,7 @@ public class SlimeController extends MobEntityController {
|
||||
|
||||
public static class EntitySlimeNPC extends EntitySlime implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
private ControllerMove oldMoveController;
|
||||
|
||||
public EntitySlimeNPC(EntityTypes<? extends EntitySlime> types, World world) {
|
||||
this(types, world, null);
|
||||
@ -48,7 +50,8 @@ public class SlimeController extends MobEntityController {
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
setSize(3, true);
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
this.oldMoveController = this.moveController;
|
||||
this.moveController = new PlayerControllerMove(this);
|
||||
}
|
||||
}
|
||||
@ -112,28 +115,6 @@ public class SlimeController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -162,6 +143,28 @@ public class SlimeController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -195,6 +198,13 @@ public class SlimeController extends MobEntityController {
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
if (npc.useMinecraftAI() && this.moveController != this.oldMoveController) {
|
||||
this.moveController = this.oldMoveController;
|
||||
}
|
||||
if (!npc.useMinecraftAI() && this.moveController == this.oldMoveController) {
|
||||
this.moveController = new PlayerControllerMove(this);
|
||||
}
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class SnowmanController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,28 +108,6 @@ public class SnowmanController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -158,6 +136,28 @@ public class SnowmanController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -184,6 +184,7 @@ public class SnowmanController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class SpiderController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,28 +107,6 @@ public class SpiderController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -157,6 +135,28 @@ public class SpiderController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -182,8 +182,10 @@ public class SpiderController extends MobEntityController {
|
||||
@Override
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null)
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,7 +45,7 @@ public class SquidController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,28 +107,6 @@ public class SquidController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -157,6 +135,28 @@ public class SquidController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -179,6 +179,15 @@ public class SquidController extends MobEntityController {
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSize() {
|
||||
if (npc == null) {
|
||||
|
@ -48,7 +48,6 @@ public class TraderLlamaController extends MobEntityController {
|
||||
|
||||
public static class EntityTraderLlamaNPC extends EntityLlamaTrader implements NPCHolder {
|
||||
boolean calledNMSHeight = false;
|
||||
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityTraderLlamaNPC(EntityTypes<? extends EntityLlamaTrader> types, World world) {
|
||||
@ -59,7 +58,7 @@ public class TraderLlamaController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
((TraderLlama) getBukkitEntity())
|
||||
.setDomestication(((TraderLlama) getBukkitEntity()).getMaxDomestication());
|
||||
}
|
||||
@ -135,28 +134,6 @@ public class TraderLlamaController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -185,6 +162,28 @@ public class TraderLlamaController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -212,9 +211,13 @@ public class TraderLlamaController extends MobEntityController {
|
||||
if (npc == null) {
|
||||
super.mobTick();
|
||||
} else {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
if (npc.useMinecraftAI()) {
|
||||
super.mobTick();
|
||||
}
|
||||
try {
|
||||
if (bJ != null) {
|
||||
bJ.invoke(this, 10); // DespawnDelay
|
||||
if (bF != null) {
|
||||
bF.invoke(this, 10); // DespawnDelay
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
@ -223,7 +226,7 @@ public class TraderLlamaController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
private static final MethodHandle bJ = NMS.getSetter(EntityLlamaTrader.class, "bJ");
|
||||
private static final MethodHandle bF = NMS.getSetter(EntityLlamaTrader.class, "bF");
|
||||
}
|
||||
|
||||
public static class TraderLlamaNPC extends CraftTraderLlama implements NPCHolder {
|
||||
|
@ -11,6 +11,7 @@ import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_15_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.nms.v1_15_R1.util.PlayerControllerMove;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
@ -37,6 +38,7 @@ public class TropicalFishController extends MobEntityController {
|
||||
|
||||
public static class EntityTropicalFishNPC extends EntityTropicalFish implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
private ControllerMove oldMoveController;
|
||||
|
||||
public EntityTropicalFishNPC(EntityTypes<? extends EntityTropicalFish> types, World world) {
|
||||
this(types, world, null);
|
||||
@ -46,7 +48,8 @@ public class TropicalFishController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
this.oldMoveController = this.moveController;
|
||||
this.moveController = new ControllerMove(this);
|
||||
}
|
||||
}
|
||||
@ -109,28 +112,6 @@ public class TropicalFishController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -159,6 +140,28 @@ public class TropicalFishController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -184,7 +187,16 @@ public class TropicalFishController extends MobEntityController {
|
||||
@Override
|
||||
public void mobTick() {
|
||||
if (npc != null) {
|
||||
NMSImpl.setNotInSchool(this);
|
||||
if (!npc.useMinecraftAI()) {
|
||||
NMSImpl.setNotInSchool(this);
|
||||
}
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
if (npc.useMinecraftAI() && this.moveController != this.oldMoveController) {
|
||||
this.moveController = this.oldMoveController;
|
||||
}
|
||||
if (!npc.useMinecraftAI() && this.moveController == this.oldMoveController) {
|
||||
this.moveController = new PlayerControllerMove(this);
|
||||
}
|
||||
}
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
|
@ -11,6 +11,7 @@ import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_15_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.nms.v1_15_R1.util.PlayerControllerMove;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
@ -41,6 +42,8 @@ public class TurtleController extends MobEntityController {
|
||||
|
||||
public static class EntityTurtleNPC extends EntityTurtle implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
private ControllerJump oldJumpController;
|
||||
private ControllerMove oldMoveController;
|
||||
|
||||
public EntityTurtleNPC(EntityTypes<? extends EntityTurtle> types, World world) {
|
||||
this(types, world, null);
|
||||
@ -50,7 +53,9 @@ public class TurtleController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
this.oldMoveController = this.moveController;
|
||||
this.oldJumpController = this.bq;
|
||||
this.moveController = new ControllerMove(this);
|
||||
this.bq = new EmptyControllerJump(this);
|
||||
}
|
||||
@ -198,6 +203,15 @@ public class TurtleController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
if (npc.useMinecraftAI() && this.moveController != this.oldMoveController) {
|
||||
this.moveController = this.oldMoveController;
|
||||
this.bq = this.oldJumpController;
|
||||
}
|
||||
if (!npc.useMinecraftAI() && this.moveController == this.oldMoveController) {
|
||||
this.moveController = new PlayerControllerMove(this);
|
||||
this.bq = new EmptyControllerJump(this);
|
||||
}
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package net.citizensnpcs.nms.v1_15_R1.entity;
|
||||
|
||||
import net.minecraft.server.v1_15_R1.Vec3D;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
|
||||
@ -44,9 +42,9 @@ public class VexController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
setNoGravity(true);
|
||||
}
|
||||
setNoGravity(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -84,28 +82,6 @@ public class VexController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -134,6 +110,28 @@ public class VexController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isLeashed() {
|
||||
if (npc == null) {
|
||||
@ -152,6 +150,7 @@ public class VexController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class VillagerController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.3);
|
||||
}
|
||||
}
|
||||
@ -241,7 +241,7 @@ public class VillagerController extends MobEntityController {
|
||||
}
|
||||
if (this.behaviorMap.size() > 0) {
|
||||
this.behaviorMap.clear();
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
super.mobTick();
|
||||
|
@ -48,7 +48,7 @@ public class VindicatorController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,28 +122,6 @@ public class VindicatorController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -172,6 +150,28 @@ public class VindicatorController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -198,6 +198,7 @@ public class VindicatorController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class WanderingTraderController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -237,6 +237,7 @@ public class WanderingTraderController extends MobEntityController {
|
||||
if (this.behaviorMap.size() > 0) {
|
||||
this.behaviorMap.clear();
|
||||
}
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
}
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
|
@ -45,7 +45,7 @@ public class WitchController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,28 +107,6 @@ public class WitchController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -157,6 +135,28 @@ public class WitchController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -182,8 +182,10 @@ public class WitchController extends MobEntityController {
|
||||
@Override
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null)
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,7 +1,5 @@
|
||||
package net.citizensnpcs.nms.v1_15_R1.entity;
|
||||
|
||||
import net.minecraft.server.v1_15_R1.Vec3D;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
|
||||
@ -44,7 +42,7 @@ public class WitherController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,28 +80,6 @@ public class WitherController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -132,6 +108,28 @@ public class WitherController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isLeashed() {
|
||||
if (npc == null)
|
||||
@ -155,6 +153,10 @@ public class WitherController extends MobEntityController {
|
||||
if (npc == null) {
|
||||
super.mobTick();
|
||||
} else {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
if (npc.useMinecraftAI()) {
|
||||
super.mobTick();
|
||||
}
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class WolfController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,28 +124,6 @@ public class WolfController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -174,6 +152,28 @@ public class WolfController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -200,6 +200,7 @@ public class WolfController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class ZombieController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,28 +107,6 @@ public class ZombieController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -157,6 +135,28 @@ public class ZombieController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -183,6 +183,7 @@ public class ZombieController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class ZombieHuskController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,28 +107,6 @@ public class ZombieHuskController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -157,6 +135,28 @@ public class ZombieHuskController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -183,6 +183,7 @@ public class ZombieHuskController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class ZombieVillagerController extends MobEntityController {
|
||||
super(types, world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,28 +107,6 @@ public class ZombieVillagerController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 CraftEntity getBukkitEntity() {
|
||||
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
|
||||
@ -157,6 +135,28 @@ public class ZombieVillagerController extends MobEntityController {
|
||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.h(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.h(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 boolean isClimbing() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
@ -183,6 +183,7 @@ public class ZombieVillagerController extends MobEntityController {
|
||||
public void mobTick() {
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -1356,12 +1356,15 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearGoals(PathfinderGoalSelector... goalSelectors) {
|
||||
public static void clearGoals(NPC npc, PathfinderGoalSelector... goalSelectors) {
|
||||
if (GOAL_SET_FIELD == null || goalSelectors == null)
|
||||
return;
|
||||
for (PathfinderGoalSelector selector : goalSelectors) {
|
||||
try {
|
||||
Collection<?> list = (Collection<?>) GOAL_SET_FIELD.invoke(selector);
|
||||
if (!list.isEmpty()) {
|
||||
npc.data().set("goal-selector-" + selector.hashCode(), Lists.newArrayList(list));
|
||||
}
|
||||
list.clear();
|
||||
} catch (Exception e) {
|
||||
Messaging.logTr(Messages.ERROR_CLEARING_GOALS, e.getLocalizedMessage());
|
||||
@ -1636,6 +1639,25 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
}
|
||||
|
||||
public static void restoreGoals(NPC npc, PathfinderGoalSelector... goalSelectors) {
|
||||
if (GOAL_SET_FIELD == null || goalSelectors == null)
|
||||
return;
|
||||
for (PathfinderGoalSelector selector : goalSelectors) {
|
||||
try {
|
||||
Collection<Object> list = (Collection<Object>) GOAL_SET_FIELD.invoke(selector);
|
||||
list.clear();
|
||||
Collection<Object> old = npc.data().get("goal-selector-" + selector.hashCode());
|
||||
if (old != null) {
|
||||
list.addAll(old);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Messaging.logTr(Messages.ERROR_RESTORING_GOALS, e.getLocalizedMessage());
|
||||
} catch (Throwable e) {
|
||||
Messaging.logTr(Messages.ERROR_RESTORING_GOALS, e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendPacket(Player player, Packet<?> packet) {
|
||||
if (packet == null)
|
||||
return;
|
||||
@ -1741,6 +1763,16 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateMinecraftAIState(NPC npc, EntityInsentient entity) {
|
||||
if (npc == null)
|
||||
return;
|
||||
if (npc.useMinecraftAI()) {
|
||||
NMSImpl.restoreGoals(npc, entity.goalSelector, entity.targetSelector);
|
||||
} else {
|
||||
NMSImpl.clearGoals(npc, entity.goalSelector, entity.targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateNavigation(NavigationAbstract navigation) {
|
||||
navigation.c();
|
||||
}
|
||||
@ -1787,6 +1819,7 @@ public class NMSImpl implements NMSBridge {
|
||||
private static final MethodHandle SIZE_FIELD_GETTER = NMS.getGetter(Entity.class, "size");
|
||||
private static final MethodHandle SIZE_FIELD_SETTER = NMS.getSetter(Entity.class, "size");
|
||||
private static Field SKULL_PROFILE_FIELD;
|
||||
|
||||
private static MethodHandle TEAM_FIELD;
|
||||
|
||||
static {
|
||||
|
@ -166,6 +166,14 @@ public class SquidController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
super.m();
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float f, float f1) {
|
||||
if (npc == null) {
|
||||
|
Loading…
Reference in New Issue
Block a user