v4.32
+ PathfinderExecutor 工具 controllerLookAt(LivingEntity entity, Entity target) 方法无法使用的问题已修复 + PathfinderExecutor 工具新增四个关于寻路的方法: + setPathEntity(LivingEntity entity, Object pathEntity) + navigationMove(LivingEntity entity, LivingEntity target, double speed) + navigationMove(LivingEntity entity, LivingEntity target) + setFollowRange(LivingEntity entity, double value)
This commit is contained in:
parent
c19590ab1f
commit
038135733b
@ -14,8 +14,6 @@ public abstract class PathfinderExecutor {
|
|||||||
|
|
||||||
public abstract Object getNavigation(LivingEntity entity);
|
public abstract Object getNavigation(LivingEntity entity);
|
||||||
|
|
||||||
public abstract Object getPathEntity(LivingEntity entity);
|
|
||||||
|
|
||||||
public abstract Object getControllerJump(LivingEntity entity);
|
public abstract Object getControllerJump(LivingEntity entity);
|
||||||
|
|
||||||
public abstract Object getControllerMove(LivingEntity entity);
|
public abstract Object getControllerMove(LivingEntity entity);
|
||||||
@ -26,6 +24,10 @@ public abstract class PathfinderExecutor {
|
|||||||
|
|
||||||
public abstract Object getTargetSelector(LivingEntity entity);
|
public abstract Object getTargetSelector(LivingEntity entity);
|
||||||
|
|
||||||
|
public abstract Object getPathEntity(LivingEntity entity);
|
||||||
|
|
||||||
|
public abstract void setPathEntity(LivingEntity entity, Object pathEntity);
|
||||||
|
|
||||||
public abstract void setGoalAi(LivingEntity entity, SimpleAi ai, int priority);
|
public abstract void setGoalAi(LivingEntity entity, SimpleAi ai, int priority);
|
||||||
|
|
||||||
public abstract void setTargetAi(LivingEntity entity, SimpleAi ai, int priority);
|
public abstract void setTargetAi(LivingEntity entity, SimpleAi ai, int priority);
|
||||||
@ -38,6 +40,10 @@ public abstract class PathfinderExecutor {
|
|||||||
|
|
||||||
public abstract boolean navigationMove(LivingEntity entity, Location location, double speed);
|
public abstract boolean navigationMove(LivingEntity entity, Location location, double speed);
|
||||||
|
|
||||||
|
public abstract boolean navigationMove(LivingEntity entity, LivingEntity target);
|
||||||
|
|
||||||
|
public abstract boolean navigationMove(LivingEntity entity, LivingEntity target, double speed);
|
||||||
|
|
||||||
public abstract boolean navigationReach(LivingEntity entity);
|
public abstract boolean navigationReach(LivingEntity entity);
|
||||||
|
|
||||||
public abstract void controllerLookAt(LivingEntity entity, Location target);
|
public abstract void controllerLookAt(LivingEntity entity, Location target);
|
||||||
@ -47,4 +53,6 @@ public abstract class PathfinderExecutor {
|
|||||||
public abstract void controllerJumpReady(LivingEntity entity);
|
public abstract void controllerJumpReady(LivingEntity entity);
|
||||||
|
|
||||||
public abstract boolean controllerJumpCurrent(LivingEntity entity);
|
public abstract boolean controllerJumpCurrent(LivingEntity entity);
|
||||||
|
|
||||||
|
public abstract void setFollowRange(LivingEntity entity, double value);
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import net.minecraft.server.v1_8_R3.*;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
|
||||||
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
|
||||||
@ -59,16 +60,6 @@ public class InternalPathfinderExecutor extends PathfinderExecutor {
|
|||||||
return ((EntityInsentient) getEntityInsentient(entity)).getNavigation();
|
return ((EntityInsentient) getEntityInsentient(entity)).getNavigation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getPathEntity(LivingEntity entity) {
|
|
||||||
try {
|
|
||||||
return pathEntity.get(getNavigation(entity));
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getControllerJump(LivingEntity entity) {
|
public Object getControllerJump(LivingEntity entity) {
|
||||||
return ((EntityInsentient) getEntityInsentient(entity)).getControllerJump();
|
return ((EntityInsentient) getEntityInsentient(entity)).getControllerJump();
|
||||||
@ -94,6 +85,25 @@ public class InternalPathfinderExecutor extends PathfinderExecutor {
|
|||||||
return ((EntityInsentient) getEntityInsentient(entity)).targetSelector;
|
return ((EntityInsentient) getEntityInsentient(entity)).targetSelector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getPathEntity(LivingEntity entity) {
|
||||||
|
try {
|
||||||
|
return pathEntity.get(getNavigation(entity));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPathEntity(LivingEntity entity, Object pathEntity) {
|
||||||
|
try {
|
||||||
|
this.pathEntity.set(getNavigation(entity), pathEntity);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGoalAi(LivingEntity entity, SimpleAi ai, int priority) {
|
public void setGoalAi(LivingEntity entity, SimpleAi ai, int priority) {
|
||||||
((EntityInsentient) getEntityInsentient(entity)).goalSelector.a(priority, (PathfinderGoal) SimpleAiSelector.getCreator().createPathfinderGoal(ai));
|
((EntityInsentient) getEntityInsentient(entity)).goalSelector.a(priority, (PathfinderGoal) SimpleAiSelector.getCreator().createPathfinderGoal(ai));
|
||||||
@ -124,7 +134,7 @@ public class InternalPathfinderExecutor extends PathfinderExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean navigationMove(LivingEntity entity, Location location) {
|
public boolean navigationMove(LivingEntity entity, Location location) {
|
||||||
return navigationMove(entity, location, entity.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).getBaseValue());
|
return navigationMove(entity, location, 0.6);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -132,6 +142,16 @@ public class InternalPathfinderExecutor extends PathfinderExecutor {
|
|||||||
return ((Navigation) getNavigation(entity)).a(location.getX(), location.getY(), location.getZ(), speed);
|
return ((Navigation) getNavigation(entity)).a(location.getX(), location.getY(), location.getZ(), speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean navigationMove(LivingEntity entity, LivingEntity target) {
|
||||||
|
return navigationMove(entity, target, 0.6);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean navigationMove(LivingEntity entity, LivingEntity target, double speed) {
|
||||||
|
return ((Navigation) getNavigation(entity)).a(((CraftEntity) target).getHandle(), speed);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean navigationReach(LivingEntity entity) {
|
public boolean navigationReach(LivingEntity entity) {
|
||||||
Object pathEntity = getPathEntity(entity);
|
Object pathEntity = getPathEntity(entity);
|
||||||
@ -145,7 +165,7 @@ public class InternalPathfinderExecutor extends PathfinderExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void controllerLookAt(LivingEntity entity, Entity target) {
|
public void controllerLookAt(LivingEntity entity, Entity target) {
|
||||||
((ControllerLook) getControllerLook(entity)).a((net.minecraft.server.v1_8_R3.Entity) target, 10, 40);
|
((ControllerLook) getControllerLook(entity)).a(((CraftEntity) target).getHandle(), 10, 40);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -161,4 +181,9 @@ public class InternalPathfinderExecutor extends PathfinderExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFollowRange(LivingEntity entity, double value) {
|
||||||
|
((EntityInsentient) getEntityInsentient(entity)).getAttributeInstance(GenericAttributes.FOLLOW_RANGE).setValue(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
package me.skymc.taboolib.common.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author sky
|
||||||
|
* @Since 2018-09-25 15:21
|
||||||
|
*/
|
||||||
|
public class SimpleCounter {
|
||||||
|
|
||||||
|
private int timer;
|
||||||
|
private int limit;
|
||||||
|
|
||||||
|
public SimpleCounter(int limit) {
|
||||||
|
this.timer = 0;
|
||||||
|
this.limit = limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean next() {
|
||||||
|
if (--timer <= 0) {
|
||||||
|
timer = limit;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user