Can't make ores shown Procedure

Started by WizaRed on

Topic category: Help with modding (Java Edition)

Last seen on 15:54, 17. Nov 2023
Joined Oct 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Can't make ores shown Procedure

Hi! I used ChatGPT to make a code for my item, but errors appeared. Please find the problem

 

Chat GPT code

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class ProcedureYourProcedureName extends YourModNameModElements.ModElement {
    public ProcedureYourProcedureName(YourModNameModElements instance) {
        super(instance, 123); // Replace 123 with your procedure ID
    }

    public static void executeProcedure(java.util.HashMap<String, Object> dependencies) {
        if (dependencies.get("entity") == null) {
            System.err.println("Failed to load dependency entity for procedure YourProcedureName!");
            return;
        }

        EntityPlayer entity = (EntityPlayer) dependencies.get("entity");
        World world = entity.world;
        ItemStack itemstack = entity.getHeldItemMainhand();

        if (itemstack.getItem() == YourModNameModItems.YourItemName) {
            // Replace YourModNameModItems.YourItemName with the real item
            BlockPos pos = entity.getPosition();
            int radius = 16; // Radius in which the ores will glow (replace with the desired value)

            for (int x = pos.getX() - radius; x <= pos.getX() + radius; x++) {
                for (int y = pos.getY() - radius; y <= pos.getY() + radius; y++) {
                    for (int z = pos.getZ() - radius; z <= pos.getZ() + radius; z++) {
                        if (world.getBlockState(new BlockPos(x, y, z)).getBlock() instanceof BlockOre) {
                            world.setLightFor(EnumSkyBlock.BLOCK, new BlockPos(x, y, z), 15);
                        }
                    }
                }
            }
        }
    }
}

 

Errors 

Executing Gradle task: runClient 
Build info: MCreator 2023.1.10610, forge-1.19.2, 64-bit, 15741 MB, Windows 11, JVM 17.0.5, JAVA_HOME: C:\Program Files\Pylo\MCreator\jdk, started on: 2023-10-06-05:02:19 
  
> Configure project : 
The code of this workspace uses official obfuscation mappings provided by Mojang. These mappings fall under their associated license you should be fully aware of. 
(c) 2020 Microsoft Corporation. These mappings are provided "as-is" and you bear the risk of using them. You may copy and use the mappings for development purposes, 
but you may not redistribute the mappings complete and unmodified. Microsoft makes no warranties, express or implied, with respect to the mappings provided here. 
Use and modification of this document or the source code (in any form) of Minecraft: Java Edition is governed by the Minecraft End User License Agreement available 
at https://account.mojang.com/documents/minecraft_eula. 
  
> Task :compileJava FAILED 
C:\MCreatorWorkspaces\thaumcraftmalum\src\main\java\net\mcreator\thaumcraftmalum\procedures\PickaxeOfTheCoreScriptProcedure.java:22: error: ')' expected 
        if (itemstack.getItem() == thaumcraftmalum:pickaxe_of_the_core) { 
                                                  ^ 
C:\MCreatorWorkspaces\thaumcraftmalum\src\main\java\net\mcreator\thaumcraftmalum\procedures\PickaxeOfTheCoreScriptProcedure.java:22: error: not a statement 
        if (itemstack.getItem() == thaumcraftmalum:pickaxe_of_the_core) { 
                                                   ^ 
C:\MCreatorWorkspaces\thaumcraftmalum\src\main\java\net\mcreator\thaumcraftmalum\procedures\PickaxeOfTheCoreScriptProcedure.java:22: error: ';' expected 
        if (itemstack.getItem() == thaumcraftmalum:pickaxe_of_the_core) { 
                                                                      ^ 
3 errors 
FAILURE: Build failed with an exception. 
* What went wrong: 
Execution failed for task ':compileJava'. 
> Compilation failed; see the compiler error output for details. 
* Try: 
> Run with --stacktrace option to get the stack trace. 
> Run with --info or --debug option to get more log output. 
> Run with --scan to get full insights. 
* Get more help at https://help.gradle.org 
BUILD FAILED in 1s 
1 actionable task: 1 executed 
  
BUILD FAILED 
Task completed in 3 seconds