Skip to content

Commit 254dbe9

Browse files
committed
feat: add forbidden arcanus ores to miner
1 parent 6ad39d4 commit 254dbe9

File tree

7 files changed

+235
-0
lines changed

7 files changed

+235
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"type": "occultism:miner",
3+
"conditions": [
4+
{
5+
"type": "forge:not",
6+
"value": {
7+
"type": "forge:tag_empty",
8+
"tag": "forge:ores/arcane_crystal"
9+
}
10+
}
11+
],
12+
"ingredient": {
13+
"tag": "occultism:miners/deeps"
14+
},
15+
"result": {
16+
"tag": "forge:ores/arcane_crystal"
17+
},
18+
"weight": 200
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"type": "occultism:miner",
3+
"conditions": [
4+
{
5+
"type": "forge:not",
6+
"value": {
7+
"type": "forge:tag_empty",
8+
"tag": "forge:ores/stella_arcanum"
9+
}
10+
}
11+
],
12+
"ingredient": {
13+
"tag": "occultism:miners/master"
14+
},
15+
"result": {
16+
"tag": "forge:ores/stella_arcanum"
17+
},
18+
"weight": 100
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"type": "occultism:miner",
3+
"conditions": [
4+
{
5+
"type": "forge:not",
6+
"value": {
7+
"type": "forge:tag_empty",
8+
"tag": "forge:ores/arcane_crystal"
9+
}
10+
}
11+
],
12+
"ingredient": {
13+
"tag": "occultism:miners/ores"
14+
},
15+
"result": {
16+
"tag": "forge:ores/arcane_crystal"
17+
},
18+
"weight": 200
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"type": "occultism:miner",
3+
"conditions": [
4+
{
5+
"type": "forge:not",
6+
"value": {
7+
"type": "forge:tag_empty",
8+
"tag": "forge:ores/xpetrified_ore"
9+
}
10+
}
11+
],
12+
"ingredient": {
13+
"tag": "occultism:miners/ores"
14+
},
15+
"result": {
16+
"tag": "forge:ores/xpetrified_ore"
17+
},
18+
"weight": 200
19+
}

src/main/java/com/github/klikli_dev/occultism/datagen/CrushingRecipeProvider.java

+22
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
/*
2+
* MIT License
3+
*
4+
* Copyright 2023 klikli-dev
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
7+
* associated documentation files (the "Software"), to deal in the Software without restriction, including
8+
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9+
* of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
10+
* conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in all copies or substantial
13+
* portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
17+
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19+
* OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+
* OTHER DEALINGS IN THE SOFTWARE.
21+
*/
22+
123
package com.github.klikli_dev.occultism.datagen;
224

325
import com.github.klikli_dev.occultism.Occultism;

