Skip to content

Add ExprFuseTicks#8552

Open
CJH3139 wants to merge 2 commits intoSkriptLang:dev/featurefrom
CJH3139:cjh/fuseticks
Open

Add ExprFuseTicks#8552
CJH3139 wants to merge 2 commits intoSkriptLang:dev/featurefrom
CJH3139:cjh/fuseticks

Conversation

@CJH3139
Copy link
Copy Markdown
Contributor

@CJH3139 CJH3139 commented Apr 17, 2026

Problem

#8489

Solution

Adds a new fuse ticks expression for creepers and primed tnts using Paper's getMaxFuseTicks()/setMaxFuseTicks() for creepers and getFuseTicks()/setFuseTicks() for tnts

Testing Completed

src/test/skript/tests/syntaxes/expressions/ExprFuseTicks.sk
Also did a quick test with effect commands in skriptTestDev
image

Supporting Information


Completes: #8489
Related: none
AI assistance: none

@CJH3139 CJH3139 requested a review from a team as a code owner April 17, 2026 05:53
@CJH3139 CJH3139 requested review from cheeezburga and erenkarakal and removed request for a team April 17, 2026 05:53
@skriptlang-automation skriptlang-automation Bot added the needs reviews A PR that needs additional reviews label Apr 17, 2026
Copy link
Copy Markdown
Member

@sovdeeth sovdeeth left a comment

Choose a reason for hiding this comment

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

Should be "fuse duration" and use timespans. You should also update/remove ExprCreeperMaxFuseTicks. Also, a duplicate of #8499 but that one may be abandoned

@AnOwlBe
Copy link
Copy Markdown

AnOwlBe commented Apr 17, 2026

Should be "fuse duration" and use timespans. You should also update/remove ExprCreeperMaxFuseTicks. Also, a duplicate of #8499 but that one may be abandoned

I kind of forgot about it lol though what needs to be done on it just accepting the changes you suggested n updating the branch?

@CJH3139 CJH3139 requested a review from sovdeeth April 17, 2026 07:15
Copy link
Copy Markdown
Member

@sovdeeth sovdeeth left a comment

Choose a reason for hiding this comment

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

Looks really good


static {
if(Skript.methodExists(LivingEntity.class, "getMaxFuseTicks"))
register(ExprCreeperMaxFuseTicks.class, Long.class, "[creeper] max[imum] fuse tick[s]", "livingentities");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This syntax doesn't conflict, so it may be worth it to deprecate it for a version instead of outright removing it. Thoughts from others?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Deprecation is better

Comment on lines +20 to +21
@Description("The fuse duration of a creeper or primed TNT. For creepers, this is the total fuse duration before explosion. For primed TNT, this is the remaining time before explosion.")
@Example("""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So creepers have max and elapsed fuse ticks, with which you can calculate remaining.
Tnt just has remaining fuse ticks.

I think you should change this to [:elapsed|:remaining|max] fuse duration and have creepers support all, tnt support remaining. Thoughts? I'm not a fan of fuse duration meaning two different things and also just not implementing creeper's getFuseTicks

public static void register(SyntaxRegistry registry) {
registry.register(
SyntaxRegistry.EXPRESSION,
infoBuilder(ExprFuseDuration.class, Timespan.class, "fuse (duration|time)", "entities", false).build()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

missing .supplier()

return "fuse duration";
}

} No newline at end of file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
}
}

assert fuse duration of entity is 0 seconds with "fuse duration of primed tnt should be capped at 0 minimum"
delete fuse duration of entity
assert fuse duration of entity is 0 seconds with "fuse duration of primed tnt should be 0 seconds after deletion"
delete entity No newline at end of file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
delete entity
delete entity

@sovdeeth
Copy link
Copy Markdown
Member

sovdeeth commented Apr 21, 2026

Should be "fuse duration" and use timespans. You should also update/remove ExprCreeperMaxFuseTicks. Also, a duplicate of #8499 but that one may be abandoned

I kind of forgot about it lol though what needs to be done on it just accepting the changes you suggested n updating the branch?

Just gonna close it in favor of this one, this one has better code.

Edit: Oh wait, sorry, I thought you (Owl) opened this one too! Are you ok with letting CJH take this PR or do you want to finish it out yourself?


static {
if(Skript.methodExists(LivingEntity.class, "getMaxFuseTicks"))
register(ExprCreeperMaxFuseTicks.class, Long.class, "[creeper] max[imum] fuse tick[s]", "livingentities");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Deprecation is better

Comment on lines +41 to +44
if (entity instanceof Creeper creeper)
return new Timespan(Timespan.TimePeriod.TICK, creeper.getMaxFuseTicks());
else if (entity instanceof TNTPrimed tnt)
return new Timespan(Timespan.TimePeriod.TICK, tnt.getFuseTicks());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (entity instanceof Creeper creeper)
return new Timespan(Timespan.TimePeriod.TICK, creeper.getMaxFuseTicks());
else if (entity instanceof TNTPrimed tnt)
return new Timespan(Timespan.TimePeriod.TICK, tnt.getFuseTicks());
if (entity instanceof Creeper creeper) {
return new Timespan(Timespan.TimePeriod.TICK, creeper.getMaxFuseTicks());
} else if (entity instanceof TNTPrimed tnt) {
return new Timespan(Timespan.TimePeriod.TICK, tnt.getFuseTicks());
}

@skriptlang-automation skriptlang-automation Bot removed the needs reviews A PR that needs additional reviews label Apr 21, 2026
@sovdeeth sovdeeth added the enhancement Feature request, an issue about something that could be improved, or a PR improving something. label Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Feature request, an issue about something that could be improved, or a PR improving something.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants