mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-11 10:57:47 +01:00
Add null check for A* finder, clone itemstacks in drop trait
This commit is contained in:
parent
72c136e97a
commit
52955febf1
@ -89,16 +89,18 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
|
||||
}
|
||||
plan = planner.plan;
|
||||
if (plan != null) {
|
||||
vector = plan.getCurrentVector();
|
||||
planner = null;
|
||||
}
|
||||
}
|
||||
if (getCancelReason() != null || plan == null || plan.isComplete()) {
|
||||
return true;
|
||||
}
|
||||
if (vector == null) {
|
||||
vector = plan.getCurrentVector();
|
||||
}
|
||||
Location loc = npc.getEntity().getLocation(NPC_LOCATION);
|
||||
/* Proper door movement - gets stuck on corners at times
|
||||
|
||||
|
||||
Block block = currLoc.getWorld().getBlockAt(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
|
||||
if (MinecraftBlockExaminer.isDoor(block.getType())) {
|
||||
Door door = (Door) block.getState().getData();
|
||||
|
@ -48,7 +48,7 @@ public class DropsTrait extends Trait {
|
||||
Random random = Util.getFastRandom();
|
||||
for (ItemDrop drop : drops) {
|
||||
if (random.nextDouble() < drop.chance) {
|
||||
event.getDrops().add(drop.drop);
|
||||
event.getDrops().add(drop.drop.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -117,7 +117,7 @@ public class DropsTrait extends Trait {
|
||||
ItemStack stack = inventory.getItem(slot);
|
||||
if (stack == null || stack.getType() == Material.AIR)
|
||||
continue;
|
||||
drops.add(new ItemDrop(stack, chances.getOrDefault(slot, 1.0)));
|
||||
drops.add(new ItemDrop(stack.clone(), chances.getOrDefault(slot, 1.0)));
|
||||
}
|
||||
}
|
||||
this.trait.drops = drops;
|
||||
|
Loading…
Reference in New Issue
Block a user