mirror of
				https://hub.spigotmc.org/stash/scm/spigot/spigot.git
				synced 2025-11-01 09:09:35 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			96 lines
		
	
	
	
		
			4.2 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			96 lines
		
	
	
	
		
			4.2 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
From af4f6f0e5a7e04567950f4f4f95572c7c96184ca Mon Sep 17 00:00:00 2001
 | 
						|
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
 | 
						|
index bbcf674..08b9ac8 100644
 | 
						|
--- a/src/main/java/net/minecraft/server/EntityItem.java
 | 
						|
+++ b/src/main/java/net/minecraft/server/EntityItem.java
 | 
						|
@@ -117,7 +117,10 @@ public class EntityItem extends Entity {
 | 
						|
     }
 | 
						|
 
 | 
						|
     private void k() {
 | 
						|
-        Iterator iterator = this.world.a(EntityItem.class, this.boundingBox.grow(0.5D, 0.0D, 0.5D)).iterator();
 | 
						|
+        // Spigot start
 | 
						|
+        double radius = world.spigotConfig.itemMerge;
 | 
						|
+        Iterator iterator = this.world.a(EntityItem.class, this.boundingBox.grow(radius, radius, radius)).iterator();
 | 
						|
+        // Spigot end
 | 
						|
 
 | 
						|
         while (iterator.hasNext()) {
 | 
						|
             EntityItem entityitem = (EntityItem) iterator.next();
 | 
						|
@@ -148,11 +151,13 @@ public class EntityItem extends Entity {
 | 
						|
             } 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
 | 
						|
index 8b07d84..97b991b 100644
 | 
						|
--- a/src/main/java/net/minecraft/server/World.java
 | 
						|
+++ b/src/main/java/net/minecraft/server/World.java
 | 
						|
@@ -934,6 +934,23 @@ public abstract class World implements IBlockAccess {
 | 
						|
             // 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 = spigotConfig.expMerge;
 | 
						|
+            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/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
 | 
						|
index f38bb25..9f07e71 100644
 | 
						|
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
 | 
						|
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
 | 
						|
@@ -106,4 +106,18 @@ public class SpigotWorldConfig
 | 
						|
         saplingModifier = getAndValidateGrowth( "Sapling" );
 | 
						|
         wheatModifier = getAndValidateGrowth( "Wheat" );
 | 
						|
     }
 | 
						|
+
 | 
						|
+    public double itemMerge;
 | 
						|
+    private void itemMerge()
 | 
						|
+    {
 | 
						|
+        itemMerge = getDouble("merge-radius.item", 2.5 );
 | 
						|
+        log( "Item Merge Radius: " + itemMerge );
 | 
						|
+    }
 | 
						|
+
 | 
						|
+    public double expMerge;
 | 
						|
+    private void expMerge()
 | 
						|
+    {
 | 
						|
+        expMerge = getDouble("merge-radius.exp", 3.0 );
 | 
						|
+        log( "Experience Merge Radius: " + expMerge );
 | 
						|
+    }
 | 
						|
 }
 | 
						|
-- 
 | 
						|
1.8.3.2
 | 
						|
 |