Add executable IC2 tool and radiation graphs
This commit is contained in:
@@ -8,13 +8,25 @@
|
||||
}
|
||||
},
|
||||
"material": "minecraft:diamond_pickaxe",
|
||||
"mechanics": [],
|
||||
"mechanics": ["ic2:charged_area_tool"],
|
||||
"name": "Алмазный бур",
|
||||
"properties": {
|
||||
"energy": {
|
||||
"defaultValue": 0,
|
||||
"defaultValue": 80000,
|
||||
"max": 80000,
|
||||
"type": "number"
|
||||
},
|
||||
"mining_cost": {
|
||||
"defaultValue": 100,
|
||||
"min": 1,
|
||||
"max": 10000,
|
||||
"type": "number"
|
||||
},
|
||||
"mining_radius": {
|
||||
"defaultValue": 1,
|
||||
"min": 0,
|
||||
"max": 4,
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"translations": {},
|
||||
|
||||
@@ -13,10 +13,22 @@
|
||||
"properties": {
|
||||
"energy": {
|
||||
"type": "number",
|
||||
"defaultValue": 0,
|
||||
"defaultValue": 300000,
|
||||
"max": 300000
|
||||
},
|
||||
"mining_cost": {
|
||||
"type": "number",
|
||||
"defaultValue": 250,
|
||||
"min": 1,
|
||||
"max": 10000
|
||||
},
|
||||
"mining_radius": {
|
||||
"type": "number",
|
||||
"defaultValue": 1,
|
||||
"min": 0,
|
||||
"max": 4
|
||||
}
|
||||
},
|
||||
"mechanics": [],
|
||||
"mechanics": ["ic2:charged_area_tool"],
|
||||
"texture": "ic2:items/tool/electric/iridium_drill"
|
||||
}
|
||||
|
||||
@@ -13,10 +13,22 @@
|
||||
"properties": {
|
||||
"energy": {
|
||||
"type": "number",
|
||||
"defaultValue": 0,
|
||||
"defaultValue": 32000,
|
||||
"max": 32000
|
||||
},
|
||||
"mining_cost": {
|
||||
"type": "number",
|
||||
"defaultValue": 50,
|
||||
"min": 1,
|
||||
"max": 10000
|
||||
},
|
||||
"mining_radius": {
|
||||
"type": "number",
|
||||
"defaultValue": 1,
|
||||
"min": 0,
|
||||
"max": 4
|
||||
}
|
||||
},
|
||||
"mechanics": [],
|
||||
"mechanics": ["ic2:charged_area_tool"],
|
||||
"texture": "ic2:items/tool/electric/drill"
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
"translations": {},
|
||||
"material": "minecraft:emerald",
|
||||
"components": {},
|
||||
"mechanics": [],
|
||||
"mechanics": ["ic2:radiation_exposure"],
|
||||
"texture": "ic2:items/resource/ingot/uranium"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"name": "Энергетическая площадная добыча",
|
||||
"logic": {
|
||||
"version": 1,
|
||||
"nodes": [
|
||||
{ "id": "before", "type": "event:break_block", "inputs": { "itemScope": "main_hand" }, "x": 40, "y": 40 },
|
||||
{ "id": "energy_before", "type": "state:get", "inputs": { "property": "energy" }, "x": 40, "y": 250 },
|
||||
{ "id": "cost", "type": "state:get", "inputs": { "property": "mining_cost" }, "x": 40, "y": 440 },
|
||||
{ "id": "enough_before", "type": "compare:gte", "inputs": {}, "x": 360, "y": 250 },
|
||||
{ "id": "allow_original", "type": "flow:branch", "inputs": {}, "x": 680, "y": 40 },
|
||||
{ "id": "cancel", "type": "action:cancel", "inputs": {}, "x": 1000, "y": 160 },
|
||||
{ "id": "after", "type": "event:after_break_block", "inputs": { "itemScope": "main_hand" }, "x": 40, "y": 700 },
|
||||
{ "id": "start", "type": "flow:sequence", "inputs": {}, "x": 360, "y": 700 },
|
||||
{ "id": "spend_original", "type": "action:change_property", "inputs": { "property": "energy", "operation": "subtract" }, "x": 680, "y": 590 },
|
||||
{ "id": "origin", "type": "context:position", "inputs": { "path": "event.position" }, "x": 360, "y": 950 },
|
||||
{ "id": "radius", "type": "state:get", "inputs": { "property": "mining_radius" }, "x": 360, "y": 1130 },
|
||||
{ "id": "area", "type": "flow:block_area", "inputs": { "plane": "look", "includeCenter": false }, "x": 680, "y": 810 },
|
||||
{ "id": "harvest", "type": "block:can_harvest", "inputs": {}, "x": 1000, "y": 1010 },
|
||||
{ "id": "energy_neighbour", "type": "state:get", "inputs": { "property": "energy" }, "x": 1000, "y": 1190 },
|
||||
{ "id": "enough_neighbour", "type": "compare:gte", "inputs": {}, "x": 1320, "y": 1190 },
|
||||
{ "id": "allowed", "type": "boolean:and", "inputs": {}, "x": 1320, "y": 1010 },
|
||||
{ "id": "mine_branch", "type": "flow:branch", "inputs": {}, "x": 1640, "y": 810 },
|
||||
{ "id": "mine", "type": "action:break_block", "inputs": { "costProperty": "energy" }, "x": 1960, "y": 810 }
|
||||
],
|
||||
"edges": [
|
||||
{ "from": { "node": "before", "port": "next" }, "to": { "node": "allow_original", "port": "in" } },
|
||||
{ "from": { "node": "energy_before", "port": "value" }, "to": { "node": "enough_before", "port": "a" } },
|
||||
{ "from": { "node": "cost", "port": "value" }, "to": { "node": "enough_before", "port": "b" } },
|
||||
{ "from": { "node": "enough_before", "port": "value" }, "to": { "node": "allow_original", "port": "condition" } },
|
||||
{ "from": { "node": "allow_original", "port": "false" }, "to": { "node": "cancel", "port": "in" } },
|
||||
{ "from": { "node": "after", "port": "next" }, "to": { "node": "start", "port": "in" } },
|
||||
{ "from": { "node": "start", "port": "first" }, "to": { "node": "spend_original", "port": "in" } },
|
||||
{ "from": { "node": "cost", "port": "value" }, "to": { "node": "spend_original", "port": "value" } },
|
||||
{ "from": { "node": "start", "port": "next" }, "to": { "node": "area", "port": "in" } },
|
||||
{ "from": { "node": "origin", "port": "value" }, "to": { "node": "area", "port": "origin" } },
|
||||
{ "from": { "node": "radius", "port": "value" }, "to": { "node": "area", "port": "radius" } },
|
||||
{ "from": { "node": "area", "port": "each" }, "to": { "node": "mine_branch", "port": "in" } },
|
||||
{ "from": { "node": "area", "port": "position" }, "to": { "node": "harvest", "port": "position" } },
|
||||
{ "from": { "node": "energy_neighbour", "port": "value" }, "to": { "node": "enough_neighbour", "port": "a" } },
|
||||
{ "from": { "node": "cost", "port": "value" }, "to": { "node": "enough_neighbour", "port": "b" } },
|
||||
{ "from": { "node": "harvest", "port": "value" }, "to": { "node": "allowed", "port": "a" } },
|
||||
{ "from": { "node": "enough_neighbour", "port": "value" }, "to": { "node": "allowed", "port": "b" } },
|
||||
{ "from": { "node": "allowed", "port": "value" }, "to": { "node": "mine_branch", "port": "condition" } },
|
||||
{ "from": { "node": "mine_branch", "port": "true" }, "to": { "node": "mine", "port": "in" } },
|
||||
{ "from": { "node": "area", "port": "position" }, "to": { "node": "mine", "port": "position" } },
|
||||
{ "from": { "node": "cost", "port": "value" }, "to": { "node": "mine", "port": "cost" } }
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"name": "Переносимое радиоактивное заражение",
|
||||
"logic": {
|
||||
"version": 1,
|
||||
"nodes": [
|
||||
{ "id": "tick", "type": "event:owner_tick", "inputs": { "itemScope": "inventory", "interval": 20 }, "x": 40, "y": 40 },
|
||||
{ "id": "owner", "type": "context:entity", "inputs": { "path": "actor.entity" }, "x": 40, "y": 920 },
|
||||
{ "id": "sequence", "type": "flow:sequence", "inputs": {}, "x": 360, "y": 40 },
|
||||
{ "id": "random_slot", "type": "flow:random_slot", "inputs": { "nonempty": true }, "x": 680, "y": 40 },
|
||||
{ "id": "old_dose", "type": "item:property", "inputs": { "property": "radiation", "fallback": 0 }, "x": 680, "y": 260 },
|
||||
{ "id": "dose", "type": "math:random_int", "inputs": { "min": 1, "max": 4 }, "x": 680, "y": 450 },
|
||||
{ "id": "add", "type": "math:add", "inputs": {}, "x": 1000, "y": 300 },
|
||||
{ "id": "limit", "type": "math:clamp", "inputs": { "min": 0, "max": 100 }, "x": 1320, "y": 300 },
|
||||
{ "id": "write", "type": "action:item_property", "inputs": { "property": "radiation", "operation": "set" }, "x": 1640, "y": 40 },
|
||||
{ "id": "inventory", "type": "flow:inventory", "inputs": { "nonempty": true }, "x": 680, "y": 700 },
|
||||
{ "id": "exposure", "type": "item:property", "inputs": { "property": "radiation", "fallback": 0 }, "x": 1000, "y": 920 },
|
||||
{ "id": "stage_one", "type": "compare:gte", "inputs": { "b": 10 }, "x": 1320, "y": 920 },
|
||||
{ "id": "stage_one_branch", "type": "flow:branch", "inputs": {}, "x": 1640, "y": 700 },
|
||||
{ "id": "effects", "type": "flow:sequence", "inputs": {}, "x": 1960, "y": 700 },
|
||||
{ "id": "nausea", "type": "action:entity_effect", "inputs": { "effect": "minecraft:nausea", "duration": 100, "level": 1 }, "x": 2280, "y": 580 },
|
||||
{ "id": "stage_two", "type": "compare:gte", "inputs": { "b": 50 }, "x": 1960, "y": 1030 },
|
||||
{ "id": "stage_two_branch", "type": "flow:branch", "inputs": {}, "x": 2280, "y": 850 },
|
||||
{ "id": "weakness", "type": "action:entity_effect", "inputs": { "effect": "minecraft:weakness", "duration": 100, "level": 2 }, "x": 2600, "y": 850 }
|
||||
],
|
||||
"edges": [
|
||||
{ "from": { "node": "tick", "port": "next" }, "to": { "node": "sequence", "port": "in" } },
|
||||
{ "from": { "node": "sequence", "port": "first" }, "to": { "node": "random_slot", "port": "in" } },
|
||||
{ "from": { "node": "random_slot", "port": "found" }, "to": { "node": "write", "port": "in" } },
|
||||
{ "from": { "node": "random_slot", "port": "slot" }, "to": { "node": "old_dose", "port": "slot" } },
|
||||
{ "from": { "node": "old_dose", "port": "value" }, "to": { "node": "add", "port": "a" } },
|
||||
{ "from": { "node": "dose", "port": "value" }, "to": { "node": "add", "port": "b" } },
|
||||
{ "from": { "node": "add", "port": "value" }, "to": { "node": "limit", "port": "value" } },
|
||||
{ "from": { "node": "limit", "port": "value" }, "to": { "node": "write", "port": "value" } },
|
||||
{ "from": { "node": "random_slot", "port": "slot" }, "to": { "node": "write", "port": "slot" } },
|
||||
{ "from": { "node": "sequence", "port": "next" }, "to": { "node": "inventory", "port": "in" } },
|
||||
{ "from": { "node": "inventory", "port": "each" }, "to": { "node": "stage_one_branch", "port": "in" } },
|
||||
{ "from": { "node": "inventory", "port": "slot" }, "to": { "node": "exposure", "port": "slot" } },
|
||||
{ "from": { "node": "exposure", "port": "value" }, "to": { "node": "stage_one", "port": "a" } },
|
||||
{ "from": { "node": "stage_one", "port": "value" }, "to": { "node": "stage_one_branch", "port": "condition" } },
|
||||
{ "from": { "node": "stage_one_branch", "port": "true" }, "to": { "node": "effects", "port": "in" } },
|
||||
{ "from": { "node": "effects", "port": "first" }, "to": { "node": "nausea", "port": "in" } },
|
||||
{ "from": { "node": "owner", "port": "value" }, "to": { "node": "nausea", "port": "entity" } },
|
||||
{ "from": { "node": "effects", "port": "next" }, "to": { "node": "stage_two_branch", "port": "in" } },
|
||||
{ "from": { "node": "exposure", "port": "value" }, "to": { "node": "stage_two", "port": "a" } },
|
||||
{ "from": { "node": "stage_two", "port": "value" }, "to": { "node": "stage_two_branch", "port": "condition" } },
|
||||
{ "from": { "node": "stage_two_branch", "port": "true" }, "to": { "node": "weakness", "port": "in" } },
|
||||
{ "from": { "node": "owner", "port": "value" }, "to": { "node": "weakness", "port": "entity" } }
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package online.astradev.packs;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.stream.Stream;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class StarterLogicLayoutTest {
|
||||
@Test
|
||||
void authoredMechanicNodesUseCoordinatesReadByTheEditor() throws IOException {
|
||||
Path mechanics = Path.of("src/starter/files/astraplus/contents/ic2/mechanics");
|
||||
try (Stream<Path> files = Files.list(mechanics)) {
|
||||
for (Path file : files.filter(path -> path.toString().endsWith(".json")).toList()) {
|
||||
JsonObject root = JsonParser.parseString(Files.readString(file)).getAsJsonObject();
|
||||
var nodes = root.getAsJsonObject("logic").getAsJsonArray("nodes");
|
||||
assertFalse(nodes.isEmpty(), file + " must contain an executable graph");
|
||||
nodes.forEach(element -> {
|
||||
JsonObject node = element.getAsJsonObject();
|
||||
assertFalse(node.has("position"), file + " uses an ignored nested position field");
|
||||
assertTrue(node.has("x") && node.get("x").isJsonPrimitive(), file + " node lacks x");
|
||||
assertTrue(node.has("y") && node.get("y").isJsonPrimitive(), file + " node lacks y");
|
||||
assertTrue(Double.isFinite(node.get("x").getAsDouble()), file + " node x is not finite");
|
||||
assertTrue(Double.isFinite(node.get("y").getAsDouble()), file + " node y is not finite");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user