mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-01 20:52:12 -07:00
Add get/set customName to Skull block (#12302)
This commit is contained in:
@@ -605,6 +605,7 @@ public net.minecraft.world.level.block.entity.SculkSensorBlockEntity lastVibrati
|
|||||||
public net.minecraft.world.level.block.entity.SculkShriekerBlockEntity warningLevel
|
public net.minecraft.world.level.block.entity.SculkShriekerBlockEntity warningLevel
|
||||||
public net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity openCount
|
public net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity openCount
|
||||||
public net.minecraft.world.level.block.entity.SignBlockEntity playerWhoMayEdit
|
public net.minecraft.world.level.block.entity.SignBlockEntity playerWhoMayEdit
|
||||||
|
public net.minecraft.world.level.block.entity.SkullBlockEntity customName
|
||||||
public net.minecraft.world.level.block.entity.SkullBlockEntity noteBlockSound
|
public net.minecraft.world.level.block.entity.SkullBlockEntity noteBlockSound
|
||||||
public net.minecraft.world.level.block.entity.SkullBlockEntity owner
|
public net.minecraft.world.level.block.entity.SkullBlockEntity owner
|
||||||
public net.minecraft.world.level.block.entity.StructureBlockEntity author
|
public net.minecraft.world.level.block.entity.StructureBlockEntity author
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package org.bukkit.block;
|
package org.bukkit.block;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
@@ -168,4 +169,24 @@ public interface Skull extends TileState {
|
|||||||
@Deprecated(since = "1.13", forRemoval = true)
|
@Deprecated(since = "1.13", forRemoval = true)
|
||||||
@Contract("_ -> fail")
|
@Contract("_ -> fail")
|
||||||
public void setSkullType(SkullType skullType);
|
public void setSkullType(SkullType skullType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the custom name of skull.
|
||||||
|
* <p>This name is set when placing a skull item that has a custom name.
|
||||||
|
* This name is only carried back to the item when broken for player heads
|
||||||
|
* (skeleton/creeper heads will not retain the name).</p>
|
||||||
|
*
|
||||||
|
* @return Custom name of skull
|
||||||
|
*/
|
||||||
|
public @Nullable Component customName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the custom name of skull.
|
||||||
|
* <p>This name is set when placing a skull item that has a custom name.
|
||||||
|
* This name is only carried back to the item when broken for player heads
|
||||||
|
* (skeleton/creeper heads will not retain the name).</p>
|
||||||
|
*
|
||||||
|
* @param customName Custom name of skull
|
||||||
|
*/
|
||||||
|
public void customName(@Nullable Component customName);
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,8 @@ package org.bukkit.craftbukkit.block;
|
|||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import io.papermc.paper.adventure.PaperAdventure;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minecraft.Util;
|
import net.minecraft.Util;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
@@ -216,4 +218,16 @@ public class CraftSkull extends CraftBlockEntityState<SkullBlockEntity> implemen
|
|||||||
public CraftSkull copy(Location location) {
|
public CraftSkull copy(Location location) {
|
||||||
return new CraftSkull(this, location);
|
return new CraftSkull(this, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable Component customName() {
|
||||||
|
SkullBlockEntity snapshot = getSnapshot();
|
||||||
|
return snapshot.customName == null ? null : PaperAdventure.asAdventure(snapshot.customName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void customName(@Nullable Component customName) {
|
||||||
|
SkullBlockEntity snapshot = getSnapshot();
|
||||||
|
snapshot.customName = customName == null ? null : PaperAdventure.asVanilla(customName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user