Dynamicly changing Pickaxe Efficiency (MineSpeed)

Started by Rotzmauz on

Topic category: Troubleshooting, bugs, and solutions

Last seen on 18:27, 25. Jun 2024
Joined Mar 2022

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Dynamicly changing Pickaxe Efficiency (MineSpeed)
Thu, 05/30/2024 - 11:19 (edited)

I wanted to change the Efficiency of a tool dynamicly and mcreator doesent give you the option to do that yet(would be cool) so i made a little workaround.

Overriding the getDestroySpeed methode in the Itemclass of my in that case pickaxe:

public float MiningSpeed = 1f;

public float getDestroySpeed(ItemStack itemstack, BlockState state){
	Player player = Minecraft.getInstance().player;
	if(player != null){
	return MiningSpeed;
	return super.getDestroySpeed(itemstack, state);

public void setMiningSpeed(float miningspeed){
	MiningSpeed = miningspeed;

and then calling the setMiningSpeed methode from a procedure with the codesnipped:

Player player = (player) entity;

float miningspeed = (float)DoubleArgumentType.getDouble(arguments, "MiningSpeed") //put whatever you want here in my case its from a command with number parameter "MiningSpeed" for now. can be everykind of variable or number whatever.

YourItemNameItem yourItemNameItem = (YourItemNameItem) player.getMainHandItem().getItem();


this seems to work fine. Im new to coding stuff so its probably a bit scuffed. if you have improvements please say so.

also im gonna try to do something similar so i can change the MiningLevel dynamically aswell.

edit: could i also just override the get tier methode?

Edited by Rotzmauz on Thu, 05/30/2024 - 11:19