Fixed chained crafters not taking over the name of the root crafter. Fixes #3418

This commit is contained in:
raoulvdberge
2022-12-10 20:01:27 +01:00
parent a0a6423432
commit 5f8b445a78
3 changed files with 28 additions and 2 deletions

View File

@@ -7,6 +7,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased] ## [Unreleased]
### Fixed
- Fixed chained crafters not taking over the name of the root crafter.
## [v1.11.1] - 2022-10-30 ## [v1.11.1] - 2022-10-30
### Fixed ### Fixed

View File

@@ -86,11 +86,23 @@ public interface ICraftingPatternContainer {
/** /**
* The name of this container for categorizing in the Crafting Manager GUI. * The name of this container for categorizing in the Crafting Manager GUI.
* Will return the name of the root container if we're in a chained scenario.
* *
* @return the name of this container * @return the name of this container
*/ */
Component getName(); Component getName();
/**
* The custom name of this container, as set in an anvil for example.
* Can be null.
*
* @return the name of this container
*/
@Nullable
default Component getCustomName() {
return null;
}
/** /**
* @return the position of this container * @return the position of this container
*/ */

View File

@@ -298,11 +298,21 @@ public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternC
} }
@Override @Override
public Component getName() { @Nullable
if (displayName != null) { public Component getCustomName() {
return displayName; return displayName;
} }
@Override
public Component getName() {
ICraftingPatternContainer root = getRootContainer();
if (root != null) {
Component displayNameOfRoot = root.getCustomName();
if (displayNameOfRoot != null) {
return displayNameOfRoot;
}
}
BlockEntity facing = getConnectedBlockEntity(); BlockEntity facing = getConnectedBlockEntity();
if (facing instanceof Nameable && ((Nameable) facing).getName() != null) { if (facing instanceof Nameable && ((Nameable) facing).getName() != null) {