mirror of
https://hub.spigotmc.org/stash/scm/spigot/spigot.git
synced 2025-09-18 21:33:01 +00:00
86 lines
4 KiB
Diff
86 lines
4 KiB
Diff
From 219b4e72804a0b262140ef21a0f4abd3fec247fc 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/world/entity/item/EntityItem.java b/src/main/java/net/minecraft/world/entity/item/EntityItem.java
|
|
index efb64b2fe..595b7d1c0 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/item/EntityItem.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/EntityItem.java
|
|
@@ -239,7 +239,10 @@ public class EntityItem extends Entity implements TraceableEntity {
|
|
|
|
private void mergeWithNeighbours() {
|
|
if (this.isMergable()) {
|
|
- List<EntityItem> list = this.level().getEntitiesOfClass(EntityItem.class, this.getBoundingBox().inflate(0.5D, 0.0D, 0.5D), (entityitem) -> {
|
|
+ // Spigot start
|
|
+ double radius = this.level().spigotConfig.itemMerge;
|
|
+ List<EntityItem> list = this.level().getEntitiesOfClass(EntityItem.class, this.getBoundingBox().inflate(radius, radius - 0.5D, radius), (entityitem) -> {
|
|
+ // Spigot end
|
|
return entityitem != this && entityitem.isMergable();
|
|
});
|
|
Iterator iterator = list.iterator();
|
|
@@ -269,7 +272,7 @@ public class EntityItem extends Entity implements TraceableEntity {
|
|
ItemStack itemstack1 = entityitem.getItem();
|
|
|
|
if (Objects.equals(this.target, entityitem.target) && areMergable(itemstack, itemstack1)) {
|
|
- if (itemstack1.getCount() < itemstack.getCount()) {
|
|
+ if (true || itemstack1.getCount() < itemstack.getCount()) { // Spigot
|
|
merge(this, itemstack, entityitem, itemstack1);
|
|
} else {
|
|
merge(entityitem, itemstack1, this, itemstack);
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
index be5b0756b..31847dc4c 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -706,6 +706,23 @@ public class CraftEventFactory {
|
|
return false;
|
|
}
|
|
|
|
+ // Spigot start - SPIGOT-7523: Merge after spawn event and only merge if the event was not cancelled (gets checked above)
|
|
+ if (entity instanceof EntityExperienceOrb xp) {
|
|
+ double radius = world.spigotConfig.expMerge;
|
|
+ if (radius > 0) {
|
|
+ List<Entity> entities = world.getEntities(entity, entity.getBoundingBox().inflate(radius, radius, radius));
|
|
+ for (Entity e : entities) {
|
|
+ if (e instanceof EntityExperienceOrb loopItem) {
|
|
+ if (!loopItem.isRemoved()) {
|
|
+ xp.value += loopItem.value;
|
|
+ loopItem.discard();
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // Spigot end
|
|
+
|
|
return true;
|
|
}
|
|
|
|
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
index f42972427..5ff085b9e 100644
|
|
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
@@ -134,4 +134,18 @@ public class SpigotWorldConfig
|
|
weepingVinesModifier = getAndValidateGrowth( "WeepingVines" );
|
|
caveVinesModifier = getAndValidateGrowth( "CaveVines" );
|
|
}
|
|
+
|
|
+ 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 );
|
|
+ }
|
|
}
|
|
--
|
|
2.43.0
|
|
|