Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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;

}

 

7 hours ago, perromercenary00 said:

i need to get the value of how much full it is 

I think the method is 'Player.getAttackStrengthScale();'

  • Author

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 

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.