Skip to content

Commit 9927ea7

Browse files
authored
Merge pull request #3258 from burin-ljx/fix_chromatic_stone
Implement the unfinished function of chromatic stone 实现异彩石未完成的功能
2 parents 2d46366 + 012e0c9 commit 9927ea7

8 files changed

Lines changed: 153 additions & 71 deletions

File tree

src/generated/resources/data/anvilcraft/advancement/recipes/item_crush/chromatic_stone.json renamed to src/generated/resources/data/anvilcraft/advancement/recipes/item_crush/item_crush/gem_from_chromatic_stone.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"criteria": {
44
"has_the_recipe": {
55
"conditions": {
6-
"recipe": "anvilcraft:item_crush/chromatic_stone"
6+
"recipe": "anvilcraft:item_crush/gem_from_chromatic_stone"
77
},
88
"trigger": "minecraft:recipe_unlocked"
99
}
@@ -15,7 +15,7 @@
1515
],
1616
"rewards": {
1717
"recipes": [
18-
"anvilcraft:item_crush/chromatic_stone"
18+
"anvilcraft:item_crush/gem_from_chromatic_stone"
1919
]
2020
}
2121
}

src/generated/resources/data/anvilcraft/recipe/item_crush/chromatic_stone.json

Lines changed: 0 additions & 46 deletions
This file was deleted.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
{
2+
"type": "anvillib_recipe:in_world_recipe",
3+
"compatible": true,
4+
"conflicting": [
5+
{
6+
"type": "anvillib_recipe:has_item_ingredient",
7+
"item": {
8+
"items": "anvilcraft:chromatic_stone"
9+
},
10+
"offset": [
11+
0.0,
12+
-0.125,
13+
0.0
14+
],
15+
"range": [
16+
0.75,
17+
0.75,
18+
0.75
19+
]
20+
}
21+
],
22+
"icon": {
23+
"count": 1,
24+
"id": "anvilcraft:crushing_table"
25+
},
26+
"non_conflicting": [
27+
{
28+
"type": "anvillib_recipe:has_block",
29+
"offset": [
30+
0.0,
31+
-1.0,
32+
0.0
33+
],
34+
"predicate": {
35+
"blocks": "anvilcraft:crushing_table"
36+
}
37+
}
38+
],
39+
"outcomes": [
40+
{
41+
"type": "anvillib_recipe:choose_one",
42+
"choices": [
43+
{
44+
"outcome": {
45+
"type": "anvillib_recipe:spawn_item",
46+
"item": "anvilcraft:ruby",
47+
"offset": [
48+
0.0,
49+
-0.6875,
50+
0.0
51+
]
52+
},
53+
"weight": 0.25
54+
},
55+
{
56+
"outcome": {
57+
"type": "anvillib_recipe:spawn_item",
58+
"item": "anvilcraft:topaz",
59+
"offset": [
60+
0.0,
61+
-0.6875,
62+
0.0
63+
]
64+
},
65+
"weight": 0.25
66+
},
67+
{
68+
"outcome": {
69+
"type": "anvillib_recipe:spawn_item",
70+
"item": "anvilcraft:sapphire",
71+
"offset": [
72+
0.0,
73+
-0.6875,
74+
0.0
75+
]
76+
},
77+
"weight": 0.25
78+
},
79+
{
80+
"outcome": {
81+
"type": "anvillib_recipe:spawn_item",
82+
"item": "minecraft:emerald",
83+
"offset": [
84+
0.0,
85+
-0.6875,
86+
0.0
87+
]
88+
},
89+
"weight": 0.25
90+
}
91+
]
92+
}
93+
],
94+
"priority": 4,
95+
"trigger": "anvilcraft:on_anvil_fall_on"
96+
}

