[Tutorial] Play a cutscene video in your mod!

Started by Shocking Artist on Thu, 06/11/2020 - 20:55

Topic category: User side tutorials

Last seen on 16:09, 15. Aug 2022
Joined May 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
[Tutorial] Play a cutscene video in your mod!
Thu, 06/30/2022 - 13:39 (edited)

Before I start, I want to say thank you to Tbroski and Klemen for helping me create this tutorial.

 

First, have a video ready, best if short and low-res.

Convert it to a PNG image sequence, you can use any service you so desire. (if you have photoshop, follow this tutorial https://ihatetomatoes.net/convert-video-image-sequence)

Then, you get a folder full of your images and name them accordingly. If you have 100 frames for example, name them from 0 to 99.

Go to the "Import Other Textures" section in MCR, and import all of them clicking the first and shift-clicking the last texture

Now to the code part, create a procedure element, and set the trigger to on player tick update.

Go to the code, and add the following:

		Entity entity = (Entity) dependencies.get("entity");
		entity.getPersistentData().putDouble("Frame", ((entity.getPersistentData().getDouble("Frame")) + 1));
		entity.getPersistentData().putString("Location",
				(("yourmodid:textures/") + (Math.round((entity.getPersistentData().getDouble("Frame")))) + (".png")));
		if (((entity.getPersistentData().getDouble("Frame")) >= maxframe)) {
			entity.getPersistentData().putDouble("Frame", 0);
		}

Replace yourmodid with your mod Id and maxframe with your max frame number.

This code snippet will create a Frame variable that increases per tick, and get the location of a frame with that variable.

Next, create an overlay element, select a dummy base texture, lock the code, and change the line of code that binds your base texture to this:

                Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation((entity.getPersistentData().getString("Location"))));

Run your mod and you should be seeing a silky smooth video playing, the video will repeat once it reaches the end.

 

Add sound and customize the code any way you want.

Edited by Shocking Artist on Thu, 06/30/2022 - 13:39
Last seen on 16:09, 15. Aug 2022
Joined May 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Dont forget to like comment…
Thu, 06/11/2020 - 20:56

Dont forget to like comment and subscribe!

Last seen on 16:09, 15. Aug 2022
Joined May 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
If you have any errors, post…
Thu, 06/11/2020 - 20:58

If you have any errors, post it below

Really nice! However, if we…
Sat, 06/20/2020 - 20:34

Really nice! However, if we have a lot o GIF, we will have a ;lot of textures/pictures, so i think it's bretter to create a folder for each GIF, as we can define the GIf path ourself.

Last seen on 23:28, 26. Jul 2021
Joined Apr 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
so would this work if i…
Tue, 06/30/2020 - 20:55

so would this work if i wanted  to make a "cutscene"in a story mode mod (a mod that has a story that you must follow)

Last seen on 16:09, 15. Aug 2022
Joined May 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Updated the tutorial a…
Mon, 08/31/2020 - 13:22

Updated the tutorial a little bit

Last seen on 21:41, 20. Jun 2022
Joined Jul 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Wow i cant believe its…
Sat, 09/05/2020 - 14:28

Wow i cant believe its really possible

Last seen on 16:06, 22. Mar 2022
Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
For a 300 frame 30 fps…
Thu, 03/04/2021 - 13:04

For a 300 frame 30 fps cutscene how much storage are we looking at once the mod is exported?

Last seen on 16:09, 15. Aug 2022
Joined May 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Depends on image size
Fri, 03/05/2021 - 14:30

Depends on image size