Jump to content

[1.20.4] extend the reach of a melee weapon i need this value i dont know how its called


Recommended Posts

this little sword like bar i dont know how is called  i need to get the value of how much full it is 

swordbar.png



i made some code to increase the horizontal range of mi melee weapons so you don't have to precisely left click on the mob but just close enough to damage it increasing the hitbox of mobs when i attack like 1.5 grow 
but it has a trouble

mi code works regardless of the sword state so you can smacks as fast as your finger allows kinda old minecrafts style i dont want that

i want it to work in synchrony whit the sword behave-our

in this video i need like 3  hits to kill a zombie whit the vanilla iron sword 
mi steel sword does the same damage than iron but if i fast click i can damage the zombie like 8 times in the same amount of time the sword only swing like two times 

to fix this i want to check the state of that sword-like bar way may code only hits if the bar its over 50% or something 

 

 

// ########## ########## ########## ##########
@Override
public boolean onEntitySwing(ItemStack stack, LivingEntity le) {
//System.out.println("onEntitySwing");

    if( swordlikebar > 50% ) {

        searchAndDamageSurroundingEntities();

    }

return false;

}

 

Link to comment
Share on other sites

yaa that was 

	// ########## ########## ########## ##########
@Override
public boolean onEntitySwing(ItemStack stack, LivingEntity le) {
//System.out.println("onEntitySwing");

if (le != null && le.isAlive()) {

Level warudo = le.level();
ItemStack main = le.getMainHandItem();
ItemStack off = le.getOffhandItem();
float swordlikebar = 0.0F;

if( warudo.isClientSide() || !can_do_it(stack)){
// return false;
}

String world = (warudo.isClientSide())? "Mundo Local" : "Mundo Remoto";

if(le instanceof Player){
Player pe = (Player)le;

swordlikebar = pe.getAttackStrengthScale(0.0F);
System.out.println(world + " swordlikebar " + swordlikebar);
}
	

	Mundo  Local swordlikebar 0.0
Mundo Remoto swordlikebar 0.31999996
Mundo  Local swordlikebar 0.0
Mundo Remoto swordlikebar 0.31999996
Mundo  Local swordlikebar 0.0
Mundo Remoto swordlikebar 0.31999996
Mundo  Local swordlikebar 0.0
Mundo Remoto swordlikebar 0.71999997
Mundo  Local swordlikebar 0.0
Mundo Remoto swordlikebar 0.39999998
Mundo  Local swordlikebar 0.0
Mundo Remoto swordlikebar 0.39999998
Mundo  Local swordlikebar 0.0
Mundo Remoto swordlikebar 0.6399999
Mundo  Local swordlikebar 0.0
Mundo Remoto swordlikebar 0.71999997
Mundo  Local swordlikebar 0.0
Mundo Remoto swordlikebar 1.0
	



dont works client side but  i dont need that here 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.