Template file error

Started by muzafferkadi on

Topic category: Plugins and third-party tools

Joined May 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Template file error
Sun, 05/02/2021 - 08:23 (edited)

Hello I make a recipe template file but file is giving this error

FTL stack trace ("~" means nesting-related):
        - Failed at: #assign ingredients += "{${mappedMCIt...  [in template "json/recipe.java.ftl" at line 9, column 13]
----
        at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:160) ~[freemarker-2.3.31.jar:2.3.31]
        at freemarker.core.Assignment.accept(Assignment.java:155) ~[freemarker-2.3.31.jar:2.3.31]
        at freemarker.core.Environment.visit(Environment.java:347) ~[freemarker-2.3.31.jar:2.3.31]
        at freemarker.core.Environment.visit(Environment.java:389) ~[freemarker-2.3.31.jar:2.3.31]
        at freemarker.core.IteratorBlock$IterationContext.executedNestedContentForCollOrSeqListing(IteratorBlock.java:291) ~[freemarker-2.3.31.jar:2.3.31]
        at freemarker.core.IteratorBlock$IterationContext.executeNestedContent(IteratorBlock.java:271) ~[freemarker-2.3.31.jar:2.3.31]
        at freemarker.core.IteratorBlock$IterationContext.accept(IteratorBlock.java:244) ~[freemarker-2.3.31.jar:2.3.31]
        at freemarker.core.Environment.visitIteratorBlock(Environment.java:657) ~[freemarker-2.3.31.jar:2.3.31]
        at freemarker.core.IteratorBlock.acceptWithResult(IteratorBlock.java:108) ~[freemarker-2.3.31.jar:2.3.31]
        at freemarker.core.IteratorBlock.accept(IteratorBlock.java:94) ~[freemarker-2.3.31.jar:2.3.31]
        at freemarker.core.Environment.visit(Environment.java:347) ~[freemarker-2.3.31.jar:2.3.31]
        at freemarker.core.Environment.visit(Environment.java:353) ~[freemarker-2.3.31.jar:2.3.31]
        at freemarker.core.Environment.visit(Environment.java:353) ~[freemarker-2.3.31.jar:2.3.31]
        at freemarker.core.Environment.process(Environment.java:326) ~[freemarker-2.3.31.jar:2.3.31]
        at freemarker.template.Template.process(Template.java:414) ~[freemarker-2.3.31.jar:2.3.31]
        at net.mcreator.generator.template.TemplateGenerator.generateTemplate(TemplateGenerator.java:84) ~[mcreator.jar:?]
        at net.mcreator.generator.template.TemplateGenerator.generateElementFromTemplate(TemplateGenerator.java:60) ~[mcreator.jar:?]
        at net.mcreator.generator.Generator.generateElement(Generator.java:246) ~[mcreator.jar:?]
        at net.mcreator.generator.Generator.generateElement(Generator.java:211) ~[mcreator.jar:?]
        at net.mcreator.ui.modgui.ModElementGUI.finishModCreation(ModElementGUI.java:382) ~[mcreator.jar:?]
        at net.mcreator.ui.modgui.ModElementGUI.lambda$finalizeGUI$7(ModElementGUI.java:274) ~[mcreator.jar:?]
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022) [?:1.8.0_275]
        at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348) [?:1.8.0_275]
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) [?:1.8.0_275]
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) [?:1.8.0_275]
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252) [?:1.8.0_275]
        at java.awt.Component.processMouseEvent(Component.java:6539) [?:1.8.0_275]
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3324) [?:1.8.0_275]
        at java.awt.Component.processEvent(Component.java:6304) [?:1.8.0_275]
        at java.awt.Container.processEvent(Container.java:2239) [?:1.8.0_275]
        at java.awt.Component.dispatchEventImpl(Component.java:4889) [?:1.8.0_275]
        at java.awt.Container.dispatchEventImpl(Container.java:2297) [?:1.8.0_275]
        at java.awt.Component.dispatchEvent(Component.java:4711) [?:1.8.0_275]
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904) [?:1.8.0_275]
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4535) [?:1.8.0_275]
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476) [?:1.8.0_275]
        at java.awt.Container.dispatchEventImpl(Container.java:2283) [?:1.8.0_275]
        at java.awt.Window.dispatchEventImpl(Window.java:2746) [?:1.8.0_275]
        at java.awt.Component.dispatchEvent(Component.java:4711) [?:1.8.0_275]
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760) [?:1.8.0_275]
        at java.awt.EventQueue.access$500(EventQueue.java:97) [?:1.8.0_275]
        at java.awt.EventQueue$3.run(EventQueue.java:709) [?:1.8.0_275]
        at java.awt.EventQueue$3.run(EventQueue.java:703) [?:1.8.0_275]
        at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_275]
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74) [?:1.8.0_275]
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84) [?:1.8.0_275]
        at java.awt.EventQueue$4.run(EventQueue.java:733) [?:1.8.0_275]
        at java.awt.EventQueue$4.run(EventQueue.java:731) [?:1.8.0_275]
        at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_275]
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74) [?:1.8.0_275]
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:730) [?:1.8.0_275]
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205) [?:1.8.0_275]
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) [?:1.8.0_275]
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) [?:1.8.0_275]
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) [?:1.8.0_275]
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) [?:1.8.0_275]
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) [?:1.8.0_275]

code:

<#-- @formatter:off -->
<#include "../mcitems.ftl">
package ${package}.item.crafting;
@Elements${JavaModName}.ModElement.Tag public class Recipe${name} extends Elements${JavaModName}.ModElement{
  @Override public void init(FMLInitializationEvent event) {
  <#if data.recipeShapeless>
    <#list data.recipeSlots as element>
        <#if !element.isEmpty()>
            <#assign ingredients += "{${mappedMCItemToIngameItemName(element)}},">
        </#if>
    </#list>
      ${ingredients[0..(ingredients?last_index_of(',') - 1)]}
  <#else>
    <#assign recipeArray = data.getOptimisedRecipe()>
    <#assign rm = [], i = 0>
    "pattern": [
    <#list recipeArray as rl>
			"<#list rl as re><#if !re.isEmpty()><#assign rm+=["\"${i}\": {${mappedMCItemToIngameItemName(re)}}"]/>${i}<#else> </#if><#assign i+=1></#list>"<#if rl?has_next>,</#if>
    </#list>
    ],
    "key": {
    <#list rm as recipeMapping>
        ${recipeMapping}<#if recipeMapping?has_next>,</#if>
    </#list>
    },
  </#if>
    "result": {
        ${mappedMCItemToIngameItemName(data.recipeReturnStack)},
    "count": ${data.recipeRetstackSize}}
  }
}
<#-- @formatter:on -->

How can I solve

Edited by muzafferkadi on Sun, 05/02/2021 - 08:23