src/main/java/com/github/klikli_dev/occultism/datagen/DataGenerators.java

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public static void gatherData(GatherDataEvent event) {
5555
generator.addProvider(event.includeServer(), new PentacleProvider(generator));
5656
generator.addProvider(event.includeServer(), new OccultismAdvancementProvider(generator));
5757
generator.addProvider(event.includeServer(), new CrushingRecipeProvider(generator.getPackOutput()));
58+
generator.addProvider(event.includeServer(), new MinerRecipeProvider(generator.getPackOutput()));
5859
generator.addProvider(event.includeClient(), new ItemModelsGenerator(generator.getPackOutput(), event.getExistingFileHelper()));
5960
generator.addProvider(event.includeClient(), new StandardBlockStateProvider(generator.getPackOutput(), event.getExistingFileHelper()));
6061

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/*
2+
* MIT License
3+
*
4+
* Copyright 2023 klikli-dev
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
7+
* associated documentation files (the "Software"), to deal in the Software without restriction, including
8+
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9+
* of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
10+
* conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in all copies or substantial
13+
* portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
17+
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19+
* OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+
* OTHER DEALINGS IN THE SOFTWARE.
21+
*/
22+
23+
package com.github.klikli_dev.occultism.datagen;
24+
25+
import com.github.klikli_dev.occultism.Occultism;
26+
import com.google.common.collect.Sets;
27+
import com.google.gson.JsonArray;
28+
import com.google.gson.JsonObject;
29+
import com.mojang.datafixers.util.Pair;
30+
import net.minecraft.data.CachedOutput;
31+
import net.minecraft.data.DataProvider;
32+
import net.minecraft.data.PackOutput;
33+
import net.minecraft.resources.ResourceLocation;
34+
35+
import java.util.ArrayList;
36+
import java.util.List;
37+
import java.util.Set;
38+
import java.util.concurrent.CompletableFuture;
39+
import java.util.function.Consumer;
40+
41+
public class MinerRecipeProvider implements DataProvider {
42+
protected final PackOutput.PathProvider recipePathProvider;
43+
44+
public MinerRecipeProvider(PackOutput packOutput) {
45+
this.recipePathProvider = packOutput.createPathProvider(PackOutput.Target.DATA_PACK, "recipes/miner");
46+
}
47+
48+
public CompletableFuture<?> run(CachedOutput pOutput) {
49+
Set<ResourceLocation> set = Sets.newHashSet();
50+
List<CompletableFuture<?>> list = new ArrayList<>();
51+
this.buildRecipes((recipe) -> {
52+
if (!set.add(recipe.getFirst())) {
53+
throw new IllegalStateException("Duplicate recipe " + recipe.getFirst());
54+
} else {
55+
list.add(DataProvider.saveStable(pOutput, recipe.getSecond(), this.recipePathProvider.json(recipe.getFirst())));
56+
}
57+
});
58+
return CompletableFuture.allOf(list.toArray(CompletableFuture[]::new));
59+
}
60+
61+
protected ResourceLocation modLoc(String path) {
62+
return new ResourceLocation(Occultism.MODID, path);
63+
}
64+
65+
protected ResourceLocation loc(String namespace, String path) {
66+
return new ResourceLocation(namespace, path);
67+
}
68+
69+
protected void buildRecipes(Consumer<Pair<ResourceLocation, JsonObject>> recipes) {
70+
this.buildForbiddenArcanusRecipes(recipes);
71+
}
72+
73+
protected void buildForbiddenArcanusRecipes(Consumer<Pair<ResourceLocation, JsonObject>> recipes) {
74+
recipes.accept(this.buildMinerRecipe(
75+
this.modLoc("deeps/deepslate_arcane_crystal"),
76+
this.modLoc("miners/deeps"),
77+
this.loc("forge", "ores/arcane_crystal"),
78+
200));
79+
80+
recipes.accept(this.buildMinerRecipe(
81+
this.modLoc("master/stella_arcanum"),
82+
this.modLoc("miners/master"),
83+
this.loc("forge", "ores/stella_arcanum"),
84+
100));
85+
86+
recipes.accept(this.buildMinerRecipe(
87+
this.modLoc("ores/arcane_crystal"),
88+
this.modLoc("miners/ores"),
89+
this.loc("forge", "ores/arcane_crystal"),
90+
200));
91+
92+
recipes.accept(this.buildMinerRecipe(
93+
this.modLoc("ores/xpetrified"),
94+
this.modLoc("miners/ores"),
95+
this.loc("forge", "ores/xpetrified_ore"),
96+
200));
97+
}
98+
99+
protected Pair<ResourceLocation, JsonObject> buildMinerRecipe(ResourceLocation name, ResourceLocation minerTag, ResourceLocation outputTag, int weight) {
100+
var recipe = this.buildMinerRecipeJson(minerTag.toString(), outputTag.toString(), weight);
101+
return new Pair<>(name, recipe);
102+
}
103+
104+
public JsonObject buildMinerRecipeJson(String minerTag, String outputTag, int weight) {
105+
var recipe = new JsonObject();
106+
recipe.addProperty("type", "occultism:miner");
107+
var conditions = this.buildMinerRecipeConditionJson(outputTag);
108+
recipe.add("conditions", conditions);
109+
var ingredient = new JsonObject();
110+
ingredient.addProperty("tag", minerTag);
111+
recipe.add("ingredient", ingredient);
112+
var result = new JsonObject();
113+
result.addProperty("tag", outputTag);
114+
recipe.add("result", result);
115+
recipe.addProperty("weight", weight);
116+
return recipe;
117+
}
118+
119+
public JsonArray buildMinerRecipeConditionJson(String outputTag) {
120+
var conditions = new JsonArray();
121+
//multiple conditions on the root level array are treated as AND by forge, but we only have one
122+
var condition = new JsonObject();
123+
condition.addProperty("type", "forge:not");
124+
var value = new JsonObject();
125+
value.addProperty("type", "forge:tag_empty");
126+
value.addProperty("tag", outputTag);
127+
condition.add("value", value);
128+
conditions.add(condition);
129+
return conditions;
130+
}
131+
132+
@Override
133+
public String getName() {
134+
return "Miner Recipes";
135+
}
136+
}

0 commit comments

Comments
 (0)