Fix entity speeds, targeting

This commit is contained in:
fullwall 2013-07-03 17:24:00 +08:00
parent fe1956a5fa
commit ea85682d67
5 changed files with 12 additions and 16 deletions

Binary file not shown.

View File

@ -54,8 +54,7 @@
<artifactId>craftbukkit</artifactId> <artifactId>craftbukkit</artifactId>
<version>${craftbukkit.version}</version> <version>${craftbukkit.version}</version>
<type>jar</type> <type>jar</type>
<scope>system</scope> <scope>provided</scope>
<systemPath>${basedir}/cb-fullwall.jar</systemPath>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.citizensnpcs</groupId> <groupId>net.citizensnpcs</groupId>
@ -126,12 +125,6 @@
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version> <version>2.3.2</version>
<configuration>
<excludes>
<exclude>net.minecraft.server.*</exclude>
<exclude>org.bukkit.craftbukkit.*</exclude>
</excludes>
</configuration>
</plugin> </plugin>
<plugin> <plugin>

View File

@ -85,7 +85,6 @@ public class CitizensNavigator implements Navigator, Runnable {
} }
public void load(DataKey root) { public void load(DataKey root) {
defaultParams.baseSpeed((float) root.getDouble("speed", UNINITIALISED_SPEED));
defaultParams.range((float) root.getDouble("pathfindingrange", Setting.DEFAULT_PATHFINDING_RANGE.asFloat())); defaultParams.range((float) root.getDouble("pathfindingrange", Setting.DEFAULT_PATHFINDING_RANGE.asFloat()));
defaultParams.stationaryTicks(root.getInt("stationaryticks", Setting.DEFAULT_STATIONARY_TICKS.asInt())); defaultParams.stationaryTicks(root.getInt("stationaryticks", Setting.DEFAULT_STATIONARY_TICKS.asInt()));
defaultParams.speedModifier((float) root.getDouble("speedmodifier", 1F)); defaultParams.speedModifier((float) root.getDouble("speedmodifier", 1F));
@ -127,7 +126,6 @@ public class CitizensNavigator implements Navigator, Runnable {
} }
public void save(DataKey root) { public void save(DataKey root) {
root.setDouble("speed", defaultParams.baseSpeed());
root.setDouble("pathfindingrange", defaultParams.range()); root.setDouble("pathfindingrange", defaultParams.range());
root.setInt("stationaryticks", defaultParams.stationaryTicks()); root.setInt("stationaryticks", defaultParams.stationaryTicks());
root.setDouble("speedmodifier", defaultParams.speedModifier()); root.setDouble("speedmodifier", defaultParams.speedModifier());

View File

@ -154,9 +154,9 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
} }
private class NavigationFieldWrapper implements TargetNavigator { private class NavigationFieldWrapper implements TargetNavigator {
float e;
boolean j = true, k, l, m; boolean j = true, k, l, m;
private final Navigation navigation; private final Navigation navigation;
float speed;
private NavigationFieldWrapper(Navigation navigation) { private NavigationFieldWrapper(Navigation navigation) {
this.navigation = navigation; this.navigation = navigation;
@ -164,18 +164,18 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
this.l = navigation.a(); this.l = navigation.a();
try { try {
if (NAV_E != null) if (NAV_E != null)
e = (float) ((AttributeInstance) NAV_E.get(navigation)).e(); speed = (float) ((AttributeInstance) NAV_E.get(navigation)).e();
if (NAV_J != null) if (NAV_J != null)
j = NAV_J.getBoolean(navigation); j = NAV_J.getBoolean(navigation);
if (NAV_M != null) if (NAV_M != null)
m = NAV_M.getBoolean(navigation); m = NAV_M.getBoolean(navigation);
} catch (Exception ex) { } catch (Exception ex) {
e = parameters.speed(); speed = parameters.speed();
} }
} }
public PathEntity findPath(Entity from, Entity to) { public PathEntity findPath(Entity from, Entity to) {
return handle.world.findPath(from, to, e, j, k, l, m); return handle.world.findPath(from, to, speed, j, k, l, m);
} }
@Override @Override

View File

@ -12,6 +12,7 @@ import java.util.WeakHashMap;
import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.util.Messaging; import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.npc.entity.EntityHumanNPC; import net.citizensnpcs.npc.entity.EntityHumanNPC;
import net.minecraft.server.v1_6_R1.AttributeInstance;
import net.minecraft.server.v1_6_R1.ControllerJump; import net.minecraft.server.v1_6_R1.ControllerJump;
import net.minecraft.server.v1_6_R1.DamageSource; import net.minecraft.server.v1_6_R1.DamageSource;
import net.minecraft.server.v1_6_R1.EnchantmentManager; import net.minecraft.server.v1_6_R1.EnchantmentManager;
@ -62,7 +63,8 @@ public class NMS {
} }
public static void attack(EntityLiving handle, Entity target) { public static void attack(EntityLiving handle, Entity target) {
float damage = (float) handle.a(GenericAttributes.e).e(); AttributeInstance attribute = handle.a(GenericAttributes.e);
float damage = (float) (attribute == null ? 1D : attribute.e());
if (handle.hasEffect(MobEffectList.INCREASE_DAMAGE)) { if (handle.hasEffect(MobEffectList.INCREASE_DAMAGE)) {
damage += 3 << handle.getEffect(MobEffectList.INCREASE_DAMAGE).getAmplifier(); damage += 3 << handle.getEffect(MobEffectList.INCREASE_DAMAGE).getAmplifier();
@ -143,7 +145,10 @@ public class NMS {
public static float getSpeedFor(NPC npc) { public static float getSpeedFor(NPC npc) {
if (!npc.isSpawned()) if (!npc.isSpawned())
return DEFAULT_SPEED; return DEFAULT_SPEED;
return (float) NMS.getHandle(npc.getBukkitEntity()).a(GenericAttributes.d).b(); // this is correct, but too slow. TODO: investigate
// return (float)
// NMS.getHandle(npc.getBukkitEntity()).a(GenericAttributes.d).b();
return DEFAULT_SPEED;
} }
public static boolean inWater(LivingEntity entity) { public static boolean inWater(LivingEntity entity) {