mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-09-28 22:47:49 +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) {
|
public LivingEntity takeOneAndSpawnEntity(Location location) {
|
||||||
|
if (stackedEntities.isEmpty()) return null;
|
||||||
NBTEntity nbtEntity = NmsManager.getNbt().newEntity();
|
NBTEntity nbtEntity = NmsManager.getNbt().newEntity();
|
||||||
nbtEntity.deSerialize(stackedEntities.getFirst().getSerializedEntity());
|
nbtEntity.deSerialize(stackedEntities.getFirst().getSerializedEntity());
|
||||||
LivingEntity newEntity = (LivingEntity)nbtEntity.spawn(location);
|
LivingEntity newEntity = (LivingEntity)nbtEntity.spawn(location);
|
||||||
|
@ -321,6 +321,7 @@ public class StackingTask extends BukkitRunnable {
|
|||||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||||
for (int i = stackSize; i > 0; i -= maxEntityStackAmount) {
|
for (int i = stackSize; i > 0; i -= maxEntityStackAmount) {
|
||||||
LivingEntity entity = stack.takeOneAndSpawnEntity(livingEntity.getLocation());
|
LivingEntity entity = stack.takeOneAndSpawnEntity(livingEntity.getLocation());
|
||||||
|
if (entity == null) continue;
|
||||||
EntityStack newStack = plugin.getEntityStackManager().addStack(entity);
|
EntityStack newStack = plugin.getEntityStackManager().addStack(entity);
|
||||||
newStack.moveEntitiesFromStack(stack, Math.min(i, maxEntityStackAmount) - 1);
|
newStack.moveEntitiesFromStack(stack, Math.min(i, maxEntityStackAmount) - 1);
|
||||||
newStack.updateStack();
|
newStack.updateStack();
|
||||||
|
Loading…
Reference in New Issue
Block a user