Skip to content

Commit

Permalink
Fix monsters despawning when an NPC of the same type is spawned
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Nov 16, 2014
1 parent 4dfdf2f commit 6236324
Show file tree
Hide file tree
Showing 59 changed files with 552 additions and 173 deletions.
3 changes: 2 additions & 1 deletion src/main/java/net/citizensnpcs/editor/EquipmentEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ public void end() {

@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() == Action.RIGHT_CLICK_AIR && Editor.hasEditor(event.getPlayer()))
if (event.getAction() == Action.RIGHT_CLICK_AIR && Editor.hasEditor(event.getPlayer())) {
event.setUseItemInHand(Result.DENY);
}
}

@EventHandler
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/net/citizensnpcs/npc/entity/BatController.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_7_R4.EntityBat;
import net.minecraft.server.v1_7_R4.NBTTagCompound;
import net.minecraft.server.v1_7_R4.World;

import org.bukkit.Bukkit;
Expand Down Expand Up @@ -65,7 +66,8 @@ protected String aT() {

@Override
protected String aU() {
return npc == null || !npc.data().has(NPC.DEATH_SOUND_METADATA) ? super.aU() : npc.data().get(NPC.DEATH_SOUND_METADATA, super.aU());
return npc == null || !npc.data().has(NPC.DEATH_SOUND_METADATA) ? super.aU() : npc.data().get(
NPC.DEATH_SOUND_METADATA, super.aU());
}

@Override
Expand Down Expand Up @@ -101,6 +103,11 @@ public void collide(net.minecraft.server.v1_7_R4.Entity entity) {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}

@Override
public boolean d(NBTTagCompound save) {
return npc == null ? super.d(save) : false;
}

@Override
public void g(double x, double y, double z) {
if (npc == null) {
Expand Down Expand Up @@ -149,7 +156,8 @@ public void setFlying(boolean flying) {

@Override
protected String t() {
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(
NPC.AMBIENT_SOUND_METADATA, super.t());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_7_R4.EntityBlaze;
import net.minecraft.server.v1_7_R4.NBTTagCompound;
import net.minecraft.server.v1_7_R4.World;

import org.bukkit.Bukkit;
Expand Down Expand Up @@ -99,6 +100,11 @@ public void collide(net.minecraft.server.v1_7_R4.Entity entity) {
}
}

@Override
public boolean d(NBTTagCompound save) {
return npc == null ? super.d(save) : false;
}

@Override
public void g(double x, double y, double z) {
if (npc == null) {
Expand Down Expand Up @@ -135,7 +141,8 @@ public NPC getNPC() {

@Override
protected String t() {
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(
NPC.AMBIENT_SOUND_METADATA, super.t());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_7_R4.EntityCaveSpider;
import net.minecraft.server.v1_7_R4.NBTTagCompound;
import net.minecraft.server.v1_7_R4.World;

import org.bukkit.Bukkit;
Expand Down Expand Up @@ -80,6 +81,14 @@ protected void b(float f) {
}
}

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

@Override
public boolean bN() {
if (npc == null) {
Expand All @@ -95,14 +104,6 @@ public boolean bN() {
return false; // shouldLeash
}

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

@Override
public void bq() {
if (npc == null) {
Expand All @@ -123,6 +124,11 @@ public void collide(net.minecraft.server.v1_7_R4.Entity entity) {
}
}

@Override
public boolean d(NBTTagCompound save) {
return npc == null ? super.d(save) : false;
}

@Override
public void e(float f, float f1) {
if (npc == null || !npc.isFlyable()) {
Expand Down Expand Up @@ -177,7 +183,8 @@ public boolean h_() {

@Override
protected String t() {
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(
NPC.AMBIENT_SOUND_METADATA, super.t());
}

@Override
Expand Down
23 changes: 15 additions & 8 deletions src/main/java/net/citizensnpcs/npc/entity/ChickenController.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_7_R4.EntityChicken;
import net.minecraft.server.v1_7_R4.NBTTagCompound;
import net.minecraft.server.v1_7_R4.World;

import org.bukkit.Bukkit;
Expand Down Expand Up @@ -91,6 +92,13 @@ protected void b(float f) {
}
}

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

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

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

@Override
public void collide(net.minecraft.server.v1_7_R4.Entity entity) {
// this method is called by both the entities involved - cancelling
Expand All @@ -120,6 +121,11 @@ public void collide(net.minecraft.server.v1_7_R4.Entity entity) {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}

@Override
public boolean d(NBTTagCompound save) {
return npc == null ? super.d(save) : false;
}

@Override
public void e(float f, float f1) {
if (npc == null || !npc.isFlyable()) {
Expand Down Expand Up @@ -174,7 +180,8 @@ public boolean h_() {

@Override
protected String t() {
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(
NPC.AMBIENT_SOUND_METADATA, super.t());
}

@Override
Expand Down
25 changes: 16 additions & 9 deletions src/main/java/net/citizensnpcs/npc/entity/CowController.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_7_R4.EntityCow;
import net.minecraft.server.v1_7_R4.NBTTagCompound;
import net.minecraft.server.v1_7_R4.World;

import org.bukkit.Bukkit;
Expand Down Expand Up @@ -92,6 +93,14 @@ protected void b(float f) {
}
}

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

@Override
public boolean bN() {
if (npc == null)
Expand All @@ -105,14 +114,6 @@ public boolean bN() {
return false; // shouldLeash
}

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

@Override
public void collide(net.minecraft.server.v1_7_R4.Entity entity) {
// this method is called by both the entities involved - cancelling
Expand All @@ -123,6 +124,11 @@ public void collide(net.minecraft.server.v1_7_R4.Entity entity) {
}
}

@Override
public boolean d(NBTTagCompound save) {
return npc == null ? super.d(save) : false;
}

@Override
public void e(float f, float f1) {
if (npc == null || !npc.isFlyable()) {
Expand Down Expand Up @@ -177,7 +183,8 @@ public boolean h_() {

@Override
protected String t() {
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(
NPC.AMBIENT_SOUND_METADATA, super.t());
}

@Override
Expand Down
25 changes: 16 additions & 9 deletions src/main/java/net/citizensnpcs/npc/entity/CreeperController.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_7_R4.EntityCreeper;
import net.minecraft.server.v1_7_R4.EntityLightning;
import net.minecraft.server.v1_7_R4.NBTTagCompound;
import net.minecraft.server.v1_7_R4.World;

import org.bukkit.Bukkit;
Expand Down Expand Up @@ -88,6 +89,14 @@ protected void b(float f) {
}
}

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

@Override
public boolean bN() {
if (npc == null)
Expand All @@ -101,14 +110,6 @@ public boolean bN() {
return false; // shouldLeash
}

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

@Override
public void collide(net.minecraft.server.v1_7_R4.Entity entity) {
// this method is called by both the entities involved - cancelling
Expand All @@ -118,6 +119,11 @@ public void collide(net.minecraft.server.v1_7_R4.Entity entity) {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}

@Override
public boolean d(NBTTagCompound save) {
return npc == null ? super.d(save) : false;
}

@Override
public void e(float f, float f1) {
if (npc == null || !npc.isFlyable()) {
Expand Down Expand Up @@ -176,7 +182,8 @@ public void setAllowPowered(boolean allowPowered) {

@Override
protected String t() {
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(
NPC.AMBIENT_SOUND_METADATA, super.t());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_7_R4.EntityEnderDragon;
import net.minecraft.server.v1_7_R4.NBTTagCompound;
import net.minecraft.server.v1_7_R4.World;

import org.bukkit.Bukkit;
Expand Down Expand Up @@ -95,6 +96,11 @@ public void collide(net.minecraft.server.v1_7_R4.Entity entity) {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}

@Override
public boolean d(NBTTagCompound save) {
return npc == null ? super.d(save) : false;
}

@Override
public void e() {
if (npc != null) {
Expand Down Expand Up @@ -156,7 +162,8 @@ public NPC getNPC() {

@Override
protected String t() {
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(
NPC.AMBIENT_SOUND_METADATA, super.t());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_7_R4.EntityEnderman;
import net.minecraft.server.v1_7_R4.NBTTagCompound;
import net.minecraft.server.v1_7_R4.World;

import org.bukkit.Bukkit;
Expand Down Expand Up @@ -120,6 +121,11 @@ public void collide(net.minecraft.server.v1_7_R4.Entity entity) {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}

@Override
public boolean d(NBTTagCompound save) {
return npc == null ? super.d(save) : false;
}

@Override
public void e() {
if (npc == null)
Expand Down Expand Up @@ -192,7 +198,8 @@ protected boolean k(double d1, double d2, double d3) {

@Override
protected String t() {
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.t() : npc.data().get(
NPC.AMBIENT_SOUND_METADATA, super.t());
}

private void updateAIWithMovement() {
Expand Down
Loading

0 comments on commit 6236324

Please sign in to comment.