gnembon / fabric-carpet

Fabric Carpet
MIT License
1.65k stars 261 forks source link

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

Open ch-yx opened 8 months ago

ch-yx commented 8 months ago

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

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.