[Tutorial] Play a cutscene video in your mod!

Started by Shocking Artist on

Topic category: User side tutorials

[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
Joined Jun 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Would you update this for 1…
Fri, 01/21/2022 - 07:01

Would you update this for 1.17? I think some methods have changed.

Joined Jun 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hello so im getting this…
Tue, 06/28/2022 - 21:23

Hello so im getting this error when i try to Run ClientImage of my code

Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Can this be updated to 1.18…
Thu, 07/07/2022 - 22:27

Can this be updated to 1.18 please? I could really use this

Joined Mar 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
the "Entity entity" line is…
Wed, 03/29/2023 - 14:08

the "Entity entity" line is making me problems

im new in mcreator and stuff so pls tell me how this works

(yes i created an account just to ask this=

Joined Sep 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
hey, i need some help... im…
Sat, 09/16/2023 - 22:53

hey, i need some help... im trying to update it to 1.20.1, this is my procedural code by now

Entity entity = Entity;
entity.getPersistentData().putDouble("Frame", ((entity.getPersistentData().getDouble("Frame")) + 1));

but it gives this error:

D:\McCreatorWorkspaces\jvzamod\src\main\java\net\mcreator\jzvamod\procedures\Cutscene1Procedure.java:8: error:   expected 
      entity.getPersistentData().putDouble("Frame", ((entity.getPersistentData().getDouble("Frame")) + 1)); 
                              ^ 
D:\McCreatorWorkspaces\jvzamod\src\main\java\net\mcreator\jzvamod\procedures\Cutscene1Procedure.java:8: error: ';' expected 
      entity.getPersistentData().putDouble("Frame", ((entity.getPersistentData().getDouble("Frame")) + 1)); 
                                ^ 
D:\McCreatorWorkspaces\jvzamod\src\main\java\net\mcreator\jzvamod\procedures\Cutscene1Procedure.java:11: error: class, interface, enum, or record expected 
} 
^

can you help me fix it?

Joined Jan 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Wait I want a cutscene to…
Sat, 04/27/2024 - 05:58

Wait I want a cutscene to play at a certain point in my story mode mod how can I do that , Do I have to just change the trigger