Skip to content

Commit

Permalink
Implement new AI API for Minecraft 1.15.2, fix Squids
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Apr 20, 2020
1 parent 725adb0 commit 0531fe8
Show file tree
Hide file tree
Showing 81 changed files with 1,735 additions and 1,470 deletions.
1 change: 1 addition & 0 deletions main/src/main/java/net/citizensnpcs/util/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions main/src/main/resources/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ public boolean m_() {
}
}

@Override
public void n() {
super.n();
if (npc != null) {
npc.update();
}
}

@Override
public void setSize(float f, float f1) {
if (npc == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ public boolean m_() {
}
}

@Override
public void n() {
super.n();
if (npc != null) {
npc.update();
}
}

@Override
public void setSize(float f, float f1) {
if (npc == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public EntityVexNPC(World world, NPC npc) {
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(goalSelector, targetSelector);
setNoGravity(true);
}
setNoGravity(true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ public boolean m_() {
}
}

@Override
public void n() {
super.n();
if (npc != null) {
npc.update();
}
}

@Override
public void setSize(float f, float f1) {
if (npc == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public EntityVexNPC(World world, NPC npc) {
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(goalSelector, targetSelector);
setNoGravity(true);
}
setNoGravity(true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ public void a(float f, float f1, float f2) {
}

@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
Expand All @@ -78,6 +80,11 @@ public void collide(net.minecraft.server.v1_13_R2.Entity entity) {
}
}

@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);
Expand All @@ -89,10 +96,8 @@ public boolean d(NBTTagCompound save) {
}

@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
Expand Down Expand Up @@ -130,11 +135,6 @@ public void f(double x, double y, double z) {
// 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)) {
Expand All @@ -148,6 +148,13 @@ public NPC getNPC() {
return npc;
}

@Override
protected void I() {
if (npc == null) {
super.I();
}
}

@Override
public boolean isLeashed() {
if (npc == null)
Expand All @@ -161,13 +168,6 @@ public boolean isLeashed() {
return false; // shouldLeash
}

@Override
protected void I() {
if (npc == null) {
super.I();
}
}

@Override
public void mobTick() {
super.mobTick();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ public void a(float f, float f1, float f2) {
}

@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
Expand All @@ -77,6 +79,11 @@ public void collide(net.minecraft.server.v1_13_R2.Entity entity) {
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);
Expand All @@ -88,10 +95,8 @@ public boolean d(NBTTagCompound save) {
}

@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
Expand Down Expand Up @@ -129,11 +134,6 @@ public void f(double x, double y, double z) {
// 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))
Expand All @@ -146,6 +146,13 @@ public NPC getNPC() {
return npc;
}

@Override
protected void I() {
if (npc == null) {
super.I();
}
}

@Override
public boolean isLeashed() {
if (npc == null)
Expand All @@ -160,27 +167,28 @@ public boolean isLeashed() {
}

@Override
protected void I() {
if (npc == null) {
super.I();
public void mobTick() {
super.mobTick();
if (npc != null) {
npc.update();
}
}

@Override
public boolean z_() {
if (npc == null || !npc.isFlyable()) {
return super.z_();
public void setSize(float f, float f1) {
if (npc == null) {
super.setSize(f, f1);
} else {
return false;
NMSImpl.setSize(this, f, f1, justCreated);
}
}

@Override
public void setSize(float f, float f1) {
if (npc == null) {
super.setSize(f, f1);
public boolean z_() {
if (npc == null || !npc.isFlyable()) {
return super.z_();
} else {
NMSImpl.setSize(this, f, f1, justCreated);
return false;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,8 @@ public EntityVexNPC(World world, NPC npc) {
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
Expand All @@ -61,6 +56,11 @@ public void collide(net.minecraft.server.v1_13_R2.Entity entity) {
}
}

@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);
Expand All @@ -71,6 +71,11 @@ public boolean d(NBTTagCompound save) {
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) {
Expand Down Expand Up @@ -106,11 +111,6 @@ public void f(double x, double y, double z) {
// 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))
Expand All @@ -123,6 +123,13 @@ public NPC getNPC() {
return npc;
}

@Override
protected void I() {
if (npc == null) {
super.I();
}
}

@Override
public boolean isLeashed() {
if (npc == null) {
Expand All @@ -137,13 +144,6 @@ public boolean isLeashed() {
return false; // shouldLeash
}

@Override
protected void I() {
if (npc == null) {
super.I();
}
}

@Override
public void mobTick() {
super.mobTick();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,8 @@ public void spawn(Location at, NPC npc) {

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) {
Expand Down
Loading

0 comments on commit 0531fe8

Please sign in to comment.