Fix bug in item parsing for holograms, allow arbitrary bounding boxes for BoundingBoxTrait, attempt to unify common code across NMS implementations

This commit is contained in:
fullwall 2023-02-13 20:32:20 +08:00
parent b0a2c51883
commit 8f43ca70e5
1053 changed files with 10975 additions and 15586 deletions

View File

@ -1,16 +1,21 @@
package net.citizensnpcs.trait;
import net.citizensnpcs.api.npc.NPC.NPCUpdate;
import java.util.function.BiFunction;
import java.util.function.Supplier;
import org.bukkit.Location;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
import net.citizensnpcs.api.util.BoundingBox;
import net.citizensnpcs.api.util.EntityDim;
import net.citizensnpcs.util.NMS;
// TODO: could set a function instead which replaces makeBoundingBox
@TraitName("boundingbox")
public class BoundingBoxTrait extends Trait {
public class BoundingBoxTrait extends Trait implements Supplier<BoundingBox> {
private EntityDim base;
private BiFunction<Location, EntityDim, BoundingBox> function;
@Persist
private float height = -1;
@Persist
@ -22,6 +27,17 @@ public class BoundingBoxTrait extends Trait {
super("boundingbox");
}
@Override
public BoundingBox get() {
if (function != null) {
return function.apply(npc.getStoredLocation(), getAdjustedBoundingBox());
}
Location location = npc.getEntity().getLocation();
EntityDim dim = getAdjustedBoundingBox();
return new BoundingBox(location.getX() - dim.width / 2, location.getY(), location.getZ() - dim.width / 2,
location.getX() + dim.width / 2, location.getY() + dim.height, location.getZ() + dim.width / 2);
}
public EntityDim getAdjustedBoundingBox() {
EntityDim desired = base.clone();
if (scale != -1) {
@ -31,19 +47,23 @@ public class BoundingBoxTrait extends Trait {
}
@Override
public void onSpawn() {
base = EntityDim.from(npc.getEntity());
public void onDespawn() {
npc.data().remove(NPC.Metadata.BOUNDING_BOX_FUNCTION);
}
@Override
public void run() {
if (!npc.isUpdating(NPCUpdate.PACKET) || !npc.isSpawned())
return;
public void onRemove() {
onDespawn();
}
EntityDim desired = getAdjustedBoundingBox();
if (!desired.equals(EntityDim.from(npc.getEntity()))) {
NMS.setDimensions(npc.getEntity(), desired);
}
@Override
public void onSpawn() {
base = EntityDim.from(npc.getEntity());
npc.data().set(NPC.Metadata.BOUNDING_BOX_FUNCTION, this);
}
public void setBoundingBoxFunction(BiFunction<Location, EntityDim, BoundingBox> func) {
this.function = func;
}
public void setHeight(float height) {

View File

@ -98,9 +98,9 @@ public class HologramTrait extends Trait {
Material item = SpigotUtil.isUsing1_13API() ? Material.matchMaterial(itemMatcher.group(1), false)
: Material.matchMaterial(itemMatcher.group(1));
NPC itemNPC = registry.createNPCUsingItem(EntityType.DROPPED_ITEM, "", new ItemStack(item, 1));
if (itemMatcher.groupCount() > 1) {
if (itemMatcher.group(2) != null) {
itemNPC.getOrAddTrait(ScoreboardTrait.class)
.setColor(Util.matchEnum(ChatColor.values(), itemMatcher.group(2)));
.setColor(Util.matchEnum(ChatColor.values(), itemMatcher.group(2).substring(1)));
}
itemNPC.spawn(currentLoc);
((ArmorStand) hologramNPC.getEntity()).addPassenger(itemNPC.getEntity());
@ -405,5 +405,5 @@ public class HologramTrait extends Trait {
}
}
private static final Pattern ITEM_MATCHER = Pattern.compile("<item:(.*?)>|<item:(.*?):(.*?)>");
private static final Pattern ITEM_MATCHER = Pattern.compile("<item:(.*?)([:].*?)?>");
}

View File

@ -7,7 +7,10 @@ import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Collection;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Supplier;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -35,6 +38,8 @@ import net.citizensnpcs.api.ai.NavigatorParameters;
import net.citizensnpcs.api.astar.pathfinder.SwimmingExaminer;
import net.citizensnpcs.api.command.CommandManager;
import net.citizensnpcs.api.command.exception.CommandException;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.jnbt.CompoundTag;
import net.citizensnpcs.api.npc.BlockBreaker;
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
@ -70,6 +75,15 @@ public class NMS {
BRIDGE.attack(attacker, bukkitTarget);
}
public static void callKnockbackEvent(NPC npc, float strength, double dx, double dz,
Consumer<NPCKnockbackEvent> cb) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
cb.accept(event);
}
}
public static void cancelMoveDestination(Entity entity) {
BRIDGE.cancelMoveDestination(entity);
}/*
@ -77,6 +91,18 @@ public class NMS {
* an Exception like it should.
*/
public static void enderTeleportTo(NPC npc, double x, double y, double z, Runnable cb) {
if (npc == null) {
cb.run();
return;
}
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
cb.run();
}
}
public static GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) throws Throwable {
return BRIDGE.fillProfileProperties(profile, requireSecure);
}
@ -433,6 +459,18 @@ public class NMS {
}
}
public static boolean isLeashed(NPC npc, Supplier<Boolean> isLeashed, Runnable unleash) {
if (npc == null)
return isLeashed.get();
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return isLeashed.get();
if (isLeashed.get()) {
unleash.run();
}
return false;
}
public static boolean isOnGround(org.bukkit.entity.Entity entity) {
return BRIDGE.isOnGround(entity);
}

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
import org.bukkit.entity.Bat;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityBat;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
@ -59,14 +60,15 @@ public class BatController extends MobEntityController {
}
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -96,13 +98,7 @@ public class BatController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -132,16 +128,7 @@ public class BatController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null) {
return super.isLeashed();
}
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
import org.bukkit.entity.Blaze;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityBlaze;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
@ -56,14 +57,15 @@ public class BlazeController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -93,13 +95,7 @@ public class BlazeController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
import org.bukkit.entity.CaveSpider;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityCaveSpider;
@ -58,6 +59,11 @@ public class CaveSpiderController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -67,12 +73,8 @@ public class CaveSpiderController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -109,13 +111,7 @@ public class CaveSpiderController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
import org.bukkit.entity.Chicken;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityChicken;
@ -58,6 +59,11 @@ public class ChickenController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(boolean flag) {
float oldw = width;
@ -78,12 +84,8 @@ public class ChickenController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -120,13 +122,7 @@ public class ChickenController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
import org.bukkit.entity.Cow;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityCow;
@ -62,6 +63,11 @@ public class CowController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(boolean flag) {
float oldw = width;
@ -82,12 +88,8 @@ public class CowController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -135,13 +137,7 @@ public class CowController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
import org.bukkit.entity.Creeper;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityCreeper;
@ -64,6 +65,11 @@ public class CreeperController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -73,12 +79,8 @@ public class CreeperController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -119,13 +121,7 @@ public class CreeperController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
import org.bukkit.entity.EnderDragon;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityEnderDragon;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
@ -56,14 +57,15 @@ public class EnderDragonController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -92,13 +94,7 @@ public class EnderDragonController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
import org.bukkit.entity.Enderman;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityEnderman;
@ -58,6 +59,11 @@ public class EndermanController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -67,12 +73,8 @@ public class EndermanController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -108,13 +110,7 @@ public class EndermanController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
import org.bukkit.entity.Endermite;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityEndermite;
@ -58,6 +59,11 @@ public class EndermiteController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -67,12 +73,8 @@ public class EndermiteController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -108,13 +110,7 @@ public class EndermiteController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftGhast;
import org.bukkit.entity.Ghast;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityGhast;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
@ -42,14 +43,15 @@ public class GhastController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -84,13 +86,7 @@ public class GhastController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftGiant;
import org.bukkit.entity.Giant;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityGiantZombie;
@ -44,6 +45,11 @@ public class GiantController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -53,12 +59,8 @@ public class GiantController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -94,13 +96,7 @@ public class GiantController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftGuardian;
import org.bukkit.entity.Guardian;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityGuardian;
@ -44,6 +45,11 @@ public class GuardianController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -53,12 +59,8 @@ public class GuardianController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -95,13 +97,7 @@ public class GuardianController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -8,15 +8,15 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftHorse;
import org.bukkit.entity.Horse;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.trait.HorseModifiers;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityHorse;
@ -30,17 +30,17 @@ public class HorseController extends MobEntityController {
super(EntityHorseNPC.class);
}
@Override
public Horse getBukkitEntity() {
return (Horse) super.getBukkitEntity();
}
@Override
public void create(Location at, NPC npc) {
npc.getOrAddTrait(HorseModifiers.class);
super.create(at, npc);
}
@Override
public Horse getBukkitEntity() {
return (Horse) super.getBukkitEntity();
}
public static class EntityHorseNPC extends EntityHorse implements NPCHolder {
private final CitizensNPC npc;
@ -56,6 +56,11 @@ public class HorseController extends MobEntityController {
}
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(boolean flag) {
float oldw = width;
@ -76,12 +81,8 @@ public class HorseController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -126,13 +127,7 @@ public class HorseController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftIronGolem;
import org.bukkit.entity.IronGolem;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityIronGolem;
@ -44,6 +45,11 @@ public class IronGolemController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -53,12 +59,8 @@ public class IronGolemController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -94,13 +96,7 @@ public class IronGolemController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,14 +7,15 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftMagmaCube;
import org.bukkit.entity.MagmaCube;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.nms.v1_10_R1.util.PlayerControllerMove;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityHuman;
@ -50,6 +51,11 @@ public class MagmaCubeController extends MobEntityController {
}
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -59,12 +65,8 @@ public class MagmaCubeController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -107,13 +109,7 @@ public class MagmaCubeController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftMushroomCow;
import org.bukkit.entity.MushroomCow;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityHuman;
@ -48,6 +49,11 @@ public class MushroomCowController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(boolean flag) {
float oldw = width;
@ -68,12 +74,8 @@ public class MushroomCowController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -116,13 +118,7 @@ public class MushroomCowController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftOcelot;
import org.bukkit.entity.Ocelot;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityOcelot;
@ -44,6 +45,11 @@ public class OcelotController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(boolean flag) {
float oldw = width;
@ -64,12 +70,8 @@ public class OcelotController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -112,13 +114,7 @@ public class OcelotController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPig;
import org.bukkit.entity.Pig;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityLightning;
@ -45,6 +46,11 @@ public class PigController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(boolean flag) {
float oldw = width;
@ -65,12 +71,8 @@ public class PigController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -115,13 +117,7 @@ public class PigController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPigZombie;
import org.bukkit.entity.PigZombie;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityPigZombie;
@ -45,6 +46,11 @@ public class PigZombieController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -54,12 +60,8 @@ public class PigZombieController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -95,13 +97,7 @@ public class PigZombieController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPolarBear;
import org.bukkit.entity.PolarBear;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityPolarBear;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
@ -42,6 +43,11 @@ public class PolarBearController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(boolean flag) {
float oldw = width;
@ -55,12 +61,8 @@ public class PolarBearController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -90,13 +92,7 @@ public class PolarBearController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -126,16 +122,7 @@ public class PolarBearController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null) {
return super.isLeashed();
}
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftRabbit;
import org.bukkit.entity.Rabbit;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityLiving;
@ -45,6 +46,11 @@ public class RabbitController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(boolean flag) {
float oldw = width;
@ -65,12 +71,8 @@ public class RabbitController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -107,13 +109,7 @@ public class RabbitController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftSheep;
import org.bukkit.entity.Sheep;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntitySheep;
@ -44,6 +45,11 @@ public class SheepController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(boolean flag) {
float oldw = width;
@ -64,12 +70,8 @@ public class SheepController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -105,13 +107,7 @@ public class SheepController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftShulker;
import org.bukkit.entity.Shulker;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityAIBodyControl;
@ -45,6 +46,11 @@ public class ShulkerController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -54,12 +60,8 @@ public class ShulkerController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -95,13 +97,7 @@ public class ShulkerController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftSilverfish;
import org.bukkit.entity.Silverfish;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntitySilverfish;
@ -44,6 +45,11 @@ public class SilverfishController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -53,12 +59,8 @@ public class SilverfishController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -94,13 +96,7 @@ public class SilverfishController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftSkeleton;
import org.bukkit.entity.Skeleton;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntitySkeleton;
@ -44,6 +45,11 @@ public class SkeletonController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -53,12 +59,8 @@ public class SkeletonController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -94,13 +96,7 @@ public class SkeletonController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,14 +7,15 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftSlime;
import org.bukkit.entity.Slime;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.nms.v1_10_R1.util.PlayerControllerMove;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityHuman;
@ -50,6 +51,11 @@ public class SlimeController extends MobEntityController {
}
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -59,12 +65,8 @@ public class SlimeController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -108,13 +110,7 @@ public class SlimeController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftSnowman;
import org.bukkit.entity.Snowman;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntitySnowman;
@ -44,6 +45,11 @@ public class SnowmanController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -53,12 +59,8 @@ public class SnowmanController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -94,13 +96,7 @@ public class SnowmanController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftSpider;
import org.bukkit.entity.Spider;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntitySpider;
@ -44,6 +45,11 @@ public class SpiderController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -53,12 +59,8 @@ public class SpiderController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -94,13 +96,7 @@ public class SpiderController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftSquid;
import org.bukkit.entity.Squid;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntitySquid;
@ -44,6 +45,11 @@ public class SquidController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -53,12 +59,8 @@ public class SquidController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -94,13 +96,7 @@ public class SquidController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftVillager;
import org.bukkit.entity.Villager;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityHuman;
@ -50,6 +51,11 @@ public class VillagerController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(boolean flag) {
float oldw = width;
@ -70,12 +76,8 @@ public class VillagerController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -129,13 +131,7 @@ public class VillagerController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftWitch;
import org.bukkit.entity.Witch;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityWitch;
@ -44,6 +45,11 @@ public class WitchController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -53,12 +59,8 @@ public class WitchController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -94,13 +96,7 @@ public class WitchController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftWither;
import org.bukkit.entity.Wither;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityWither;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
@ -42,14 +43,15 @@ public class WitherController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -84,13 +86,7 @@ public class WitherController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -8,13 +8,14 @@ import org.bukkit.entity.Wolf;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityLiving;
@ -46,6 +47,11 @@ public class WolfController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(boolean flag) {
float oldw = width;
@ -66,12 +72,8 @@ public class WolfController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -108,13 +110,7 @@ public class WolfController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftZombie;
import org.bukkit.entity.Zombie;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityZombie;
@ -44,6 +45,11 @@ public class ZombieController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -53,12 +59,8 @@ public class ZombieController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -94,13 +96,7 @@ public class ZombieController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -9,9 +9,11 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityAreaEffectCloud;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -52,6 +54,11 @@ public class AreaEffectCloudController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -11,10 +11,12 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityArmorStand;
import net.minecraft.server.v1_10_R1.EntityHuman;
import net.minecraft.server.v1_10_R1.EnumHand;
@ -60,6 +62,11 @@ public class ArmorStandController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public EnumInteractionResult a(EntityHuman entityhuman, Vec3D vec3d, ItemStack itemstack, EnumHand enumhand) {
if (npc == null) {

View File

@ -9,10 +9,12 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityBoat;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -53,6 +55,11 @@ public class BoatController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -9,10 +9,12 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityDragonFireball;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -53,6 +55,11 @@ public class DragonFireballController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -11,10 +11,12 @@ import org.bukkit.entity.Entity;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
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_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityEgg;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -68,6 +70,11 @@ public class EggController extends AbstractEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -9,9 +9,11 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityEnderCrystal;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -52,6 +54,11 @@ public class EnderCrystalController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -9,9 +9,11 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityEnderPearl;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -52,6 +54,11 @@ public class EnderPearlController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -9,9 +9,11 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityEnderSignal;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -52,6 +54,11 @@ public class EnderSignalController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -9,9 +9,11 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityExperienceOrb;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -38,6 +40,11 @@ public class ExperienceOrbController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -12,11 +12,13 @@ import org.bukkit.entity.FallingBlock;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
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_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.Block;
import net.minecraft.server.v1_10_R1.EntityFallingBlock;
import net.minecraft.server.v1_10_R1.IBlockData;
@ -60,6 +62,11 @@ public class FallingBlockController extends AbstractEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -9,9 +9,11 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityFireworks;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -38,6 +40,11 @@ public class FireworkController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -9,9 +9,11 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityFishingHook;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -38,6 +40,11 @@ public class FishingHookController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -11,10 +11,12 @@ import org.bukkit.entity.Item;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
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_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityHuman;
import net.minecraft.server.v1_10_R1.EntityItem;
import net.minecraft.server.v1_10_R1.ItemStack;
@ -51,6 +53,11 @@ public class ItemController extends AbstractEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -11,9 +11,11 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.EntityItemFrame;
import net.minecraft.server.v1_10_R1.EnumDirection;
@ -51,6 +53,11 @@ public class ItemFrameController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -9,10 +9,12 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityLargeFireball;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -39,6 +41,11 @@ public class LargeFireballController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -9,9 +9,11 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityLeash;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -38,6 +40,11 @@ public class LeashController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -9,10 +9,12 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityMinecartChest;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -39,6 +41,11 @@ public class MinecartChestController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -9,10 +9,12 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityMinecartCommandBlock;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -39,6 +41,11 @@ public class MinecartCommandController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -9,10 +9,12 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityMinecartFurnace;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -39,6 +41,11 @@ public class MinecartFurnaceController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -5,10 +5,12 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityMinecartHopper;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -35,6 +37,11 @@ public class MinecartHopperController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -9,10 +9,12 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityMinecartRideable;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -39,6 +41,11 @@ public class MinecartRideableController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -5,10 +5,12 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityMinecartMobSpawner;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -35,6 +37,11 @@ public class MinecartSpawnerController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -5,10 +5,12 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityMinecartTNT;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -35,6 +37,11 @@ public class MinecartTNTController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -9,9 +9,11 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityPainting;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -38,6 +40,11 @@ public class PaintingController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -9,9 +9,11 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityShulkerBullet;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -38,6 +40,11 @@ public class ShulkerBulletController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -9,9 +9,11 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntitySmallFireball;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -38,6 +40,11 @@ public class SmallFireballController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -9,9 +9,11 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntitySnowball;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -38,6 +40,11 @@ public class SnowballController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -9,9 +9,11 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntitySpectralArrow;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -38,6 +40,11 @@ public class SpectralArrowController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -9,9 +9,11 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityTNTPrimed;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -38,6 +40,11 @@ public class TNTPrimedController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -9,9 +9,11 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityThrownExpBottle;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -38,6 +40,11 @@ public class ThrownExpBottleController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -9,9 +9,11 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityPotion;
import net.minecraft.server.v1_10_R1.Items;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
@ -39,6 +41,11 @@ public class ThrownPotionController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -9,9 +9,11 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityTippedArrow;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -38,6 +40,11 @@ public class TippedArrowController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -9,9 +9,11 @@ import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.EntityWitherSkull;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.World;
@ -38,6 +40,11 @@ public class WitherSkullController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
// this method is called by both the entities involved - cancelling

View File

@ -0,0 +1,21 @@
package net.citizensnpcs.nms.v1_10_R1.util;
import java.util.function.Supplier;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.util.BoundingBox;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
public class NMSBoundingBox {
private NMSBoundingBox() {
}
public static AxisAlignedBB convert(BoundingBox box) {
return new AxisAlignedBB(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ);
}
public static AxisAlignedBB makeBB(NPC npc, AxisAlignedBB def) {
return npc == null || !npc.data().has(NPC.Metadata.BOUNDING_BOX_FUNCTION) ? def
: convert(npc.data().<Supplier<BoundingBox>> get(NPC.Metadata.BOUNDING_BOX_FUNCTION).get());
}
}

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity;
import org.bukkit.entity.Bat;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityBat;
import net.minecraft.server.v1_11_R1.NBTTagCompound;
@ -59,14 +60,15 @@ public class BatController extends MobEntityController {
}
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -96,13 +98,7 @@ public class BatController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity;
import org.bukkit.entity.Blaze;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityBlaze;
import net.minecraft.server.v1_11_R1.NBTTagCompound;
@ -56,14 +57,15 @@ public class BlazeController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -93,13 +95,7 @@ public class BlazeController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -130,15 +126,7 @@ public class BlazeController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null)
return super.isLeashed();
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity;
import org.bukkit.entity.CaveSpider;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityCaveSpider;
@ -58,6 +59,11 @@ public class CaveSpiderController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -67,12 +73,8 @@ public class CaveSpiderController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -109,13 +111,7 @@ public class CaveSpiderController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity;
import org.bukkit.entity.Chicken;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityChicken;
@ -58,6 +59,11 @@ public class ChickenController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(boolean flag) {
float oldw = width;
@ -78,12 +84,8 @@ public class ChickenController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -120,13 +122,7 @@ public class ChickenController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -166,15 +162,7 @@ public class ChickenController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null)
return super.isLeashed();
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity;
import org.bukkit.entity.Cow;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityCow;
@ -62,6 +63,11 @@ public class CowController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(boolean flag) {
float oldw = width;
@ -82,12 +88,8 @@ public class CowController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -135,13 +137,7 @@ public class CowController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -181,15 +177,7 @@ public class CowController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null)
return super.isLeashed();
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity;
import org.bukkit.entity.Creeper;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityCreeper;
@ -61,6 +62,11 @@ public class CreeperController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -70,12 +76,8 @@ public class CreeperController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -111,13 +113,7 @@ public class CreeperController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -157,15 +153,7 @@ public class CreeperController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null)
return super.isLeashed();
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity;
import org.bukkit.entity.EnderDragon;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityEnderDragon;
import net.minecraft.server.v1_11_R1.NBTTagCompound;
@ -56,14 +57,15 @@ public class EnderDragonController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -92,13 +94,7 @@ public class EnderDragonController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -129,15 +125,7 @@ public class EnderDragonController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null)
return super.isLeashed();
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity;
import org.bukkit.entity.Enderman;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityEnderman;
@ -58,6 +59,11 @@ public class EndermanController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -67,12 +73,8 @@ public class EndermanController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -108,13 +110,7 @@ public class EndermanController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -154,15 +150,7 @@ public class EndermanController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null)
return super.isLeashed();
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity;
import org.bukkit.entity.Endermite;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityEndermite;
@ -58,6 +59,11 @@ public class EndermiteController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -67,12 +73,8 @@ public class EndermiteController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -108,13 +110,7 @@ public class EndermiteController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -154,15 +150,7 @@ public class EndermiteController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null)
return super.isLeashed();
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEvoker;
import org.bukkit.entity.Evoker;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityEvoker;
@ -44,6 +45,11 @@ public class EvokerController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -53,12 +59,8 @@ public class EvokerController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -95,13 +97,7 @@ public class EvokerController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -141,15 +137,7 @@ public class EvokerController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null)
return super.isLeashed();
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftGhast;
import org.bukkit.entity.Ghast;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityGhast;
import net.minecraft.server.v1_11_R1.NBTTagCompound;
@ -42,14 +43,15 @@ public class GhastController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -84,13 +86,7 @@ public class GhastController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -121,15 +117,7 @@ public class GhastController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null)
return super.isLeashed();
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftGiant;
import org.bukkit.entity.Giant;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityGiantZombie;
@ -44,6 +45,11 @@ public class GiantController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -53,12 +59,8 @@ public class GiantController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -94,13 +96,7 @@ public class GiantController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -140,15 +136,7 @@ public class GiantController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null)
return super.isLeashed();
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftGuardian;
import org.bukkit.entity.Guardian;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityGuardian;
@ -44,6 +45,11 @@ public class GuardianController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -53,12 +59,8 @@ public class GuardianController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -95,13 +97,7 @@ public class GuardianController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -141,15 +137,7 @@ public class GuardianController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null)
return super.isLeashed();
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity;
import org.bukkit.entity.ElderGuardian;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityGuardianElder;
@ -44,6 +45,11 @@ public class GuardianElderController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -53,12 +59,8 @@ public class GuardianElderController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -95,13 +97,7 @@ public class GuardianElderController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -141,15 +137,7 @@ public class GuardianElderController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null)
return super.isLeashed();
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

View File

@ -8,15 +8,15 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftHorse;
import org.bukkit.entity.Horse;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.trait.HorseModifiers;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityHorse;
@ -30,17 +30,17 @@ public class HorseController extends MobEntityController {
super(EntityHorseNPC.class);
}
@Override
public Horse getBukkitEntity() {
return (Horse) super.getBukkitEntity();
}
@Override
public void create(Location at, NPC npc) {
npc.getOrAddTrait(HorseModifiers.class);
super.create(at, npc);
}
@Override
public Horse getBukkitEntity() {
return (Horse) super.getBukkitEntity();
}
public static class EntityHorseNPC extends EntityHorse implements NPCHolder {
private final CitizensNPC npc;
@ -56,6 +56,11 @@ public class HorseController extends MobEntityController {
}
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(boolean flag) {
float oldw = width;
@ -76,12 +81,8 @@ public class HorseController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -118,13 +119,7 @@ public class HorseController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -164,15 +159,7 @@ public class HorseController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null)
return super.isLeashed();
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

View File

@ -8,15 +8,15 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity;
import org.bukkit.entity.Donkey;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.trait.HorseModifiers;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityHorseDonkey;
@ -30,17 +30,17 @@ public class HorseDonkeyController extends MobEntityController {
super(EntityHorseDonkeyNPC.class);
}
@Override
public Donkey getBukkitEntity() {
return (Donkey) super.getBukkitEntity();
}
@Override
public void create(Location at, NPC npc) {
npc.addTrait(HorseModifiers.class);
super.create(at, npc);
}
@Override
public Donkey getBukkitEntity() {
return (Donkey) super.getBukkitEntity();
}
public static class EntityHorseDonkeyNPC extends EntityHorseDonkey implements NPCHolder {
private final CitizensNPC npc;
@ -56,6 +56,11 @@ public class HorseDonkeyController extends MobEntityController {
}
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(boolean flag) {
float oldw = width;
@ -76,12 +81,8 @@ public class HorseDonkeyController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -118,13 +119,7 @@ public class HorseDonkeyController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -164,15 +159,7 @@ public class HorseDonkeyController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null)
return super.isLeashed();
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

View File

@ -8,15 +8,15 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftMule;
import org.bukkit.entity.Mule;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.trait.HorseModifiers;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityHorseMule;
@ -30,17 +30,17 @@ public class HorseMuleController extends MobEntityController {
super(EntityHorseMuleNPC.class);
}
@Override
public Mule getBukkitEntity() {
return (Mule) super.getBukkitEntity();
}
@Override
public void create(Location at, NPC npc) {
npc.getOrAddTrait(HorseModifiers.class);
super.create(at, npc);
}
@Override
public Mule getBukkitEntity() {
return (Mule) super.getBukkitEntity();
}
public static class EntityHorseMuleNPC extends EntityHorseMule implements NPCHolder {
private final CitizensNPC npc;
@ -56,6 +56,11 @@ public class HorseMuleController extends MobEntityController {
}
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(boolean flag) {
float oldw = width;
@ -76,12 +81,8 @@ public class HorseMuleController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -118,13 +119,7 @@ public class HorseMuleController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -164,15 +159,7 @@ public class HorseMuleController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null)
return super.isLeashed();
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

View File

@ -8,15 +8,15 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftSkeletonHorse;
import org.bukkit.entity.SkeletonHorse;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.trait.HorseModifiers;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityHorseSkeleton;
@ -30,17 +30,17 @@ public class HorseSkeletonController extends MobEntityController {
super(EntityHorseSkeletonNPC.class);
}
@Override
public SkeletonHorse getBukkitEntity() {
return (SkeletonHorse) super.getBukkitEntity();
}
@Override
public void create(Location at, NPC npc) {
npc.getOrAddTrait(HorseModifiers.class);
super.create(at, npc);
}
@Override
public SkeletonHorse getBukkitEntity() {
return (SkeletonHorse) super.getBukkitEntity();
}
public static class EntityHorseSkeletonNPC extends EntityHorseSkeleton implements NPCHolder {
private final CitizensNPC npc;
@ -57,6 +57,11 @@ public class HorseSkeletonController extends MobEntityController {
}
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(boolean flag) {
float oldw = width;
@ -77,12 +82,8 @@ public class HorseSkeletonController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -119,13 +120,7 @@ public class HorseSkeletonController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -165,15 +160,7 @@ public class HorseSkeletonController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null)
return super.isLeashed();
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

View File

@ -8,15 +8,15 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftZombieHorse;
import org.bukkit.entity.ZombieHorse;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.trait.HorseModifiers;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityHorseZombie;
@ -30,17 +30,17 @@ public class HorseZombieController extends MobEntityController {
super(EntityHorseZombieNPC.class);
}
@Override
public ZombieHorse getBukkitEntity() {
return (ZombieHorse) super.getBukkitEntity();
}
@Override
public void create(Location at, NPC npc) {
npc.getOrAddTrait(HorseModifiers.class);
super.create(at, npc);
}
@Override
public ZombieHorse getBukkitEntity() {
return (ZombieHorse) super.getBukkitEntity();
}
public static class EntityHorseZombieNPC extends EntityHorseZombie implements NPCHolder {
private final CitizensNPC npc;
@ -57,6 +57,11 @@ public class HorseZombieController extends MobEntityController {
}
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(boolean flag) {
float oldw = width;
@ -77,12 +82,8 @@ public class HorseZombieController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -119,13 +120,7 @@ public class HorseZombieController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -165,15 +160,7 @@ public class HorseZombieController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null)
return super.isLeashed();
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftIronGolem;
import org.bukkit.entity.IronGolem;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityIronGolem;
@ -44,6 +45,11 @@ public class IronGolemController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -53,12 +59,8 @@ public class IronGolemController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -94,13 +96,7 @@ public class IronGolemController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -140,15 +136,7 @@ public class IronGolemController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null)
return super.isLeashed();
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

View File

@ -8,15 +8,15 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftLlama;
import org.bukkit.entity.Llama;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.trait.HorseModifiers;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityLlama;
@ -30,17 +30,17 @@ public class LlamaController extends MobEntityController {
super(EntityLlamaNPC.class);
}
@Override
public Llama getBukkitEntity() {
return (Llama) super.getBukkitEntity();
}
@Override
public void create(Location at, NPC npc) {
npc.getOrAddTrait(HorseModifiers.class);
super.create(at, npc);
}
@Override
public Llama getBukkitEntity() {
return (Llama) super.getBukkitEntity();
}
public static class EntityLlamaNPC extends EntityLlama implements NPCHolder {
private final CitizensNPC npc;
@ -56,6 +56,11 @@ public class LlamaController extends MobEntityController {
}
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(boolean flag) {
float oldw = width;
@ -76,12 +81,8 @@ public class LlamaController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -118,13 +119,7 @@ public class LlamaController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -164,15 +159,7 @@ public class LlamaController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null)
return super.isLeashed();
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

View File

@ -7,14 +7,15 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftMagmaCube;
import org.bukkit.entity.MagmaCube;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.nms.v1_11_R1.util.PlayerControllerMove;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityHuman;
@ -50,6 +51,11 @@ public class MagmaCubeController extends MobEntityController {
}
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -59,12 +65,8 @@ public class MagmaCubeController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -115,13 +117,7 @@ public class MagmaCubeController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -161,15 +157,7 @@ public class MagmaCubeController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null)
return super.isLeashed();
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftMushroomCow;
import org.bukkit.entity.MushroomCow;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityHuman;
@ -47,6 +48,11 @@ public class MushroomCowController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(boolean flag) {
float oldw = width;
@ -67,12 +73,8 @@ public class MushroomCowController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -115,13 +117,7 @@ public class MushroomCowController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -161,15 +157,7 @@ public class MushroomCowController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null)
return super.isLeashed();
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftOcelot;
import org.bukkit.entity.Ocelot;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityOcelot;
@ -44,6 +45,11 @@ public class OcelotController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(boolean flag) {
float oldw = width;
@ -64,12 +70,8 @@ public class OcelotController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -112,13 +114,7 @@ public class OcelotController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -158,15 +154,7 @@ public class OcelotController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null)
return super.isLeashed();
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPig;
import org.bukkit.entity.Pig;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityLightning;
@ -45,6 +46,11 @@ public class PigController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(boolean flag) {
float oldw = width;
@ -65,12 +71,8 @@ public class PigController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -113,13 +115,7 @@ public class PigController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -159,15 +155,7 @@ public class PigController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null)
return super.isLeashed();
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPigZombie;
import org.bukkit.entity.PigZombie;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityPigZombie;
@ -45,6 +46,11 @@ public class PigZombieController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
if (npc == null || !npc.isFlyable()) {
@ -54,12 +60,8 @@ public class PigZombieController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -95,13 +97,7 @@ public class PigZombieController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -141,15 +137,7 @@ public class PigZombieController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null)
return super.isLeashed();
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPolarBear;
import org.bukkit.entity.PolarBear;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityPolarBear;
import net.minecraft.server.v1_11_R1.NBTTagCompound;
@ -42,6 +43,11 @@ public class PolarBearController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(boolean flag) {
float oldw = width;
@ -55,12 +61,8 @@ public class PolarBearController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -90,13 +92,7 @@ public class PolarBearController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftRabbit;
import org.bukkit.entity.Rabbit;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityLiving;
@ -45,6 +46,11 @@ public class RabbitController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(boolean flag) {
float oldw = width;
@ -65,12 +71,8 @@ public class RabbitController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -107,13 +109,7 @@ public class RabbitController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -158,15 +154,7 @@ public class RabbitController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null)
return super.isLeashed();
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

View File

@ -7,13 +7,14 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftSheep;
import org.bukkit.entity.Sheep;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntitySheep;
@ -44,6 +45,11 @@ public class SheepController extends MobEntityController {
this.npc = (CitizensNPC) npc;
}
@Override
public void a(AxisAlignedBB bb) {
super.a(NMSBoundingBox.makeBB(npc, bb));
}
@Override
public void a(boolean flag) {
float oldw = width;
@ -64,12 +70,8 @@ public class SheepController extends MobEntityController {
@Override
public void a(Entity entity, float strength, double dx, double dz) {
NPCKnockbackEvent event = new NPCKnockbackEvent(npc, strength, dx, dz);
Bukkit.getPluginManager().callEvent(event);
Vector kb = event.getKnockbackVector();
if (!event.isCancelled()) {
super.a(entity, (float) event.getStrength(), kb.getX(), kb.getZ());
}
NMS.callKnockbackEvent(npc, strength, dx, dz, (evt) -> super.a(entity, (float) evt.getStrength(),
evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ()));
}
@Override
@ -105,13 +107,7 @@ public class SheepController extends MobEntityController {
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null)
super.enderTeleportTo(d0, d1, d2);
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
super.enderTeleportTo(d0, d1, d2);
}
NMS.enderTeleportTo(npc, d0, d1, d2, () -> super.enderTeleportTo(d0, d1, d2));
}
@Override
@ -151,15 +147,7 @@ public class SheepController extends MobEntityController {
@Override
public boolean isLeashed() {
if (npc == null)
return super.isLeashed();
boolean protectedDefault = npc.isProtected();
if (!protectedDefault || !npc.data().get(NPC.Metadata.LEASH_PROTECTED, protectedDefault))
return super.isLeashed();
if (super.isLeashed()) {
unleash(true, false); // clearLeash with client update
}
return false; // shouldLeash
return NMS.isLeashed(npc, super::isLeashed, () -> unleash(true, false));
}
@Override

Some files were not shown because too many files have changed in this diff Show More