generated from neoforged/MDK
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
424 additions
and
441 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
src/generated/resources/assets/examplemod/models/item/example_block.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent": "minecraft:item/generated", | ||
"textures": { | ||
"layer0": "examplemod:item/example_block" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.enderio.regilite; | ||
|
||
import com.enderio.regilite.utils.BundledDataProvider; | ||
import it.unimi.dsi.fastutil.objects.ObjectArrayList; | ||
import it.unimi.dsi.fastutil.objects.ObjectList; | ||
import net.neoforged.bus.api.IEventBus; | ||
import net.neoforged.neoforge.data.event.GatherDataEvent; | ||
|
||
/** | ||
* Abstract Regilite implementation that handles registration of module events. | ||
* This can be used if a mod wants to implement its own modules to replace or extend existing ones. | ||
* This might incur some more boilerplate, but is more ergonomic than shadowing the existing Regilite methods. | ||
* If you only want to add a custom registry to Regilite, extend Regilite instead. | ||
*/ | ||
public abstract class AbstractRegilite { | ||
private final String modId; | ||
|
||
private final ObjectList<RegiliteModuleDataGen> modulesWithDataGeneration = new ObjectArrayList<>(); | ||
private final ObjectList<RegiliteModuleEvents> modulesWithEvents = new ObjectArrayList<>(); | ||
|
||
protected AbstractRegilite(String modId) { | ||
this.modId = modId; | ||
} | ||
|
||
/** | ||
* Register a module within the Regiltie container. | ||
* This will hook the different module types into the correct places (events and datagen for example). | ||
*/ | ||
protected <T> T registerModule(T module) { | ||
if (module instanceof RegiliteModuleDataGen dataGenModule) { | ||
modulesWithDataGeneration.add(dataGenModule); | ||
} | ||
|
||
if (module instanceof RegiliteModuleEvents eventsModule) { | ||
modulesWithEvents.add(eventsModule); | ||
} | ||
|
||
return module; | ||
} | ||
|
||
public String modId() { | ||
return modId; | ||
} | ||
|
||
/** | ||
* Register all event handlers for Regilite's modules. | ||
* You should perform this in your mod entrypoint. | ||
* @param modEventBus The mod event bus. | ||
*/ | ||
public void register(IEventBus modEventBus) { | ||
modEventBus.addListener(this::onGatherData); | ||
|
||
for (var module : modulesWithEvents) { | ||
module.register(modEventBus); | ||
} | ||
} | ||
|
||
protected void onGatherData(GatherDataEvent event) { | ||
var provider = new BundledDataProvider(modId); | ||
|
||
for (var module : modulesWithDataGeneration) { | ||
module.gatherProviders(event, provider::addSubProvider); | ||
} | ||
|
||
event.getGenerator().addProvider(true, provider); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 0 additions & 35 deletions
35
src/main/java/com/enderio/regilite/events/ColorEvents.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.