Skip to content

Commit c5b5a37

Browse files
committed
Fix mcitems and Recipe ME
1 parent 0139b6d commit c5b5a37

File tree

8 files changed

+129
-39
lines changed

8 files changed

+129
-39
lines changed

src/main/resources/datapack-1.12.x/templates/recipe/smelting.json.ftl

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

src/main/resources/forge-1.12.2/recipe.definition.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
templates:
2-
- template: recipe/smelting.json.ftl # loaded from datapack generator
3-
writer: json
4-
name: "@MODASSETSROOT/recipes/@[getName()].json"
5-
condition: "recipeType %= Smelting"
62
- template: recipe/crafting.json.ftl # loaded from datapack generator
73
writer: json
84
name: "@MODASSETSROOT/recipes/@[getName()].json"
@@ -16,4 +12,10 @@ templates:
1612
name: "@MODASSETSROOT/advancements/recipes/@registryname.json"
1713
condition: "hasAdvancement()"
1814

19-
field_exclusions: [cookingBookCategory, craftingBookCategory, blastFurnaceRecipeMaker, smokerRecipeMaker, stoneCutterRecipeMaker, campfireCookingRecipeMaker, smithingRecipeMaker]
15+
global_templates:
16+
- template: elementinits/recipes.java.ftl
17+
writer: java
18+
name: "@SRCROOT/@BASEPACKAGEPATH/init/@JavaModNameRecipes.java"
19+
condition: "${w.getGElementsOfType('recipe')?filter(e -> e.recipeType == 'Smelting' || e.recipeType == 'Brewing')?size != 0}"
20+
21+
field_exclusions: [cookingBookCategory, craftingBookCategory, blastFurnaceRecipeMaker, smokerRecipeMaker, stoneCutterRecipeMaker, campfireCookingRecipeMaker, smithingRecipeMaker, cookingTime]

src/main/resources/forge-1.12.2/templates/dispensebehaviour.java.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class ${name}ItemExtension {
4747
int z = blockSource.getBlockPos().getZ();
4848

4949
<#if hasSuccessCondition>
50-
this.successful(<@procedureOBJToConditionCode data.dispenseSuccessCondition/>);
50+
this.successful = <@procedureOBJToConditionCode data.dispenseSuccessCondition/>;
5151
</#if>
5252

5353
<#if hasProcedure(data.dispenseResultItemstack)>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<#--
2+
# MCreator (https://mcreator.net/)
3+
# Copyright (C) 2012-2020, Pylo
4+
# Copyright (C) 2020-2025, Pylo, opensource contributors
5+
#
6+
# This program is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# This program is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU General Public License
17+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
#
19+
# Additional permission for code generator templates (*.ftl files)
20+
#
21+
# As a special exception, you may create a larger work that contains part or
22+
# all of the MCreator code generator templates (*.ftl files) and distribute
23+
# that work under terms of your choice, so long as that work isn't itself a
24+
# template for code generation. Alternatively, if you modify or redistribute
25+
# the template itself, you may (at your option) remove this special exception,
26+
# which will cause the template and the resulting code generator output files
27+
# to be licensed under the GNU General Public License without this special
28+
# exception.
29+
-->
30+
31+
<#-- @formatter:off -->
32+
33+
/*
34+
* MCreator note: This file will be REGENERATED on each build.
35+
*/
36+
37+
package ${package}.init;
38+
<#include "../mcitems.ftl">
39+
40+
public class ${JavaModName}Recipes {
41+
42+
public static void load() {
43+
<#list recipes as recipe>
44+
<#if recipe.recipeType == "Brewing">
45+
BrewingRecipeRegistry.addRecipe(new ${recipe.getModElement().getName()}BrewingRecipe());
46+
<#elseif recipe.recipeType == "Smelting">
47+
GameRegistry.addSmelting(${mappedMCItemToItemStackCode(recipe.smeltingInputStack, 1)}, ${mappedMCItemToItemStackCode(recipe.smeltingReturnStack, recipe.recipeRetstackSize)}, ${recipe.xpReward}f);
48+
</#if>
49+
</#list>
50+
}
51+
}
52+
<#-- @formatter:on -->

src/main/resources/forge-1.12.2/templates/modbase/mod.java.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import org.apache.logging.log4j.Logger;
4343
}
4444

