mirror of
https://hub.spigotmc.org/stash/scm/spigot/spigot.git
synced 2025-09-18 21:33:01 +00:00
86 lines
4.1 KiB
Diff
86 lines
4.1 KiB
Diff
From a72a1112c768a77ce006f578a85040475245e85a 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 5ab42a5e0..3a902d7a2 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/item/EntityItem.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/EntityItem.java
|
|
@@ -200,7 +200,10 @@ public class EntityItem extends Entity {
|
|
|
|
private void mergeNearby() {
|
|
if (this.A()) {
|
|
- List<EntityItem> list = this.level.a(EntityItem.class, this.getBoundingBox().grow(0.5D, 0.0D, 0.5D), (entityitem) -> {
|
|
+ // Spigot start
|
|
+ double radius = level.spigotConfig.itemMerge;
|
|
+ List<EntityItem> list = this.level.a(EntityItem.class, this.getBoundingBox().grow(radius, radius, radius), (entityitem) -> {
|
|
+ // Spigot end
|
|
return entityitem != this && entityitem.A();
|
|
});
|
|
Iterator iterator = list.iterator();
|
|
@@ -230,7 +233,7 @@ public class EntityItem extends Entity {
|
|
ItemStack itemstack1 = entityitem.getItemStack();
|
|
|
|
if (Objects.equals(this.getOwner(), entityitem.getOwner()) && a(itemstack, itemstack1)) {
|
|
- if (itemstack1.getCount() < itemstack.getCount()) {
|
|
+ if (true || itemstack1.getCount() < itemstack.getCount()) { // Spigot
|
|
a(this, itemstack, entityitem, itemstack1);
|
|
} else {
|
|
a(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 1be8babf3..7bcf04042 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -611,6 +611,23 @@ public class CraftEventFactory {
|
|
return true;
|
|
}
|
|
event = CraftEventFactory.callLightningStrikeEvent((LightningStrike) entity.getBukkitEntity(), cause);
|
|
+ // Spigot start
|
|
+ } else if (entity instanceof EntityExperienceOrb) {
|
|
+ EntityExperienceOrb xp = (EntityExperienceOrb) entity;
|
|
+ double radius = world.spigotConfig.expMerge;
|
|
+ if (radius > 0) {
|
|
+ List<Entity> entities = world.getEntities(entity, entity.getBoundingBox().grow(radius, radius, radius));
|
|
+ for (Entity e : entities) {
|
|
+ if (e instanceof EntityExperienceOrb) {
|
|
+ EntityExperienceOrb loopItem = (EntityExperienceOrb) e;
|
|
+ if (!loopItem.isRemoved()) {
|
|
+ xp.value += loopItem.value;
|
|
+ loopItem.die();
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // Spigot end
|
|
} else if (!(entity instanceof EntityPlayer)) {
|
|
event = CraftEventFactory.callEntitySpawnEvent(entity);
|
|
}
|
|
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
index fb9c4fc78..8c855cf9b 100644
|
|
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
@@ -128,4 +128,18 @@ public class SpigotWorldConfig
|
|
sweetBerryModifier = getAndValidateGrowth( "SweetBerry" );
|
|
kelpModifier = getAndValidateGrowth( "Kelp" );
|
|
}
|
|
+
|
|
+ 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.25.1
|
|
|