Skip to content

Commit 0e7e453

Browse files
committed
Add noteblocksound to player head item meta
1 parent 103f5fc commit 0e7e453

File tree

4 files changed

+46
-9
lines changed

4 files changed

+46
-9
lines changed

src/main/java/com/laytonsmith/abstraction/MCSkullMeta.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@ public interface MCSkullMeta extends MCItemMeta {
1616

1717
void setProfile(MCPlayerProfile profile);
1818

19+
String getNoteBlockSound();
20+
21+
void setNoteBlockSound(String noteBlockSound);
22+
1923
}

src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCSkullMeta.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.laytonsmith.abstraction.MCPlayerProfile;
77
import com.laytonsmith.abstraction.MCSkullMeta;
88
import com.laytonsmith.core.Static;
9+
import org.bukkit.NamespacedKey;
910
import org.bukkit.OfflinePlayer;
1011
import org.bukkit.inventory.meta.SkullMeta;
1112

@@ -71,4 +72,18 @@ public void setProfile(MCPlayerProfile profile) {
7172
// Completes the profile from user cache.
7273
this.sm.setPlayerProfile((PlayerProfile) profile.getHandle());
7374
}
75+
76+
@Override
77+
public String getNoteBlockSound() {
78+
NamespacedKey sound = this.sm.getNoteBlockSound();
79+
if(sound == null) {
80+
return null;
81+
}
82+
return sound.toString();
83+
}
84+
85+
@Override
86+
public void setNoteBlockSound(String noteBlockSound) {
87+
this.sm.setNoteBlockSound(NamespacedKey.fromString(noteBlockSound));
88+
}
7489
}

