started on structures and implementation
@@ -4,7 +4,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.system.CallbackI;
|
||||
|
||||
public class Ref {
|
||||
public static final String MOD_ID = "masterfulmachinery";
|
||||
public static final String MOD_ID = "mm";
|
||||
public static ResourceLocation res(String path){
|
||||
return new ResourceLocation(MOD_ID, path);
|
||||
}
|
||||
@@ -15,5 +15,14 @@ public class Ref {
|
||||
public static final ResourceLocation ITEM_TYPE = res("items");
|
||||
}
|
||||
|
||||
public static final class Reg {
|
||||
public static final ResourceLocation STRUCTURE_KEY_TYPE = res("structures/key_type");
|
||||
public static final class SKT {
|
||||
public static final ResourceLocation BLOCK = res("block");
|
||||
public static final ResourceLocation PORT = res("port");
|
||||
public static final ResourceLocation PORT_TIER = res("port_tier");
|
||||
}
|
||||
}
|
||||
|
||||
public static final ResourceLocation JEI_PLUGIN = res("jei");
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class MMItemGroup extends ItemGroup {
|
||||
public static final MMItemGroup INSTANCE = new MMItemGroup();
|
||||
|
||||
public MMItemGroup() {
|
||||
super("masterfulmachinery");
|
||||
super("mm");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.ticticboooom.mods.mm.data;
|
||||
|
||||
import com.electronwill.nightconfig.core.conversion.ConversionTable;
|
||||
import com.ticticboooom.mods.mm.data.model.ControllerModel;
|
||||
import com.ticticboooom.mods.mm.data.model.PortModel;
|
||||
import com.ticticboooom.mods.mm.data.model.StructureModel;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -10,4 +12,5 @@ import java.util.Map;
|
||||
public class DataRegistry {
|
||||
public static final Map<ResourceLocation, ControllerModel> CONTROLLERS = new HashMap<>();
|
||||
public static final Map<ResourceLocation, PortModel> PORTS = new HashMap<>();
|
||||
public static final Map<ResourceLocation, StructureModel> STRUCTURES = new HashMap<>();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.ticticboooom.mods.mm.data.model;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class StructureModel {
|
||||
public ResourceLocation id;
|
||||
public ResourceLocation controllerId;
|
||||
public List<List<String>> pattern;
|
||||
public Map<Character, Key> keys;
|
||||
|
||||
public static final class Key {
|
||||
public ResourceLocation type;
|
||||
public Object data;
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ public class ControllerReloadListener extends JsonReloadListener {
|
||||
public static final Gson GSON = new Gson();
|
||||
|
||||
public ControllerReloadListener() {
|
||||
super(GSON, "masterfulmachinery/controllers");
|
||||
super(GSON, "mm/controllers");
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -22,7 +22,7 @@ public class PortReloadListener extends JsonReloadListener {
|
||||
public static final Gson GSON = new Gson();
|
||||
|
||||
public PortReloadListener() {
|
||||
super(GSON, "masterfulmachinery/ports");
|
||||
super(GSON, "mm/port_tiers");
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -2,6 +2,9 @@ package com.ticticboooom.mods.mm.data.reload;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.ticticboooom.mods.mm.data.DataRegistry;
|
||||
import com.ticticboooom.mods.mm.data.model.StructureModel;
|
||||
import net.minecraft.client.resources.JsonReloadListener;
|
||||
import net.minecraft.profiler.IProfiler;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
@@ -17,7 +20,7 @@ public class StructureReloadListener extends JsonReloadListener {
|
||||
public static final Gson GSON = new Gson();
|
||||
|
||||
public StructureReloadListener() {
|
||||
super(GSON, "masterfulmachinery/machines");
|
||||
super(GSON, "mm/machines");
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -27,6 +30,12 @@ public class StructureReloadListener extends JsonReloadListener {
|
||||
|
||||
@Override
|
||||
protected void apply(Map<ResourceLocation, JsonElement> objectIn, IResourceManager resourceManagerIn, IProfiler profilerIn) {
|
||||
|
||||
for (Map.Entry<ResourceLocation, JsonElement> entry : objectIn.entrySet()) {
|
||||
DataRegistry.STRUCTURES.put(entry.getKey(), parse(entry.getKey(), entry.getValue().getAsJsonObject()));
|
||||
}
|
||||
}
|
||||
|
||||
private StructureModel parse(ResourceLocation key, JsonObject asJsonObject) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.ticticboooom.mods.mm.setup;
|
||||
|
||||
import com.ticticboooom.mods.mm.Ref;
|
||||
import com.ticticboooom.mods.mm.structures.StructureKeyType;
|
||||
import com.ticticboooom.mods.mm.structures.keys.BlockStructureKeyType;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
import net.minecraftforge.registries.RegistryBuilder;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class MMRegistries {
|
||||
|
||||
public static IForgeRegistry<StructureKeyType> STRUCTURE_KEY_TYPES;
|
||||
|
||||
@SubscribeEvent
|
||||
public static void on(RegistryEvent.NewRegistry event) {
|
||||
STRUCTURE_KEY_TYPES = new RegistryBuilder<StructureKeyType>().setName(Ref.Reg.STRUCTURE_KEY_TYPE).setType(StructureKeyType.class).create();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void register(RegistryEvent.Register<StructureKeyType> event) {
|
||||
event.getRegistry().registerAll(
|
||||
new BlockStructureKeyType().setRegistryName(Ref.Reg.SKT.BLOCK)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.ticticboooom.mods.mm.structures;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class StructureKeyType extends ForgeRegistryEntry<StructureKeyType> {
|
||||
public abstract boolean matches(JsonElement json);
|
||||
public abstract Object parse(JsonElement json, List<ResourceLocation> controllerIds, ResourceLocation structureId);
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.ticticboooom.mods.mm.structures.keys;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.ticticboooom.mods.mm.data.util.ParserUtils;
|
||||
import com.ticticboooom.mods.mm.structures.StructureKeyType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class BlockStructureKeyType extends StructureKeyType {
|
||||
@Override
|
||||
public boolean matches(JsonElement json) {
|
||||
if (json.isJsonPrimitive()){
|
||||
return true;
|
||||
}
|
||||
if (json.isJsonObject()){
|
||||
if (json.getAsJsonObject().has("include")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object parse(JsonElement json, List<ResourceLocation> controllerIds, ResourceLocation structureId) {
|
||||
Value result = new Value();
|
||||
result.blockSelector = new ArrayList<>();
|
||||
if (json.isJsonPrimitive()) {
|
||||
result.blockSelector.add(json.getAsString());
|
||||
return result;
|
||||
}
|
||||
if (json.isJsonObject()) {
|
||||
JsonObject jsonObj = json.getAsJsonObject();
|
||||
JsonElement includesJson = jsonObj.get("include");
|
||||
if (includesJson.isJsonPrimitive()) {
|
||||
result.blockSelector.add(includesJson.getAsString());
|
||||
return result;
|
||||
}
|
||||
|
||||
JsonArray includes = includesJson.getAsJsonArray();
|
||||
includes.forEach(x -> result.blockSelector.add(x.getAsString()));
|
||||
result.properties = ParserUtils.parseOrDefault(jsonObj, "properties", x -> {
|
||||
HashMap<String, String> res = new HashMap<>();
|
||||
JsonObject obj = x.getAsJsonObject();
|
||||
obj.keySet().forEach(z -> {
|
||||
res.put(z, obj.get(z).getAsString());
|
||||
});
|
||||
return res;
|
||||
}, new HashMap<>());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static final class Value {
|
||||
public List<String> blockSelector;
|
||||
public Map<String, String> properties;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.ticticboooom.mods.mm.structures.keys;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.ticticboooom.mods.mm.Ref;
|
||||
import com.ticticboooom.mods.mm.data.util.ParserUtils;
|
||||
import com.ticticboooom.mods.mm.structures.StructureKeyType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class PortStructureKeyType extends StructureKeyType {
|
||||
@Override
|
||||
public boolean matches(JsonElement json) {
|
||||
JsonObject obj = json.getAsJsonObject();
|
||||
String type = obj.get("type").getAsString();
|
||||
return type.equals(Ref.Reg.SKT.PORT.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object parse(JsonElement json, List<ResourceLocation> controllerIds, ResourceLocation structureId) {
|
||||
Value result = new Value();
|
||||
JsonObject obj = json.getAsJsonObject();
|
||||
result.port = ResourceLocation.tryCreate(obj.get("port").getAsString());
|
||||
result.input = ParserUtils.parseOrDefault(obj, "input", x -> Optional.of(x.getAsBoolean()), Optional.empty());
|
||||
return result;
|
||||
}
|
||||
|
||||
public static final class Value {
|
||||
public ResourceLocation port;
|
||||
public Optional<Boolean> input;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.ticticboooom.mods.mm.structures.keys;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.ticticboooom.mods.mm.Ref;
|
||||
import com.ticticboooom.mods.mm.data.util.ParserUtils;
|
||||
import com.ticticboooom.mods.mm.structures.StructureKeyType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class PortTierStructureKeyType extends StructureKeyType {
|
||||
@Override
|
||||
public boolean matches(JsonElement json) {
|
||||
JsonObject obj = json.getAsJsonObject();
|
||||
String type = obj.get("type").getAsString();
|
||||
return type.equals(Ref.Reg.SKT.PORT_TIER.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object parse(JsonElement json, List<ResourceLocation> controllerIds, ResourceLocation structureId) {
|
||||
}
|
||||
|
||||
public static final class Value {
|
||||
public ResourceLocation portTier;
|
||||
public Optional<Boolean> input;
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 701 B After Width: | Height: | Size: 701 B |
|
Before Width: | Height: | Size: 711 B After Width: | Height: | Size: 711 B |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 693 B After Width: | Height: | Size: 693 B |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"controllerId": "main",
|
||||
"controllerId": "test:main",
|
||||
"name": "Main Items",
|
||||
"type": "masterfulmachinery:items",
|
||||
"type": "mm:items",
|
||||
"defaultModel": {
|
||||
"block": "minecraft:sponge",
|
||||
"properties": {}
|
||||
21
src/test/resources/data/test/mm/processes/myrecipe.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"structure": "test:mystructure",
|
||||
"inputs": {
|
||||
"firstboi": {
|
||||
"type": "mm:modifiable",
|
||||
"modifier_results": {
|
||||
"starter": {
|
||||
"type": "mm:nothing"
|
||||
},
|
||||
"basic": {
|
||||
"type": "mm:speed",
|
||||
"ticks": "-10%"
|
||||
},
|
||||
"intermediate": {
|
||||
"type": "mm:chance",
|
||||
"chance": "+10%"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
100
src/test/resources/data/test/mm/structures/mystructure.json
Normal file
@@ -0,0 +1,100 @@
|
||||
{
|
||||
"controllerId": [
|
||||
"test:main",
|
||||
"test:second"
|
||||
],
|
||||
"controllerSettings": {
|
||||
"facing": "west"
|
||||
},
|
||||
"pattern": [
|
||||
[
|
||||
"ABC",
|
||||
"DEF",
|
||||
"GHI"
|
||||
],
|
||||
[
|
||||
" ",
|
||||
" C ",
|
||||
" "
|
||||
],
|
||||
[
|
||||
"KLM",
|
||||
"NOP",
|
||||
" "
|
||||
]
|
||||
],
|
||||
"keys": {
|
||||
"A": {
|
||||
"include": [
|
||||
"minecraft:dirt",
|
||||
"#minecraft:logs"
|
||||
]
|
||||
},
|
||||
"B": "minecraft:glass",
|
||||
"D": "#minecraft:wools",
|
||||
"E": {
|
||||
"include": "#minecraft:logs",
|
||||
"exclude": [
|
||||
"minecraft:oak_log"
|
||||
]
|
||||
},
|
||||
"F": {
|
||||
"type": "mm:port_group",
|
||||
"group": "mygroup"
|
||||
},
|
||||
"G": {
|
||||
"type": "mm:port_tier",
|
||||
"portTier": "item_main",
|
||||
"input": false
|
||||
},
|
||||
"H": {
|
||||
"type": "mm:port",
|
||||
"port": "mm:items",
|
||||
"input": true
|
||||
},
|
||||
"I": {
|
||||
"type": "mm:modifiable",
|
||||
"modifiers": {
|
||||
"starter": "minecraft:air",
|
||||
"basic": {
|
||||
"include": [
|
||||
"minecraft:stone",
|
||||
"minecraft:cobblestone"
|
||||
]
|
||||
},
|
||||
"intermediate": {
|
||||
"include": "minecraft:iron_block"
|
||||
}
|
||||
}
|
||||
},
|
||||
"J": {
|
||||
"include": "#minecraft:logs",
|
||||
"properties": {
|
||||
"axis": "x"
|
||||
}
|
||||
}
|
||||
},
|
||||
"requiredPorts": {
|
||||
"first": {
|
||||
"port": "mm:items",
|
||||
"input": true,
|
||||
"tiers": [
|
||||
"item_main"
|
||||
]
|
||||
},
|
||||
"second": {
|
||||
"port": "mm:fluids",
|
||||
"input": false
|
||||
},
|
||||
"third": {
|
||||
"port": "mm:fluids",
|
||||
"input": true
|
||||
}
|
||||
},
|
||||
"portGroupings": {
|
||||
"mygroup": [
|
||||
"first",
|
||||
"third"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1,2 @@
|
||||
#Mon Feb 07 23:27:43 GMT 2022
|
||||
VERSION_CODE=1356
|
||||
#Thu Feb 17 07:48:47 GMT 2022
|
||||
VERSION_CODE=1358
|
||||
|
||||