geforkt von Mirrors/Paper
#1125: Add support for NoteBlock sounds in Skulls
By: Doc <nachito94@msn.com>
Dieser Commit ist enthalten in:
Ursprung
7f7ce313db
Commit
be664f5cc4
@ -0,0 +1,26 @@
|
||||
--- a/net/minecraft/world/level/block/entity/TileEntitySkull.java
|
||||
+++ b/net/minecraft/world/level/block/entity/TileEntitySkull.java
|
||||
@@ -33,7 +33,7 @@
|
||||
@Nullable
|
||||
public GameProfile owner;
|
||||
@Nullable
|
||||
- private MinecraftKey noteBlockSound;
|
||||
+ public MinecraftKey noteBlockSound; // PAIL private->public
|
||||
private int animationTickCount;
|
||||
private boolean isAnimating;
|
||||
|
||||
@@ -148,9 +148,12 @@
|
||||
gameprofile1 = TileEntitySkull.sessionService.fillProfileProperties(gameprofile1, true);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - decompile error
|
||||
+ final GameProfile finalgameprofile1 = gameprofile1;
|
||||
TileEntitySkull.mainThreadExecutor.execute(() -> {
|
||||
- TileEntitySkull.profileCache.add(gameprofile1);
|
||||
- consumer.accept(gameprofile1);
|
||||
+ TileEntitySkull.profileCache.add(finalgameprofile1);
|
||||
+ consumer.accept(finalgameprofile1);
|
||||
+ // CraftBukkit end
|
||||
});
|
||||
}, () -> {
|
||||
TileEntitySkull.mainThreadExecutor.execute(() -> {
|
@ -2,9 +2,11 @@ package org.bukkit.craftbukkit.block;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.resources.MinecraftKey;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.level.block.entity.TileEntitySkull;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.SkullType;
|
||||
import org.bukkit.World;
|
||||
@ -15,7 +17,9 @@ import org.bukkit.block.data.Directional;
|
||||
import org.bukkit.block.data.Rotatable;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.profile.CraftPlayerProfile;
|
||||
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
import org.bukkit.profile.PlayerProfile;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implements Skull {
|
||||
|
||||
@ -120,6 +124,21 @@ public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implement
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespacedKey getNoteBlockSound() {
|
||||
MinecraftKey key = getSnapshot().getNoteBlockSound();
|
||||
return (key != null) ? CraftNamespacedKey.fromMinecraft(key) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNoteBlockSound(@Nullable NamespacedKey namespacedKey) {
|
||||
if (namespacedKey == null) {
|
||||
this.getSnapshot().noteBlockSound = null;
|
||||
return;
|
||||
}
|
||||
this.getSnapshot().noteBlockSound = CraftNamespacedKey.toMinecraft(namespacedKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockFace getRotation() {
|
||||
BlockData blockData = getBlockData();
|
||||
|
@ -4,19 +4,23 @@ import com.google.common.collect.ImmutableMap.Builder;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import net.minecraft.nbt.GameProfileSerializer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.resources.MinecraftKey;
|
||||
import net.minecraft.world.level.block.entity.TileEntitySkull;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.serialization.DelegateDeserialization;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.inventory.CraftMetaItem.SerializableMeta;
|
||||
import org.bukkit.craftbukkit.profile.CraftPlayerProfile;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.profile.PlayerProfile;
|
||||
|
||||
@ -44,10 +48,15 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
static final ItemMetaKey SKULL_PROFILE = new ItemMetaKey("SkullProfile");
|
||||
|
||||
static final ItemMetaKey SKULL_OWNER = new ItemMetaKey("SkullOwner", "skull-owner");
|
||||
|
||||
@ItemMetaKey.Specific(ItemMetaKey.Specific.To.NBT)
|
||||
static final ItemMetaKey BLOCK_ENTITY_TAG = new ItemMetaKey("BlockEntityTag");
|
||||
static final ItemMetaKey NOTE_BLOCK_SOUND = new ItemMetaKey("note_block_sound");
|
||||
static final int MAX_OWNER_LENGTH = 16;
|
||||
|
||||
private GameProfile profile;
|
||||
private NBTTagCompound serializedProfile;
|
||||
private MinecraftKey noteBlockSound;
|
||||
|
||||
CraftMetaSkull(CraftMetaItem meta) {
|
||||
super(meta);
|
||||
@ -56,6 +65,7 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
}
|
||||
CraftMetaSkull skullMeta = (CraftMetaSkull) meta;
|
||||
this.setProfile(skullMeta.profile);
|
||||
this.noteBlockSound = skullMeta.noteBlockSound;
|
||||
}
|
||||
|
||||
CraftMetaSkull(NBTTagCompound tag) {
|
||||
@ -66,6 +76,13 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
} else if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_STRING) && !tag.getString(SKULL_OWNER.NBT).isEmpty()) {
|
||||
this.setProfile(new GameProfile(null, tag.getString(SKULL_OWNER.NBT)));
|
||||
}
|
||||
|
||||
if (tag.contains(BLOCK_ENTITY_TAG.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) {
|
||||
NBTTagCompound nbtTagCompound = tag.getCompound(BLOCK_ENTITY_TAG.NBT).copy();
|
||||
if (nbtTagCompound.contains(NOTE_BLOCK_SOUND.NBT, 8)) {
|
||||
this.noteBlockSound = MinecraftKey.tryParse(nbtTagCompound.getString(NOTE_BLOCK_SOUND.NBT));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CraftMetaSkull(Map<String, Object> map) {
|
||||
@ -78,6 +95,15 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
setOwner(SerializableMeta.getString(map, SKULL_OWNER.BUKKIT, true));
|
||||
}
|
||||
}
|
||||
|
||||
if (noteBlockSound == null) {
|
||||
Object object = map.get(NOTE_BLOCK_SOUND.BUKKIT);
|
||||
if (object instanceof NamespacedKey) {
|
||||
setNoteBlockSound((NamespacedKey) object);
|
||||
} else {
|
||||
setNoteBlockSound(SerializableMeta.getObject(NamespacedKey.class, map, NOTE_BLOCK_SOUND.BUKKIT, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -94,6 +120,13 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
|
||||
this.setProfile(GameProfileSerializer.readGameProfile(skullTag));
|
||||
}
|
||||
|
||||
if (tag.contains(BLOCK_ENTITY_TAG.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) {
|
||||
NBTTagCompound nbtTagCompound = tag.getCompound(BLOCK_ENTITY_TAG.NBT).copy();
|
||||
if (nbtTagCompound.contains(NOTE_BLOCK_SOUND.NBT, 8)) {
|
||||
this.noteBlockSound = MinecraftKey.tryParse(nbtTagCompound.getString(NOTE_BLOCK_SOUND.NBT));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setProfile(GameProfile profile) {
|
||||
@ -114,6 +147,12 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
tag.put(SKULL_OWNER.NBT, serializedProfile);
|
||||
});
|
||||
}
|
||||
|
||||
if (noteBlockSound != null) {
|
||||
NBTTagCompound nbtTagCompound = new NBTTagCompound();
|
||||
nbtTagCompound.putString(NOTE_BLOCK_SOUND.NBT, this.noteBlockSound.toString());
|
||||
tag.put(BLOCK_ENTITY_TAG.NBT, nbtTagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -122,7 +161,7 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
}
|
||||
|
||||
boolean isSkullEmpty() {
|
||||
return profile == null;
|
||||
return profile == null && noteBlockSound == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -206,6 +245,20 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNoteBlockSound(NamespacedKey noteBlockSound) {
|
||||
if (noteBlockSound == null) {
|
||||
this.noteBlockSound = null;
|
||||
} else {
|
||||
this.noteBlockSound = CraftNamespacedKey.toMinecraft(noteBlockSound);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespacedKey getNoteBlockSound() {
|
||||
return (this.noteBlockSound == null) ? null : CraftNamespacedKey.fromMinecraft(this.noteBlockSound);
|
||||
}
|
||||
|
||||
@Override
|
||||
int applyHash() {
|
||||
final int original;
|
||||
@ -213,6 +266,9 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
if (hasOwner()) {
|
||||
hash = 61 * hash + profile.hashCode();
|
||||
}
|
||||
if (this.noteBlockSound != null) {
|
||||
hash = 61 * hash + noteBlockSound.hashCode();
|
||||
}
|
||||
return original != hash ? CraftMetaSkull.class.hashCode() ^ hash : hash;
|
||||
}
|
||||
|
||||
@ -225,7 +281,7 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
CraftMetaSkull that = (CraftMetaSkull) meta;
|
||||
|
||||
// SPIGOT-5403: equals does not check properties
|
||||
return (this.profile != null ? that.profile != null && this.serializedProfile.equals(that.serializedProfile) : that.profile == null);
|
||||
return (this.profile != null ? that.profile != null && this.serializedProfile.equals(that.serializedProfile) : that.profile == null) && Objects.equals(this.noteBlockSound, that.noteBlockSound);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -241,6 +297,10 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
if (this.profile != null) {
|
||||
return builder.put(SKULL_OWNER.BUKKIT, new CraftPlayerProfile(this.profile));
|
||||
}
|
||||
NamespacedKey namespacedKeyNB = this.getNoteBlockSound();
|
||||
if (namespacedKeyNB != null) {
|
||||
return builder.put(NOTE_BLOCK_SOUND.BUKKIT, namespacedKeyNB);
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren