Jump to content

Changing Swing Speed


GravityWolf

Recommended Posts

This is my third time doing this, and I hope I get a response this time xD

 

So, basically, I want it so I could change the swing speed, like if you were using a Haste potion effect. (I don't want to do that though, it doesn't give me enough speed options that way) I tried looking in the Potions class, and I found

 

    public static final Potion digSpeed = (new Potion(3, false, 14270531)).setPotionName("potion.digSpeed").setIconIndex(2, 0).setEffectiveness(1.5D);

 

There was nothing else in the code about it, so I took it that 142703531 had something to do with it. If you know anything about it, or have any ideas on it, it would be great if you could let me know! Thanks!

 

~GravityWolf

Link to comment
Share on other sites

Hope this doesn't count as spam, but I think I made some progress:

 

I found this:

 

if (this.isPotionActive(Potion.digSpeed))
        {
            f *= 1.0F + (float)(this.getActivePotionEffect(Potion.digSpeed).getAmplifier() + 1) * 0.2F;
        }

 

and this:

 

private int getArmSwingAnimationEnd()
    {
        return this.isPotionActive(Potion.digSpeed) ? 6 - (1 + this.getActivePotionEffect(Potion.digSpeed).getAmplifier()) * 1 : (this.isPotionActive(Potion.digSlowdown) ? 6 + (1 + this.getActivePotionEffect(Potion.digSlowdown).getAmplifier()) * 2 : 6);
    }

 

I think these are important, the second one probably more so. They seem to require potion effects, and like I said in the OP, I don't really want to use potion effects. If you have any ideas, let me know! Thanks!

 

~GravityWolf

Link to comment
Share on other sites

Are you trying to increase speed for swinging a sword or breaking a block?

if its a block you wanna do this

 

 

	@ForgeSubscribe
// haste
public void onUpdate(PlayerEvent.BreakSpeed event) {
	EntityPlayer e = null;

	if (event.entityLiving instanceof EntityPlayer) {
		e = (EntityPlayer) event.entityLiving;
		if (e == null)
			return;

		final int vigor = EnchantmentHelper.getEnchantmentLevel(effectId, e.getHeldItem());

		if (vigor > 0) {
			event.newSpeed += (2.0F * vigor);

		}
	}
}
}

 

Link to comment
Share on other sites

Why not look into the Haste effect?

 

 

I think you'd be better off making a pseudo potion item instead of using the vanilla potion class.

 

I would do that, but it swings too fast too quickly. What I mean is Haste 1 gives you increased swing speed, but Haste 2 gives you almost double speed of Haste 1.

 

Are you trying to increase speed for swinging a sword or breaking a block?

if its a block you wanna do this

 

 

	@ForgeSubscribe
// haste
public void onUpdate(PlayerEvent.BreakSpeed event) {
	EntityPlayer e = null;

	if (event.entityLiving instanceof EntityPlayer) {
		e = (EntityPlayer) event.entityLiving;
		if (e == null)
			return;

		final int vigor = EnchantmentHelper.getEnchantmentLevel(effectId, e.getHeldItem());

		if (vigor > 0) {
			event.newSpeed += (2.0F * vigor);

		}
	}
}
}

 

 

I'm looking for sword swing speed.

Link to comment
Share on other sites

I'm not sure how to add this, however Dinnerbone has stated that the attribute system will encompass swing speed (as well as bow draw time), so if I were you I might just flesh out the other areas of my mod and hope that the attributes for that come in 1.7 :D

Link to comment
Share on other sites

I'm not sure how to add this, however Dinnerbone has stated that the attribute system will encompass swing speed (as well as bow draw time), so if I were you I might just flesh out the other areas of my mod and hope that the attributes for that come in 1.7 :D

 

I will use that when that comes out, but for now I think I can utilize the haste effect code.

Link to comment
Share on other sites

Yeah potion effects still seem to be obfuscated (the critical functions for many are things like 'func_902349' and such)

