mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-04 07:17:46 +01:00
SPIGOT-7960: Improve natural item drop methods
By: md_5 <git@md-5.net>
This commit is contained in:
parent
c7707ece4c
commit
b3b4fd1c4b
@ -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);
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user