-
-
Notifications
You must be signed in to change notification settings - Fork 112
Trial Spawner and Vaults 1.21 additions #2790
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
base: dev
Are you sure you want to change the base?
Conversation
| // | ||
| // @Location true | ||
| // | ||
| // @Triggers when a vault block state changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be block's or block changes state.
Also . at the end.
| // <context.old_state> returns the vault state before the change. | ||
| // <context.new_state> returns the vault state after the change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs some reference/link as to what the states are, maybe just one link in Triggers (but can also be here if you prefer)
| public BlockDispenseLootScriptEvent() { | ||
| registerCouldMatcher("loot dispenses from <block>"); | ||
| this.<BlockDispenseLootScriptEvent, ListTag>registerDetermination(null, ListTag.class, (evt, context, input) -> { | ||
| List<ItemStack> items = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick, but can initialize to input.size().
| @Override | ||
| public ObjectTag getContext(String name) { | ||
| return switch (name) { | ||
| case "item" -> item; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has the same issue with the context potentially becoming outdated due to another plugin accessing it (e.g. if you - wait a bit in a script and then read it) - need to dynamically get the item here, but can keep the field for matches optimization.
|
|
||
| public BlockDispenseLootScriptEvent() { | ||
| registerCouldMatcher("loot dispenses from <block>"); | ||
| this.<BlockDispenseLootScriptEvent, ListTag>registerDetermination(null, ListTag.class, (evt, context, input) -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just in general, prefixed determinations (to match their context counterparts) are usually preferred as they're easier to understand in scripts & look cleaner if the event ever gets more than one determination.
| || data instanceof Tripwire | ||
| || (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_19) && (data instanceof SculkCatalyst | ||
| || data instanceof SculkShrieker)); | ||
| || data instanceof SculkShrieker)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double space.
| else if (isSculkCatalyst()) { | ||
| return ((SculkCatalyst) material.getModernData()).isBloom() ? "BLOOM" : "NORMAL"; // TODO: 1.19 | ||
| else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_21) && getBlockData() instanceof TrialSpawner trialSpawner) { | ||
| return new ElementTag(trialSpawner.getTrialSpawnerState().name(), true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can use the enum constructor for these
Replaces #2771
Additions:
Updates:
Some of this was copied from @MrMaleficus's earlier PR, so credit to them for the events.