Skip to content

Commit

Permalink
Possible fix for baby entities moving over time
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Mar 17, 2014
1 parent 5a0125e commit 531c79a
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/java/net/citizensnpcs/commands/NPCCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public void copy(CommandContext args, CommandSender sender, NPC npc) throws Comm
}

CommandSenderCreateNPCEvent event = sender instanceof Player ? new PlayerCreateNPCEvent((Player) sender, copy)
: new CommandSenderCreateNPCEvent(sender, copy);
: new CommandSenderCreateNPCEvent(sender, copy);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
event.getNPC().destroy();
Expand Down Expand Up @@ -341,7 +341,7 @@ public void create(CommandContext args, CommandSender sender, NPC npc) throws Co
spawnLoc = args.getSenderLocation();
}
CommandSenderCreateNPCEvent event = sender instanceof Player ? new PlayerCreateNPCEvent((Player) sender, npc)
: new CommandSenderCreateNPCEvent(sender, npc);
: new CommandSenderCreateNPCEvent(sender, npc);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
npc.destroy();
Expand Down Expand Up @@ -495,7 +495,7 @@ public void gamemode(CommandContext args, CommandSender sender, NPC npc) {
permission = "citizens.npc.gravity")
public void gravity(CommandContext args, CommandSender sender, NPC npc) {
boolean enabled = npc.getTrait(Gravity.class).toggle();
String key = enabled ? Messages.GRAVITY_ENABLED : Messages.GRAVITY_DISABLED;
String key = !enabled ? Messages.GRAVITY_ENABLED : Messages.GRAVITY_DISABLED;
Messaging.sendTr(sender, key, npc.getName());
}

Expand Down Expand Up @@ -1013,7 +1013,7 @@ public void pose(CommandContext args, CommandSender sender, NPC npc) throws Comm
@Requirements(selected = true, ownership = true, types = { EntityType.CREEPER })
public void power(CommandContext args, CommandSender sender, NPC npc) {
Messaging
.sendTr(sender, npc.getTrait(Powered.class).toggle() ? Messages.POWERED_SET : Messages.POWERED_STOPPED);
.sendTr(sender, npc.getTrait(Powered.class).toggle() ? Messages.POWERED_SET : Messages.POWERED_STOPPED);
}

@Command(
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/net/citizensnpcs/npc/entity/ChickenController.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ public EntityChickenNPC(World world, NPC npc) {
}
}

@Override
public void a(boolean flag) {
float oldw = width;
float oldl = length;
super.a(flag);
if (oldw != width || oldl != length) {
this.setPosition(locX - 0.01, locY, locZ - 0.01);
this.setPosition(locX + 0.01, locY, locZ + 0.01);
}
}

@Override
protected void a(double d0, boolean flag) {
if (npc == null || !npc.isFlyable()) {
Expand Down Expand Up @@ -161,6 +172,15 @@ public boolean h_() {
}
}

@Override
public void move(double x, double y, double z) {
double oldx = this.locX;
double oldz = this.locZ;
super.move(x, y, z);
if (x != 0 || z != 0 || oldx != locX || oldz != locZ)
System.out.println(x + " " + z + " " + (oldx - locX) + " " + (oldz - locZ));
}

@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/net/citizensnpcs/npc/entity/CowController.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ public EntityCowNPC(World world, NPC npc) {
}
}

@Override
public void a(boolean flag) {
float oldw = width;
float oldl = length;
super.a(flag);
if (oldw != width || oldl != length) {
this.setPosition(locX - 0.01, locY, locZ - 0.01);
this.setPosition(locX + 0.01, locY, locZ + 0.01);
}
}

@Override
protected void a(double d0, boolean flag) {
if (npc == null || !npc.isFlyable()) {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/net/citizensnpcs/npc/entity/HorseController.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ public EntityHorseNPC(World world, NPC npc) {
}
}

@Override
public void a(boolean flag) {
float oldw = width;
float oldl = length;
super.a(flag);
if (oldw != width || oldl != length) {
this.setPosition(locX - 0.01, locY, locZ - 0.01);
this.setPosition(locX + 0.01, locY, locZ + 0.01);
}
}

@Override
protected void a(double d0, boolean flag) {
if (npc == null || !npc.isFlyable()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ public EntityMushroomCowNPC(World world, NPC npc) {
}
}

@Override
public void a(boolean flag) {
float oldw = width;
float oldl = length;
super.a(flag);
if (oldw != width || oldl != length) {
this.setPosition(locX - 0.01, locY, locZ - 0.01);
this.setPosition(locX + 0.01, locY, locZ + 0.01);
}
}

@Override
protected void a(double d0, boolean flag) {
if (npc == null || !npc.isFlyable()) {
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/net/citizensnpcs/npc/entity/OcelotController.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,17 @@ public EntityOcelotNPC(World world, NPC npc) {
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMS.clearGoals(goalSelector, targetSelector);
}
}

@Override
public void a(boolean flag) {
float oldw = width;
float oldl = length;
super.a(flag);
if (oldw != width || oldl != length) {
this.setPosition(locX - 0.01, locY, locZ - 0.01);
this.setPosition(locX + 0.01, locY, locZ + 0.01);
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/main/java/net/citizensnpcs/npc/entity/PigController.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ public EntityPigNPC(World world, NPC npc) {
}
}

@Override
public void a(boolean flag) {
float oldw = width;
float oldl = length;
super.a(flag);
if (oldw != width || oldl != length) {
this.setPosition(locX - 0.01, locY, locZ - 0.01);
this.setPosition(locX + 0.01, locY, locZ + 0.01);
}
}

@Override
protected void a(double d0, boolean flag) {
if (npc == null || !npc.isFlyable()) {
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/net/citizensnpcs/npc/entity/SheepController.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,17 @@ public EntitySheepNPC(World world, NPC npc) {
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMS.clearGoals(goalSelector, targetSelector);
}
}

@Override
public void a(boolean flag) {
float oldw = width;
float oldl = length;
super.a(flag);
if (oldw != width || oldl != length) {
this.setPosition(locX - 0.01, locY, locZ - 0.01);
this.setPosition(locX + 0.01, locY, locZ + 0.01);
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/main/java/net/citizensnpcs/npc/entity/VillagerController.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ public EntityVillagerNPC(World world, NPC npc) {
}
}

@Override
public void a(boolean flag) {
float oldw = width;
float oldl = length;
super.a(flag);
if (oldw != width || oldl != length) {
this.setPosition(locX - 0.01, locY, locZ - 0.01);
this.setPosition(locX + 0.01, locY, locZ + 0.01);
}
}

@Override
protected void a(double d0, boolean flag) {
if (npc == null || !npc.isFlyable()) {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/net/citizensnpcs/npc/entity/WolfController.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ public EntityWolfNPC(World world, NPC npc) {
}
}

@Override
public void a(boolean flag) {
float oldw = width;
float oldl = length;
super.a(flag);
if (oldw != width || oldl != length) {
this.setPosition(locX - 0.01, locY, locZ - 0.01);
this.setPosition(locX + 0.01, locY, locZ + 0.01);
}
}

@Override
protected void a(double d0, boolean flag) {
if (npc == null || !npc.isFlyable()) {
Expand Down

0 comments on commit 531c79a

Please sign in to comment.