-
-
Notifications
You must be signed in to change notification settings - Fork 110
Determination format modernization Part.2 #2689
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
@@ -34,6 +34,9 @@ public class RedstoneScriptEvent extends BukkitScriptEvent implements Listener { | |||
|
|||
public RedstoneScriptEvent() { | |||
registerCouldMatcher("redstone recalculated"); | |||
this.<RedstoneScriptEvent, ElementTag>registerDetermination(null, ElementTag.class, (evt, context, current) -> { | |||
evt.event.setNewCurrent(current.asInt()); |
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.
these rewrites are removing the error checks that the prior impl had
return switch (name) { | ||
case "location" -> location; | ||
case "item" -> item; | ||
case "recipe_id" -> new ElementTag(Utilities.namespacedKeyToString(event.getRecipe().getKey()), 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.
this is a functionality change
Updated |
@@ -44,6 +45,11 @@ public class FurnaceStartsSmeltingScriptEvent extends BukkitScriptEvent implemen | |||
|
|||
public FurnaceStartsSmeltingScriptEvent() { | |||
registerCouldMatcher("furnace starts smelting <item>"); | |||
this.<FurnaceStartsSmeltingScriptEvent, DurationTag>registerDetermination(null, DurationTag.class, (evt, context, time) -> { | |||
if (time.asElement().isInt()) { |
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 still has no error handling that was previously available. Go test a bad determination on an old build vs your version and compare the results
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.
... go test a good determination too, this is registered as a DurationTag, so asElement.isInt is always false
@@ -34,6 +34,11 @@ public class RedstoneScriptEvent extends BukkitScriptEvent implements Listener { | |||
|
|||
public RedstoneScriptEvent() { | |||
registerCouldMatcher("redstone recalculated"); | |||
this.<RedstoneScriptEvent, ElementTag>registerDetermination(null, ElementTag.class, (evt, context, current) -> { | |||
if (current.asElement().isInt()) { |
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.
It should already be an element?
@@ -50,6 +50,9 @@ public class PlayerCraftsItemScriptEvent extends BukkitScriptEvent implements Li | |||
// --> | |||
|
|||
public PlayerCraftsItemScriptEvent() { | |||
this.<PlayerCraftsItemScriptEvent, ItemTag>registerDetermination(null, ItemTag.class, (evt, context, result_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.
Java naming standards - this would be resultItem
if (!couldMatchItem(path.eventArgLowerAt(2))) { | ||
return false; | ||
} | ||
return true; | ||
return couldMatchItem(path.eventArgLowerAt(2)); |
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.
That syntax was intentional - either way if anything just update it to registerCouldMatcher
, no point changing around code that needs to be removed anyway
@@ -47,6 +47,11 @@ public class PlayerItemTakesDamageScriptEvent extends BukkitScriptEvent implemen | |||
|
|||
public PlayerItemTakesDamageScriptEvent() { | |||
registerCouldMatcher("player <item> takes damage"); | |||
this.<PlayerItemTakesDamageScriptEvent, ElementTag>registerDetermination(null, ElementTag.class, (evt, context, amount) -> { | |||
if (amount.asElement().isInt()) { |
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.
Same here, this is already an element
Marking this as a draft for now, feel free to mark as ready to review once comments are addressed. |
Updating the determination format for the following ScriptEvents :
FurnaceStartsSmeltingScriptEvent
RedstoneScriptEvent
EntityHealsScriptEvent
PlayerCraftsItemScriptEvent
PlayerItemTakesDamageScriptEvent