mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-09-28 15:17:43 +02:00
Fix entity speeds, targeting
This commit is contained in:
parent
fe1956a5fa
commit
ea85682d67
BIN
cb-fullwall.jar
BIN
cb-fullwall.jar
Binary file not shown.
9
pom.xml
9
pom.xml
@ -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>
|
||||||
|
@ -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());
|
||||||
|
@ -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
|
||||||
|
@ -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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user