diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/Magnet.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/Magnet.java index 25d41f3f..46c80c9d 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/Magnet.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/Magnet.java @@ -112,6 +112,8 @@ public class Magnet extends ItemDE implements IBauble, IConfigurableItem { entity.posZ).expand(range, range, range)); boolean playSound = false; + boolean didPlayerDrop; + NBTTagCompound itemNBT = new NBTTagCompound(); for (EntityItem item : items) { if (item.getEntityItem() == null || ModHelper.isAE2EntityFloatingItem(item) @@ -126,19 +128,36 @@ public class Magnet extends ItemDE implements IBauble, IConfigurableItem { == item.getEntityItem().getItemDamage())) { continue; } - playSound = true; - if (item.delayBeforeCanPickup > 0) { - item.delayBeforeCanPickup = 0; + EntityPlayer closestPlayer = world.getClosestPlayerToEntity(item, range); + if (closestPlayer != null && closestPlayer != player) { + continue; + } + + item.writeEntityToNBT(itemNBT); + + if (!world.isRemote) { + didPlayerDrop = item.func_145800_j() != null + && item.func_145800_j().equals(player.getCommandSenderName()); + if (!didPlayerDrop) item.delayBeforeCanPickup = 0; + if (item.delayBeforeCanPickup <= 0) { + itemNBT.setBoolean("attractable", true); + item.readEntityFromNBT(itemNBT); + } + } + + if (itemNBT.getBoolean("attractable")) { + playSound = true; + item.motionX = 0; + item.motionY = 0; + item.motionZ = 0; + item.setPosition( + entity.posX - 0.2 + (world.rand.nextDouble() * 0.4), + entity.posY - 0.6, + entity.posZ - 0.2 + (world.rand.nextDouble() * 0.4)); } - item.motionX = 0; - item.motionY = 0; - item.motionZ = 0; - item.setPosition( - entity.posX - 0.2 + (world.rand.nextDouble() * 0.4), - entity.posY - 0.6, - entity.posZ - 0.2 + (world.rand.nextDouble() * 0.4)); } + if (playSound && !ConfigHandler.itemDislocatorDisableSound) { world.playSoundAtEntity( entity,