mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-28 20:17:50 +01:00
Update for 1.3
This commit is contained in:
parent
3c3c6cc5f1
commit
b9b6004e65
2
pom.xml
2
pom.xml
@ -11,7 +11,7 @@
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<craftbukkit.version>1.2.5-R4.1-SNAPSHOT</craftbukkit.version>
|
||||
<craftbukkit.version>1.3.1-R0.1-SNAPSHOT</craftbukkit.version>
|
||||
<citizensapi.version>2.0-SNAPSHOT</citizensapi.version>
|
||||
<build.number>Unknown</build.number>
|
||||
</properties>
|
||||
|
@ -367,5 +367,5 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
Thread.currentThread().setContextClassLoader(contextClassLoader);
|
||||
}
|
||||
|
||||
private static final String COMPATIBLE_MC_VERSION = "1.2.5";
|
||||
private static final String COMPATIBLE_MC_VERSION = "1.3.1";
|
||||
}
|
@ -201,7 +201,7 @@ public class NPCCommands {
|
||||
if (npc == null || args.argsLength() == 2) {
|
||||
if (args.argsLength() < 2)
|
||||
throw new CommandException("No NPC selected.");
|
||||
npc = CitizensAPI.getNPCRegistry().getById(args.getInteger(2));
|
||||
npc = CitizensAPI.getNPCRegistry().getById(args.getInteger(1));
|
||||
if (npc == null)
|
||||
throw new CommandException("No NPC found with that ID.");
|
||||
}
|
||||
|
@ -18,22 +18,20 @@ import org.bukkit.command.CommandSender;
|
||||
import com.google.common.base.Splitter;
|
||||
|
||||
public class ScriptCommands {
|
||||
private final Citizens plugin;
|
||||
|
||||
public ScriptCommands(Citizens plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "script" },
|
||||
modifiers = { "compile", "run" },
|
||||
usage = "compile|run [file]",
|
||||
usage = "compile|run [file] (--methods [methods])",
|
||||
desc = "compile and run a script",
|
||||
min = 2,
|
||||
max = 2,
|
||||
permission = "script.compile")
|
||||
public void runScript(final CommandContext args, final CommandSender sender, NPC npc) throws CommandException {
|
||||
File file = new File(plugin.getDataFolder(), args.getString(1));
|
||||
public void runScript(final CommandContext args, final CommandSender sender, NPC npc)
|
||||
throws CommandException {
|
||||
File file = new File(CitizensAPI.getScriptFolder(), args.getString(1));
|
||||
if (!file.exists())
|
||||
throw new CommandException("The file '" + args.getString(1) + "' doesn't exist!");
|
||||
CitizensAPI.getScriptCompiler().compile(file).withCallback(new CompileCallback() {
|
||||
|
@ -141,7 +141,7 @@ public class CitizensNavigator implements Navigator {
|
||||
private void updatePathfindingRange() {
|
||||
if (PATHFINDING_RANGE == null)
|
||||
return;
|
||||
Navigation navigation = npc.getHandle().al();
|
||||
Navigation navigation = npc.getHandle().getNavigation();
|
||||
try {
|
||||
PATHFINDING_RANGE.set(navigation, pathfindingRange);
|
||||
} catch (Exception ex) {
|
||||
@ -168,7 +168,7 @@ public class CitizensNavigator implements Navigator {
|
||||
MOVEMENT_SPEEDS.put(EntityType.PLAYER, 1F);
|
||||
MOVEMENT_SPEEDS.put(EntityType.VILLAGER, 0.3F);
|
||||
try {
|
||||
SPEED_FIELD = EntityLiving.class.getDeclaredField("bb");
|
||||
SPEED_FIELD = EntityLiving.class.getDeclaredField("bw");
|
||||
SPEED_FIELD.setAccessible(true);
|
||||
PATHFINDING_RANGE = Navigation.class.getDeclaredField("e");
|
||||
PATHFINDING_RANGE.setAccessible(true);
|
||||
|
@ -31,7 +31,7 @@ public class MCNavigationStrategy implements PathStrategy {
|
||||
// navigation won't execute, and calling entity.move doesn't
|
||||
// entirely fix the problem.
|
||||
}
|
||||
navigation = entity.al();
|
||||
navigation = entity.getNavigation();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -46,6 +46,6 @@ public class MCNavigationStrategy implements PathStrategy {
|
||||
|
||||
@Override
|
||||
public boolean update() {
|
||||
return navigation.e();
|
||||
return navigation.f();
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import org.bukkit.entity.LivingEntity;
|
||||
|
||||
public class MCTargetStrategy implements PathStrategy, EntityTarget {
|
||||
private final boolean aggro;
|
||||
private int attackTicks;
|
||||
private final EntityLiving handle, target;
|
||||
private final float speed;
|
||||
|
||||
@ -26,9 +27,9 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
|
||||
}
|
||||
|
||||
private boolean canAttack() {
|
||||
return handle.attackTicks == 0
|
||||
return attackTicks == 0
|
||||
&& (handle.boundingBox.e > target.boundingBox.b && handle.boundingBox.b < target.boundingBox.e)
|
||||
&& distanceSquared() <= ATTACK_DISTANCE && handle.h(target);
|
||||
&& distanceSquared() <= ATTACK_DISTANCE && handle.l(target);
|
||||
}
|
||||
|
||||
private double distanceSquared() {
|
||||
@ -60,10 +61,10 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
|
||||
if (target == null || target.dead)
|
||||
return true;
|
||||
new MCNavigationStrategy(handle, target, speed).update();
|
||||
handle.getControllerLook().a(target, 10.0F, handle.D());
|
||||
handle.getControllerLook().a(target, 10.0F, handle.bf());
|
||||
if (aggro && canAttack()) {
|
||||
if (handle instanceof EntityMonster) {
|
||||
((EntityMonster) handle).a((net.minecraft.server.Entity) target);
|
||||
((EntityMonster) handle).k(target);
|
||||
// the cast is necessary to resolve overloaded method a
|
||||
} else if (handle instanceof EntityPlayer) {
|
||||
EntityPlayer humanHandle = (EntityPlayer) handle;
|
||||
@ -71,10 +72,15 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
|
||||
Util.sendPacketNearby(handle.getBukkitEntity().getLocation(), new Packet18ArmAnimation(
|
||||
humanHandle, 1), 64);
|
||||
}
|
||||
attackTicks = ATTACK_DELAY_TICKS;
|
||||
}
|
||||
if (attackTicks > 0)
|
||||
attackTicks--;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final int ATTACK_DELAY_TICKS = 20;
|
||||
|
||||
private static final double ATTACK_DISTANCE = 1.75 * 1.75;
|
||||
}
|
@ -7,7 +7,6 @@ import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntityBlaze;
|
||||
import net.minecraft.server.PathfinderGoalSelector;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
import org.bukkit.entity.Blaze;
|
||||
@ -35,24 +34,16 @@ public class CitizensBlazeNPC extends CitizensMobNPC {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
goalSelector = new PathfinderGoalSelector();
|
||||
targetSelector = new PathfinderGoalSelector();
|
||||
Util.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.b_(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.b_(x, y, z);
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything if the event is cancelled.
|
||||
public void be() {
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
else
|
||||
super.be();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,11 +55,19 @@ public class CitizensBlazeNPC extends CitizensMobNPC {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void d_() {
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
else
|
||||
super.d_();
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.g(x, y, z);
|
||||
// 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
|
||||
|
@ -7,7 +7,6 @@ import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntityCaveSpider;
|
||||
import net.minecraft.server.PathfinderGoalSelector;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
import org.bukkit.entity.CaveSpider;
|
||||
@ -31,24 +30,22 @@ public class CitizensCaveSpiderNPC extends CitizensMobNPC {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
goalSelector = new PathfinderGoalSelector();
|
||||
targetSelector = new PathfinderGoalSelector();
|
||||
Util.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.b_(x, y, z);
|
||||
return;
|
||||
public void bc() {
|
||||
super.bc();
|
||||
npc.update();
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.b_(x, y, z);
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything if the event is cancelled.
|
||||
|
||||
@Override
|
||||
public void be() {
|
||||
if (npc == null)
|
||||
super.be();
|
||||
else
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -60,22 +57,24 @@ public class CitizensCaveSpiderNPC extends CitizensMobNPC {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void d_() {
|
||||
if (npc == null)
|
||||
super.d_();
|
||||
else
|
||||
npc.update();
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.g(x, y, z);
|
||||
// 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 NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void z_() {
|
||||
super.z_();
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntityChicken;
|
||||
import net.minecraft.server.PathfinderGoalSelector;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
import org.bukkit.entity.Chicken;
|
||||
@ -35,24 +34,15 @@ public class CitizensChickenNPC extends CitizensMobNPC {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
goalSelector = new PathfinderGoalSelector();
|
||||
targetSelector = new PathfinderGoalSelector();
|
||||
Util.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.b_(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.b_(x, y, z);
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything if the event is cancelled.
|
||||
public void bc() {
|
||||
super.bc();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,15 +54,24 @@ public class CitizensChickenNPC extends CitizensMobNPC {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.g(x, y, z);
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void z_() {
|
||||
super.z_();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntityCow;
|
||||
import net.minecraft.server.PathfinderGoalSelector;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
import org.bukkit.entity.Cow;
|
||||
@ -35,24 +34,15 @@ public class CitizensCowNPC extends CitizensMobNPC {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
goalSelector = new PathfinderGoalSelector();
|
||||
targetSelector = new PathfinderGoalSelector();
|
||||
Util.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.b_(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.b_(x, y, z);
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything if the event is cancelled.
|
||||
public void bc() {
|
||||
super.bc();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,15 +54,24 @@ public class CitizensCowNPC extends CitizensMobNPC {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.g(x, y, z);
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void z_() {
|
||||
super.z_();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -7,8 +7,7 @@ import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntityCreeper;
|
||||
import net.minecraft.server.EntityWeatherLighting;
|
||||
import net.minecraft.server.PathfinderGoalSelector;
|
||||
import net.minecraft.server.EntityLightning;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
import org.bukkit.entity.Creeper;
|
||||
@ -36,30 +35,21 @@ public class CitizensCreeperNPC extends CitizensMobNPC {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
goalSelector = new PathfinderGoalSelector();
|
||||
targetSelector = new PathfinderGoalSelector();
|
||||
Util.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(EntityWeatherLighting entityweatherlighting) {
|
||||
public void a(EntityLightning entitylightning) {
|
||||
if (npc == null)
|
||||
super.a(entityweatherlighting);
|
||||
super.a(entitylightning);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.b_(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.b_(x, y, z);
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything if the event is cancelled.
|
||||
public void bc() {
|
||||
super.bc();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -71,15 +61,24 @@ public class CitizensCreeperNPC extends CitizensMobNPC {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.g(x, y, z);
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC
|
||||
// so we prevent it from doing anything if the event is cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void z_() {
|
||||
super.z_();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntityEnderDragon;
|
||||
import net.minecraft.server.PathfinderGoalSelector;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
import org.bukkit.entity.EnderDragon;
|
||||
@ -31,24 +30,14 @@ public class CitizensEnderDragonNPC extends CitizensMobNPC {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
goalSelector = new PathfinderGoalSelector();
|
||||
targetSelector = new PathfinderGoalSelector();
|
||||
Util.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.b_(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.b_(x, y, z);
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything if the event is cancelled.
|
||||
public void be() {
|
||||
if (npc == null)
|
||||
super.be();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -60,17 +49,27 @@ public class CitizensEnderDragonNPC extends CitizensMobNPC {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void d_() {
|
||||
if (npc == null)
|
||||
super.d_();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e() {
|
||||
public void d() {
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
else
|
||||
super.e();
|
||||
super.d();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.g(x, y, z);
|
||||
// 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
|
||||
|
@ -10,7 +10,6 @@ import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Messaging;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntityEnderman;
|
||||
import net.minecraft.server.PathfinderGoalSelector;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
import org.bukkit.Material;
|
||||
@ -73,24 +72,24 @@ public class CitizensEndermanNPC extends CitizensMobNPC implements Equipable {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
goalSelector = new PathfinderGoalSelector();
|
||||
targetSelector = new PathfinderGoalSelector();
|
||||
Util.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.b_(x, y, z);
|
||||
return;
|
||||
public void bc() {
|
||||
if (npc == null)
|
||||
super.bc();
|
||||
else
|
||||
npc.update();
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.b_(x, y, z);
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything if the event is cancelled.
|
||||
|
||||
@Override
|
||||
public void be() {
|
||||
if (npc == null)
|
||||
super.be();
|
||||
else
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -102,27 +101,30 @@ public class CitizensEndermanNPC extends CitizensMobNPC implements Equipable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void d_() {
|
||||
public void d() {
|
||||
if (npc == null)
|
||||
super.d_();
|
||||
else
|
||||
npc.update();
|
||||
super.d();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e() {
|
||||
if (npc == null)
|
||||
super.e();
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.g(x, y, z);
|
||||
// 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 NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void z_() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntityGhast;
|
||||
import net.minecraft.server.PathfinderGoalSelector;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
import org.bukkit.entity.Ghast;
|
||||
@ -35,24 +34,16 @@ public class CitizensGhastNPC extends CitizensMobNPC {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
goalSelector = new PathfinderGoalSelector();
|
||||
targetSelector = new PathfinderGoalSelector();
|
||||
Util.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.b_(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.b_(x, y, z);
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything if the event is cancelled.
|
||||
public void be() {
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
else
|
||||
super.be();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,11 +55,19 @@ public class CitizensGhastNPC extends CitizensMobNPC {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void d_() {
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
else
|
||||
super.d_();
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.g(x, y, z);
|
||||
// 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
|
||||
|
@ -7,7 +7,6 @@ import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntityGiantZombie;
|
||||
import net.minecraft.server.PathfinderGoalSelector;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
import org.bukkit.entity.Giant;
|
||||
@ -31,24 +30,16 @@ public class CitizensGiantNPC extends CitizensMobNPC {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
goalSelector = new PathfinderGoalSelector();
|
||||
targetSelector = new PathfinderGoalSelector();
|
||||
Util.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.b_(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.b_(x, y, z);
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything if the event is cancelled.
|
||||
public void be() {
|
||||
if (npc == null)
|
||||
super.be();
|
||||
else
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -60,8 +51,19 @@ public class CitizensGiantNPC extends CitizensMobNPC {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void d_() {
|
||||
npc.update();
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.g(x, y, z);
|
||||
// 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
|
||||
|
@ -32,11 +32,12 @@ public class CitizensHumanNPC extends CitizensNPC implements Equipable {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
handle.X = loc.getYaw() % 360;
|
||||
handle.as = loc.getYaw() % 360;
|
||||
// set the head yaw in another tick - if done immediately,
|
||||
// minecraft will not update it.
|
||||
}
|
||||
});
|
||||
handle.getBukkitEntity().setSleepingIgnored(true);
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntityIronGolem;
|
||||
import net.minecraft.server.PathfinderGoalSelector;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
import org.bukkit.entity.IronGolem;
|
||||
@ -31,24 +30,15 @@ public class CitizensIronGolemNPC extends CitizensMobNPC {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
goalSelector = new PathfinderGoalSelector();
|
||||
targetSelector = new PathfinderGoalSelector();
|
||||
Util.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.b_(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.b_(x, y, z);
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything if the event is cancelled.
|
||||
public void bc() {
|
||||
super.bc();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -60,15 +50,24 @@ public class CitizensIronGolemNPC extends CitizensMobNPC {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.g(x, y, z);
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void z_() {
|
||||
super.z_();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntityMagmaCube;
|
||||
import net.minecraft.server.PathfinderGoalSelector;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
import org.bukkit.entity.MagmaCube;
|
||||
@ -36,24 +35,23 @@ public class CitizensMagmaCubeNPC extends CitizensMobNPC {
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
setSize(3);
|
||||
goalSelector = new PathfinderGoalSelector();
|
||||
targetSelector = new PathfinderGoalSelector();
|
||||
Util.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.b_(x, y, z);
|
||||
return;
|
||||
public void bc() {
|
||||
super.bc();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.b_(x, y, z);
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything if the event is cancelled.
|
||||
|
||||
@Override
|
||||
public void be() {
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
else
|
||||
super.be();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -65,23 +63,24 @@ public class CitizensMagmaCubeNPC extends CitizensMobNPC {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void d_() {
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
else
|
||||
super.d_();
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.g(x, y, z);
|
||||
// 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 NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void z_() {
|
||||
super.z_();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntityMushroomCow;
|
||||
import net.minecraft.server.PathfinderGoalSelector;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
import org.bukkit.entity.MushroomCow;
|
||||
@ -35,24 +34,15 @@ public class CitizensMushroomCowNPC extends CitizensMobNPC {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
goalSelector = new PathfinderGoalSelector();
|
||||
targetSelector = new PathfinderGoalSelector();
|
||||
Util.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.b_(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.b_(x, y, z);
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything if the event is cancelled.
|
||||
public void bc() {
|
||||
super.bc();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,15 +54,24 @@ public class CitizensMushroomCowNPC extends CitizensMobNPC {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.g(x, y, z);
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void z_() {
|
||||
super.z_();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntityOcelot;
|
||||
import net.minecraft.server.PathfinderGoalSelector;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
import org.bukkit.entity.Ocelot;
|
||||
@ -35,24 +34,15 @@ public class CitizensOcelotNPC extends CitizensMobNPC {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
goalSelector = new PathfinderGoalSelector();
|
||||
targetSelector = new PathfinderGoalSelector();
|
||||
Util.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.b_(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.b_(x, y, z);
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything if the event is cancelled.
|
||||
public void bc() {
|
||||
super.bc();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,15 +54,24 @@ public class CitizensOcelotNPC extends CitizensMobNPC {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.g(x, y, z);
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void z_() {
|
||||
super.z_();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -10,9 +10,8 @@ import net.citizensnpcs.trait.Saddle;
|
||||
import net.citizensnpcs.util.Messaging;
|
||||
import net.citizensnpcs.util.StringHelper;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntityLightning;
|
||||
import net.minecraft.server.EntityPig;
|
||||
import net.minecraft.server.EntityWeatherLighting;
|
||||
import net.minecraft.server.PathfinderGoalSelector;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
import org.bukkit.Material;
|
||||
@ -62,30 +61,21 @@ public class CitizensPigNPC extends CitizensMobNPC implements Equipable {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
goalSelector = new PathfinderGoalSelector();
|
||||
targetSelector = new PathfinderGoalSelector();
|
||||
Util.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(EntityWeatherLighting entityweatherlighting) {
|
||||
public void a(EntityLightning entitylightning) {
|
||||
if (npc == null)
|
||||
super.a(entityweatherlighting);
|
||||
super.a(entitylightning);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.b_(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.b_(x, y, z);
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything if the event is cancelled.
|
||||
public void bc() {
|
||||
super.bc();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -97,15 +87,24 @@ public class CitizensPigNPC extends CitizensMobNPC implements Equipable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.g(x, y, z);
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void z_() {
|
||||
super.z_();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntityPigZombie;
|
||||
import net.minecraft.server.PathfinderGoalSelector;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
import org.bukkit.entity.PigZombie;
|
||||
@ -35,24 +34,23 @@ public class CitizensPigZombieNPC extends CitizensMobNPC {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
goalSelector = new PathfinderGoalSelector();
|
||||
targetSelector = new PathfinderGoalSelector();
|
||||
Util.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.b_(x, y, z);
|
||||
return;
|
||||
public void bc() {
|
||||
super.bc();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.b_(x, y, z);
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything if the event is cancelled.
|
||||
|
||||
@Override
|
||||
public void be() {
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
else
|
||||
super.be();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,23 +62,24 @@ public class CitizensPigZombieNPC extends CitizensMobNPC {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void d_() {
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
else
|
||||
super.d_();
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.g(x, y, z);
|
||||
// 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 NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void z_() {
|
||||
super.z_();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
}
|
@ -12,7 +12,6 @@ import net.citizensnpcs.util.Messaging;
|
||||
import net.citizensnpcs.util.StringHelper;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntitySheep;
|
||||
import net.minecraft.server.PathfinderGoalSelector;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
@ -73,24 +72,15 @@ public class CitizensSheepNPC extends CitizensMobNPC implements Equipable {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
goalSelector = new PathfinderGoalSelector();
|
||||
targetSelector = new PathfinderGoalSelector();
|
||||
Util.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.b_(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.b_(x, y, z);
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything if the event is cancelled.
|
||||
public void bc() {
|
||||
super.bc();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -102,15 +92,24 @@ public class CitizensSheepNPC extends CitizensMobNPC implements Equipable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.g(x, y, z);
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void z_() {
|
||||
super.z_();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntitySilverfish;
|
||||
import net.minecraft.server.PathfinderGoalSelector;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
import org.bukkit.entity.Silverfish;
|
||||
@ -35,24 +34,23 @@ public class CitizensSilverfishNPC extends CitizensMobNPC {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
goalSelector = new PathfinderGoalSelector();
|
||||
targetSelector = new PathfinderGoalSelector();
|
||||
Util.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.b_(x, y, z);
|
||||
return;
|
||||
public void bc() {
|
||||
super.bc();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.b_(x, y, z);
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything if the event is cancelled.
|
||||
|
||||
@Override
|
||||
public void be() {
|
||||
if (npc == null)
|
||||
super.be();
|
||||
else
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,23 +62,24 @@ public class CitizensSilverfishNPC extends CitizensMobNPC {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void d_() {
|
||||
if (npc == null)
|
||||
super.d_();
|
||||
else
|
||||
npc.update();
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.g(x, y, z);
|
||||
// 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 NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void z_() {
|
||||
super.z_();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntitySkeleton;
|
||||
import net.minecraft.server.PathfinderGoalSelector;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
import org.bukkit.entity.Skeleton;
|
||||
@ -35,24 +34,15 @@ public class CitizensSkeletonNPC extends CitizensMobNPC {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
goalSelector = new PathfinderGoalSelector();
|
||||
targetSelector = new PathfinderGoalSelector();
|
||||
Util.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.b_(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.b_(x, y, z);
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything if the event is cancelled.
|
||||
public void bc() {
|
||||
super.bc();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,15 +54,24 @@ public class CitizensSkeletonNPC extends CitizensMobNPC {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.g(x, y, z);
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void z_() {
|
||||
super.z_();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntitySlime;
|
||||
import net.minecraft.server.PathfinderGoalSelector;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
import org.bukkit.entity.Slime;
|
||||
@ -36,24 +35,23 @@ public class CitizensSlimeNPC extends CitizensMobNPC {
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
setSize(3);
|
||||
goalSelector = new PathfinderGoalSelector();
|
||||
targetSelector = new PathfinderGoalSelector();
|
||||
Util.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.b_(x, y, z);
|
||||
return;
|
||||
public void bc() {
|
||||
super.bc();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.b_(x, y, z);
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything if the event is cancelled.
|
||||
|
||||
@Override
|
||||
public void be() {
|
||||
if (npc == null)
|
||||
super.be();
|
||||
else
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -65,23 +63,24 @@ public class CitizensSlimeNPC extends CitizensMobNPC {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void d_() {
|
||||
if (npc == null)
|
||||
super.d_();
|
||||
else
|
||||
npc.update();
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.g(x, y, z);
|
||||
// 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 NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void z_() {
|
||||
super.z_();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntitySnowman;
|
||||
import net.minecraft.server.PathfinderGoalSelector;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
import org.bukkit.entity.Snowman;
|
||||
@ -31,24 +30,14 @@ public class CitizensSnowmanNPC extends CitizensMobNPC {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
goalSelector = new PathfinderGoalSelector();
|
||||
targetSelector = new PathfinderGoalSelector();
|
||||
Util.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.b_(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.b_(x, y, z);
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything if the event is cancelled.
|
||||
public void bc() {
|
||||
super.bc();
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -60,14 +49,24 @@ public class CitizensSnowmanNPC extends CitizensMobNPC {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.g(x, y, z);
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void z_() {
|
||||
super.z_();
|
||||
npc.update();
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntitySpider;
|
||||
import net.minecraft.server.PathfinderGoalSelector;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
import org.bukkit.entity.Spider;
|
||||
@ -34,24 +33,23 @@ public class CitizensSpiderNPC extends CitizensMobNPC {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
goalSelector = new PathfinderGoalSelector();
|
||||
targetSelector = new PathfinderGoalSelector();
|
||||
Util.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.b_(x, y, z);
|
||||
return;
|
||||
public void bc() {
|
||||
super.bc();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.b_(x, y, z);
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything if the event is cancelled.
|
||||
|
||||
@Override
|
||||
public void be() {
|
||||
if (npc == null)
|
||||
super.be();
|
||||
else
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -63,23 +61,24 @@ public class CitizensSpiderNPC extends CitizensMobNPC {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void d_() {
|
||||
if (npc == null)
|
||||
super.d_();
|
||||
else
|
||||
npc.update();
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.g(x, y, z);
|
||||
// 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 NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void z_() {
|
||||
super.z_();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntitySquid;
|
||||
import net.minecraft.server.PathfinderGoalSelector;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
import org.bukkit.entity.Squid;
|
||||
@ -35,24 +34,16 @@ public class CitizensSquidNPC extends CitizensMobNPC {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
goalSelector = new PathfinderGoalSelector();
|
||||
targetSelector = new PathfinderGoalSelector();
|
||||
Util.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.b_(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.b_(x, y, z);
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything if the event is cancelled.
|
||||
public void be() {
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
else
|
||||
super.be();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,11 +55,19 @@ public class CitizensSquidNPC extends CitizensMobNPC {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void d_() {
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
else
|
||||
super.d_();
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.g(x, y, z);
|
||||
// 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
|
||||
|
@ -7,7 +7,6 @@ import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntityVillager;
|
||||
import net.minecraft.server.PathfinderGoalSelector;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
import org.bukkit.entity.Villager;
|
||||
@ -35,24 +34,15 @@ public class CitizensVillagerNPC extends CitizensMobNPC {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
goalSelector = new PathfinderGoalSelector();
|
||||
targetSelector = new PathfinderGoalSelector();
|
||||
Util.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.b_(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.b_(x, y, z);
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything if the event is cancelled.
|
||||
public void bc() {
|
||||
super.bc();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,15 +54,24 @@ public class CitizensVillagerNPC extends CitizensMobNPC {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.g(x, y, z);
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void z_() {
|
||||
super.z_();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntityWolf;
|
||||
import net.minecraft.server.PathfinderGoalSelector;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
import org.bukkit.entity.Wolf;
|
||||
@ -35,24 +34,15 @@ public class CitizensWolfNPC extends CitizensMobNPC {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
goalSelector = new PathfinderGoalSelector();
|
||||
targetSelector = new PathfinderGoalSelector();
|
||||
Util.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.b_(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.b_(x, y, z);
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything if the event is cancelled.
|
||||
public void bc() {
|
||||
super.bc();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,15 +54,24 @@ public class CitizensWolfNPC extends CitizensMobNPC {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.g(x, y, z);
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void z_() {
|
||||
super.z_();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntityZombie;
|
||||
import net.minecraft.server.PathfinderGoalSelector;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
import org.bukkit.entity.Zombie;
|
||||
@ -35,24 +34,15 @@ public class CitizensZombieNPC extends CitizensMobNPC {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
goalSelector = new PathfinderGoalSelector();
|
||||
targetSelector = new PathfinderGoalSelector();
|
||||
Util.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.b_(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.b_(x, y, z);
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything if the event is cancelled.
|
||||
public void bc() {
|
||||
super.bc();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,15 +54,24 @@ public class CitizensZombieNPC extends CitizensMobNPC {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.g(x, y, z);
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void z_() {
|
||||
super.z_();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -6,11 +6,12 @@ import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.npc.network.NPCNetHandler;
|
||||
import net.citizensnpcs.npc.network.NPCNetworkManager;
|
||||
import net.citizensnpcs.npc.network.EmptyNetHandler;
|
||||
import net.citizensnpcs.npc.network.EmptyNetworkManager;
|
||||
import net.citizensnpcs.npc.network.NPCSocket;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
import net.minecraft.server.EnumGamemode;
|
||||
import net.minecraft.server.ItemInWorldManager;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.Navigation;
|
||||
@ -21,46 +22,31 @@ import net.minecraft.server.World;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
||||
private CitizensNPC npc;
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityHumanNPC(MinecraftServer minecraftServer, World world, String string,
|
||||
ItemInWorldManager itemInWorldManager, NPC npc) {
|
||||
super(minecraftServer, world, string, itemInWorldManager);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
itemInWorldManager.setGameMode(0);
|
||||
itemInWorldManager.setGameMode(EnumGamemode.SURVIVAL);
|
||||
|
||||
NPCSocket socket = new NPCSocket();
|
||||
NetworkManager netMgr = new NPCNetworkManager(socket, "npc mgr", new NetHandler() {
|
||||
NetworkManager netMgr = new EmptyNetworkManager(socket, "npc mgr", new NetHandler() {
|
||||
@Override
|
||||
public boolean c() {
|
||||
public boolean a() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
netServerHandler = new NPCNetHandler(minecraftServer, netMgr, this);
|
||||
}, server.E().getPrivate());
|
||||
netServerHandler = new EmptyNetHandler(minecraftServer, netMgr, this);
|
||||
netMgr.a(netServerHandler);
|
||||
|
||||
try {
|
||||
socket.close();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
// swallow
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.b_(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.b_(x, y, z);
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything if the event is cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
@ -70,11 +56,31 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void F_() {
|
||||
super.F_();
|
||||
Navigation navigation = al();
|
||||
if (!navigation.e()) {
|
||||
navigation.d();
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
NPCPushEvent event = Util.callPushEvent(npc, new Vector(x, y, z));
|
||||
if (!event.isCancelled())
|
||||
super.g(x, y, z);
|
||||
// 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 NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h_() {
|
||||
super.h_();
|
||||
Navigation navigation = getNavigation();
|
||||
if (!navigation.f()) {
|
||||
navigation.e();
|
||||
moveOnCurrentHeading();
|
||||
} else if (motX != 0 || motZ != 0 || motY != 0) {
|
||||
// a(0, 0);
|
||||
@ -84,33 +90,28 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
private void moveOnCurrentHeading() {
|
||||
getControllerMove().c();
|
||||
getControllerLook().a();
|
||||
getControllerJump().b();
|
||||
|
||||
// taken from EntityLiving
|
||||
if (aZ) {
|
||||
boolean inLiquid = aT() || aU();
|
||||
if (bu) {
|
||||
boolean inLiquid = G() || H();
|
||||
if (inLiquid) {
|
||||
motY += 0.04;
|
||||
} else if (onGround && q == 0) {
|
||||
} else if (onGround && bE == 0) {
|
||||
// this.ac(); - this doesn't jump high enough
|
||||
motY = 0.6;
|
||||
q = 10;
|
||||
bE = 10;
|
||||
}
|
||||
} else {
|
||||
q = 0;
|
||||
bE = 0;
|
||||
}
|
||||
|
||||
aX *= 0.98F;
|
||||
a(aW, aX);
|
||||
X = yaw;
|
||||
as = yaw;
|
||||
}
|
||||
|
||||
}
|
@ -18,14 +18,11 @@ import net.minecraft.server.Packet3Chat;
|
||||
import net.minecraft.server.Packet51MapChunk;
|
||||
|
||||
public class EmptyNetHandler extends NetServerHandler {
|
||||
public EmptyNetHandler(MinecraftServer minecraftServer, NetworkManager networkManager, EntityPlayer entityPlayer) {
|
||||
public EmptyNetHandler(MinecraftServer minecraftServer, NetworkManager networkManager,
|
||||
EntityPlayer entityPlayer) {
|
||||
super(minecraftServer, networkManager, entityPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(Packet102WindowClick packet) {
|
||||
}
|
||||
@ -74,10 +71,6 @@ public class EmptyNetHandler extends NetServerHandler {
|
||||
public void a(String string, Object[] objects) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String string) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacket(Packet packet) {
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package net.citizensnpcs.npc.network;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.Socket;
|
||||
import java.security.PrivateKey;
|
||||
|
||||
import net.minecraft.server.NetHandler;
|
||||
import net.minecraft.server.NetworkManager;
|
||||
@ -9,8 +10,8 @@ import net.minecraft.server.Packet;
|
||||
|
||||
public class EmptyNetworkManager extends NetworkManager {
|
||||
|
||||
public EmptyNetworkManager(Socket socket, String string, NetHandler netHandler) {
|
||||
super(socket, string, netHandler);
|
||||
public EmptyNetworkManager(Socket socket, String string, NetHandler netHandler, PrivateKey key) {
|
||||
super(socket, string, netHandler, key);
|
||||
|
||||
try {
|
||||
// the field above the 3 synchronized lists
|
||||
|
@ -1,85 +0,0 @@
|
||||
package net.citizensnpcs.npc.network;
|
||||
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.NetServerHandler;
|
||||
import net.minecraft.server.NetworkManager;
|
||||
import net.minecraft.server.Packet;
|
||||
import net.minecraft.server.Packet102WindowClick;
|
||||
import net.minecraft.server.Packet106Transaction;
|
||||
import net.minecraft.server.Packet10Flying;
|
||||
import net.minecraft.server.Packet130UpdateSign;
|
||||
import net.minecraft.server.Packet14BlockDig;
|
||||
import net.minecraft.server.Packet15Place;
|
||||
import net.minecraft.server.Packet16BlockItemSwitch;
|
||||
import net.minecraft.server.Packet255KickDisconnect;
|
||||
import net.minecraft.server.Packet28EntityVelocity;
|
||||
import net.minecraft.server.Packet3Chat;
|
||||
import net.minecraft.server.Packet51MapChunk;
|
||||
|
||||
public class NPCNetHandler extends NetServerHandler {
|
||||
|
||||
public NPCNetHandler(MinecraftServer minecraftServer, NetworkManager networkManager, EntityPlayer entityPlayer) {
|
||||
super(minecraftServer, networkManager, entityPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(Packet102WindowClick packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(Packet106Transaction packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(Packet10Flying packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(Packet130UpdateSign packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(Packet14BlockDig packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(Packet15Place packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(Packet16BlockItemSwitch packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(Packet255KickDisconnect packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(Packet28EntityVelocity packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(Packet3Chat packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(Packet51MapChunk packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(String string, Object[] objects) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String string) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacket(Packet packet) {
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package net.citizensnpcs.npc.network;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.Socket;
|
||||
|
||||
import net.minecraft.server.NetHandler;
|
||||
import net.minecraft.server.NetworkManager;
|
||||
import net.minecraft.server.Packet;
|
||||
|
||||
public class NPCNetworkManager extends NetworkManager {
|
||||
|
||||
public NPCNetworkManager(Socket socket, String string, NetHandler netHandler) {
|
||||
super(socket, string, netHandler);
|
||||
|
||||
try {
|
||||
// the field above the 3 synchronized lists
|
||||
Field f = NetworkManager.class.getDeclaredField("l");
|
||||
f.setAccessible(true);
|
||||
f.set(this, false);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NetHandler netHandler) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(String s, Object... objects) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void d() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int e() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void queue(Packet packet) {
|
||||
}
|
||||
}
|
@ -42,7 +42,7 @@ public class Behaviour extends Trait {
|
||||
}
|
||||
|
||||
public void addScripts(Iterable<String> scripts) {
|
||||
BehaviourCallback callback = new BehaviourCallback(new Goals());
|
||||
BehaviourCallback callback = new BehaviourCallback();
|
||||
Iterable<File> transformed = Iterables.transform(scripts, fileConverterFunction);
|
||||
CitizensAPI.getScriptCompiler().compile(transformed).withCallback(callback).begin();
|
||||
}
|
||||
@ -85,35 +85,27 @@ public class Behaviour extends Trait {
|
||||
key.setString("scripts", Joiner.on(",").join(scripts));
|
||||
}
|
||||
|
||||
private class BehaviourCallback implements CompileCallback {
|
||||
private final Goals goals;
|
||||
public class BehaviourCallback implements CompileCallback {
|
||||
private final Map<Goal, Integer> goals = Maps.newHashMap();
|
||||
|
||||
private BehaviourCallback(Goals goals) {
|
||||
this.goals = goals;
|
||||
public void addGoal(int priority, Goal goal) {
|
||||
Validate.notNull(goal);
|
||||
goals.put(goal, priority);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCompileTaskFinished() {
|
||||
addedGoals.putAll(goals.goals);
|
||||
addedGoals.putAll(goals);
|
||||
if (!npc.isSpawned())
|
||||
return;
|
||||
for (Entry<Goal, Integer> entry : goals.goals.entrySet()) {
|
||||
for (Entry<Goal, Integer> entry : goals.entrySet()) {
|
||||
npc.getDefaultGoalController().addGoal(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScriptCompiled(ScriptFactory script) {
|
||||
script.newInstance().invoke("addGoals", goals, npc);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Goals {
|
||||
private final Map<Goal, Integer> goals = Maps.newHashMap();
|
||||
|
||||
public void addGoal(Goal goal, int priority) {
|
||||
Validate.notNull(goal);
|
||||
goals.put(goal, priority);
|
||||
script.newInstance().invoke("addGoals", this, npc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class LookClose extends Trait implements Toggleable {
|
||||
EntityLiving handle = ((CraftLivingEntity) from).getHandle();
|
||||
handle.yaw = (float) yaw - 90;
|
||||
handle.pitch = (float) pitch;
|
||||
handle.X = handle.yaw;
|
||||
handle.as = handle.yaw;
|
||||
}
|
||||
|
||||
private void findNewTarget() {
|
||||
|
@ -1,9 +1,11 @@
|
||||
package net.citizensnpcs.util;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.citizensnpcs.Settings.Setting;
|
||||
@ -11,6 +13,7 @@ import net.citizensnpcs.api.event.NPCCollisionEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.minecraft.server.Packet;
|
||||
import net.minecraft.server.PathfinderGoalSelector;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -31,6 +34,8 @@ public class Util {
|
||||
private Util() {
|
||||
}
|
||||
|
||||
private static Field GOAL_FIELD;
|
||||
|
||||
private static final Map<Class<?>, Class<?>> primitiveClassMap = Maps.newHashMap();
|
||||
|
||||
public static void callCollisionEvent(NPC npc, net.minecraft.server.Entity entity) {
|
||||
@ -44,6 +49,18 @@ public class Util {
|
||||
return event;
|
||||
}
|
||||
|
||||
public static void clearGoals(PathfinderGoalSelector... goalSelectors) {
|
||||
if (GOAL_FIELD == null || goalSelectors == null)
|
||||
return;
|
||||
for (PathfinderGoalSelector selector : goalSelectors) {
|
||||
try {
|
||||
List<?> list = (List<?>) GOAL_FIELD.get(selector);
|
||||
list.clear();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a set of instantiation parameters, attempts to find a matching
|
||||
* constructor with the greatest number of matching class parameters and
|
||||
@ -178,5 +195,10 @@ public class Util {
|
||||
primitiveClassMap.put(long.class, Long.class);
|
||||
primitiveClassMap.put(float.class, Float.class);
|
||||
primitiveClassMap.put(double.class, Double.class);
|
||||
try {
|
||||
GOAL_FIELD = PathfinderGoalSelector.class.getDeclaredField("a");
|
||||
} catch (Exception e) {
|
||||
GOAL_FIELD = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user