Update for 1.4

This commit is contained in:
fullwall 2012-10-28 12:37:37 +08:00
parent 85c0a67759
commit 61caf6d9ef
36 changed files with 483 additions and 147 deletions

View File

@ -403,5 +403,5 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
Thread.currentThread().setContextClassLoader(contextClassLoader);
}
private static final String COMPATIBLE_MC_VERSION = "1.3";
private static final String COMPATIBLE_MC_VERSION = "1.4";
}

View File

@ -9,6 +9,7 @@ import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.npc.NPCRegistry;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.entity.CitizensBatNPC;
import net.citizensnpcs.npc.entity.CitizensBlazeNPC;
import net.citizensnpcs.npc.entity.CitizensCaveSpiderNPC;
import net.citizensnpcs.npc.entity.CitizensChickenNPC;
@ -33,6 +34,8 @@ import net.citizensnpcs.npc.entity.CitizensSnowmanNPC;
import net.citizensnpcs.npc.entity.CitizensSpiderNPC;
import net.citizensnpcs.npc.entity.CitizensSquidNPC;
import net.citizensnpcs.npc.entity.CitizensVillagerNPC;
import net.citizensnpcs.npc.entity.CitizensWitchNPC;
import net.citizensnpcs.npc.entity.CitizensWitherNPC;
import net.citizensnpcs.npc.entity.CitizensWolfNPC;
import net.citizensnpcs.npc.entity.CitizensZombieNPC;
import net.citizensnpcs.util.ByIdArray;
@ -50,6 +53,7 @@ public class CitizensNPCRegistry implements NPCRegistry {
public CitizensNPCRegistry(NPCDataStore store) {
saves = store;
types.put(EntityType.BAT, CitizensBatNPC.class);
types.put(EntityType.BLAZE, CitizensBlazeNPC.class);
types.put(EntityType.CAVE_SPIDER, CitizensCaveSpiderNPC.class);
types.put(EntityType.CHICKEN, CitizensChickenNPC.class);
@ -75,6 +79,8 @@ public class CitizensNPCRegistry implements NPCRegistry {
types.put(EntityType.SQUID, CitizensSquidNPC.class);
types.put(EntityType.VILLAGER, CitizensVillagerNPC.class);
types.put(EntityType.WOLF, CitizensWolfNPC.class);
types.put(EntityType.WITCH, CitizensWitchNPC.class);
types.put(EntityType.WITHER, CitizensWitherNPC.class);
types.put(EntityType.ZOMBIE, CitizensZombieNPC.class);
}

View File

@ -0,0 +1,115 @@
package net.citizensnpcs.npc.entity;
import net.citizensnpcs.api.event.NPCPushEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.npc.CitizensMobNPC;
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.EntityBat;
import net.minecraft.server.World;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftBat;
import org.bukkit.entity.Bat;
import org.bukkit.entity.Entity;
import org.bukkit.util.Vector;
public class CitizensBatNPC extends CitizensMobNPC {
public CitizensBatNPC(int id, String name) {
super(id, name, EntityBatNPC.class);
}
@Override
public Bat getBukkitEntity() {
return (Bat) super.getBukkitEntity();
}
public static class BatNPC extends CraftBat implements NPCHolder {
private final CitizensNPC npc;
public BatNPC(EntityBatNPC entity) {
super((CraftServer) Bukkit.getServer(), entity);
this.npc = entity.npc;
}
@Override
public NPC getNPC() {
return npc;
}
}
public static class EntityBatNPC extends EntityBat implements NPCHolder {
private final CitizensNPC npc;
public EntityBatNPC(World world) {
this(world, null);
}
public EntityBatNPC(World world, NPC npc) {
super(world);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMS.clearGoals(goalSelector, targetSelector);
}
}
@Override
public void bi() {
super.bi();
if (npc != null)
npc.update();
}
@Override
public void j_() {
if (npc == null)
super.j_();
}
@Override
public void collide(net.minecraft.server.Entity entity) {
// this method is called by both the entities involved - cancelling
// it will not stop the NPC from moving.
super.collide(entity);
if (npc != null)
Util.callCollisionEvent(npc, entity);
}
@Override
public void g(double x, double y, double z) {
if (npc == null) {
super.g(x, y, z);
return;
}
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
super.g(x, y, z);
return;
}
Vector vector = new Vector(x, y, z);
NPCPushEvent event = Util.callPushEvent(npc, vector);
if (!event.isCancelled()) {
vector = event.getCollisionVector();
super.g(vector.getX(), vector.getY(), vector.getZ());
}
// when another entity collides, this method is called to push the
// NPC so we prevent it from doing anything if the event is
// cancelled.
}
@Override
public Entity getBukkitEntity() {
if (bukkitEntity == null && npc != null)
bukkitEntity = new BatNPC(this);
return super.getBukkitEntity();
}
@Override
public NPC getNPC() {
return npc;
}
}
}

View File

@ -58,18 +58,18 @@ public class CitizensBlazeNPC extends CitizensMobNPC {
}
@Override
public void bb() {
public void bh() {
if (npc == null)
super.bb();
// check despawn method, we only want to despawn on chunk unload.
}
@Override
public void be() {
public void bk() {
if (npc != null)
npc.update();
else
super.be();
super.bk();
}
@Override

View File

@ -57,22 +57,23 @@ public class CitizensCaveSpiderNPC extends CitizensMobNPC {
}
@Override
public void bb() {
public void bh() {
if (npc == null)
super.bb();
super.bh();
// check despawn method, we only want to despawn on chunk unload.
}
@Override
public void bc() {
super.bc();
npc.update();
public void bi() {
super.bi();
if (npc != null)
npc.update();
}
@Override
public void be() {
public void bk() {
if (npc == null)
super.be();
super.bk();
else {
NMS.updateAI(this);
npc.update();

View File

@ -18,7 +18,6 @@ import org.bukkit.entity.Entity;
import org.bukkit.util.Vector;
public class CitizensChickenNPC extends CitizensMobNPC {
public CitizensChickenNPC(int id, String name) {
super(id, name, EntityChickenNPC.class);
}
@ -58,8 +57,8 @@ public class CitizensChickenNPC extends CitizensMobNPC {
}
@Override
public void bc() {
super.bc();
public void bi() {
super.bi();
if (npc != null)
npc.update();
}

View File

@ -58,8 +58,8 @@ public class CitizensCowNPC extends CitizensMobNPC {
}
@Override
public void bc() {
super.bc();
public void bi() {
super.bi();
if (npc != null)
npc.update();
}

View File

@ -65,15 +65,15 @@ public class CitizensCreeperNPC extends CitizensMobNPC {
}
@Override
public void bb() {
public void bh() {
if (npc == null)
super.bb();
super.bh();
// check despawn method, we only want to despawn on chunk unload.
}
@Override
public void bc() {
super.bc();
public void bi() {
super.bi();
if (npc != null)
npc.update();
}

View File

@ -54,16 +54,16 @@ public class CitizensEnderDragonNPC extends CitizensMobNPC {
}
@Override
public void bb() {
public void bh() {
if (npc == null)
super.bb();
super.bh();
// check despawn method, we only want to despawn on chunk unload.
}
@Override
public void be() {
public void bk() {
if (npc == null)
super.be();
super.bk();
}
@Override
@ -76,11 +76,11 @@ public class CitizensEnderDragonNPC extends CitizensMobNPC {
}
@Override
public void d() {
public void c() {
if (npc != null)
npc.update();
else
super.d();
super.c();
}
@Override

View File

@ -91,23 +91,23 @@ public class CitizensEndermanNPC extends CitizensMobNPC implements Equipable {
}
@Override
public void bb() {
public void bh() {
if (npc == null)
super.bb();
super.bh();
// check despawn method, we only want to despawn on chunk unload.
}
@Override
public void bc() {
super.bc();
public void bi() {
super.bi();
if (npc != null)
npc.update();
}
@Override
public void be() {
public void bk() {
if (npc == null)
super.be();
super.bk();
else {
NMS.updateAI(this);
npc.update();
@ -124,9 +124,9 @@ public class CitizensEndermanNPC extends CitizensMobNPC implements Equipable {
}
@Override
public void d() {
public void c() {
if (npc == null)
super.d();
super.c();
else {
NMS.updateAI(this);
npc.update();

View File

@ -44,18 +44,18 @@ public class CitizensGhastNPC extends CitizensMobNPC {
}
@Override
public void bb() {
public void bh() {
if (npc == null)
super.bb();
super.bh();
// check despawn method, we only want to despawn on chunk unload.
}
@Override
public void be() {
public void bk() {
if (npc != null)
npc.update();
else
super.be();
super.bk();
}
@Override

View File

@ -40,16 +40,16 @@ public class CitizensGiantNPC extends CitizensMobNPC {
}
@Override
public void bb() {
public void bh() {
if (npc == null)
super.bb();
super.bh();
// check despawn method, we only want to despawn on chunk unload.
}
@Override
public void be() {
public void bk() {
if (npc == null)
super.be();
super.bk();
else
npc.update();
}

View File

@ -34,7 +34,7 @@ public class CitizensHumanNPC extends CitizensNPC implements Equipable {
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
@Override
public void run() {
handle.as = loc.getYaw() % 360;
handle.ay = loc.getYaw() % 360;
// set the head yaw in another tick - if done immediately,
// minecraft will not update it.
boolean removeFromPlayerList = Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean();

View File

@ -40,15 +40,15 @@ public class CitizensIronGolemNPC extends CitizensMobNPC {
}
@Override
public void bb() {
public void bh() {
if (npc == null)
super.bb();
super.bh();
// check despawn method, we only want to despawn on chunk unload.
}
@Override
public void bc() {
super.bc();
public void bi() {
super.bi();
if (npc != null)
npc.update();
}

View File

@ -45,23 +45,23 @@ public class CitizensMagmaCubeNPC extends CitizensMobNPC {
}
@Override
public void bb() {
public void bh() {
if (npc == null)
super.bb();
super.bh();
// check despawn method, we only want to despawn on chunk unload.
}
@Override
public void bc() {
super.bc();
public void bi() {
super.bi();
if (npc != null)
npc.update();
}
@Override
public void be() {
public void bk() {
if (npc == null)
super.be();
super.bk();
else {
NMS.updateAI(this);
npc.update();

View File

@ -44,8 +44,8 @@ public class CitizensMushroomCowNPC extends CitizensMobNPC {
}
@Override
public void bc() {
super.bc();
public void bi() {
super.bi();
if (npc != null)
npc.update();
}

View File

@ -44,15 +44,15 @@ public class CitizensOcelotNPC extends CitizensMobNPC {
}
@Override
public void bb() {
public void bh() {
if (npc == null)
super.bb();
super.bh();
// check despawn method, we only want to despawn on chunk unload.
}
@Override
public void bc() {
super.bc();
public void bi() {
super.bi();
if (npc != null)
npc.update();
}

View File

@ -74,8 +74,8 @@ public class CitizensPigNPC extends CitizensMobNPC implements Equipable {
}
@Override
public void bc() {
super.bc();
public void bi() {
super.bi();
if (npc != null)
npc.update();
}

View File

@ -44,23 +44,23 @@ public class CitizensPigZombieNPC extends CitizensMobNPC {
}
@Override
public void bb() {
public void bh() {
if (npc == null)
super.bb();
super.bh();
// check despawn method, we only want to despawn on chunk unload.
}
@Override
public void bc() {
super.bc();
public void bi() {
super.bi();
if (npc != null)
npc.update();
}
@Override
public void be() {
public void bk() {
if (npc == null)
super.be();
super.bk();
else {
NMS.updateAI(this);
npc.update();

View File

@ -73,8 +73,8 @@ public class CitizensSheepNPC extends CitizensMobNPC implements Equipable {
}
@Override
public void bc() {
super.bc();
public void bi() {
super.bi();
if (npc != null)
npc.update();
}

View File

@ -44,23 +44,23 @@ public class CitizensSilverfishNPC extends CitizensMobNPC {
}
@Override
public void bb() {
public void bh() {
if (npc == null)
super.bb();
super.bh();
// check despawn method, we only want to despawn on chunk unload.
}
@Override
public void bc() {
super.bc();
public void bi() {
super.bi();
if (npc != null)
npc.update();
}
@Override
public void be() {
public void bk() {
if (npc == null)
super.be();
super.bk();
else {
NMS.updateAI(this);
npc.update();

View File

@ -44,15 +44,15 @@ public class CitizensSkeletonNPC extends CitizensMobNPC {
}
@Override
public void bb() {
public void bh() {
if (npc == null)
super.bb();
super.bh();
// check despawn method, we only want to despawn on chunk unload.
}
@Override
public void bc() {
super.bc();
public void bi() {
super.bi();
if (npc != null)
npc.update();
}

View File

@ -45,23 +45,23 @@ public class CitizensSlimeNPC extends CitizensMobNPC {
}
@Override
public void bb() {
public void bh() {
if (npc == null)
super.bb();
super.bh();
// check despawn method, we only want to despawn on chunk unload.
}
@Override
public void bc() {
super.bc();
public void bi() {
super.bi();
if (npc != null)
npc.update();
}
@Override
public void be() {
public void bk() {
if (npc == null)
super.be();
super.bk();
else {
npc.update();
NMS.updateAI(this);

View File

@ -40,15 +40,15 @@ public class CitizensSnowmanNPC extends CitizensMobNPC {
}
@Override
public void bb() {
public void bh() {
if (npc == null)
super.bb();
super.bh();
// check despawn method, we only want to despawn on chunk unload.
}
@Override
public void bc() {
super.bc();
public void bi() {
super.bi();
if (npc != null)
npc.update();
}

View File

@ -43,23 +43,23 @@ public class CitizensSpiderNPC extends CitizensMobNPC {
}
@Override
public void bb() {
public void bh() {
if (npc == null)
super.bb();
super.bh();
// check despawn method, we only want to despawn on chunk unload.
}
@Override
public void bc() {
super.bc();
public void bi() {
super.bi();
if (npc != null)
npc.update();
}
@Override
public void be() {
public void bk() {
if (npc == null)
super.be();
super.bk();
else {
NMS.updateAI(this);
npc.update();

View File

@ -44,18 +44,18 @@ public class CitizensSquidNPC extends CitizensMobNPC {
}
@Override
public void bb() {
public void bh() {
if (npc == null)
super.bb();
super.bh();
// check despawn method, we only want to despawn on chunk unload.
}
@Override
public void be() {
public void bk() {
if (npc != null)
npc.update();
else
super.be();
super.bk();
}
@Override

View File

@ -45,15 +45,15 @@ public class CitizensVillagerNPC extends CitizensMobNPC {
}
@Override
public void bb() {
public void bh() {
if (npc == null)
super.bb();
super.bh();
// check despawn method, we only want to despawn on chunk unload.
}
@Override
public void bc() {
super.bc();
public void bi() {
super.bi();
if (npc != null)
npc.update();
}

View File

@ -0,0 +1,109 @@
package net.citizensnpcs.npc.entity;
import net.citizensnpcs.api.event.NPCPushEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.npc.CitizensMobNPC;
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.EntityWitch;
import net.minecraft.server.World;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftWitch;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Witch;
import org.bukkit.util.Vector;
public class CitizensWitchNPC extends CitizensMobNPC {
public CitizensWitchNPC(int id, String name) {
super(id, name, EntityWitchNPC.class);
}
@Override
public Witch getBukkitEntity() {
return (Witch) super.getBukkitEntity();
}
public static class WitchNPC extends CraftWitch implements NPCHolder {
private final CitizensNPC npc;
public WitchNPC(EntityWitchNPC entity) {
super((CraftServer) Bukkit.getServer(), entity);
this.npc = entity.npc;
}
@Override
public NPC getNPC() {
return npc;
}
}
public static class EntityWitchNPC extends EntityWitch implements NPCHolder {
private final CitizensNPC npc;
public EntityWitchNPC(World world) {
this(world, null);
}
public EntityWitchNPC(World world, NPC npc) {
super(world);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMS.clearGoals(goalSelector, targetSelector);
}
}
@Override
public void bi() {
super.bi();
if (npc != null)
npc.update();
}
@Override
public void collide(net.minecraft.server.Entity entity) {
// this method is called by both the entities involved - cancelling
// it will not stop the NPC from moving.
super.collide(entity);
if (npc != null)
Util.callCollisionEvent(npc, entity);
}
@Override
public void g(double x, double y, double z) {
if (npc == null) {
super.g(x, y, z);
return;
}
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
super.g(x, y, z);
return;
}
Vector vector = new Vector(x, y, z);
NPCPushEvent event = Util.callPushEvent(npc, vector);
if (!event.isCancelled()) {
vector = event.getCollisionVector();
super.g(vector.getX(), vector.getY(), vector.getZ());
}
// when another entity collides, this method is called to push the
// NPC so we prevent it from doing anything if the event is
// cancelled.
}
@Override
public Entity getBukkitEntity() {
if (bukkitEntity == null && npc != null)
bukkitEntity = new WitchNPC(this);
return super.getBukkitEntity();
}
@Override
public NPC getNPC() {
return npc;
}
}
}

View File

@ -0,0 +1,115 @@
package net.citizensnpcs.npc.entity;
import net.citizensnpcs.api.event.NPCPushEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.npc.CitizensMobNPC;
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.EntityWither;
import net.minecraft.server.World;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftWither;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Wither;
import org.bukkit.util.Vector;
public class CitizensWitherNPC extends CitizensMobNPC {
public CitizensWitherNPC(int id, String name) {
super(id, name, EntityWitherNPC.class);
}
@Override
public Wither getBukkitEntity() {
return (Wither) super.getBukkitEntity();
}
public static class WitherNPC extends CraftWither implements NPCHolder {
private final CitizensNPC npc;
public WitherNPC(EntityWitherNPC entity) {
super((CraftServer) Bukkit.getServer(), entity);
this.npc = entity.npc;
}
@Override
public NPC getNPC() {
return npc;
}
}
public static class EntityWitherNPC extends EntityWither implements NPCHolder {
private final CitizensNPC npc;
public EntityWitherNPC(World world) {
this(world, null);
}
public EntityWitherNPC(World world, NPC npc) {
super(world);
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMS.clearGoals(goalSelector, targetSelector);
}
}
@Override
public void bi() {
super.bi();
if (npc != null)
npc.update();
}
@Override
public void collide(net.minecraft.server.Entity entity) {
// this method is called by both the entities involved - cancelling
// it will not stop the NPC from moving.
super.collide(entity);
if (npc != null)
Util.callCollisionEvent(npc, entity);
}
@Override
public void g(double x, double y, double z) {
if (npc == null) {
super.g(x, y, z);
return;
}
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
super.g(x, y, z);
return;
}
Vector vector = new Vector(x, y, z);
NPCPushEvent event = Util.callPushEvent(npc, vector);
if (!event.isCancelled()) {
vector = event.getCollisionVector();
super.g(vector.getX(), vector.getY(), vector.getZ());
}
// when another entity collides, this method is called to push the
// NPC so we prevent it from doing anything if the event is
// cancelled.
}
@Override
public Entity getBukkitEntity() {
if (bukkitEntity == null && npc != null)
bukkitEntity = new WitherNPC(this);
return super.getBukkitEntity();
}
@Override
public NPC getNPC() {
return npc;
}
@Override
public void c() {
if (npc == null)
super.c();
}
}
}

View File

@ -44,15 +44,15 @@ public class CitizensWolfNPC extends CitizensMobNPC {
}
@Override
public void bb() {
public void bh() {
if (npc == null)
super.bb();
super.bh();
// check despawn method, we only want to despawn on chunk unload.
}
@Override
public void bc() {
super.bc();
public void bi() {
super.bi();
if (npc != null)
npc.update();
}

View File

@ -44,15 +44,15 @@ public class CitizensZombieNPC extends CitizensMobNPC {
}
@Override
public void bb() {
public void bh() {
if (npc == null)
super.bb();
super.bh();
// check despawn method, we only want to despawn on chunk unload.
}
@Override
public void bc() {
super.bc();
public void bi() {
super.bi();
if (npc != null)
npc.update();
}

View File

@ -85,8 +85,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
}
@Override
public void h_() {
super.h_();
public void j_() {
super.j_();
if (npc == null)
return;
Navigation navigation = getNavigation();
@ -114,7 +114,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
public boolean a() {
return false;
}
}, server.E().getPrivate());
}, server.F().getPrivate());
netServerHandler = new EmptyNetHandler(minecraftServer, netMgr, this);
netMgr.a(netServerHandler);
} catch (IOException e) {
@ -138,28 +138,28 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
e(npc.getNavigator().getDefaultParameters().speed());
// taken from EntityLiving update method
if (bu) {
if (bG) {
/* boolean inLiquid = H() || J();
if (inLiquid) {
motY += 0.04;
} else (handled elsewhere)*/
if (onGround && bE == 0) {
if (onGround && bW == 0) {
// this.aZ(); - this doesn't jump high enough
motY = 0.6;
bE = 10;
bW = 10;
}
} else
bE = 0;
bW = 0;
br *= 0.98F;
bs *= 0.98F;
bt *= 0.9F;
bD *= 0.98F;
bE *= 0.98F;
bF *= 0.9F;
float prev = aG;
aG *= bs() * npc.getNavigator().getDefaultParameters().speed();
e(br, bs); // movement method
aG = prev;
as = yaw; // update head yaw to match entity yaw
float prev = aM;
aM *= bs() * npc.getNavigator().getDefaultParameters().speed();
e(bD, bE); // movement method
aM = prev;
ay = yaw; // update head yaw to match entity yaw
}
public static class PlayerNPC extends CraftPlayer implements NPCHolder {

View File

@ -249,8 +249,10 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
.newEnumMap(EntityType.class);
static {
controllerTypes.put(EntityType.BAT, AirController.class);
controllerTypes.put(EntityType.BLAZE, AirController.class);
controllerTypes.put(EntityType.ENDER_DRAGON, AirController.class);
controllerTypes.put(EntityType.GHAST, AirController.class);
controllerTypes.put(EntityType.WITHER, AirController.class);
}
}

View File

@ -15,7 +15,7 @@ public class EntityEnderCrystalMarker extends EntityEnderCrystal {
}
@Override
public void h_() {
public void j_() {
}
@Override

View File

@ -33,8 +33,6 @@ public class NMS {
// util class
}
private static Field DAMAGE_FIELD;
private static final float DEFAULT_SPEED = 0.4F;
private static Map<Class<? extends Entity>, Integer> ENTITY_CLASS_TO_INT;
private static final Map<Class<? extends Entity>, Constructor<? extends Entity>> ENTITY_CONSTRUCTOR_CACHE = new WeakHashMap<Class<? extends Entity>, Constructor<? extends Entity>>();
@ -61,7 +59,7 @@ public class NMS {
}
public static void attack(EntityLiving handle, EntityLiving target) {
int damage = getDamage(handle);
int damage = handle instanceof EntityMonster ? ((EntityMonster) handle).c((Entity) target) : 2;
if (handle.hasEffect(MobEffectList.INCREASE_DAMAGE)) {
damage += 3 << handle.getEffect(MobEffectList.INCREASE_DAMAGE).getAmplifier();
@ -99,16 +97,6 @@ public class NMS {
return constructor;
}
private static int getDamage(EntityLiving handle) {
if (DAMAGE_FIELD == null)
return 2;
try {
return DAMAGE_FIELD.getInt(handle);
} catch (Exception e) {
}
return 2;
}
private static Field getField(Class<?> clazz, String field) {
Field f = null;
try {
@ -144,11 +132,11 @@ public class NMS {
}
public static void look(ControllerLook controllerLook, EntityLiving handle, EntityLiving target) {
controllerLook.a(target, 10.0F, handle.bf());
controllerLook.a(target, 10.0F, handle.bm());
}
public static void look(EntityLiving handle, float yaw, float pitch) {
handle.yaw = handle.as = yaw;
handle.yaw = handle.ay = yaw;
handle.pitch = pitch;
}
@ -266,12 +254,11 @@ public class NMS {
MOVEMENT_SPEEDS.put(EntityType.PLAYER, 1F);
MOVEMENT_SPEEDS.put(EntityType.VILLAGER, 0.3F);
LAND_SPEED_MODIFIER_FIELD = getField(EntityLiving.class, "bB");
SPEED_FIELD = getField(EntityLiving.class, "bw");
LAND_SPEED_MODIFIER_FIELD = getField(EntityLiving.class, "bQ");
SPEED_FIELD = getField(EntityLiving.class, "bI");
NAVIGATION_WORLD_FIELD = getField(Navigation.class, "b");
PATHFINDING_RANGE = getField(Navigation.class, "e");
GOAL_FIELD = getField(PathfinderGoalSelector.class, "a");
DAMAGE_FIELD = getField(EntityMonster.class, "damage");
try {
Field field = getField(EntityTypes.class, "d");

View File

@ -32,7 +32,8 @@ public enum PlayerAnimation {
@Override
protected void playAnimation(EntityPlayer player, int radius) {
player.getBukkitEntity().setSneaking(true);
sendPacketNearby(new Packet40EntityMetadata(player.id, player.getDataWatcher()), player, radius);
sendPacketNearby(new Packet40EntityMetadata(player.id, player.getDataWatcher(), true), player,
radius);
}
},
STOP_SLEEPING {
@ -46,7 +47,8 @@ public enum PlayerAnimation {
@Override
protected void playAnimation(EntityPlayer player, int radius) {
player.getBukkitEntity().setSneaking(false);
sendPacketNearby(new Packet40EntityMetadata(player.id, player.getDataWatcher()), player, radius);
sendPacketNearby(new Packet40EntityMetadata(player.id, player.getDataWatcher(), true), player,
radius);
}
},
SWING_ARM {