4545
@Mod.EventHandler public void init(FMLInitializationEvent event) {
46+
<#if w.getGElementsOfType('recipe')?filter(e -> e.recipeType == 'Smelting' || e.recipeType == 'Brewing')?size != 0>${JavaModName}Recipes.load();</#if>
4647
<#if w.hasElementsOfType("loottable")>${JavaModName}Loottables.load();</#if>
4748
<#if w.hasElementsOfType("keybind")>${JavaModName}KeyMappings.registerKeyBindings();</#if>
4849
<#if w.getGElementsOfType('itemextension')?filter(e -> e.hasDispenseBehavior)?size != 0>${JavaModName}ItemExtensions.load();</#if>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<#--
2+
# MCreator (https://mcreator.net/)
3+
# Copyright (C) 2012-2020, Pylo
4+
# Copyright (C) 2020-2025, Pylo, opensource contributors
5+
#
6+
# This program is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# This program is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU General Public License
17+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
#
19+
# Additional permission for code generator templates (*.ftl files)
20+
#
21+
# As a special exception, you may create a larger work that contains part or
22+
# all of the MCreator code generator templates (*.ftl files) and distribute
23+
# that work under terms of your choice, so long as that work isn't itself a
24+
# template for code generation. Alternatively, if you modify or redistribute
25+
# the template itself, you may (at your option) remove this special exception,
26+
# which will cause the template and the resulting code generator output files
27+
# to be licensed under the GNU General Public License without this special
28+
# exception.
29+
-->
30+
31+
<#-- @formatter:off -->
32+
<#include "../mcitems.ftl">
33+
package ${package}.recipes.brewing;
34+
35+
public class ${name}BrewingRecipe implements IBrewingRecipe {
36+
37+
@Override public boolean isInput(ItemStack input) {
38+
<#if data.brewingInputStack?starts_with("POTION:")>
39+
Item inputItem = input.getItem();
40+
return (inputItem == Items.POTION || inputItem == Items.SPLASH_POTION || inputItem == Items.LINGERING_POTION)
41+
&& PotionUtils.getPotionFromItem(input) == ${generator.map(data.brewingInputStack?replace("POTION:",""), "potions")};
42+
<#else>
43+
return ${mappedMCItemToIngredient(data.brewingInputStack)}.test(input);
44+
</#if>
45+
}
46+
47+
@Override public boolean isIngredient(ItemStack ingredient) {
48+
return ${mappedMCItemToIngredient(data.brewingIngredientStack)}.test(ingredient);
49+
}
50+
51+
@Override public ItemStack getOutput(ItemStack input, ItemStack ingredient) {
52+
if (isInput(input) && isIngredient(ingredient)) {
53+
<#if data.brewingReturnStack?starts_with("POTION:")>
54+
return PotionUtils.addPotionToItemStack(
55+
<#if data.brewingInputStack?starts_with("POTION:")>
56+
new ItemStack(input.getItem())
57+
<#else>
58+
new ItemStack(Items.POTION)
59+
</#if>, ${generator.map(data.brewingReturnStack?replace("POTION:",""), "potions")});
60+
<#else>
61+
return ${mappedMCItemToItemStackCode(data.brewingReturnStack, 1)};
62+
</#if>
63+
}
64+
return ItemStack.EMPTY;
65+
}
66+
}

src/main/resources/forge-1.12.2/templates/smelting.java.ftl

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

src/main/resources/forge-1.12.2/utils/mcitems.ftl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
<#function toItemStack item amount>
4646
<#if amount == 1 && !hasMetadata(item)>
4747
<#return "new ItemStack(" + item + ")">
48-
<#if hasMetadata(item)>
49-
<#return "new ItemStack(" + splitMetadata(item)[0] + "," + (amount == amount?floor)?then(amount + ")","(int)(" + amount + "), " + splitMetadata(item)[1] + ")">
48+
<#elseif hasMetadata(item)>
49+
<#return "new ItemStack(" + splitMetadata(item)[0] + "," + (amount == amount?floor)?then(amount + ")","(int)(" + amount + "), " + splitMetadata(item)[1] + ")")>
5050
<#else>
5151
<#return "new ItemStack(" + item + "," + (amount == amount?floor)?then(amount + ")","(int)(" + amount + "))")>
5252
</#if>

0 commit comments

Comments
 (0)