mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-02 21:41:43 +01:00
Update to 1.2
This commit is contained in:
parent
fcc857d398
commit
477d223aca
4
pom.xml
4
pom.xml
@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<bukkit.version>1.1-R5-SNAPSHOT</bukkit.version>
|
<bukkit.version>1.2.2-R0-SNAPSHOT</bukkit.version>
|
||||||
<craftbukkit.version>1.1-R5-SNAPSHOT</craftbukkit.version>
|
<craftbukkit.version>1.2.2-R0-SNAPSHOT</craftbukkit.version>
|
||||||
<citizensapi.version>2.0-SNAPSHOT</citizensapi.version>
|
<citizensapi.version>2.0-SNAPSHOT</citizensapi.version>
|
||||||
<build.number>Unknown</build.number>
|
<build.number>Unknown</build.number>
|
||||||
</properties>
|
</properties>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.citizensnpcs.npc.ai;
|
package net.citizensnpcs.npc.ai;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
@ -14,6 +15,7 @@ import org.bukkit.entity.Player;
|
|||||||
public class MoveStrategy implements PathStrategy {
|
public class MoveStrategy implements PathStrategy {
|
||||||
private static final double JUMP_VELOCITY = 0.49D;
|
private static final double JUMP_VELOCITY = 0.49D;
|
||||||
|
|
||||||
|
private Float cachedMotion;
|
||||||
private final EntityLiving handle;
|
private final EntityLiving handle;
|
||||||
private final PathEntity path;
|
private final PathEntity path;
|
||||||
private final Random random = new Random();
|
private final Random random = new Random();
|
||||||
@ -21,7 +23,7 @@ public class MoveStrategy implements PathStrategy {
|
|||||||
public MoveStrategy(CitizensNPC handle, Location destination) {
|
public MoveStrategy(CitizensNPC handle, Location destination) {
|
||||||
this.handle = handle.getHandle();
|
this.handle = handle.getHandle();
|
||||||
this.path = this.handle.world.a(this.handle, destination.getBlockX(), destination.getBlockY(),
|
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) {
|
MoveStrategy(EntityLiving handle, PathEntity path) {
|
||||||
@ -59,8 +61,16 @@ public class MoveStrategy implements PathStrategy {
|
|||||||
handle.yaw += getYawDifference(diffZ, diffX);
|
handle.yaw += getYawDifference(diffZ, diffX);
|
||||||
if (vector.b - yHeight > 0.0D)
|
if (vector.b - yHeight > 0.0D)
|
||||||
jump();
|
jump();
|
||||||
handle.d(handle.ar());
|
if (cachedMotion == null) {
|
||||||
handle.d();
|
try {
|
||||||
|
cachedMotion = MOTION_FIELD.getFloat(handle);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
handle.e(cachedMotion);
|
||||||
// handle.walk();
|
// handle.walk();
|
||||||
|
|
||||||
if (handle.positionChanged)
|
if (handle.positionChanged)
|
||||||
@ -80,4 +90,15 @@ public class MoveStrategy implements PathStrategy {
|
|||||||
if (handle.onGround)
|
if (handle.onGround)
|
||||||
handle.motY = JUMP_VELOCITY;
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -14,7 +14,7 @@ public class TargetStrategy implements PathStrategy {
|
|||||||
private PathStrategy current = null;
|
private PathStrategy current = null;
|
||||||
|
|
||||||
public TargetStrategy(CitizensNPC handle, LivingEntity target, boolean aggro) {
|
public TargetStrategy(CitizensNPC handle, LivingEntity target, boolean aggro) {
|
||||||
this.handle = (EntityLiving) handle.getHandle();
|
this.handle = handle.getHandle();
|
||||||
this.target = ((CraftLivingEntity) target).getHandle();
|
this.target = ((CraftLivingEntity) target).getHandle();
|
||||||
this.aggro = aggro;
|
this.aggro = aggro;
|
||||||
}
|
}
|
||||||
@ -23,10 +23,10 @@ public class TargetStrategy implements PathStrategy {
|
|||||||
public boolean update() {
|
public boolean update() {
|
||||||
if (target == null || target.dead)
|
if (target == null || target.dead)
|
||||||
return true;
|
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 (aggro && canAttack()) {
|
||||||
if (handle instanceof EntityMonster) {
|
if (handle instanceof EntityMonster) {
|
||||||
((EntityMonster) handle).d(target);
|
((EntityMonster) handle).a(target);
|
||||||
} else if (handle instanceof EntityHuman) {
|
} else if (handle instanceof EntityHuman) {
|
||||||
((EntityHuman) handle).attack(target);
|
((EntityHuman) handle).attack(target);
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ public class TargetStrategy implements PathStrategy {
|
|||||||
private boolean canAttack() {
|
private boolean canAttack() {
|
||||||
return handle.attackTicks == 0
|
return handle.attackTicks == 0
|
||||||
&& (handle.boundingBox.e > target.boundingBox.b && handle.boundingBox.b < target.boundingBox.e)
|
&& (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;
|
private static final double ATTACK_DISTANCE = 1.75 * 1.75;
|
||||||
|
@ -2,7 +2,6 @@ package net.citizensnpcs.npc.entity;
|
|||||||
|
|
||||||
import net.citizensnpcs.npc.CitizensMobNPC;
|
import net.citizensnpcs.npc.CitizensMobNPC;
|
||||||
import net.citizensnpcs.npc.CitizensNPCManager;
|
import net.citizensnpcs.npc.CitizensNPCManager;
|
||||||
|
|
||||||
import net.minecraft.server.EntityBlaze;
|
import net.minecraft.server.EntityBlaze;
|
||||||
import net.minecraft.server.World;
|
import net.minecraft.server.World;
|
||||||
|
|
||||||
@ -26,7 +25,7 @@ public class CitizensBlazeNPC extends CitizensMobNPC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void m_() {
|
public void d_() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ public class CitizensCaveSpiderNPC extends CitizensMobNPC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void m_() {
|
public void d_() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ public class CitizensChickenNPC extends CitizensMobNPC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void m_() {
|
public void d_() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ public class CitizensCowNPC extends CitizensMobNPC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void m_() {
|
public void d_() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ public class CitizensCreeperNPC extends CitizensMobNPC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void m_() {
|
public void d_() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,11 +25,11 @@ public class CitizensEnderDragonNPC extends CitizensMobNPC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void m_() {
|
public void d_() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void d() {
|
public void e() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,11 +25,11 @@ public class CitizensEndermanNPC extends CitizensMobNPC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void m_() {
|
public void d_() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void d() {
|
public void e() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ public class CitizensGhastNPC extends CitizensMobNPC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void m_() {
|
public void d_() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ public class CitizensGiantNPC extends CitizensMobNPC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void m_() {
|
public void d_() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -26,7 +26,7 @@ public class CitizensMagmaCubeNPC extends CitizensMobNPC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void m_() {
|
public void d_() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ public class CitizensMushroomCowNPC extends CitizensMobNPC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void m_() {
|
public void d_() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ public class CitizensPigNPC extends CitizensMobNPC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void m_() {
|
public void d_() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ public class CitizensPigZombieNPC extends CitizensMobNPC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void m_() {
|
public void d_() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ public class CitizensSheepNPC extends CitizensMobNPC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void m_() {
|
public void d_() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ public class CitizensSilverfishNPC extends CitizensMobNPC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void m_() {
|
public void d_() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ public class CitizensSkeletonNPC extends CitizensMobNPC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void m_() {
|
public void d_() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -26,7 +26,7 @@ public class CitizensSlimeNPC extends CitizensMobNPC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void m_() {
|
public void d_() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ public class CitizensSnowmanNPC extends CitizensMobNPC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void m_() {
|
public void d_() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ public class CitizensSpiderNPC extends CitizensMobNPC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void m_() {
|
public void d_() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ public class CitizensSquidNPC extends CitizensMobNPC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void m_() {
|
public void d_() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ public class CitizensVillagerNPC extends CitizensMobNPC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void m_() {
|
public void d_() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ public class CitizensWolfNPC extends CitizensMobNPC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void m_() {
|
public void d_() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ public class CitizensZombieNPC extends CitizensMobNPC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void m_() {
|
public void d_() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user