Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lectern page tag/mech fix #2598

Merged
merged 5 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3679,13 +3679,30 @@ else if (PolygonTag.matches(attribute.getParam())) {
// @returns ElementTag(Number)
// @mechanism LocationTag.lectern_page
// @group world
// @deprecated Use 'LocationTag.page'
// @description
// Returns the current page on display in the book on this Lectern block.
// Deprecated in favor of <@link tag LocationTag.page>.
// -->
tagProcessor.registerTag(ElementTag.class, "lectern_page", (attribute, object) -> {
BukkitImplDeprecations.lecternPage.warn(attribute.context);
BlockState state = object.getBlockStateForTag(attribute);
if (state instanceof Lectern) {
return new ElementTag(((Lectern) state).getPage());
if (state instanceof Lectern lectern) {
return new ElementTag(lectern.getPage());
}
return null;
});

// <--[tag]
// @attribute <LocationTag.page>
// @returns ElementTag(Number)
// @mechanism LocationTag.page
// @group world
// @description
// Returns the current page on display in the book on this Lectern block.
// -->
tagProcessor.registerTag(ElementTag.class, "page", (attribute, object) -> {
if (object.getBlockState() instanceof Lectern lectern) {
return new ElementTag(lectern.getPage() + 1);
}
return null;
});
Expand Down Expand Up @@ -4468,6 +4485,28 @@ else if (mechanism.requireObject(EntityTag.class)) {
chiseledBookshelf.setLastInteractedSlot(input.asInt() - 1);
}
});

// <--[mechanism]
// @object LocationTag
// @name page
// @input ElementTag(Number)
// @description
// Changes the page currently displayed on the book in a lectern block.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it's usually Sets?

// @tags
// <LocationTag.page>
// -->
tagProcessor.registerMechanism("page", false, ElementTag.class, (object, mechanism, input) -> {
if (!mechanism.requireInteger()) {
return;
}
if (object.getBlockState() instanceof Lectern lectern) {
lectern.setPage(input.asInt() - 1);
lectern.update();
}
else {
mechanism.echoError("The 'LocationTag.page' mechanism can only be called on a lectern block.");
}
});
}

public static final ObjectTagProcessor<LocationTag> tagProcessor = new ObjectTagProcessor<>();
Expand Down Expand Up @@ -5067,15 +5106,17 @@ else if (state instanceof Dropper) {
// @object LocationTag
// @name lectern_page
// @input ElementTag(Number)
// @deprecated Use LocationTag.page
// @description
// Changes the page currently displayed on the book in a lectern block.
// Deprecated in favor of <@link tag LocationTag.page>.
// @tags
// <LocationTag.lectern_page>
// -->
if (mechanism.matches("lectern_page") && mechanism.requireInteger()) {
BukkitImplDeprecations.lecternPage.warn(mechanism.context);
BlockState state = getBlockState();
if (state instanceof Lectern) {
((Lectern) state).setPage(mechanism.getValue().asInt());
if (state instanceof Lectern lectern) {
lectern.setPage(mechanism.getValue().asInt());
state.update();
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ public class BukkitImplDeprecations {
// Added 2023/11/16, deprecate officially by 2027
public static Warning takeExperience = new FutureWarning("takeExperience", "Using the 'take' command to take experience is deprecated in favor of the 'experience' command.");

// Added 2024/02/19, deprecate officially by 2027.
public static Warning lecternPage = new FutureWarning("lecternPage", "'LocationTag.lectern_page' is deprecated in favor of 'LocationTag.page'.");

// ==================== PAST deprecations of things that are already gone but still have a warning left behind ====================

// Removed upstream 2023/10/29 without warning.
Expand Down