mirror of
https://github.com/PaperMC/Paper.git
synced 2025-05-19 13:40:24 -07:00
Configurable xp orb merge group count (#12503)
This commit is contained in:
parent
6f1f5b67e0
commit
88a3a87015
@ -97,7 +97,7 @@
|
|||||||
Vec3 vec3 = new Vec3(
|
Vec3 vec3 = new Vec3(
|
||||||
this.followingPlayer.getX() - this.getX(),
|
this.followingPlayer.getX() - this.getX(),
|
||||||
this.followingPlayer.getY() + this.followingPlayer.getEyeHeight() / 2.0 - this.getY(),
|
this.followingPlayer.getY() + this.followingPlayer.getEyeHeight() / 2.0 - this.getY(),
|
||||||
@@ -161,16 +_,27 @@
|
@@ -161,18 +_,29 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void award(ServerLevel level, Vec3 pos, int amount) {
|
public static void award(ServerLevel level, Vec3 pos, int amount) {
|
||||||
@ -124,9 +124,17 @@
|
|||||||
private static boolean tryMergeToExisting(ServerLevel level, Vec3 pos, int amount) {
|
private static boolean tryMergeToExisting(ServerLevel level, Vec3 pos, int amount) {
|
||||||
+ // Paper - TODO some other event for this kind of merge
|
+ // Paper - TODO some other event for this kind of merge
|
||||||
AABB aabb = AABB.ofSize(pos, 1.0, 1.0, 1.0);
|
AABB aabb = AABB.ofSize(pos, 1.0, 1.0, 1.0);
|
||||||
int randomInt = level.getRandom().nextInt(40);
|
- int randomInt = level.getRandom().nextInt(40);
|
||||||
|
+ int randomInt = level.getRandom().nextInt(io.papermc.paper.configuration.GlobalConfiguration.get().misc.xpOrbGroupsPerArea.or(ORB_GROUPS_PER_AREA)); // Paper - Configure how many orb groups per area
|
||||||
List<ExperienceOrb> entities = level.getEntities(EntityTypeTest.forClass(ExperienceOrb.class), aabb, orb -> canMerge(orb, randomInt, amount));
|
List<ExperienceOrb> entities = level.getEntities(EntityTypeTest.forClass(ExperienceOrb.class), aabb, orb -> canMerge(orb, randomInt, amount));
|
||||||
@@ -193,9 +_,14 @@
|
if (!entities.isEmpty()) {
|
||||||
|
ExperienceOrb experienceOrb = entities.get(0);
|
||||||
|
@@ -189,13 +_,18 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean canMerge(ExperienceOrb orb, int amount, int other) {
|
||||||
|
- return !orb.isRemoved() && (orb.getId() - amount) % 40 == 0 && orb.getValue() == other;
|
||||||
|
+ return !orb.isRemoved() && (orb.getId() - amount) % io.papermc.paper.configuration.GlobalConfiguration.get().misc.xpOrbGroupsPerArea.or(ORB_GROUPS_PER_AREA) == 0 && orb.getValue() == other; // Paper - Configure how many orbs will merge together
|
||||||
}
|
}
|
||||||
|
|
||||||
private void merge(ExperienceOrb orb) {
|
private void merge(ExperienceOrb orb) {
|
||||||
|
@ -62,7 +62,8 @@ public abstract class Configurations<G, W> {
|
|||||||
protected ObjectMapper.Factory.Builder createObjectMapper() {
|
protected ObjectMapper.Factory.Builder createObjectMapper() {
|
||||||
return ObjectMapper.factoryBuilder()
|
return ObjectMapper.factoryBuilder()
|
||||||
.addConstraint(Constraint.class, new Constraint.Factory())
|
.addConstraint(Constraint.class, new Constraint.Factory())
|
||||||
.addConstraint(Constraints.Min.class, Number.class, new Constraints.Min.Factory());
|
.addConstraint(Constraints.Min.class, Number.class, new Constraints.Min.Factory())
|
||||||
|
.addConstraint(Constraints.Max.class, Number.class, new Constraints.Max.Factory());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected YamlConfigurationLoader.Builder createLoaderBuilder() {
|
protected YamlConfigurationLoader.Builder createLoaderBuilder() {
|
||||||
|
@ -356,6 +356,9 @@ public class GlobalConfiguration extends ConfigurationPart {
|
|||||||
public IntOr.Default compressionLevel = IntOr.Default.USE_DEFAULT;
|
public IntOr.Default compressionLevel = IntOr.Default.USE_DEFAULT;
|
||||||
@Comment("Defines the leniency distance added on the server to the interaction range of a player when validating interact packets.")
|
@Comment("Defines the leniency distance added on the server to the interaction range of a player when validating interact packets.")
|
||||||
public DoubleOr.Default clientInteractionLeniencyDistance = DoubleOr.Default.USE_DEFAULT;
|
public DoubleOr.Default clientInteractionLeniencyDistance = DoubleOr.Default.USE_DEFAULT;
|
||||||
|
@Comment("Defines how many orbs groups can exist in an area.")
|
||||||
|
@Constraints.Min(1)
|
||||||
|
public IntOr.Default xpOrbGroupsPerArea = IntOr.Default.USE_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockUpdates blockUpdates;
|
public BlockUpdates blockUpdates;
|
||||||
|
@ -40,4 +40,22 @@ public final class Constraints {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Documented
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.FIELD)
|
||||||
|
public @interface Max {
|
||||||
|
int value();
|
||||||
|
|
||||||
|
final class Factory implements Constraint.Factory<Max, Number> {
|
||||||
|
@Override
|
||||||
|
public Constraint<Number> make(Max data, Type type) {
|
||||||
|
return value -> {
|
||||||
|
if (value != null && value.intValue() > data.value()) {
|
||||||
|
throw new SerializationException(value + " is greater than the max " + data.value());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user