mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-18 21:32:48 +01:00
Initial pass of non-living NPCs
This commit is contained in:
parent
e772611ec1
commit
ecbd2efe28
@ -32,6 +32,32 @@ import net.citizensnpcs.npc.entity.WitchController;
|
||||
import net.citizensnpcs.npc.entity.WitherController;
|
||||
import net.citizensnpcs.npc.entity.WolfController;
|
||||
import net.citizensnpcs.npc.entity.ZombieController;
|
||||
import net.citizensnpcs.npc.entity.nonliving.ArrowController;
|
||||
import net.citizensnpcs.npc.entity.nonliving.BoatController;
|
||||
import net.citizensnpcs.npc.entity.nonliving.EggController;
|
||||
import net.citizensnpcs.npc.entity.nonliving.EnderCrystalController;
|
||||
import net.citizensnpcs.npc.entity.nonliving.EnderPearlController;
|
||||
import net.citizensnpcs.npc.entity.nonliving.EnderSignalController;
|
||||
import net.citizensnpcs.npc.entity.nonliving.FallingBlockController;
|
||||
import net.citizensnpcs.npc.entity.nonliving.FireworkController;
|
||||
import net.citizensnpcs.npc.entity.nonliving.FishingHookController;
|
||||
import net.citizensnpcs.npc.entity.nonliving.ItemController;
|
||||
import net.citizensnpcs.npc.entity.nonliving.ItemFrameController;
|
||||
import net.citizensnpcs.npc.entity.nonliving.LargeFireballController;
|
||||
import net.citizensnpcs.npc.entity.nonliving.LeashController;
|
||||
import net.citizensnpcs.npc.entity.nonliving.MinecartChestController;
|
||||
import net.citizensnpcs.npc.entity.nonliving.MinecartCommandController;
|
||||
import net.citizensnpcs.npc.entity.nonliving.MinecartFurnaceController;
|
||||
import net.citizensnpcs.npc.entity.nonliving.MinecartHopperController;
|
||||
import net.citizensnpcs.npc.entity.nonliving.MinecartRideableController;
|
||||
import net.citizensnpcs.npc.entity.nonliving.MinecartTNTController;
|
||||
import net.citizensnpcs.npc.entity.nonliving.PaintingController;
|
||||
import net.citizensnpcs.npc.entity.nonliving.SmallFireballController;
|
||||
import net.citizensnpcs.npc.entity.nonliving.SnowballController;
|
||||
import net.citizensnpcs.npc.entity.nonliving.TNTPrimedController;
|
||||
import net.citizensnpcs.npc.entity.nonliving.ThrownExpBottleController;
|
||||
import net.citizensnpcs.npc.entity.nonliving.ThrownPotionController;
|
||||
import net.citizensnpcs.npc.entity.nonliving.WitherSkullController;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
@ -62,21 +88,41 @@ public class EntityControllers {
|
||||
private static final Map<EntityType, Class<? extends EntityController>> TYPES = Maps.newEnumMap(EntityType.class);
|
||||
|
||||
static {
|
||||
TYPES.put(EntityType.ARROW, ArrowController.class);
|
||||
TYPES.put(EntityType.BAT, BatController.class);
|
||||
TYPES.put(EntityType.BLAZE, BlazeController.class);
|
||||
TYPES.put(EntityType.BOAT, BoatController.class);
|
||||
TYPES.put(EntityType.CAVE_SPIDER, CaveSpiderController.class);
|
||||
TYPES.put(EntityType.CHICKEN, ChickenController.class);
|
||||
TYPES.put(EntityType.COW, CowController.class);
|
||||
TYPES.put(EntityType.CREEPER, CreeperController.class);
|
||||
TYPES.put(EntityType.DROPPED_ITEM, ItemController.class);
|
||||
TYPES.put(EntityType.EGG, EggController.class);
|
||||
TYPES.put(EntityType.ENDER_CRYSTAL, EnderCrystalController.class);
|
||||
TYPES.put(EntityType.ENDER_DRAGON, EnderDragonController.class);
|
||||
TYPES.put(EntityType.ENDER_PEARL, EnderPearlController.class);
|
||||
TYPES.put(EntityType.ENDER_SIGNAL, EnderSignalController.class);
|
||||
TYPES.put(EntityType.ENDERMAN, EndermanController.class);
|
||||
TYPES.put(EntityType.FALLING_BLOCK, FallingBlockController.class);
|
||||
TYPES.put(EntityType.FIREWORK, FireworkController.class);
|
||||
TYPES.put(EntityType.FIREBALL, LargeFireballController.class);
|
||||
TYPES.put(EntityType.FISHING_HOOK, FishingHookController.class);
|
||||
TYPES.put(EntityType.GHAST, GhastController.class);
|
||||
TYPES.put(EntityType.GIANT, GiantController.class);
|
||||
TYPES.put(EntityType.HORSE, HorseController.class);
|
||||
TYPES.put(EntityType.IRON_GOLEM, IronGolemController.class);
|
||||
TYPES.put(EntityType.ITEM_FRAME, ItemFrameController.class);
|
||||
TYPES.put(EntityType.LEASH_HITCH, LeashController.class);
|
||||
TYPES.put(EntityType.MAGMA_CUBE, MagmaCubeController.class);
|
||||
TYPES.put(EntityType.MINECART, MinecartRideableController.class);
|
||||
TYPES.put(EntityType.MINECART_CHEST, MinecartChestController.class);
|
||||
TYPES.put(EntityType.MINECART_COMMAND, MinecartCommandController.class);
|
||||
TYPES.put(EntityType.MINECART_FURNACE, MinecartFurnaceController.class);
|
||||
TYPES.put(EntityType.MINECART_HOPPER, MinecartHopperController.class);
|
||||
TYPES.put(EntityType.MINECART_TNT, MinecartTNTController.class);
|
||||
TYPES.put(EntityType.MUSHROOM_COW, MushroomCowController.class);
|
||||
TYPES.put(EntityType.OCELOT, OcelotController.class);
|
||||
TYPES.put(EntityType.PAINTING, PaintingController.class);
|
||||
TYPES.put(EntityType.PIG, PigController.class);
|
||||
TYPES.put(EntityType.PIG_ZOMBIE, PigZombieController.class);
|
||||
TYPES.put(EntityType.PLAYER, HumanController.class);
|
||||
@ -84,13 +130,19 @@ public class EntityControllers {
|
||||
TYPES.put(EntityType.SILVERFISH, SilverfishController.class);
|
||||
TYPES.put(EntityType.SKELETON, SkeletonController.class);
|
||||
TYPES.put(EntityType.SLIME, SlimeController.class);
|
||||
TYPES.put(EntityType.SMALL_FIREBALL, SmallFireballController.class);
|
||||
TYPES.put(EntityType.SNOWBALL, SnowballController.class);
|
||||
TYPES.put(EntityType.SNOWMAN, SnowmanController.class);
|
||||
TYPES.put(EntityType.SPIDER, SpiderController.class);
|
||||
TYPES.put(EntityType.SPLASH_POTION, ThrownPotionController.class);
|
||||
TYPES.put(EntityType.SQUID, SquidController.class);
|
||||
TYPES.put(EntityType.THROWN_EXP_BOTTLE, ThrownExpBottleController.class);
|
||||
TYPES.put(EntityType.PRIMED_TNT, TNTPrimedController.class);
|
||||
TYPES.put(EntityType.VILLAGER, VillagerController.class);
|
||||
TYPES.put(EntityType.WOLF, WolfController.class);
|
||||
TYPES.put(EntityType.WITCH, WitchController.class);
|
||||
TYPES.put(EntityType.WITHER, WitherController.class);
|
||||
TYPES.put(EntityType.WITHER_SKULL, WitherSkullController.class);
|
||||
TYPES.put(EntityType.ZOMBIE, ZombieController.class);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,109 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntityArrow;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftArrow;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class ArrowController extends MobEntityController {
|
||||
public ArrowController() {
|
||||
super(EntityArrowNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Arrow getBukkitEntity() {
|
||||
return (Arrow) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class ArrowNPC extends CraftArrow implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public ArrowNPC(EntityArrowNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntityArrowNPC extends EntityArrow implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityArrowNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityArrowNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new ArrowNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntityBoat;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftBoat;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Boat;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class BoatController extends MobEntityController {
|
||||
public BoatController() {
|
||||
super(EntityBoatNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boat getBukkitEntity() {
|
||||
return (Boat) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class BoatNPC extends CraftBoat implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public BoatNPC(EntityBoatNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntityBoatNPC extends EntityBoat implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityBoatNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityBoatNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new BoatNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntityEgg;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEgg;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Egg;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class EggController extends MobEntityController {
|
||||
public EggController() {
|
||||
super(EntityEggNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Egg getBukkitEntity() {
|
||||
return (Egg) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EggNPC extends CraftEgg implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EggNPC(EntityEggNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntityEggNPC extends EntityEgg implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityEggNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityEggNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new EggNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntityEnderCrystal;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEnderCrystal;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.EnderCrystal;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class EnderCrystalController extends MobEntityController {
|
||||
public EnderCrystalController() {
|
||||
super(EntityEnderCrystalNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnderCrystal getBukkitEntity() {
|
||||
return (EnderCrystal) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EnderCrystalNPC extends CraftEnderCrystal implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EnderCrystalNPC(EntityEnderCrystalNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntityEnderCrystalNPC extends EntityEnderCrystal implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityEnderCrystalNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityEnderCrystalNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new EnderCrystalNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntityEnderPearl;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEnderPearl;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.EnderPearl;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class EnderPearlController extends MobEntityController {
|
||||
public EnderPearlController() {
|
||||
super(EntityEnderPearlNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnderPearl getBukkitEntity() {
|
||||
return (EnderPearl) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EnderPearlNPC extends CraftEnderPearl implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EnderPearlNPC(EntityEnderPearlNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntityEnderPearlNPC extends EntityEnderPearl implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityEnderPearlNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityEnderPearlNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new EnderPearlNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntityEnderSignal;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEnderSignal;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.EnderSignal;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class EnderSignalController extends MobEntityController {
|
||||
public EnderSignalController() {
|
||||
super(EntityEnderSignalNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnderSignal getBukkitEntity() {
|
||||
return (EnderSignal) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EnderSignalNPC extends CraftEnderSignal implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EnderSignalNPC(EntityEnderSignalNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntityEnderSignalNPC extends EntityEnderSignal implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityEnderSignalNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityEnderSignalNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new EnderSignalNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntityExperienceOrb;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftExperienceOrb;
|
||||
import org.bukkit.entity.ExperienceOrb;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class ExperienceOrbController extends MobEntityController {
|
||||
public ExperienceOrbController() {
|
||||
super(EntityExperienceOrbNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExperienceOrb getBukkitEntity() {
|
||||
return (ExperienceOrb) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityExperienceOrbNPC extends EntityExperienceOrb implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityExperienceOrbNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityExperienceOrbNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new ExperienceOrbNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ExperienceOrbNPC extends CraftExperienceOrb implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public ExperienceOrbNPC(EntityExperienceOrbNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntityFallingBlock;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftFallingSand;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class FallingBlockController extends MobEntityController {
|
||||
public FallingBlockController() {
|
||||
super(EntityFallingBlockNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FallingBlock getBukkitEntity() {
|
||||
return (FallingBlock) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityFallingBlockNPC extends EntityFallingBlock implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityFallingBlockNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityFallingBlockNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new FallingBlockNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class FallingBlockNPC extends CraftFallingSand implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public FallingBlockNPC(EntityFallingBlockNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntityFireworks;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftFirework;
|
||||
import org.bukkit.entity.Firework;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class FireworkController extends MobEntityController {
|
||||
public FireworkController() {
|
||||
super(EntityFireworkNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Firework getBukkitEntity() {
|
||||
return (Firework) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityFireworkNPC extends EntityFireworks implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityFireworkNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityFireworkNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new FireworkNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class FireworkNPC extends CraftFirework implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public FireworkNPC(EntityFireworkNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntityFishingHook;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftFish;
|
||||
import org.bukkit.entity.Fish;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class FishingHookController extends MobEntityController {
|
||||
public FishingHookController() {
|
||||
super(EntityFishingHookNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fish getBukkitEntity() {
|
||||
return (Fish) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityFishingHookNPC extends EntityFishingHook implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityFishingHookNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityFishingHookNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new FishingHookNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class FishingHookNPC extends CraftFish implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public FishingHookNPC(EntityFishingHookNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,132 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_7_R1.EntityItem;
|
||||
import net.minecraft.server.v1_7_R1.ItemStack;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
import net.minecraft.server.v1_7_R1.WorldServer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftItem;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class ItemController extends AbstractEntityController {
|
||||
public ItemController() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Entity createEntity(Location at, NPC npc) {
|
||||
WorldServer ws = ((CraftWorld) at.getWorld()).getHandle();
|
||||
final EntityItemNPC handle = new EntityItemNPC(ws, npc, at.getX(), at.getY(), at.getZ(),
|
||||
CraftItemStack.asNMSCopy(new org.bukkit.inventory.ItemStack(Material.STONE)));
|
||||
return handle.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getBukkitEntity() {
|
||||
return (Item) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityItemNPC extends EntityItem implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityItemNPC(World world) {
|
||||
super(world);
|
||||
this.npc = null;
|
||||
}
|
||||
|
||||
public EntityItemNPC(World world, NPC npc, double x, double y, double z, ItemStack stack) {
|
||||
super(world, x, y, z, stack);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(EntityHuman entityhuman) {
|
||||
if (npc == null) {
|
||||
super.b_(entityhuman);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new ItemNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ItemNPC extends CraftItem implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public ItemNPC(EntityItemNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,117 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntityItemFrame;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftItemFrame;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class ItemFrameController extends MobEntityController {
|
||||
public ItemFrameController() {
|
||||
super(EntityItemFrameNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemFrame getBukkitEntity() {
|
||||
return (ItemFrame) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityItemFrameNPC extends EntityItemFrame implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityItemFrameNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityItemFrameNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
setDirection(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new ItemFrameNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean survives() {
|
||||
return npc == null || !npc.isProtected() ? super.survives() : true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ItemFrameNPC extends CraftItemFrame implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public ItemFrameNPC(EntityItemFrameNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntityLargeFireball;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftLargeFireball;
|
||||
import org.bukkit.entity.LargeFireball;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class LargeFireballController extends MobEntityController {
|
||||
public LargeFireballController() {
|
||||
super(EntityLargeFireballNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LargeFireball getBukkitEntity() {
|
||||
return (LargeFireball) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityLargeFireballNPC extends EntityLargeFireball implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityLargeFireballNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityLargeFireballNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new LargeFireballNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class LargeFireballNPC extends CraftLargeFireball implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public LargeFireballNPC(EntityLargeFireballNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntityLeash;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftLeash;
|
||||
import org.bukkit.entity.LeashHitch;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class LeashController extends MobEntityController {
|
||||
public LeashController() {
|
||||
super(EntityLeashNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LeashHitch getBukkitEntity() {
|
||||
return (LeashHitch) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityLeashNPC extends EntityLeash implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityLeashNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityLeashNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new LeashNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean survives() {
|
||||
return npc == null || !npc.isProtected() ? super.survives() : true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class LeashNPC extends CraftLeash implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public LeashNPC(EntityLeashNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntityMinecartChest;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftMinecartChest;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class MinecartChestController extends MobEntityController {
|
||||
public MinecartChestController() {
|
||||
super(EntityMinecartChestNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Minecart getBukkitEntity() {
|
||||
return (Minecart) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityMinecartChestNPC extends EntityMinecartChest implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityMinecartChestNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityMinecartChestNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new MinecartChestNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class MinecartChestNPC extends CraftMinecartChest implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public MinecartChestNPC(EntityMinecartChestNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntityMinecartCommandBlock;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftMinecartCommand;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class MinecartCommandController extends MobEntityController {
|
||||
public MinecartCommandController() {
|
||||
super(EntityMinecartCommandNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Minecart getBukkitEntity() {
|
||||
return (Minecart) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityMinecartCommandNPC extends EntityMinecartCommandBlock implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityMinecartCommandNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityMinecartCommandNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new MinecartCommandNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class MinecartCommandNPC extends CraftMinecartCommand implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public MinecartCommandNPC(EntityMinecartCommandNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntityMinecartFurnace;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftMinecartFurnace;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class MinecartFurnaceController extends MobEntityController {
|
||||
public MinecartFurnaceController() {
|
||||
super(EntityMinecartFurnaceNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Minecart getBukkitEntity() {
|
||||
return (Minecart) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityMinecartFurnaceNPC extends EntityMinecartFurnace implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityMinecartFurnaceNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityMinecartFurnaceNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new MinecartFurnaceNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class MinecartFurnaceNPC extends CraftMinecartFurnace implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public MinecartFurnaceNPC(EntityMinecartFurnaceNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntityMinecartHopper;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class MinecartHopperController extends MobEntityController {
|
||||
public MinecartHopperController() {
|
||||
super(EntityMinecartHopperNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Minecart getBukkitEntity() {
|
||||
return (Minecart) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityMinecartHopperNPC extends EntityMinecartHopper implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityMinecartHopperNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityMinecartHopperNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntityMinecartRideable;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftMinecartRideable;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class MinecartRideableController extends MobEntityController {
|
||||
public MinecartRideableController() {
|
||||
super(EntityMinecartRideableNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Minecart getBukkitEntity() {
|
||||
return (Minecart) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityMinecartRideableNPC extends EntityMinecartRideable implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityMinecartRideableNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityMinecartRideableNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new MinecartRideableNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class MinecartRideableNPC extends CraftMinecartRideable implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public MinecartRideableNPC(EntityMinecartRideableNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntityMinecartMobSpawner;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class MinecartSpawnerController extends MobEntityController {
|
||||
public MinecartSpawnerController() {
|
||||
super(EntityMinecartSpawnerNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Minecart getBukkitEntity() {
|
||||
return (Minecart) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityMinecartSpawnerNPC extends EntityMinecartMobSpawner implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityMinecartSpawnerNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityMinecartSpawnerNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntityMinecartTNT;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class MinecartTNTController extends MobEntityController {
|
||||
public MinecartTNTController() {
|
||||
super(EntityMinecartTNTNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Minecart getBukkitEntity() {
|
||||
return (Minecart) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityMinecartTNTNPC extends EntityMinecartTNT implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityMinecartTNTNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityMinecartTNTNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntityPainting;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftPainting;
|
||||
import org.bukkit.entity.Painting;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class PaintingController extends MobEntityController {
|
||||
public PaintingController() {
|
||||
super(EntityPaintingNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Painting getBukkitEntity() {
|
||||
return (Painting) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityPaintingNPC extends EntityPainting implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityPaintingNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityPaintingNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new PaintingNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean survives() {
|
||||
return npc == null || !npc.isProtected() ? super.survives() : true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class PaintingNPC extends CraftPainting implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public PaintingNPC(EntityPaintingNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntitySmallFireball;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftSmallFireball;
|
||||
import org.bukkit.entity.SmallFireball;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class SmallFireballController extends MobEntityController {
|
||||
public SmallFireballController() {
|
||||
super(EntitySmallFireballNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SmallFireball getBukkitEntity() {
|
||||
return (SmallFireball) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntitySmallFireballNPC extends EntitySmallFireball implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntitySmallFireballNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntitySmallFireballNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new SmallFireballNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class SmallFireballNPC extends CraftSmallFireball implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public SmallFireballNPC(EntitySmallFireballNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntitySnowball;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftSnowball;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Snowball;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class SnowballController extends MobEntityController {
|
||||
public SnowballController() {
|
||||
super(EntitySnowballNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Snowball getBukkitEntity() {
|
||||
return (Snowball) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class SnowballNPC extends CraftSnowball implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public SnowballNPC(EntitySnowballNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntitySnowballNPC extends EntitySnowball implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntitySnowballNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntitySnowballNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new SnowballNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntityTNTPrimed;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftTNTPrimed;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class TNTPrimedController extends MobEntityController {
|
||||
public TNTPrimedController() {
|
||||
super(EntityTNTPrimedNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TNTPrimed getBukkitEntity() {
|
||||
return (TNTPrimed) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityTNTPrimedNPC extends EntityTNTPrimed implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityTNTPrimedNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityTNTPrimedNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new TNTPrimedNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class TNTPrimedNPC extends CraftTNTPrimed implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public TNTPrimedNPC(EntityTNTPrimedNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntityThrownExpBottle;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftThrownExpBottle;
|
||||
import org.bukkit.entity.ThrownExpBottle;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class ThrownExpBottleController extends MobEntityController {
|
||||
public ThrownExpBottleController() {
|
||||
super(EntityThrownExpBottleNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThrownExpBottle getBukkitEntity() {
|
||||
return (ThrownExpBottle) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityThrownExpBottleNPC extends EntityThrownExpBottle implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityThrownExpBottleNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityThrownExpBottleNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new ThrownExpBottleNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ThrownExpBottleNPC extends CraftThrownExpBottle implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public ThrownExpBottleNPC(EntityThrownExpBottleNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntityPotion;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftThrownPotion;
|
||||
import org.bukkit.entity.ThrownPotion;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class ThrownPotionController extends MobEntityController {
|
||||
public ThrownPotionController() {
|
||||
super(EntityThrownPotionNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThrownPotion getBukkitEntity() {
|
||||
return (ThrownPotion) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityThrownPotionNPC extends EntityPotion implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityThrownPotionNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityThrownPotionNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new ThrownPotionNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ThrownPotionNPC extends CraftThrownPotion implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public ThrownPotionNPC(EntityThrownPotionNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package net.citizensnpcs.npc.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_7_R1.EntityWitherSkull;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftWitherSkull;
|
||||
import org.bukkit.entity.WitherSkull;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class WitherSkullController extends MobEntityController {
|
||||
public WitherSkullController() {
|
||||
super(EntityWitherSkullNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WitherSkull getBukkitEntity() {
|
||||
return (WitherSkull) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityWitherSkullNPC extends EntityWitherSkull implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityWitherSkullNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityWitherSkullNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new WitherSkullNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void h() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.h();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class WitherSkullNPC extends CraftWitherSkull implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public WitherSkullNPC(EntityWitherSkullNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
@ -23,19 +23,6 @@ public class Util {
|
||||
private Util() {
|
||||
}
|
||||
|
||||
public static boolean isAlwaysFlyable(EntityType type) {
|
||||
switch (type) {
|
||||
case BAT:
|
||||
case BLAZE:
|
||||
case GHAST:
|
||||
case ENDER_DRAGON:
|
||||
case WITHER:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void assumePose(Entity entity, float yaw, float pitch) {
|
||||
NMS.look(entity, yaw, pitch);
|
||||
}
|
||||
@ -96,6 +83,19 @@ public class Util {
|
||||
return raw.substring(start, end);
|
||||
}
|
||||
|
||||
public static boolean isAlwaysFlyable(EntityType type) {
|
||||
switch (type) {
|
||||
case BAT:
|
||||
case BLAZE:
|
||||
case GHAST:
|
||||
case ENDER_DRAGON:
|
||||
case WITHER:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isLoaded(Location location) {
|
||||
if (location.getWorld() == null)
|
||||
return false;
|
||||
@ -123,7 +123,8 @@ public class Util {
|
||||
public static <T extends Enum<?>> T matchEnum(T[] values, String toMatch) {
|
||||
toMatch = toMatch.toLowerCase().replace('-', '_').replace(' ', '_');
|
||||
for (T check : values) {
|
||||
if (toMatch.equals(check.name().toLowerCase())) {
|
||||
if (toMatch.equals(check.name().toLowerCase()) || toMatch.equals("item")
|
||||
&& check == EntityType.DROPPED_ITEM) {
|
||||
return check; // check for an exact match first
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user