I'd just use a vanilla one with whatever power level you need for now, no real reason why not... also, maybe you could try to find a way to make the sword buff you with like 10 ticks of haste whenever you click with it, that way when they stop clicking the effect would just go away before they could see it

Creator of Metroid Cubed! Power Suits, Beams, Hypermode and more!

width=174 height=100http://i.imgur.com/ghgWmA3.jpg[/img]

Link to comment
Share on other sites

Got it to work using this:

 

public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) {

	if(entity instanceof EntityPlayer) {

		EntityPlayer player = (EntityPlayer) entity;
            ItemStack equipped = player.getCurrentEquippedItem();
            
            if(equipped == stack) {
            	
            	if(player.isSwingInProgress) {
            	
            	if(swingSpeed == 0) {
            		
            	} else if (swingSpeed == 1) {
            		
                	player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 1, 0));
            		
            	} else if (swingSpeed == 2) {
            		
                	player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 1, 1));
            		
            	} else if (swingSpeed == 3) {
            		
            		player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 1, 2));
            		
            	} else if (swingSpeed == -1) {
            		
                	player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 1, 0));
            		
            	} else if (swingSpeed == -2) {
            		
                	player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 1, 1));
            		
            	} else if (swingSpeed == -3) {
            		
                	player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 1, 2));
                	
            	} else if (swingSpeed == -4) {
            		
            		player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 1, 3));
            		
            	}
            	
            	}
            }

	}

}

 

SwingSpeed is my own custom variable, just btw

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • @bluedisgusted That actually fully fixed it, thank you so much
    • Hi, I would like to know how to create multiple hitboxes for the player like the ender dragon. I've searched everywhere but I haven't found anything.
    • FOLKWIN EXPERT RECOVERY is the crypto hero we all need in the ongoing battle against cryptocurrency theft. With the rise in popularity of digital assets like Bitcoin and Ethereum, crypto crime has also been on the rise as hackers look to steal funds stored in virtual wallets. Many a crypto investor has fallen victim to clever scams and hacking schemes that drain wallets of their precious coins. But fear not, for FOLKWIN EXPERT RECOVERY has arrived as a beacon of hope for those who have had their hard-earned crypto stolen. This service is like a superhero for tracking down lost or stolen cryptocurrency, utilizing their advanced forensic technology and expertise to follow the blockchain paper trail and identify where your funds have gone. Their team of ethical hackers act like detectives, piecing together crypto transactions and unmasking the thieves behind complex cybercrimes. No case is too difficult for FOLKWIN EXPERT RECOVERY; they have recovered millions in stolen crypto assets from around the globe. Their mission is to reunite victims with their lost funds and bring criminals who prey on cryptocurrency investors to justice. With their help, those who have been robbed of their digital fortunes now have a crypto guardian to call upon in their time of need. FOLKWIN EXPERT RECOVERY gives victims the hope that all is not lost forever when crypto theft occurs.For support, Contact details is: TELEGRAM: @FOLKWIN_EXPERT_RECOVERY, EMAIL: FOLKWINEXPERTRECOVERY at TECH-CENTER dot COM, WEBSITE: WWW.FOLKWINEXPERTRECOVERY.COM .  are the heroes we need in the ongoing battle to make cryptocurrency ownership safe and secure for all. Get FOLKWIN EXPERT RECOVERY on your side when you have issues like this by dialing: Do this and thank me later. God Blessings to all, I'm forever grateful oh God for the successful recovery. I recommend FOLKWIN EXPERT RECOVERY the best ever and i'm so happy i got all my lost money back. Best Regards. Pamela K Ingram.
    • Made it work. As a note, one of the times it didn't recognize the recipe cause the MOD_ID constant I was using somewhere was NOT referencing my MOD_ID but rather another static variable with the same name. Maybe OP is having a similar problem
    • What exactly is the issue?
  • Topics

×
×
  • Create New...

Important Information

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