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

some planned screen anvancement and let functions of screen support crafter. #1833

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

17183248569
Copy link
Contributor

@17183248569 17183248569 commented Oct 16, 2023

i want to try my best to do that....... maybe i will need others help in the future....

  • get_current_screen()
  • event of player opening GUI

that pr is to add a scarpet usage like this:

/script run __on_player_open_screen(player, screen_type)->get_current_screen(player [, a lambda callback could be here] )

to make script can touch vanilla screens. (after getting the screen object, users can use it.)
because the user may want to append a callback to the returned screen, i let the 2nd argument of __on_player_open_screen be screen_type instead of a screenvalue itself.

=================================

it supports crafters now.
use create_screen(player(),'crafter_3x3', 'screen name') to create one.
which has following property:
crafter_slot_disable_0
crafter_slot_disable_1
...
crafter_slot_disable_8 (the slots "lock")

crafter_enable (the red arrow in the middle of the GUI) (should it be called red_arrow directly?)

===================================

example 1:
/execute as @p run script run create_screen(p,'crafter_3x3','333',_(s,p,x,y)->(if(!s,return());screen_property(s,'crafter_slot_disable_0',screen_property(s,'crafter_slot_disable_8'))))

Minecraft__1.20.3_-_Singleplayer_2023-12-10_05-55-53.1.webm

===============
example 2:

/script run __on_player_open_screen(p,s)->get_current_screen(p,_(s,p,x,y)->(if(!s,return());screen_property(s,'crafter_slot_disable_0',screen_property(s,'crafter_slot_disable_8'))))
Minecraft__1.20.3_-_Singleplayer_2023-12-10_06-02-03.webm

the script creates an callback function to be run on player opens a vanilla screen. and in which, another callback is added to that vanilla screen.

{
this.screenHandler = player.containerMenu;

this.name = Component.literal("seems that the game forgot that");//should i make something like a weak map to remember it?
Copy link
Contributor

Choose a reason for hiding this comment

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

I would not use a map, since you aren't gonna know whether a screen will ever be retrieved from get_current_screen at all. It just creates additional overhead, that would be required even if no scripts are running. Setting it to null and returning a null value when querying name is probably the best option IMO.

Copy link
Contributor Author

@17183248569 17183248569 Oct 17, 2023

Choose a reason for hiding this comment

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

ok. i let it be null now.

@17183248569 17183248569 changed the title some planned screen anvancement some planned screen anvancement and let functions of screen support crafter. Nov 1, 2023
@17183248569 17183248569 marked this pull request as draft December 26, 2023 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants