Skip to content
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

Refactor PlaybackController #200

Merged
merged 27 commits into from
Apr 14, 2024

Conversation

ScribbleTAS
Copy link
Member

@ScribbleTAS ScribbleTAS commented Feb 27, 2024

Continuation of #179

Changes

PlaybackController

The main focus of this PR was to reduce complexity in the PlaybackController, the main class for starting/stopping recordings/playbacks.

Up to now, everything playback related was added to the controller, without any consideration for architecture.

Hooks into the VirtualInput-System are now added via EventVirtualKeyboardTick, EventVirtualMouseTick, EventVirtualCameraAngleTick.
Any future TASmod extensions can use these too by implementing EventVirtualKeyboardTick in your class and registering it via EventListenerRegistry.register(YourClass)

PlaybackMetadata

The first lines of the TASfile contain metadata that is used for storing playback specific configuration.
In Alpha9 this metadata consisted of:

  • Author of the TAS
  • Title of the TAS
  • Playtime / Runtime of the TAS
  • Rerecords
  • Starting location of the TAS
  • Starting seed of the TAS

All of these (except starting seed, which is due in #190) have now been rewritten in the form of PlaybackMetadata.

public class CustomMetadataExtension implements PlaybackMetadataExtension {
	@Override
	public String getExtensionName() {
		return "Name";
	}

	@Override
	public void onCreate() {
		// Unused atm
	}

	@Override
	public PlaybackMetadata onStore() {
		PlaybackMetadata metadata = new PlaybackMetadata(this);
		metadata.setValue("Test", "Test")
		return metadata;
	}

	@Override
	public void onLoad(PlaybackMetadata metadata) {
		System.out.printLn(metadata.getValue("Test"));
	}

	@Override
	public void onClear() {
		// E.g. When /clearinputs is run
	}
}

After registering this class under PlaybackMetadataRegistry, any time you run /saveTAS or /loadTAS,
your custom metadata is automatically stored in the TASFile in the first lines. (At the time of writing, serialization is not implemented, this is my next task)

Such a system will also be used for making extensions to a line in the TASFile itself.

Fixes

Fixed a load of interpolation issues introduced in the #179 PR.

TODO

  • Why only focus on one, when you can have both! Rename copyFrom to moveFrom and write copyFrom that actually copies the methods!
  • New PlaybackMetadata
    • Run author etc via PM
    • Run start location via PM
  • Add event to enable playuntil
  • Add event to trigger printing the author name at the start of the TAS

@ScribbleTAS ScribbleTAS added this to the Beta1.0 milestone Feb 27, 2024
@ScribbleTAS ScribbleTAS added Core Issue relates to core concepts Refactor This issue talks about refactoring code labels Feb 27, 2024
@ScribbleTAS ScribbleTAS self-assigned this Feb 27, 2024
@ScribbleTAS ScribbleTAS linked an issue Apr 1, 2024 that may be closed by this pull request
…tTASState

- Fixed issues with deep copy
- Fixed bug in interpolation leading to nullpointer exception
`clone()` used to just clone the object without the associated subticks.
This has been renamed to `shallowClone()` and now clone actually does a
deep clone of the VirtualPeripherals
- [VirtualInput] Removed old interpolation
- [VirtualInput] Add a way to disable recording subticks for camera angle
@ScribbleTAS ScribbleTAS changed the title Refactor Playback Refactor PlaybackController Apr 4, 2024
Changed constructor of PlaybackMetadata to accept PlaybackMetadataExtension.
This is to encourage users to write `new PlaybackMetadata(this)` to ensure,
that the metadata extension name is also in the PlaybackMetadata.

- Added PlaybackMetadata and PlaybackMetadataRegistry tests
- [Events] Added seperate EventPlaybackClient file under events for playback specific events^
- Moved tasfile specific serializers to subpackage tasfile
- Added PlaybackLoadException
- Removed credits from PlaybackControllerClient
- Removed startposition from PlaybackControllerClient
- Added onClear to MetadaExtension for cleaning up.
- Moved TeleportPacket handling to from PlaybackControllerServer to StartpositionMetadataExtension
- Add documentation to StartpositionMetadataExtension
- Add documentation to CreditsMetadataExtension
- Removed credits and metadata related methods from PlaybackControllerClient
@ScribbleTAS ScribbleTAS marked this pull request as ready for review April 13, 2024 19:21
@ScribbleTAS ScribbleTAS requested a review from PancakeTAS April 13, 2024 19:22
@ScribbleTAS ScribbleTAS merged commit 709c511 into MinecraftTAS:develop Apr 14, 2024
2 checks passed
@ScribbleTAS ScribbleTAS deleted the refactor/playback branch April 14, 2024 11:48
@ScribbleTAS ScribbleTAS mentioned this pull request Apr 14, 2024
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Issue relates to core concepts Refactor This issue talks about refactoring code
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Crash when using /fullplay and no TAS is loaded
2 participants