summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2018-10-31 20:09:21 +1100
committermd_5 <git@md-5.net>2018-10-31 20:10:39 +1100
commitaed3aecbafff223bb8c48ace7cb18f8a7dd0b6d5 (patch)
tree84f8a64654846fdb6247c92508ef36f3a1b01ac1 /src/main/java/org
parent1057710a78ec00a5812b26ebd800f0b645edde34 (diff)
downloadcraftbukkit-aed3aecbafff223bb8c48ace7cb18f8a7dd0b6d5.tar
craftbukkit-aed3aecbafff223bb8c48ace7cb18f8a7dd0b6d5.tar.gz
craftbukkit-aed3aecbafff223bb8c48ace7cb18f8a7dd0b6d5.tar.lz
craftbukkit-aed3aecbafff223bb8c48ace7cb18f8a7dd0b6d5.tar.xz
craftbukkit-aed3aecbafff223bb8c48ace7cb18f8a7dd0b6d5.zip
Make natural item dropping mimic Vanilla
Make sure we don't regress SPIGOT-260 by using exact drop method like Entity does
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftWorld.java37
-rw-r--r--src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java4
2 files changed, 8 insertions, 33 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 16fbf732..944595a1 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -292,39 +292,14 @@ public class CraftWorld implements World {
return new CraftItem(world.getServer(), entity);
}
- private static void randomLocationWithinBlock(Location loc, double xs, double ys, double zs) {
- double prevX = loc.getX();
- double prevY = loc.getY();
- double prevZ = loc.getZ();
- loc.add(xs, ys, zs);
- if (loc.getX() < Math.floor(prevX)) {
- loc.setX(Math.floor(prevX));
- }
- if (loc.getX() >= Math.ceil(prevX)) {
- loc.setX(Math.ceil(prevX - 0.01));
- }
- if (loc.getY() < Math.floor(prevY)) {
- loc.setY(Math.floor(prevY));
- }
- if (loc.getY() >= Math.ceil(prevY)) {
- loc.setY(Math.ceil(prevY - 0.01));
- }
- if (loc.getZ() < Math.floor(prevZ)) {
- loc.setZ(Math.floor(prevZ));
- }
- if (loc.getZ() >= Math.ceil(prevZ)) {
- loc.setZ(Math.ceil(prevZ - 0.01));
- }
- }
-
public org.bukkit.entity.Item dropItemNaturally(Location loc, ItemStack item) {
- double xs = world.random.nextFloat() * 0.7F - 0.35D;
- double ys = world.random.nextFloat() * 0.7F - 0.35D;
- double zs = world.random.nextFloat() * 0.7F - 0.35D;
+ 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;
loc = loc.clone();
- // Makes sure the new item is created within the block the location points to.
- // This prevents item spill in 1-block wide farms.
- randomLocationWithinBlock(loc, xs, ys, zs);
+ loc.setX(loc.getX() + xs);
+ loc.setY(loc.getY() + ys);
+ loc.setZ(loc.getZ() + zs);
return dropItem(loc, item);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 4e69ccc7..df8e99f2 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -438,7 +438,7 @@ public class CraftEventFactory {
for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
if (stack == null || stack.getType() == Material.AIR || stack.getAmount() == 0) continue;
- world.dropItemNaturally(entity.getLocation(), stack);
+ world.dropItem(entity.getLocation(), stack);
}
return event;
@@ -464,7 +464,7 @@ public class CraftEventFactory {
for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
if (stack == null || stack.getType() == Material.AIR) continue;
- world.dropItemNaturally(entity.getLocation(), stack);
+ world.dropItem(entity.getLocation(), stack);
}
return event;