Paper/CraftBukkit-Patches/0007-Merge-tweaks-and-configuration.patch

118 Zeilen
6.4 KiB
Diff

From e06797e10a91fd0b1e19b9dee8b4eed064f7ad1f Mon Sep 17 00:00:00 2001
2013-03-22 23:48:22 +01:00
From: md_5 <md_5@live.com.au>
Date: Sat, 23 Mar 2013 09:46:33 +1100
Subject: [PATCH] Merge tweaks and configuration
This allows the merging of Experience orbs, as well as the configuration of the merge radius of items. Additionally it refactors the merge algorithm to be a better experience for players.
diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java
2013-05-04 02:14:25 +02:00
index 0225f53..294ab8f 100644
2013-03-22 23:48:22 +01:00
--- a/src/main/java/net/minecraft/server/EntityItem.java
+++ b/src/main/java/net/minecraft/server/EntityItem.java
2013-05-04 02:14:25 +02:00
@@ -114,7 +114,10 @@ public class EntityItem extends Entity {
2013-03-22 23:48:22 +01:00
}
private void g() {
- Iterator iterator = this.world.a(EntityItem.class, this.boundingBox.grow(0.5D, 0.0D, 0.5D)).iterator();
+ // Spigot start
+ double radius = world.getWorld().itemMergeRadius;
+ Iterator iterator = this.world.a(EntityItem.class, this.boundingBox.grow(radius, radius, radius)).iterator();
+ // Spigot end
while (iterator.hasNext()) {
EntityItem entityitem = (EntityItem) iterator.next();
2013-05-04 02:14:25 +02:00
@@ -143,11 +146,13 @@ public class EntityItem extends Entity {
2013-03-22 23:48:22 +01:00
} else if (itemstack1.count + itemstack.count > itemstack1.getMaxStackSize()) {
return false;
} else {
- itemstack1.count += itemstack.count;
- entityitem.pickupDelay = Math.max(entityitem.pickupDelay, this.pickupDelay);
- entityitem.age = Math.min(entityitem.age, this.age);
- entityitem.setItemStack(itemstack1);
- this.die();
+ // Spigot start
+ itemstack.count += itemstack1.count;
+ this.pickupDelay = Math.max(entityitem.pickupDelay, this.pickupDelay);
+ this.age = Math.min(entityitem.age, this.age);
+ this.setItemStack(itemstack);
+ entityitem.die();
+ // Spigot end
return true;
}
} else {
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
2013-05-04 02:14:25 +02:00
index 70dd295..b339688 100644
2013-03-22 23:48:22 +01:00
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -949,6 +949,23 @@ public abstract class World implements IBlockAccess {
2013-03-22 23:48:22 +01:00
// Not all projectiles extend EntityProjectile, so check for Bukkit interface instead
event = CraftEventFactory.callProjectileLaunchEvent(entity);
}
+ // Spigot start
+ else if (entity instanceof EntityExperienceOrb) {
+ EntityExperienceOrb xp = (EntityExperienceOrb) entity;
+ double radius = this.getWorld().expMergeRadius;
+ if (radius > 0) {
+ List<Entity> entities = this.getEntities(entity, entity.boundingBox.grow(radius, radius, radius));
+ for (Entity e : entities) {
+ if (e instanceof EntityExperienceOrb) {
+ EntityExperienceOrb loopItem = (EntityExperienceOrb) e;
+ if (!loopItem.dead) {
+ xp.value += loopItem.value;
+ loopItem.die();
+ }
+ }
+ }
+ }
+ } // Spigot end
if (event != null && (event.isCancelled() || entity.dead)) {
entity.dead = true;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
2013-05-04 02:14:25 +02:00
index 63e8e69..68fd274 100644
2013-03-22 23:48:22 +01:00
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -92,6 +92,8 @@ public class CraftWorld implements World {
2013-03-22 23:48:22 +01:00
randomLightingUpdates = configuration.getBoolean("world-settings.default.random-light-updates", randomLightingUpdates);
mobSpawnRange = configuration.getInt("world-settings.default.mob-spawn-range", mobSpawnRange);
aggregateTicks = Math.max(1, configuration.getInt("world-settings.default.aggregate-chunkticks", aggregateTicks));
+ itemMergeRadius = configuration.getDouble("world-settings.default.item-merge-radius", itemMergeRadius);
+ expMergeRadius = configuration.getDouble("world-settings.default.exp-merge-radius", expMergeRadius);
wheatGrowthModifier = configuration.getInt("world-settings.default.wheat-growth-modifier", wheatGrowthModifier);
cactusGrowthModifier = configuration.getInt("world-settings.default.cactus-growth-modifier", cactusGrowthModifier);
@@ -107,6 +109,8 @@ public class CraftWorld implements World {
2013-03-22 23:48:22 +01:00
randomLightingUpdates = configuration.getBoolean("world-settings." + name + ".random-light-updates", randomLightingUpdates);
mobSpawnRange = configuration.getInt("world-settings." + name + ".mob-spawn-range", mobSpawnRange);
aggregateTicks = Math.max(1, configuration.getInt("world-settings." + name + ".aggregate-chunkticks", aggregateTicks));
+ itemMergeRadius = configuration.getDouble("world-settings." + name + ".item-merge-radius", itemMergeRadius);
+ expMergeRadius = configuration.getDouble("world-settings." + name + ".exp-merge-radius", expMergeRadius);
wheatGrowthModifier = configuration.getInt("world-settings." + name + ".wheat-growth-modifier", wheatGrowthModifier);
cactusGrowthModifier = configuration.getInt("world-settings." + name + ".cactus-growth-modifier", cactusGrowthModifier);
@@ -138,6 +142,8 @@ public class CraftWorld implements World {
2013-03-22 23:48:22 +01:00
public boolean randomLightingUpdates = false;
public int mobSpawnRange = 4;
public int aggregateTicks = 4;
+ public double itemMergeRadius = 3.5;
+ public double expMergeRadius = 3.5;
//Crop growth rates:
public int wheatGrowthModifier = 100;
public int cactusGrowthModifier = 100;
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
index b7c0376..92241d9 100644
2013-03-22 23:48:22 +01:00
--- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml
@@ -37,6 +37,8 @@ world-settings:
mob-spawn-range: 4
random-light-updates: false
aggregate-chunkticks: 4
+ item-merge-radius: 3.5
+ exp-merge-radius: 3.5
wheat-growth-modifier: 100
cactus-growth-modifier: 100
melon-growth-modifier: 100
--
1.8.1.2
2013-03-22 23:48:22 +01:00