2024-12-10 17:47:23|Myriagame |source:minecraft skins
This tutorial is set by the author's setting without permission.
Modular machine: community version from entry to the soil -part.3.3 mechanical event system
This tutorial is displaying modular machinery: the community version of CRT's advanced available API.
The main modules used in this tutorial are modular machinery: community version -1.11.1 -R33, Crafttweaker.
Note: The content of this tutorial may change at any time. Please carefully compare the module version used in this tutorial, so as not to cause module updates to cause inexplicable error problems.
Tutorial directory:
Part.1 Basic Machinery Creation
Part.2 Basic Formula Create
PART.3.1 Advanced formula application
Part 3.2 Formula adapter recipeadapter
Part.3.3 Mechanical Event System (Current)
Part.4.1 parallel formula processing (unfinished)
Part.4.2 Factory system (unfinished)
Part.4.3 Factory event system (unfinished)
Part.4.4 Smart Data Interface (unfinished)
Part.4.5 Unilateral / multi -square mechanical upgrade (unfinished)
Part.4.6 Custom GUI information (unfinished)
Part.5 configuration file analysis (unfinished)
Environmental preparation
This tutorial is highly recommended to use Visual Studio Code (hereinafter referred to as vScode), which can greatly reduce your magic workload.
Using VSCODE, you can use its powerful functions to complete complex operations faster. At the same time, it has code prompts to greatly reduce the difficulty and error rate of code reading. At the same time, you can install plug -in to expand the function to make it stronger.
Reading this tutorial means that you are familiar with most of the advanced use of Zenscript, and you have learned about basic mechanical creation and formula creation.
Module
If you have installed Crafttweaker and modular mechanical body and the game has been started, you can skip this description.
introduce
The event system provided by MMCE allows the author to more conveniently write the advanced mechanism of formula, simple and easy to use.
As of the MMCE-R33 version, there are currently 9 formulas and 4 mechanical events.
This tutorial will introduce 5 formulas and 4 mechanical events of ordinary mechanical controllers.
Formula
All formulas are independent, and they will only be triggered by the formula of the registered name.
There are 5 formula events, which are recipeCheckevent (formula checking event) -> RecipeStartevent -> Recipepretickevent -> Recipeposttickevent (formula) -> RecipePosttickevent (formula) -> RecipepostticKevent > RecipefinisheventTo.
Among them, recipepretickevent (formula pre -tick event) and recipeposttickevent (formula completion of the TICK event) will be triggered many times.
These events can only be added through the recipeprimer (formula builtr).
Universal Zengetter
These methods can be used in all formula events.
// Get the mechanical formula corresponding to the eventActiveMachinereCipe ActiveRecipe
// Get the mechanical controller of the trigger event
ImachineController GetController
RecipeCheckevent
This incident will be triggered when the mechanical controller scans the formula, and the event will be triggered after the formula meets the operating conditions.
At the same time, after the mechanical completes a formula, this formula will continue to check, which will also trigger this incident when the operating conditions are met.
Example:
// Add a formula check event monitor to the current formulaaddcheckhandler (IEVENTHADLR
event); #Example
Import Mods.modularMachinery.Rcipecheckevent;
addcheckhandler (function (event as recipeCheckevent) {
// Treat the event ...})
There is also an additional ZenMethod in this incident:
// Call this method to set the formula check to fail, and will prevent other incident listeners from continuing to receive this event.// Once it is set to fail, the formula will not start working, and the machine will continue to scan other formulas.
// Reason is the cause of mechanical failure (support localization string)
void Setfailed (String Reason)
Recipestartevent (formula starting event)
This incident will be triggered after the mechanical running formula, and this event is usually triggered after the recipeCheckevent triggers.
Example:
// Add a formula to the current formula to start event monitoradDStarthandler (IEVENTHANDLER
Event) #Example
Import Mods.modularMachinery.recipestartEvent;
adDStarthandler (function (event as recipestartevent) {
// Treatment of the event ...
})
Recipepretickevent (formula pre -tick event)
This event will be triggered before the formula starts (e.g., for example: energy input and output), and each tick will trigger this event.
Example:
recipepretickevent (formula pre -tick event):// Add a formula pre -tick event monitor to the current formula
addpretickhandler (IEVENTHANDLER
Event) #Example
Import Mods.modularMachinery.Rcipetickevent;
AddPretickhandler (Function (event as recipeickevent) {
// Treatment of the event ...
})
There are two additional ZenMethod in this incident:
// Prevent the progress of the machine from increasing the progress (but still tick and consumes energy), and set the reason for the reason, the reasons will be exported on the controller.void Preventprogressing (String Reason)
// Set the running status to fail and set the cause of failure.
// When the DestRuctRecipe is True, the running formula (swallowing material) will be canceled, and False will not.
void SetFailed (Boolean Destructrucipe, String Reason)
Recipeposttickevent
This incident will be triggered after the formula completes Tick (for example: after energy consumed or output), and each tick trigger this event.
Example:
recipeposttickevent (formula pre -tick event):// Add a formula pre -tick event monitor to the current formula
addposttickhandler (IEVENTHANDLER
event) #Example
Import Mods.modularMachinery.Rcipetickevent;
AddPosttickhandler (Function (event as recipeickevent) {// handle event ...
})
There are two additional ZenMethod in this incident:
// Prevent the progress of the machine from increasing the progress (but still tick and consumes energy), and set the reason for the reason, the reasons will be exported on the controller.Void Preventprogressing (String Reason) // Set the running status to fail and set the cause of failure.
// When the DestRuctRecipe is True, the running formula (swallowing material) will be canceled, and False will not.
void SetFailed (Boolean Destructrucipe, String Reason)
Recipefinishevent
This incident will be triggered after the formula is completed, only once.
Example:
#ExampleImport Mods.modularMachinery.Rcipefinishevent;
addfinishhandler (Function (Event As Recipefinishevent) {{
// Treatment of the event ...
})
Mechanical event
All machine events are independent, and they will only be triggered by the specified registered machine.
These incident listeners can be added through Mmevents or MachineBuilder.
Universal Zengetter
All mechanical events can be used.
// Get the mechanical controller of the trigger eventImachineController GetController
MachineStructionFormedEvent
When a mechanical controller forms a structure, this event is triggered.
Example:
// Form structural eventsMmevents.onStructionFormed (String MachineRegistryname, IEVENTHANDLER
#Example
Mmevents.onStructionFormed ("Tokmak_reactor", Function
// Treatment of the event ...
});
MachinePretickevent (mechanical pre -tick event)
When mechanical formation structure, this incident is triggered before the start of the mechanical logic.
Example:
// pre -tick eventMmevents.onmachinePretick (String MachineRegistryName, IEVENTHANDLER
Function) #Example
Mmevents.onmachinePretick ("Tokmak_reactor", Function (Event as MachineTickevent) {
// Treatment of the event ...
});
MachinePosttickevent (mechanical completion) When mechanical formation structure, the mechanical logic execution triggers this event.
Example:
// Complete the tick eventMmevents.onmachinePostation (String Machine onRegistry, IEVENTHANDLER
Function) #Example
Mmevents.onmachinePosttick ("Tokmak_reactor", Function (Event as MachineTickevent) {
// Treatment of the event ...
});
Controllerguirenderevent (controller GUI rendering event)
When the client opens the controller of the corresponding machine, the incident is triggered, allowing the author to add custom information to the controller.
Example:
// The controller GUI rendering eventMmevents.onControllerguirender (String MachineRegistry, IEVENTHANDLER
Function) #Example
Mmevents.onControllerguirender ("Tokmak_reactor", Function (Event as Controllerguirendrevent) {{
// Treatment of the event ...
});
There is an additional Zengetter and Zensetter in this incident:
// Get or set additional information arrayString [] extrainfo
SMARTINTERFACEUPDATEEVENT
When the data interface binds of the controller is updated, this event is triggered.
Example:
// Intelligent data interface update eventMmevents.onsmartInterfaceUpdate (String MachineRegistryname, IEVENTHANDLER
Function)) #Example
Mmevents.onsmartInterfaceupdate ("Tokmak_reactor", Function
// Treatment of the event ...
});
There are two additional Zengetter in this incident:
// Obtain the position of the smart data interface of the trigger eventIBLOCKPOS Interfacepos
// Get the updated data
SMARTINTERFACEDATA NewData
National Service DNF Dark Ni
2025-01-28 09:19:27The new screenshot of the be
2025-01-28 09:18:57The 15th anniversary wallpap
2025-01-28 09:18:273DM Xuanyuan Sinicization Gr
2025-01-28 09:17:57French magazine is the first
2025-01-28 09:17:27The sneak game "Republic" wi
2025-01-28 09:16:57The story between humans and
2025-01-28 09:16:27Capture "Trinity 3: Artifact
2025-01-28 09:15:27Wind direction change "Myste
2025-01-28 09:14:57DICE's new project "Dream" w
2025-01-28 09:14:27Pirate Minecraft Skins
Minecraft Skins
2024-12-10 04:11:27Pirate Minecraft Skins
Minecraft Skins
2024-12-10 04:11:26Master Minecraft Skins
Minecraft Skins
2024-12-10 04:11:25King Minecraft Skins
Minecraft Skins
2024-12-10 04:11:25Guide Minecraft Skins
Minecraft Skins
2024-12-10 04:11:24Dark Knight Minecraft Skins
Minecraft Skins
2024-12-10 04:11:23Sparta Minecraft Skins
Minecraft Skins
2024-12-10 04:11:23Moncraft Skins of the War
Minecraft Skins
2024-12-10 04:11:22Red Witch Minecraft Skins
Minecraft Skins
2024-12-10 04:11:22Golden Cavaliers Minecraft S
Minecraft Skins
2024-12-10 04:11:22