Package net.mcreator.blockly
Class BlocklyToCode
java.lang.Object
net.mcreator.blockly.BlocklyToCode
- All Implemented Interfaces:
IGeneratorProvider
,IWorkspaceProvider
- Direct Known Subclasses:
BlocklyToJava
,BlocklyToJSONTrigger
-
Field Summary
Modifier and TypeFieldDescriptionprotected final List
<IBlockGenerator> protected final BlocklyEditorType
protected String
-
Constructor Summary
ConstructorDescriptionBlocklyToCode
(Workspace workspace, ModElement parent, BlocklyEditorType editorType, TemplateGenerator templateGenerator, IBlockGenerator... externalGenerators) -
Method Summary
Modifier and TypeMethodDescriptionfinal void
addCompileNote
(BlocklyCompileNote compileNote) final void
addDependency
(Dependency dependency) final BlocklyToCode
boolean
checkIfDepProviderInputsProvide
(Dependency dependency) final void
static String
directProcessOutputBlock
(BlocklyToCode master, Element element) Helper method to get the code of an output block and remove surrounding parentheses if possiblestatic String
directProcessStatementBlock
(BlocklyToCode master, Element element) final List
<BlocklyCompileNote> final List
<Dependency> final String
getStatementInputsMatching
(Predicate<StatementInput> predicate) final TemplateGenerator
This method returns collection of machine names of all blocks that are present in the provided Blockly arrangementfinal Workspace
final void
final void
processBlockProcedure
(List<Element> blocks) final void
processOutputBlock
(Element condition) final void
processOutputBlockToInt
(Element element) Helper method to process an output block and cast to int when neededfinal void
Helper method to process an output block and remove surrounding parentheses if possiblefinal void
processOutputBlockWithoutParentheses
(Element element, String blacklist) Helper method to process an output block and remove surrounding parentheses if possiblefinal void
pushDepProviderInputStack
(DependencyProviderInput statementInput) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.mcreator.generator.IGeneratorProvider
getGenerator, getGeneratorConfiguration, getGeneratorStats
Methods inherited from interface net.mcreator.workspace.IWorkspaceProvider
getFileManager, getFolderManager, getModElementManager, getWorkspaceFolder, getWorkspaceSettings
-
Field Details
-
blockGenerators
-
editorType
-
lastProceduralBlockType
-
-
Constructor Details
-
BlocklyToCode
public BlocklyToCode(Workspace workspace, ModElement parent, BlocklyEditorType editorType, @Nullable TemplateGenerator templateGenerator, IBlockGenerator... externalGenerators)
-
-
Method Details
-
getGeneratedCode
-
getCompileNotes
-
getParent
-
getEditorType
-
getDependencies
-
append
-
clearCodeGeneratorBuffer
public final void clearCodeGeneratorBuffer() -
addCompileNote
-
addDependency
-
getTemplateGenerator
-
getWorkspace
- Specified by:
getWorkspace
in interfaceIWorkspaceProvider
-
pushDepProviderInputStack
-
popDepProviderInputStack
public final void popDepProviderInputStack() -
checkIfDepProviderInputsProvide
-
getStatementInputsMatching
-
processBlockProcedure
- Throws:
TemplateGeneratorException
-
processOutputBlock
- Throws:
TemplateGeneratorException
-
directProcessOutputBlock
public static String directProcessOutputBlock(BlocklyToCode master, Element element) throws TemplateGeneratorException - Throws:
TemplateGeneratorException
-
directProcessStatementBlock
public static String directProcessStatementBlock(BlocklyToCode master, Element element) throws TemplateGeneratorException - Throws:
TemplateGeneratorException
-
processOutputBlockWithoutParentheses
public final void processOutputBlockWithoutParentheses(Element element) throws TemplateGeneratorException Helper method to process an output block and remove surrounding parentheses if possible- Parameters:
element
- The element to process- Throws:
TemplateGeneratorException
- If the template can't be generated
-
processOutputBlockWithoutParentheses
public final void processOutputBlockWithoutParentheses(Element element, String blacklist) throws TemplateGeneratorException Helper method to process an output block and remove surrounding parentheses if possible- Parameters:
element
- The element to processblacklist
- The characters that can't be contained at the top nesting level when optimizing the element- Throws:
TemplateGeneratorException
- If the template can't be generated
-
directProcessOutputBlockWithoutParentheses
public String directProcessOutputBlockWithoutParentheses(Element element) throws TemplateGeneratorException Helper method to get the code of an output block and remove surrounding parentheses if possible- Parameters:
element
- The element to process- Returns:
- The generated code of the element with parentheses optimization
- Throws:
TemplateGeneratorException
- If the template can't be generated
-
processOutputBlockToInt
Helper method to process an output block and cast to int when needed- Parameters:
element
- The element to process- Throws:
TemplateGeneratorException
- If the template can't be generated
-
getUsedBlocks
This method returns collection of machine names of all blocks that are present in the provided Blockly arrangement- Returns:
- Unmodifiable collection of machine names of all blocks that are present in the provided Blockly arrangement
-