mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-23 02:55:45 +01:00
Add a blockStrengthModifier to BlockBreaker.Configuration and implement setPaused/isPaused in CitizensNavigator
This commit is contained in:
parent
f9497b31c2
commit
e25df6cd47
@ -88,7 +88,7 @@ public class BlockBreaker extends BehaviorGoalAdapter {
|
||||
return BehaviorStatus.SUCCESS;
|
||||
} else {
|
||||
int tickDifference = currentTick - startDigTick;
|
||||
float damage = getStrength(block) * (tickDifference + 1);
|
||||
float damage = getStrength(block) * (tickDifference + 1) * configuration.blockStrengthModifier();
|
||||
if (damage >= 1F) {
|
||||
entity.world.getWorld().getBlockAt(x, y, z)
|
||||
.breakNaturally(CraftItemStack.asCraftMirror(getCurrentItem()));
|
||||
@ -144,7 +144,17 @@ public class BlockBreaker extends BehaviorGoalAdapter {
|
||||
public static class Configuration {
|
||||
private Runnable callback;
|
||||
private org.bukkit.inventory.ItemStack itemStack;
|
||||
private double radius;
|
||||
private float modifier = 1;
|
||||
private double radius = -1;
|
||||
|
||||
public float blockStrengthModifier() {
|
||||
return modifier;
|
||||
}
|
||||
|
||||
public Configuration blockStrengthModifier(float modifier) {
|
||||
this.modifier = modifier;
|
||||
return this;
|
||||
}
|
||||
|
||||
private Runnable callback() {
|
||||
return callback;
|
||||
|
@ -37,6 +37,7 @@ public class CitizensNavigator implements Navigator, Runnable {
|
||||
private int lastX, lastY, lastZ;
|
||||
private NavigatorParameters localParams = defaultParams;
|
||||
private final NPC npc;
|
||||
private boolean paused;
|
||||
private int stationaryTicks;
|
||||
|
||||
public CitizensNavigator(NPC npc) {
|
||||
@ -85,6 +86,10 @@ public class CitizensNavigator implements Navigator, Runnable {
|
||||
return executing != null;
|
||||
}
|
||||
|
||||
public boolean isPaused() {
|
||||
return paused;
|
||||
}
|
||||
|
||||
public void load(DataKey root) {
|
||||
defaultParams.range((float) root.getDouble("pathfindingrange", Setting.DEFAULT_PATHFINDING_RANGE.asFloat()));
|
||||
defaultParams.stationaryTicks(root.getInt("stationaryticks", Setting.DEFAULT_STATIONARY_TICKS.asInt()));
|
||||
@ -107,7 +112,7 @@ public class CitizensNavigator implements Navigator, Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!isNavigating() || !npc.isSpawned())
|
||||
if (!isNavigating() || !npc.isSpawned() || paused)
|
||||
return;
|
||||
if (updateStationaryStatus())
|
||||
return;
|
||||
@ -134,6 +139,10 @@ public class CitizensNavigator implements Navigator, Runnable {
|
||||
root.setBoolean("usedefaultstuckaction", defaultParams.stuckAction() == TeleportStuckAction.INSTANCE);
|
||||
}
|
||||
|
||||
public void setPaused(boolean paused) {
|
||||
this.paused = paused;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTarget(Entity target, boolean aggressive) {
|
||||
if (!npc.isSpawned())
|
||||
|
Loading…
Reference in New Issue
Block a user