src/generated/resources/data/anvilcraft/recipe/time_warp/chromatic_stone.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
"type": "anvilcraft:time_warp",
33
"consume": 1000,
44
"fluid": "anvilcraft:melt_gem",
5-
"ingredients": [
6-
{
7-
"items": "minecraft:stone"
8-
}
9-
],
105
"results": [
116
{
127
"id": "anvilcraft:chromatic_stone"

src/main/java/dev/dubhe/anvilcraft/data/recipe/ItemCrushRecipeLoader.java

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package dev.dubhe.anvilcraft.data.recipe;
22

33
import com.tterrag.registrate.providers.RegistrateRecipeProvider;
4+
import dev.anvilcraft.lib.recipe.outcome.SpawnItem;
45
import dev.dubhe.anvilcraft.AnvilCraft;
56
import dev.dubhe.anvilcraft.init.block.ModBlocks;
67
import dev.dubhe.anvilcraft.init.item.ModFoodItems;
78
import dev.dubhe.anvilcraft.init.item.ModItems;
9+
import dev.dubhe.anvilcraft.init.recipe.ModRecipeTriggers;
10+
import dev.dubhe.anvilcraft.recipe.anvil.builder.ExtendInWorldRecipeBuilder;
811
import dev.dubhe.anvilcraft.recipe.anvil.wrap.ItemCrushRecipe;
912
import net.minecraft.tags.ItemTags;
1013
import net.minecraft.world.item.Items;
@@ -58,14 +61,44 @@ public static void init(RegistrateRecipeProvider provider) {
5861
.result(ModItems.SAPPHIRE.get(), 0.25f)
5962
.result(ModItems.RUBY.get(), 0.25f)
6063
.save(provider, AnvilCraft.of("item_crush/geode_gems"));
61-
ItemCrushRecipe.builder()
62-
.requires(ModBlocks.CHROMATIC_STONE)
63-
.result(Items.QUARTZ, 3)
64-
.result(Items.EMERALD, 0.25f)
65-
.result(ModItems.TOPAZ.get(), 0.25f)
66-
.result(ModItems.SAPPHIRE.get(), 0.25f)
67-
.result(ModItems.RUBY.get(), 0.25f)
68-
.save(provider, AnvilCraft.of("item_crush/chromatic_stone"));
64+
65+
ExtendInWorldRecipeBuilder.extendCompatible(ModRecipeTriggers.ON_ANVIL_FALL_ON)
66+
.group("item_crush")
67+
.icon(ModBlocks.CRUSHING_TABLE.asStack())
68+
.hasBlock(0, -1, 0, ModBlocks.CRUSHING_TABLE.getDefaultState())
69+
.hasItemIngredient((builder) -> builder
70+
.offset(0, -.125, 0)
71+
.range(.75, .75, .75)
72+
.of(ModBlocks.CHROMATIC_STONE)
73+
)
74+
.chooseOne((builder) -> builder
75+
.choice(
76+
SpawnItem.builder()
77+
.offset(0, -.6875, 0)
78+
.item(ModItems.RUBY)
79+
.build(),
80+
.25f
81+
).choice(
82+
SpawnItem.builder()
83+
.offset(0, -.6875, 0)
84+
.item(ModItems.TOPAZ)
85+
.build(),
86+
.25f
87+
).choice(
88+
SpawnItem.builder()
89+
.offset(0, -.6875, 0)
90+
.item(ModItems.SAPPHIRE)
91+
.build(),
92+
.25f
93+
).choice(
94+
SpawnItem.builder()
95+
.offset(0, -.6875, 0)
96+
.item(Items.EMERALD)
97+
.build(),
98+
.25f
99+
)
100+
)
101+
.save(provider, AnvilCraft.of("item_crush/gem_from_chromatic_stone"));
69102

70103
ItemCrushRecipe.builder()
71104
.requires(Items.CREEPER_HEAD)

src/main/java/dev/dubhe/anvilcraft/data/recipe/TimeWarpRecipeLoader.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,17 @@ public static void init(RegistrateRecipeProvider provider) {
7474
.consume(1000)
7575
.fluid(ModBlocks.MELT_GEM_CAULDRON.get())
7676
.save(provider);
77-
TimeWarpRecipe.builder()
78-
.requires(Blocks.STONE)
79-
.result(ModBlocks.CHROMATIC_STONE)
80-
.consume(1000)
81-
.fluid(ModBlocks.MELT_GEM_CAULDRON.get())
82-
.save(provider);
8377
TimeWarpRecipe.builder()
8478
.requires(ItemTags.LOGS)
8579
.result(Items.COAL)
8680
.save(provider, AnvilCraft.of("time_warp/coal_from_logs"));
8781

82+
TimeWarpRecipe.builder()
83+
.fluid(ModBlocks.MELT_GEM_CAULDRON.get())
84+
.consume(1000)
85+
.result(ModBlocks.CHROMATIC_STONE)
86+
.save(provider);
87+
8888
timeWarpToOilCauldron(provider, Items.ROTTEN_FLESH, 64);
8989
timeWarpToOilCauldron(provider, Items.SPIDER_EYE, 64);
9090
timeWarpToOilCauldron(provider, ModItemTags.RAW_CHICKEN, 64);
@@ -201,7 +201,6 @@ public static void init(RegistrateRecipeProvider provider) {
201201
.result(ModItems.RAW_LEAD.asStack())
202202
.save(provider, AnvilCraft.of("time_warp/raw_uranium_from_plutonium_block"));
203203

204-
205204
TimeWarpRecipe.builder()
206205
.requires(ItemIngredientPredicate.Builder.item()
207206
.of(ModBlocks.RESIN_BLOCK)

src/main/java/dev/dubhe/anvilcraft/integration/jei/category/anvil/TimeWarpCategory.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,9 @@ public void draw(
139139
RenderSupport.SINGLE_BLOCK
140140
);
141141

142-
arrowIn.draw(guiGraphics, 54, 20);
142+
if (!recipe.getInputItems().isEmpty()) {
143+
arrowIn.draw(guiGraphics, 54, 20);
144+
}
143145
arrowOut.draw(guiGraphics, 92, 19);
144146

145147
JeiSlotUtil.drawInputSlots(guiGraphics, slotDefault, recipe.getInputItems().size());

src/main/java/dev/dubhe/anvilcraft/recipe/anvil/wrap/TimeWarpRecipe.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,11 @@ protected TimeWarpRecipe of(List<ItemIngredientPredicate> itemIngredients, List<
408408

409409
@Override
410410
public void validate(ResourceLocation id) {
411-
if (itemIngredients.isEmpty()) {
412-
throw new IllegalArgumentException("Recipe ingredients must not be empty, RecipeId: " + id);
411+
HasCauldronSimple hasCauldronSimple = this.hasCauldron.build();
412+
if (itemIngredients.isEmpty()
413+
&& (hasCauldronSimple.fluid().equals(HasCauldron.EMPTY)
414+
|| hasCauldronSimple.fluid().equals(HasCauldron.NULL))) {
415+
throw new IllegalArgumentException("Recipe input must not be empty, RecipeId: " + id);
413416
}
414417
}
415418

0 commit comments

Comments
 (0)