diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 0cffbfaac3..9fa5252463 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -49,6 +49,7 @@ import net.minecraft.sounds.SoundCategory; import net.minecraft.sounds.SoundEffect; import net.minecraft.sounds.SoundEffects; import net.minecraft.util.ArraySetSorted; +import net.minecraft.util.MathHelper; import net.minecraft.util.Unit; import net.minecraft.world.EnumDifficulty; import net.minecraft.world.entity.EntityLightning; @@ -568,9 +569,9 @@ public class CraftWorld extends CraftRegionAccessor implements World { Preconditions.checkArgument(loc != null, "Location cannot be null"); Preconditions.checkArgument(item != null, "ItemStack cannot be null"); - double xs = (world.random.nextFloat() * 0.5F) + 0.25D; - double ys = (world.random.nextFloat() * 0.5F) + 0.25D; - double zs = (world.random.nextFloat() * 0.5F) + 0.25D; + double xs = 0.5D + MathHelper.nextDouble(world.random, -0.25D, 0.25D); + double ys = 0.5D + MathHelper.nextDouble(world.random, -0.25D, 0.25D) - ((double) EntityTypes.ITEM.getHeight() / 2.0D); + double zs = MathHelper.nextDouble(world.random, -0.25D, 0.25D); loc = loc.clone().add(xs, ys, zs); return dropItem(loc, item, function); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftAbstractInventoryView.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftAbstractInventoryView.java index 58d2dfe817..bc49532e57 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftAbstractInventoryView.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftAbstractInventoryView.java @@ -1,6 +1,9 @@ package org.bukkit.craftbukkit.inventory; import com.google.common.base.Preconditions; +import net.minecraft.world.InventoryUtils; +import net.minecraft.world.entity.player.EntityHuman; +import org.bukkit.craftbukkit.entity.CraftHumanEntity; import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryView; @@ -16,7 +19,8 @@ public abstract class CraftAbstractInventoryView implements InventoryView { if (inventory != null) { inventory.setItem(convertSlot(slot), item); } else if (item != null) { - getPlayer().getWorld().dropItemNaturally(getPlayer().getLocation(), item); + EntityHuman handle = ((CraftHumanEntity) getPlayer()).getHandle(); + InventoryUtils.dropItemStack(handle.level(), handle.getX(), handle.getY(), handle.getZ(), CraftItemStack.asNMSCopy(item)); } }