tutorial:propertydelegates
                Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tutorial:propertydelegates [2020/08/14 17:18] – [Showing the Information with the Screen] manymoney2 | tutorial:propertydelegates [2022/05/27 16:00] (current) – solidblock | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Syncing Integers with PropertyDelegates ====== | ====== Syncing Integers with PropertyDelegates ====== | ||
| - | **PropertyDelegate: | + | **PropertyDelegate: | 
| - | In this Tutorial we will sync Integer values between the client and the Server, an example for this in vanilla  | + | In this Tutorial we will sync Integer values between the client and the server, an example for this in Vanilla  | 
| - | To understand this tutorial you need to read the first [[tutorial: | + | To understand this tutorial you need to read the first [[tutorial: | 
| Methods which have no code here were already shown in that tutorial. | Methods which have no code here were already shown in that tutorial. | ||
| Line 12: | Line 12: | ||
| As the Block class does not need to be changed at all we leave it out here. | As the Block class does not need to be changed at all we leave it out here. | ||
| - | Our BlockEntity now implements Tickable, this will provide the tick() method which gets called every tick. We use it to increase our Integer we want to sync | + | Our '' | 
| <code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
| Line 67: | Line 67: | ||
| @Override | @Override | ||
| public Text getDisplayName() { | public Text getDisplayName() { | ||
| - |         return new TranslatableText(getCachedState().getBlock().getTranslationKey()); | + |          | 
| + |         return Text.translatable(getCachedState().getBlock().getTranslationKey()); | ||
| } | } | ||
| Line 133: | Line 134: | ||
| ====== Showing the Information with the Screen ====== | ====== Showing the Information with the Screen ====== | ||
| - | As the screen gets the ScreenHandler in its constructor, | + | As the screen gets the '' | 
| <code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
| Line 171: | Line 172: | ||
| ====== Result ====== | ====== Result ====== | ||
| - | As the registration of the ScreenHandler is identical to the first tutorial we can see the result already! | + | As the registration of the '' | 
| - | When the BlockEntity is placed it will increase the syncedInt by one each tick, when we look inside the container the integer will | + | When the BlockEntity is placed it will increase the '' | 
| automatically be synced to the client and rendered in the top left corner. | automatically be synced to the client and rendered in the top left corner. | ||
| + | [[https:// | ||
| - | + | If you want a more realistic example, you might want to have a look at '' | |
| - | If you want a more realistic example, you might want to have a look at AbstractFurnaceEntity and AbstractFurnaceScreenHandler in the minecraft  | + | |
tutorial/propertydelegates.1597425500.txt.gz · Last modified: 2020/08/14 17:18 by manymoney2