mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
Nameable Banner API
This commit is contained in:
parent
24d356944c
commit
1f68916ac9
2 changed files with 31 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
||||||
--- a/net/minecraft/world/level/block/entity/BannerBlockEntity.java
|
--- a/net/minecraft/world/level/block/entity/BannerBlockEntity.java
|
||||||
+++ b/net/minecraft/world/level/block/entity/BannerBlockEntity.java
|
+++ b/net/minecraft/world/level/block/entity/BannerBlockEntity.java
|
||||||
@@ -19,6 +19,10 @@
|
@@ -19,13 +19,17 @@
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
@ -11,6 +11,14 @@
|
||||||
public class BannerBlockEntity extends BlockEntity implements Nameable {
|
public class BannerBlockEntity extends BlockEntity implements Nameable {
|
||||||
|
|
||||||
private static final Logger LOGGER = LogUtils.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
public static final int MAX_PATTERNS = 6;
|
||||||
|
private static final String TAG_PATTERNS = "patterns";
|
||||||
|
@Nullable
|
||||||
|
- private Component name;
|
||||||
|
+ public Component name; // Paper - public
|
||||||
|
public DyeColor baseColor;
|
||||||
|
private BannerPatternLayers patterns;
|
||||||
|
|
||||||
@@ -74,7 +78,7 @@
|
@@ -74,7 +78,7 @@
|
||||||
BannerPatternLayers.CODEC.parse(registries.createSerializationContext(NbtOps.INSTANCE), nbt.get("patterns")).resultOrPartial((s) -> {
|
BannerPatternLayers.CODEC.parse(registries.createSerializationContext(NbtOps.INSTANCE), nbt.get("patterns")).resultOrPartial((s) -> {
|
||||||
BannerBlockEntity.LOGGER.error("Failed to parse banner patterns: '{}'", s);
|
BannerBlockEntity.LOGGER.error("Failed to parse banner patterns: '{}'", s);
|
||||||
|
|
|
@ -112,4 +112,26 @@ public class CraftBanner extends CraftBlockEntityState<BannerBlockEntity> implem
|
||||||
public CraftBanner copy(Location location) {
|
public CraftBanner copy(Location location) {
|
||||||
return new CraftBanner(this, location);
|
return new CraftBanner(this, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Paper start
|
||||||
|
@Override
|
||||||
|
public net.kyori.adventure.text.Component customName() {
|
||||||
|
return io.papermc.paper.adventure.PaperAdventure.asAdventure(this.getSnapshot().getCustomName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void customName(net.kyori.adventure.text.Component customName) {
|
||||||
|
this.getSnapshot().name = io.papermc.paper.adventure.PaperAdventure.asVanilla(customName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCustomName() {
|
||||||
|
return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serializeOrNull(this.customName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCustomName(String name) {
|
||||||
|
this.customName(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserializeOrNull(name));
|
||||||
|
}
|
||||||
|
// Paper end
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue