Make sure theres a stack to split before attempting.

This commit is contained in:
Brianna 2020-09-17 08:44:00 -05:00
parent 59b2b3e6b0
commit fae3383ab1
2 changed files with 2 additions and 0 deletions

View File

@ -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);

View File

@ -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();