Skip to content

Commit 5622c9d

Browse files
Expose attribute sentiment (#12974)
Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
1 parent a9e7674 commit 5622c9d

File tree

5 files changed

+29
-2
lines changed

5 files changed

+29
-2
lines changed

build-data/paper.at

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ public net.minecraft.world.entity.Mob lootTable
254254
public net.minecraft.world.entity.Mob lootTableSeed
255255
public net.minecraft.world.entity.OminousItemSpawner setItem(Lnet/minecraft/world/item/ItemStack;)V
256256
public net.minecraft.world.entity.OminousItemSpawner spawnItemAfterTicks
257+
public net.minecraft.world.entity.ai.attributes.Attribute sentiment
257258
public net.minecraft.world.entity.ai.attributes.AttributeSupplier getAttributeInstance(Lnet/minecraft/core/Holder;)Lnet/minecraft/world/entity/ai/attributes/AttributeInstance;
258259
public net.minecraft.world.entity.ai.control.MoveControl$Operation
259260
public net.minecraft.world.entity.ai.gossip.GossipContainer gossips

paper-api/src/main/java/org/bukkit/attribute/Attribute.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ private static Attribute getAttribute(@NotNull String key) {
163163
return Registry.ATTRIBUTE.getOrThrow(NamespacedKey.minecraft(key));
164164
}
165165

166+
/**
167+
* {@return the sentiment of this attribute}
168+
*/
169+
@NotNull
170+
Sentiment getSentiment();
171+
166172
/**
167173
* @param name of the attribute.
168174
* @return the attribute with the given name.
@@ -185,4 +191,17 @@ static Attribute valueOf(@NotNull String name) {
185191
static Attribute[] values() {
186192
return Lists.newArrayList(Registry.ATTRIBUTE).toArray(new Attribute[0]);
187193
}
194+
195+
/**
196+
* An attribute sentiment describes the intent behind the attribute, meaning
197+
* whether it is supposed to be a positive, neutral, or negative attribute.
198+
*/
199+
enum Sentiment {
200+
// Start generate - AttributeSentiment
201+
// @GeneratedFrom 1.21.8
202+
POSITIVE,
203+
NEUTRAL,
204+
NEGATIVE;
205+
// End generate - AttributeSentiment
206+
}
188207
}

paper-generator/src/main/java/io/papermc/generator/Rewriters.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import org.bukkit.SoundCategory;
4949
import org.bukkit.Statistic;
5050
import org.bukkit.Tag;
51+
import org.bukkit.attribute.Attribute;
5152
import org.bukkit.block.Biome;
5253
import org.bukkit.block.BlockType;
5354
import org.bukkit.block.banner.PatternType;
@@ -129,6 +130,7 @@ protected EnumValue.Builder rewriteEnumValue(net.minecraft.world.entity.animal.P
129130
.register("SalmonVariant", Salmon.Variant.class, new EnumCloneRewriter<>(net.minecraft.world.entity.animal.Salmon.Variant.class))
130131
.register("ArmadilloState", Armadillo.State.class, new EnumCloneRewriter<>(net.minecraft.world.entity.animal.armadillo.Armadillo.ArmadilloState.class))
131132
.register("SoundCategory", SoundCategory.class, new EnumCloneRewriter<>(SoundSource.class))
133+
.register("AttributeSentiment", Attribute.Sentiment.class, new EnumCloneRewriter<>(net.minecraft.world.entity.ai.attributes.Attribute.Sentiment.class))
132134
.register("ItemUseAnimation", ItemUseAnimation.class, new EnumCloneRewriter<>(net.minecraft.world.item.ItemUseAnimation.class))
133135
.register("ItemRarity", ItemRarity.class, new EnumCloneRewriter<>(Rarity.class) {
134136
@Override

paper-server/patches/sources/net/minecraft/stats/ServerRecipeBook.java.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
ResourceKey<Recipe<?>> resourceKey = recipeHolder.id();
66
if (!this.known.contains(resourceKey) && !recipeHolder.value().isSpecial()) {
77
+ // Paper start - PlayerRecipeDiscoverEvent event
8-
+ org.bukkit.event.player.PlayerRecipeDiscoverEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerRecipeListUpdateEvent(player, recipeHolder);
8+
+ final org.bukkit.event.player.PlayerRecipeDiscoverEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerRecipeListUpdateEvent(player, recipeHolder);
99
+ if (event.isCancelled()) continue;
10-
+ // Paper end
10+
+ // Paper end - PlayerRecipeDiscoverEvent event
1111
this.add(resourceKey);
1212
this.addHighlight(resourceKey);
1313
this.displayResolver

paper-server/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttribute.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ public CraftAttribute(final Holder<net.minecraft.world.entity.ai.attributes.Attr
5656
super(holder, count++);
5757
}
5858

59+
@Override
60+
public Sentiment getSentiment() {
61+
return Sentiment.valueOf(this.getHandle().sentiment.name());
62+
}
63+
5964
@Override
6065
public String getTranslationKey() {
6166
return this.getHandle().getDescriptionId();

0 commit comments

Comments
 (0)