Skip to content

Commit a27fcac

Browse files
authored
setup mods
1 parent 2ad137e commit a27fcac

File tree

7 files changed

+200
-80
lines changed

7 files changed

+200
-80
lines changed

README.md

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,2 @@
1-
### Cleanroom IDF
2-
3-
CleanroomIDF is a template for the development with cleanroom, based on [IdeallandFramework](https://github.com/IdeallandEarthDept/IdeallandFramework), [TemplateDevEnv](https://github.com/CleanroomMC/TemplateDevEnv/tree/master) and [1.12.2-FG6-Template](https://github.com/kappa-maintainer/1.12.2-FG6-Template)
4-
5-
6-
### About the branchs
7-
8-
There are many branchs here.
9-
10-
`main` is the main branch
11-
12-
~~`full` is the main with the codes of idf~~
13-
14-
the branchs start with `_` is the contribution to upstream, do not use!
15-
16-
the branchs start with `__` is the expirement, do not use!
17-
18-
### About the action
19-
20-
The action is used for check.
21-
22-
You can edit it for you own mod build.
23-
24-
### How to use
25-
26-
- Click `use this template` at the top.
27-
28-
- Clone the repository you have created with this template.
29-
30-
- Edit `version.properties`, `gradle.properties` and `build.gradle` until it is ok.
31-
32-
- In the local repository, run the command `gradlew setupDecompWorkspace`
33-
34-
- Open the project folder in IDEA.
35-
36-
- Right-click in IDEA `build.gradle` of your project, and select `Link Gradle Project`, after completion, hit `Refresh All` in the gradle tab on the right.
37-
38-
- Run `gradlew runClient` and `gradlew runServer`, or use the auto-imported run configurations in IntelliJ like `1. Run Client`.
1+
ShotaASM
2+
a script mod enables you write asm codes in scripts

gradle.properties

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ mapping_version= 39-1.12
1313

1414
# Mod Information
1515
# HIGHLY RECOMMEND complying with SemVer for mod_version: https://semver.org/
16-
root_package=com.somebody.example
17-
mod_id=example
18-
mod_name=Mod Name
19-
mod_version=1.0.0
16+
root_package=mods.Hileb.shotaasm
17+
mod_id=shotaasm
18+
mod_name=Shota ASM
19+
mod_version=0.0.1
2020

2121
# Mod Metadata (Optional)
22-
mod_description=the demo desc
23-
mod_url=www.demo_url.net
24-
mod_update_json=www.demo_url.net
22+
mod_description=a script mod enables you write asm codes in scripts
23+
mod_url=https://github.com/Ecdcaeb/ShotaASM
24+
mod_update_json=
2525
# Delimit authors with commas
26-
mod_authors=somebody
26+
mod_authors=Hileb
2727
mod_credits=IDF, CleanroomMC, Kappa
2828
mod_logo_path=
2929

@@ -56,9 +56,9 @@ mixin_refmap = mixins.${mod_id}.refmap.json
5656
# Only make a coremod if you are absolutely sure of what you are doing
5757
# Change the property `coremod_includes_mod` to false if your coremod doesn't have a @Mod annotation
5858
# You MUST state a class name for `coremod_plugin_class_name` if you are making a coremod, the class should implement `IFMLLoadingPlugin`
59-
is_coremod = false
60-
coremod_includes_mod = true
61-
coremod_plugin_class_name =
59+
is_coremod = true
60+
coremod_includes_mod = false
61+
coremod_plugin_class_name = mods.Hileb.shotaasm.ShotaASM
6262

6363
# AssetMover
6464
# Convenient way to allow downloading of assets from official vanilla Minecraft servers, CurseForge, or any direct links

setupDecomp.bat

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
package mods.Hileb.shotaasm;
2+
3+
import com.google.gson.JsonArray;
4+
import com.google.gson.JsonElement;
5+
import com.google.gson.JsonObject;
6+
import com.google.gson.JsonParser;
7+
import net.minecraftforge.fml.common.ModMetadata;
8+
import net.minecraftforge.fml.common.versioning.VersionParser;
9+
10+
import java.io.InputStream;
11+
import java.io.InputStreamReader;
12+
import java.util.HashMap;
13+
import java.util.Map;
14+
15+
@SuppressWarnings("all")
16+
public class MetaDataDecoder {
17+
public static Map<String, ModMetadata> decodeMcModInfo(InputStream stream) {
18+
JsonElement element = JsonParser.parseReader(new InputStreamReader(stream));
19+
if (element instanceof JsonArray array) {
20+
Map<String, ModMetadata> map = HashMap.newHashMap(array.size());
21+
for (JsonElement element1 : array) {
22+
ModMetadata modMetadata = decodeMetaData(element);
23+
map.put(modMetadata.modId, modMetadata);
24+
}
25+
return map;
26+
} else {
27+
ModMetadata modMetadata = decodeMetaData(element);
28+
return Map.of(modMetadata.modId, modMetadata);
29+
}
30+
}
31+
32+
@SuppressWarnings("all")
33+
public static ModMetadata decodeMetaData(JsonElement jsonElement){
34+
JsonObject json = jsonElement.getAsJsonObject();
35+
ModMetadata metadata = new ModMetadata();
36+
37+
//basic message
38+
metadata.modId = json.get("modid").getAsString();
39+
metadata.name = json.get("name").getAsString();
40+
41+
//optional message
42+
if (json.has("description")) metadata.description = json.get("description").getAsString();
43+
if (json.has("credits")) metadata.credits = json.get("credits").getAsString();
44+
if (json.has("url")) metadata.url = json.get("url").getAsString();
45+
if (json.has("updateJSON")) metadata.updateJSON = json.get("updateJSON").getAsString();
46+
if (json.has("logoFile")) metadata.logoFile = json.get("logoFile").getAsString();
47+
if (json.has("version")) metadata.version = json.get("version").getAsString();
48+
if (json.has("parent")) metadata.parent = json.get("parent").getAsString();
49+
if (json.has("useDependencyInformation")) metadata.useDependencyInformation = json.get("useDependencyInformation").getAsBoolean();
50+
if (metadata.useDependencyInformation){
51+
if (json.has("requiredMods")){
52+
for(JsonElement element : json.getAsJsonArray("requiredMods")){
53+
metadata.requiredMods.add(VersionParser.parseVersionReference(element.getAsString()));
54+
}
55+
}
56+
if (json.has("dependencies")){
57+
for(JsonElement element : json.getAsJsonArray("dependencies")){
58+
metadata.dependencies.add(VersionParser.parseVersionReference(element.getAsString()));
59+
}
60+
}
61+
if (json.has("dependants")){
62+
for(JsonElement element : json.getAsJsonArray("dependants")){
63+
metadata.dependants.add(VersionParser.parseVersionReference(element.getAsString()));
64+
}
65+
}
66+
}
67+
if (json.has("authorList")){
68+
for(JsonElement element : json.getAsJsonArray("authorList")){
69+
metadata.authorList.add(element.getAsString());
70+
}
71+
}
72+
if (json.has("screenshots")){ // this field was never used
73+
JsonArray array = json.getAsJsonArray("screenshots");
74+
int size = array.size();
75+
String[] screenshots = new String[size];
76+
for (int i = 0; i < size; i++){
77+
screenshots[i] = array.get(i).getAsString();
78+
}
79+
metadata.screenshots = screenshots;
80+
}else metadata.screenshots = new String[0];
81+
if (json.has("updateUrl")){ // this field is out of date
82+
metadata.updateUrl = json.get("updateUrl").getAsString();
83+
}
84+
85+
return metadata;
86+
}
87+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package mods.Hileb.shotaasm;
2+
3+
public class ScriptLoader {
4+
public static Runnable loadScript(String name, byte[] text) {
5+
return null; // TODO : impl script load
6+
}
7+
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
package mods.Hileb.shotaasm;
2+
3+
import net.minecraftforge.fml.common.ModMetadata;
4+
import org.apache.logging.log4j.*;
5+
6+
import net.minecraftforge.fml.common.DummyModContainer;
7+
import net.minecraftforge.fml.relauncher.*;
8+
9+
import java.util.*;
10+
11+
import java.io.CharArrayReader;
12+
import java.io.File;
13+
import java.nio.charset.StandardCharsets;
14+
import java.nio.file.Files;
15+
import org.apache.commons.io.IOUtils;
16+
17+
@IFMLLoadingPlugin.Name(ShotaASM.NAME)
18+
@IFMLLoadingPlugin.MCVersion(net.minecraftforge.common.ForgeVersion.mcVersion)
19+
public class ShotaASM implements IFMLLoadingPlugin {
20+
public static final String NAME = "ShotaASM";
21+
public static final String MOD_ID = "shotaasm"
22+
public static final ModMetadata MOD_METADATA = MetaDataDecoder.decodeMcModInfo(ShotaASM.class.getResourceAsStream("mcmod.info")).get(MOD_ID);
23+
public static final Logger LOGGER = LogManager.getLogger(NAME);
24+
25+
public static File source = null;
26+
27+
@Override
28+
public String[] getASMTransformerClass() {
29+
return null;
30+
}
31+
32+
@Override
33+
public String getModContainerClass() {
34+
return "mods.Hileb.shotaasm.ShotaASM$Container";
35+
}
36+
37+
@Override
38+
public String getSetupClass() {
39+
return "mods.Hileb.shotaasm.ShotaASM$Setup";
40+
}
41+
42+
@Override
43+
public void injectData(Map<String, Object> map) {
44+
source = (File) data.get("coremodLocation");
45+
}
46+
47+
@Override
48+
public String getAccessTransformerClass() {
49+
return null;
50+
}
51+
52+
public static class Container extends DummyModContainer{
53+
54+
public Container(){
55+
super(MOD_METADATA);
56+
}
57+
58+
@Override
59+
public boolean registerBus(EventBus bus, LoadController controller) {
60+
return true;
61+
}
62+
63+
@Override
64+
public File getSource() {
65+
return source;
66+
}
67+
68+
}
69+
70+
public static class Setup implements IFMLCallHook {
71+
72+
public void injectData(Map<String,Object> data) {
73+
74+
}
75+
76+
public Void call() {
77+
File root = new File(Launch.minecraftHome, "shotaasm");
78+
if (!root.exists()) {
79+
root.mkdirs();
80+
}
81+
82+
List<Runnable> list = new ArrayList<>();
83+
for (File file : root.listFiles()) {
84+
byte[] text = IOUtils.toByteArray(Files.newBufferedReader(file.toPath()), StandardCharsets.UTF_8);
85+
String name = file.getName();
86+
list.add(ScriptLoader.loadScript(name, text));
87+
}
88+
list.forEach(Runnable::run);
89+
}
90+
91+
}
92+
93+
}

src/main/java/mods/somebody/example/Example.java

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)