onBlockDestroy Method Trouble

Started by RaeaTheDev on

Topic category: Help with modding (Java Edition)

Last seen on 16:59, 19. Jun 2020
Joined Feb 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
onBlockDestroy Method Trouble

Hello, I'm new to MCreator and Minecraft modding. I'm trying to create a mod where the tools cost power. I'm having issues with adding the onBlockDestroyed method to the pickaxe item I made. I've tried looking around but it doesn't seem like it's been covered a lot.

Could anyone try and help me resolve this issue? I feel like there's something simple I'm just not getting yet.

Console:

Executing gradle task: runClient
Build info: MCreator 2020.1.05419, 1.14.4, 64-bit, 8117 MB, Windows 10, JVM 1.8.0_232, JAVA_HOME: C:\Program Files\Pylo\MCreator\jdk
> Configure project :
New Dep: net.minecraftforge:forge:1.14.4-28.1.117_mapped_snapshot_20190719-1.14.3
> Task :compileJava FAILED
C:\Users\Seremedy\Desktop\Game Dev\Minecraft Mods\Mana_Forge\src\main\java\net\mcreator\mana_forge\MCreatorMagitechPick.java:22: error: cannot find symbol
import net.minecraft.entity.EntityLivingBase;
                           ^
  symbol:   class EntityLivingBase
  location: package net.minecraft.entity
C:\Users\Seremedy\Desktop\Game Dev\Minecraft Mods\Mana_Forge\src\main\java\net\mcreator\mana_forge\MCreatorMagitechPick.java:79: error: cannot find symbol
   public boolean onBlockDestroyed(ItemStack stack, World world, Block block, BlockPos pos, EntityLivingBase player) 
                                                    ^
  symbol:   class World
  location: class MCreatorMagitechPick
C:\Users\Seremedy\Desktop\Game Dev\Minecraft Mods\Mana_Forge\src\main\java\net\mcreator\mana_forge\MCreatorMagitechPick.java:79: error: cannot find symbol
   public boolean onBlockDestroyed(ItemStack stack, World world, Block block, BlockPos pos, EntityLivingBase player) 
                                                                 ^
  symbol:   class Block
  location: class MCreatorMagitechPick
C:\Users\Seremedy\Desktop\Game Dev\Minecraft Mods\Mana_Forge\src\main\java\net\mcreator\mana_forge\MCreatorMagitechPick.java:79: error: cannot find symbol
   public boolean onBlockDestroyed(ItemStack stack, World world, Block block, BlockPos pos, EntityLivingBase player) 
                                                                                            ^
  symbol:   class EntityLivingBase
  location: class MCreatorMagitechPick
4 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.9/userguide/command_line_interface.html#sec:c…
BUILD FAILED in 1s
1 actionable task: 1 executed
BUILD FAILED
Task completed in 4061 milliseconds

Last seen on 03:03, 6. Feb 2024
Joined Apr 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You mean power as Durability…
Sat, 02/29/2020 - 02:07

You mean power as Durability or like RF energy?
if something like RF than you will need 2 same tools [1. With 0 stats and 2. with your desired stats]
and some sort of charging bench

In that charge bench you will be checking for item 
if varian 1 than remove it from slot and place there variant 2
than add 1 to NBT Tag "power" for this item "Power will be your durability in this case" "Additionally you can add upgrades that will be adding more values to your tool if you want to spend more time on it"
Next WhenBlockDestroyedWithTool trigger make procedure:
Set NBT Tag "power" to [[Get NBT Tag value "power"] - [1]]
Note: Bind this also to WhenEntityHitByThisTool triger
 

Last on ItemInInventoryTick trigger make procedure that:
If [Get NBT Tag Value "power" <= [0]] do
   Remove item from entity main hand
   Add item "Variant 1 of a tool" to entities inventory
end

 

IMPORTANT NOTE !!!!!!!!!!!!!!!!1111!!!11!!!
Set both tools to have 0 Durability otherwise they will be breaking
Also remember to use tags for itemstacks