-
-
Notifications
You must be signed in to change notification settings - Fork 15
SpeedRunIGT API Document
RedLime edited this page Nov 16, 2022
·
31 revisions
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
//modImplementation "com.github.RedLime:SpeedRunIGT:${project.minecraft_version}-SNAPSHOT"
modImplementation "com.github.RedLime:SpeedRunIGT:1.16.1-SNAPSHOT"
}
in fabric.mod.json
"depends": {
"minecraft": "...",
"speedrunigt": ">=7.0"
}
InGameTimer timer = InGameTimer.getInstance();
InGameTimer.onComplete(igt -> {
MinecraftClient.getInstance().player.sendMessage("Cool bro, " + InGameTime.timeToStringFormat(igt.getInGameTime()));
});
# Example method
public void onPlayerDeath() {
InGameTimer.getInstance().tryInsertNewTimeline("death");
}
in fabric.mod.json
...
"entrypoints": {
...
"speedrunigt": [
"com.redlimerl.mcsr.breakbeehive.BreakBeehiveImpl"
]
},
public class BreakBeehiveImpl implements SpeedRunIGTApi {
public static final RunCategory BREAK_BEEHIVE_CATEGORY =
new RunCategory("break_beehive", "mc_juice/full_game#Break_Beenest", "Break Beehive");
@Override
public RunCategory registerCategory() {
return BREAK_BEEHIVE_CATEGORY;
}
}
Result :
Note! In the development environment, the SpeedRunIGT strings are not displayed normally. but "In the development environment" only. (Fixed in 13.0)
@Mixin(ClientWorld.class)
public class ClientWorldMixin {
@Inject(method = "updateListeners", at = @At("TAIL"))
public void onBlockUpdate(BlockPos pos, BlockState oldState, BlockState newState, int flags, CallbackInfo ci) {
// Get a timer
InGameTimer timer = InGameTimer.getInstance();
// Check has player selected the your category and the timer is running
if (timer.getCategory() == BreakBeehiveImpl.BREAK_BEEHIVE_CATEGORY && timer.isPlaying()) {
if (flags == 11 && newState.getBlock() == Blocks.AIR && oldState.getBlock() instanceof BeehiveBlock) {
// Stop the timer
InGameTimer.complete();
}
}
}
}
public class BreakBeehiveImpl implements SpeedRunIGTApi {
@Override
public OptionButtonFactory createOptionButton() {
return screen -> new OptionButtonFactory.Builder()
.setToolTip(() -> "Test Option Button Tooltip!")
.setCategory("My category")
.setButtonWidget(new ButtonWidget(0, 0, 150, 20, new LiteralText("Test Button"), button -> {}));
}
}
Result :
Note! In the development environment, the SpeedRunIGT strings are not displayed normally. but "In the development environment" only. (Fixed in 13.0)