From d2e7064d44c594467f79387c3893715c8ac1f968 Mon Sep 17 00:00:00 2001 From: fullwall Date: Thu, 1 Mar 2012 23:12:47 +0800 Subject: [PATCH] Update to 1.2 --- pom.xml | 4 +-- .../net/citizensnpcs/npc/ai/MoveStrategy.java | 27 ++++++++++++++++--- .../citizensnpcs/npc/ai/TargetStrategy.java | 8 +++--- .../npc/entity/CitizensBlazeNPC.java | 3 +-- .../npc/entity/CitizensCaveSpiderNPC.java | 2 +- .../npc/entity/CitizensChickenNPC.java | 2 +- .../npc/entity/CitizensCowNPC.java | 2 +- .../npc/entity/CitizensCreeperNPC.java | 2 +- .../npc/entity/CitizensEnderDragonNPC.java | 4 +-- .../npc/entity/CitizensEndermanNPC.java | 4 +-- .../npc/entity/CitizensGhastNPC.java | 2 +- .../npc/entity/CitizensGiantNPC.java | 2 +- .../npc/entity/CitizensMagmaCubeNPC.java | 2 +- .../npc/entity/CitizensMushroomCowNPC.java | 2 +- .../npc/entity/CitizensPigNPC.java | 2 +- .../npc/entity/CitizensPigZombieNPC.java | 2 +- .../npc/entity/CitizensSheepNPC.java | 2 +- .../npc/entity/CitizensSilverfishNPC.java | 2 +- .../npc/entity/CitizensSkeletonNPC.java | 2 +- .../npc/entity/CitizensSlimeNPC.java | 2 +- .../npc/entity/CitizensSnowmanNPC.java | 2 +- .../npc/entity/CitizensSpiderNPC.java | 2 +- .../npc/entity/CitizensSquidNPC.java | 2 +- .../npc/entity/CitizensVillagerNPC.java | 2 +- .../npc/entity/CitizensWolfNPC.java | 2 +- .../npc/entity/CitizensZombieNPC.java | 2 +- 26 files changed, 55 insertions(+), 35 deletions(-) diff --git a/pom.xml b/pom.xml index 196ffd90b..be4b722ea 100644 --- a/pom.xml +++ b/pom.xml @@ -11,8 +11,8 @@ UTF-8 - 1.1-R5-SNAPSHOT - 1.1-R5-SNAPSHOT + 1.2.2-R0-SNAPSHOT + 1.2.2-R0-SNAPSHOT 2.0-SNAPSHOT Unknown diff --git a/src/main/java/net/citizensnpcs/npc/ai/MoveStrategy.java b/src/main/java/net/citizensnpcs/npc/ai/MoveStrategy.java index 9ec1f176d..e2339c772 100644 --- a/src/main/java/net/citizensnpcs/npc/ai/MoveStrategy.java +++ b/src/main/java/net/citizensnpcs/npc/ai/MoveStrategy.java @@ -1,5 +1,6 @@ package net.citizensnpcs.npc.ai; +import java.lang.reflect.Field; import java.util.Random; import net.citizensnpcs.npc.CitizensNPC; @@ -14,6 +15,7 @@ import org.bukkit.entity.Player; public class MoveStrategy implements PathStrategy { private static final double JUMP_VELOCITY = 0.49D; + private Float cachedMotion; private final EntityLiving handle; private final PathEntity path; private final Random random = new Random(); @@ -21,7 +23,7 @@ public class MoveStrategy implements PathStrategy { public MoveStrategy(CitizensNPC handle, Location destination) { this.handle = handle.getHandle(); this.path = this.handle.world.a(this.handle, destination.getBlockX(), destination.getBlockY(), - destination.getBlockZ(), 16F); + destination.getBlockZ(), 16F, true, false, false, true); } MoveStrategy(EntityLiving handle, PathEntity path) { @@ -59,8 +61,16 @@ public class MoveStrategy implements PathStrategy { handle.yaw += getYawDifference(diffZ, diffX); if (vector.b - yHeight > 0.0D) jump(); - handle.d(handle.ar()); - handle.d(); + if (cachedMotion == null) { + try { + cachedMotion = MOTION_FIELD.getFloat(handle); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + } + handle.e(cachedMotion); // handle.walk(); if (handle.positionChanged) @@ -80,4 +90,15 @@ public class MoveStrategy implements PathStrategy { if (handle.onGround) handle.motY = JUMP_VELOCITY; } + + private static Field MOTION_FIELD; + static { + try { + MOTION_FIELD = EntityLiving.class.getDeclaredField("bb"); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } + } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/ai/TargetStrategy.java b/src/main/java/net/citizensnpcs/npc/ai/TargetStrategy.java index 1223a1cba..2ccbdf63b 100644 --- a/src/main/java/net/citizensnpcs/npc/ai/TargetStrategy.java +++ b/src/main/java/net/citizensnpcs/npc/ai/TargetStrategy.java @@ -14,7 +14,7 @@ public class TargetStrategy implements PathStrategy { private PathStrategy current = null; public TargetStrategy(CitizensNPC handle, LivingEntity target, boolean aggro) { - this.handle = (EntityLiving) handle.getHandle(); + this.handle = handle.getHandle(); this.target = ((CraftLivingEntity) target).getHandle(); this.aggro = aggro; } @@ -23,10 +23,10 @@ public class TargetStrategy implements PathStrategy { public boolean update() { if (target == null || target.dead) return true; - current = new MoveStrategy(handle, handle.world.findPath(handle, target, 16F)); + current = new MoveStrategy(handle, handle.world.findPath(handle, target, 16F, true, false, false, true)); if (aggro && canAttack()) { if (handle instanceof EntityMonster) { - ((EntityMonster) handle).d(target); + ((EntityMonster) handle).a(target); } else if (handle instanceof EntityHuman) { ((EntityHuman) handle).attack(target); } @@ -39,7 +39,7 @@ public class TargetStrategy implements PathStrategy { private boolean canAttack() { return handle.attackTicks == 0 && (handle.boundingBox.e > target.boundingBox.b && handle.boundingBox.b < target.boundingBox.e) - && distanceSquared() <= ATTACK_DISTANCE && handle.g(target); + && distanceSquared() <= ATTACK_DISTANCE && handle.h(target); } private static final double ATTACK_DISTANCE = 1.75 * 1.75; diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensBlazeNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensBlazeNPC.java index b44de4444..c0f9be134 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensBlazeNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensBlazeNPC.java @@ -2,7 +2,6 @@ package net.citizensnpcs.npc.entity; import net.citizensnpcs.npc.CitizensMobNPC; import net.citizensnpcs.npc.CitizensNPCManager; - import net.minecraft.server.EntityBlaze; import net.minecraft.server.World; @@ -26,7 +25,7 @@ public class CitizensBlazeNPC extends CitizensMobNPC { } @Override - public void m_() { + public void d_() { } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensCaveSpiderNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensCaveSpiderNPC.java index 2f74f25dc..2eddac6f5 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensCaveSpiderNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensCaveSpiderNPC.java @@ -25,7 +25,7 @@ public class CitizensCaveSpiderNPC extends CitizensMobNPC { } @Override - public void m_() { + public void d_() { } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensChickenNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensChickenNPC.java index 88bc84558..2d583be4b 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensChickenNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensChickenNPC.java @@ -25,7 +25,7 @@ public class CitizensChickenNPC extends CitizensMobNPC { } @Override - public void m_() { + public void d_() { } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensCowNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensCowNPC.java index ce4fb2a98..5e6cdf763 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensCowNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensCowNPC.java @@ -25,7 +25,7 @@ public class CitizensCowNPC extends CitizensMobNPC { } @Override - public void m_() { + public void d_() { } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensCreeperNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensCreeperNPC.java index 4c89e4237..dc3448dae 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensCreeperNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensCreeperNPC.java @@ -25,7 +25,7 @@ public class CitizensCreeperNPC extends CitizensMobNPC { } @Override - public void m_() { + public void d_() { } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensEnderDragonNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensEnderDragonNPC.java index c2f2bfba9..fd6208ea7 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensEnderDragonNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensEnderDragonNPC.java @@ -25,11 +25,11 @@ public class CitizensEnderDragonNPC extends CitizensMobNPC { } @Override - public void m_() { + public void d_() { } @Override - public void d() { + public void e() { } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensEndermanNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensEndermanNPC.java index 074cc48eb..941e918ac 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensEndermanNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensEndermanNPC.java @@ -25,11 +25,11 @@ public class CitizensEndermanNPC extends CitizensMobNPC { } @Override - public void m_() { + public void d_() { } @Override - public void d() { + public void e() { } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensGhastNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensGhastNPC.java index 05ea1bdd1..a533cafb0 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensGhastNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensGhastNPC.java @@ -25,7 +25,7 @@ public class CitizensGhastNPC extends CitizensMobNPC { } @Override - public void m_() { + public void d_() { } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensGiantNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensGiantNPC.java index 4e1f1c4ac..7ab2c1d1b 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensGiantNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensGiantNPC.java @@ -25,7 +25,7 @@ public class CitizensGiantNPC extends CitizensMobNPC { } @Override - public void m_() { + public void d_() { } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensMagmaCubeNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensMagmaCubeNPC.java index 5d08c7d08..fc5ececca 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensMagmaCubeNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensMagmaCubeNPC.java @@ -26,7 +26,7 @@ public class CitizensMagmaCubeNPC extends CitizensMobNPC { } @Override - public void m_() { + public void d_() { } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensMushroomCowNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensMushroomCowNPC.java index 9bf543a93..8daf5ec01 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensMushroomCowNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensMushroomCowNPC.java @@ -25,7 +25,7 @@ public class CitizensMushroomCowNPC extends CitizensMobNPC { } @Override - public void m_() { + public void d_() { } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensPigNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensPigNPC.java index 95e32f82b..4911bba42 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensPigNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensPigNPC.java @@ -25,7 +25,7 @@ public class CitizensPigNPC extends CitizensMobNPC { } @Override - public void m_() { + public void d_() { } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensPigZombieNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensPigZombieNPC.java index a7e3108b3..5b8a2672f 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensPigZombieNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensPigZombieNPC.java @@ -25,7 +25,7 @@ public class CitizensPigZombieNPC extends CitizensMobNPC { } @Override - public void m_() { + public void d_() { } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensSheepNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensSheepNPC.java index 27942620b..5c14201fd 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensSheepNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensSheepNPC.java @@ -25,7 +25,7 @@ public class CitizensSheepNPC extends CitizensMobNPC { } @Override - public void m_() { + public void d_() { } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensSilverfishNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensSilverfishNPC.java index e4081fef8..6c4bb385b 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensSilverfishNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensSilverfishNPC.java @@ -25,7 +25,7 @@ public class CitizensSilverfishNPC extends CitizensMobNPC { } @Override - public void m_() { + public void d_() { } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensSkeletonNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensSkeletonNPC.java index fa2fd028c..9ee35e266 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensSkeletonNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensSkeletonNPC.java @@ -25,7 +25,7 @@ public class CitizensSkeletonNPC extends CitizensMobNPC { } @Override - public void m_() { + public void d_() { } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensSlimeNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensSlimeNPC.java index 79150b977..819c49785 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensSlimeNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensSlimeNPC.java @@ -26,7 +26,7 @@ public class CitizensSlimeNPC extends CitizensMobNPC { } @Override - public void m_() { + public void d_() { } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensSnowmanNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensSnowmanNPC.java index ef96508b3..6c23ee97d 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensSnowmanNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensSnowmanNPC.java @@ -25,7 +25,7 @@ public class CitizensSnowmanNPC extends CitizensMobNPC { } @Override - public void m_() { + public void d_() { } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensSpiderNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensSpiderNPC.java index 11399a833..db6012ec1 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensSpiderNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensSpiderNPC.java @@ -25,7 +25,7 @@ public class CitizensSpiderNPC extends CitizensMobNPC { } @Override - public void m_() { + public void d_() { } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensSquidNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensSquidNPC.java index becee447f..df98685db 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensSquidNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensSquidNPC.java @@ -25,7 +25,7 @@ public class CitizensSquidNPC extends CitizensMobNPC { } @Override - public void m_() { + public void d_() { } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensVillagerNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensVillagerNPC.java index dd74b0c19..8835608bc 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensVillagerNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensVillagerNPC.java @@ -25,7 +25,7 @@ public class CitizensVillagerNPC extends CitizensMobNPC { } @Override - public void m_() { + public void d_() { } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensWolfNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensWolfNPC.java index a230a38d8..991db66dd 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensWolfNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensWolfNPC.java @@ -25,7 +25,7 @@ public class CitizensWolfNPC extends CitizensMobNPC { } @Override - public void m_() { + public void d_() { } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensZombieNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensZombieNPC.java index 330de331d..427cac385 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensZombieNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensZombieNPC.java @@ -25,7 +25,7 @@ public class CitizensZombieNPC extends CitizensMobNPC { } @Override - public void m_() { + public void d_() { } } } \ No newline at end of file