mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-09-27 14:12:59 +02:00
Make sure theres a stack to split before attempting.
This commit is contained in:
parent
59b2b3e6b0
commit
fae3383ab1
@ -87,6 +87,7 @@ public class ColdEntityStack implements Stackable {
|
||||
}
|
||||
|
||||
public LivingEntity takeOneAndSpawnEntity(Location location) {
|
||||
if (stackedEntities.isEmpty()) return null;
|
||||
NBTEntity nbtEntity = NmsManager.getNbt().newEntity();
|
||||
nbtEntity.deSerialize(stackedEntities.getFirst().getSerializedEntity());
|
||||
LivingEntity newEntity = (LivingEntity)nbtEntity.spawn(location);
|
||||
|
@ -321,6 +321,7 @@ public class StackingTask extends BukkitRunnable {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
for (int i = stackSize; i > 0; i -= maxEntityStackAmount) {
|
||||
LivingEntity entity = stack.takeOneAndSpawnEntity(livingEntity.getLocation());
|
||||
if (entity == null) continue;
|
||||
EntityStack newStack = plugin.getEntityStackManager().addStack(entity);
|
||||
newStack.moveEntitiesFromStack(stack, Math.min(i, maxEntityStackAmount) - 1);
|
||||
newStack.updateStack();
|
||||
|
Loading…
Reference in New Issue
Block a user