mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
Add transient modifiers (#9244)
This allows adding modifiers as transient. Transient modifiers don't get saved with the NBT data. Vanilla itself uses transient modifiers for speed modifications like sprinting or powder snow. This just exposes it in the API.
This commit is contained in:
parent
e36eed4507
commit
c137b5dc31
27
patches/api/Add-transient-modifier-API.patch
Normal file
27
patches/api/Add-transient-modifier-API.patch
Normal file
@ -0,0 +1,27 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Malfrador <malfrador@gmail.com>
|
||||
Date: Wed, 31 May 2023 21:25:01 +0200
|
||||
Subject: [PATCH] Add transient modifier API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/attribute/AttributeInstance.java b/src/main/java/org/bukkit/attribute/AttributeInstance.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/attribute/AttributeInstance.java
|
||||
+++ b/src/main/java/org/bukkit/attribute/AttributeInstance.java
|
||||
@@ -0,0 +0,0 @@ public interface AttributeInstance {
|
||||
*/
|
||||
void addModifier(@NotNull AttributeModifier modifier);
|
||||
|
||||
+ // Paper start - Transient modifier API
|
||||
+ /**
|
||||
+ * Add a transient modifier to this instance.
|
||||
+ * Transient modifiers are not persisted (saved with the NBT data)
|
||||
+ *
|
||||
+ * @param modifier to add
|
||||
+ */
|
||||
+ void addTransientModifier(@NotNull AttributeModifier modifier);
|
||||
+ // Paper end
|
||||
+
|
||||
/**
|
||||
* Remove a modifier from this instance.
|
||||
*
|
41
patches/server/Add-transient-modifier-API.patch
Normal file
41
patches/server/Add-transient-modifier-API.patch
Normal file
@ -0,0 +1,41 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Malfrador <malfrador@gmail.com>
|
||||
Date: Wed, 31 May 2023 23:30:00 +0200
|
||||
Subject: [PATCH] Add transient modifier API
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/attribute/UnmodifiableAttributeInstance.java b/src/main/java/io/papermc/paper/attribute/UnmodifiableAttributeInstance.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/io/papermc/paper/attribute/UnmodifiableAttributeInstance.java
|
||||
+++ b/src/main/java/io/papermc/paper/attribute/UnmodifiableAttributeInstance.java
|
||||
@@ -0,0 +0,0 @@ public class UnmodifiableAttributeInstance extends CraftAttributeInstance {
|
||||
throw new UnsupportedOperationException("Cannot modify default attributes");
|
||||
}
|
||||
|
||||
+ @Override
|
||||
+ public void addTransientModifier(AttributeModifier modifier) {
|
||||
+ throw new UnsupportedOperationException("Cannot modify default attributes");
|
||||
+ }
|
||||
+
|
||||
@Override
|
||||
public void removeModifier(AttributeModifier modifier) {
|
||||
throw new UnsupportedOperationException("Cannot modify default attributes");
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java
|
||||
@@ -0,0 +0,0 @@ public class CraftAttributeInstance implements AttributeInstance {
|
||||
this.handle.addPermanentModifier(CraftAttributeInstance.convert(modifier));
|
||||
}
|
||||
|
||||
+ // Paper start - Transient modifier API
|
||||
+ @Override
|
||||
+ public void addTransientModifier(AttributeModifier modifier) {
|
||||
+ Preconditions.checkArgument(modifier != null, "modifier");
|
||||
+ this.handle.addTransientModifier(CraftAttributeInstance.convert(modifier));
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public void removeModifier(AttributeModifier modifier) {
|
||||
Preconditions.checkArgument(modifier != null, "modifier");
|
Loading…
Reference in New Issue
Block a user