Fix entity speeds, targeting

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

Binary file not shown.

View File

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

View File

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

View File

@ -154,9 +154,9 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
}
private class NavigationFieldWrapper implements TargetNavigator {
float e;
boolean j = true, k, l, m;
private final Navigation navigation;
float speed;
private NavigationFieldWrapper(Navigation navigation) {
this.navigation = navigation;
@ -164,18 +164,18 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
this.l = navigation.a();
try {
if (NAV_E != null)
e = (float) ((AttributeInstance) NAV_E.get(navigation)).e();
speed = (float) ((AttributeInstance) NAV_E.get(navigation)).e();
if (NAV_J != null)
j = NAV_J.getBoolean(navigation);
if (NAV_M != null)
m = NAV_M.getBoolean(navigation);
} catch (Exception ex) {
e = parameters.speed();
speed = parameters.speed();
}
}
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

View File

@ -12,6 +12,7 @@ import java.util.WeakHashMap;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.util.Messaging;
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.DamageSource;
import net.minecraft.server.v1_6_R1.EnchantmentManager;
@ -62,7 +63,8 @@ public class NMS {
}
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)) {
damage += 3 << handle.getEffect(MobEffectList.INCREASE_DAMAGE).getAmplifier();
@ -143,7 +145,10 @@ public class NMS {
public static float getSpeedFor(NPC npc) {
if (!npc.isSpawned())
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) {