From d444e088c43180262aa74204680e077dfe60eeb5 Mon Sep 17 00:00:00 2001 From: Glitchfinder Date: Wed, 2 Jan 2013 18:03:52 -0800 Subject: [PATCH] Patching a bug where mcMMO drops too few items, and yet another concurrent modification exception. --- src/main/java/com/gmail/nossr50/util/Misc.java | 8 +++++++- .../util/blockmeta/chunkmeta/HashChunkManager.java | 6 ++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java index ffba54dfd..dc160cba5 100644 --- a/src/main/java/com/gmail/nossr50/util/Misc.java +++ b/src/main/java/com/gmail/nossr50/util/Misc.java @@ -5,6 +5,7 @@ import java.util.Random; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageEvent; @@ -253,7 +254,12 @@ public class Misc { return; } - location.getWorld().dropItemNaturally(location, itemStack).setItemStack(itemStack); + Item newItem = location.getWorld().dropItemNaturally(location, itemStack); + + ItemStack cloned = itemStack.clone(); + cloned.setAmount(newItem.getItemStack().getAmount()); + + newItem.setItemStack(cloned); } /** diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java index 442f67eb3..22ac95612 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java @@ -254,14 +254,16 @@ public class HashChunkManager implements ChunkManager { if(store.containsKey(world.getName() + "," + cx + "," + cz)) { ChunkStore out = store.get(world.getName() + "," + cx + "," + cz); - for(Entity entity : spawnedMobs) { + List tempSpawnedMobs = new ArrayList(spawnedMobs); + for(Entity entity : tempSpawnedMobs) { if(!isEntityInChunk(entity, cx, cz, world)) continue; out.addSpawnedMob(entity.getUniqueId()); } - for(Entity entity : spawnedPets) { + List tempSpawnedPets = new ArrayList(spawnedPets); + for(Entity entity : tempSpawnedPets) { if(!isEntityInChunk(entity, cx, cz, world)) continue;