src/main/java/com/laytonsmith/core/ObjectGenerator.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,14 @@ public Construct itemMeta(MCItemStack is, Target t) {
789789
ma.set("owneruuid", CNull.NULL, t);
790790
}
791791
}
792+
if(Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_19_3)) {
793+
String sound = ((MCSkullMeta) meta).getNoteBlockSound();
794+
if(sound == null) {
795+
ma.set("noteblocksound", CNull.NULL, t);
796+
} else {
797+
ma.set("noteblocksound", new CString(sound, t), t);
798+
}
799+
}
792800
} else if(meta instanceof MCEnchantmentStorageMeta) {
793801
Construct stored;
794802
if(((MCEnchantmentStorageMeta) meta).hasStoredEnchants()) {
@@ -1539,6 +1547,14 @@ public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t) throws ConfigRunti
15391547
}
15401548
}
15411549
}
1550+
if(Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_19_3)) {
1551+
if(ma.containsKey("noteblocksound")) {
1552+
Mixed sound = ma.get("noteblocksound", t);
1553+
if(!(sound instanceof CNull)) {
1554+
((MCSkullMeta) meta).setNoteBlockSound(sound.val());
1555+
}
1556+
}
1557+
}
15421558
} else if(meta instanceof MCEnchantmentStorageMeta) {
15431559
if(ma.containsKey("stored")) {
15441560
Mixed stored = ma.get("stored", t);

src/main/resources/functionDocs/get_itemmeta

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ array {[player,] slot} Returns an associative array of known item data in the sl
55
These fields exist for all items with meta.
66
{| width="100%" cellspacing="1" cellpadding="1" border="1" class="wikitable"
77
|-
8-
! scope="col" width="15%" | Field
8+
! scope="col" width="12%" | Field
99
! scope="col" width="15%" | Type
10-
! scope="col" width="70%" | Description
10+
! scope="col" width="73%" | Description
1111
|-
1212
! display
1313
| string
@@ -57,8 +57,8 @@ These fields optionally exist for any item type.
5757
{| width="100%" cellspacing="1" cellpadding="1" border="1" class="wikitable"
5858
|-
5959
! scope="col" width="12%" | Field
60-
! scope="col" width="23%" | Type
61-
! scope="col" width="65%" | Description
60+
! scope="col" width="15%" | Type
61+
! scope="col" width="73%" | Description
6262
|-
6363
! damage
6464
| int
@@ -101,11 +101,11 @@ These fields optionally exist for any item type.
101101
|-
102102
! glider
103103
| boolean
104-
| Overrides if the item allows gliding when equipped like an elytra. (MC 1.21.3+)
104+
| Overrides if the item allows gliding like an elytra when equipped. (MC 1.21.3+)
105105
|-
106106
! remainder
107107
| associative array
108-
| Overrides the remaining item when the this item is used. (MC 1.21.3+)
108+
| Overrides the remaining item when the quantity of this item decreases after use. (e.g. a bucket after drinking a milk bucket) (MC 1.21.3+)
109109
|}
110110

111111
These fields only exist for specific item types.
@@ -224,6 +224,7 @@ The remaining tags are not yet supported.
224224
! GoatHorns
225225
|
226226
* '''instrument''' : (string) The instrument name (can be ponder_goat_horn, sing_goat_horn, seek_goat_horn, feel_goat_horn, admire_goat_horn, call_goat_horn, yearn_goat_horn, dream_goat_horn). (MC 1.19.3+)
227+
Custom instrument definitions featuring a different sound event, description, duration and range are not yet supported. (missing server API)
227228
|-
228229
! Inventory Blocks
229230
|
@@ -257,6 +258,7 @@ The remaining tags are not yet supported.
257258
* '''owner''' : (string) The user name. Can be null if there is no owner.
258259
* '''owneruuid''' : (string) The user UUID. Can be null if there is no owner.
259260
* '''texture''' : (string) The texture property value used for custom heads. This is a base64 encoded JSON object seen under the "Value" key in vanilla. It contains the skin texture URL among other things. Requires an owner. (Paper only)
261+
* '''noteblocksound''' : (string) The namespaced sound id played when player head is on top of a noteblock. (MC 1.19.3+)
260262
|-
261263
! Potions
262264
|
@@ -325,7 +327,7 @@ The entity's custom name is derived from the item "display" string. All other tr
325327
Other data not yet supported in item meta:
326328

327329
* MC 1.13.2 : "can_break" and "can_place_on" (Paper only)
328-
* MC 1.20.5 : "item_name", "note_block_sound", "intangible_projectile" (Paper 1.21.3 only), "instrument" (partial support due to partial server API), "tool" (partial server API), "hide_tooltip" (later integrated into "tooltip_display"), "lock" (insufficient server API)
329-
* MC 1.21.2 : "damage_resistant", "tooltip_style", "use_cooldown", "item_model", "death_protection" (Paper only), "repairable" (Paper only), "consumable" (added in Spigot 1.21.4 API), "equippable" (added in Spigot 1.21.5 API)
330+
* MC 1.20.5 : "item_name", "intangible_projectile" (Paper 1.21.3 only), "instrument" (can only get custom definitions in Paper, not set), "tool" (cannot get tags in 'rules', can_destroy_blocks_in_creative field only in Paper), "hide_tooltip" (later integrated into "tooltip_display"), "lock" (can only set with server API)
331+
* MC 1.21.2 : "damage_resistant", "tooltip_style", "use_cooldown", "item_model", "death_protection" (Paper only), "repairable" (Paper only), "consumable" (added in Spigot 1.21.4 API, Paper API separate), "equippable" (added in Spigot 1.21.5 API)
330332
* MC 1.21.4 : "custom_model_data" (for anything other than a single float rounded down)
331-
* MC 1.21.5 : "weapon", "blocks_attacks", "break_sound", "provides_banner_patterns", "provides_trim_material", "potion_duration_scale" (Paper only), "tooltip_display" (partially supported with "flags")
333+
* MC 1.21.5 : "weapon" (separate Paper/Spigot API), "blocks_attacks" (separate Paper/Spigot API), "break_sound" (separate Paper/Spigot API), "provides_banner_patterns" (Paper only), "provides_trim_material" (Paper only), "potion_duration_scale" (Paper only), "tooltip_display" (partially supported with "flags")

0 commit comments

Comments
 (0)