Jump to content

Recommended Posts

Posted

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

Posted

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

Posted

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.

Kain

Posted

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);

		}
	}
}
}

 

Posted

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.

Posted

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

Posted

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.

Posted

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]

Posted

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

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • There is an issue with Create - maybe a conflict with randompatches
    • Honestly, the forums are a back burner thing. Not many people use it. Best option is discord. I know that I haven't looked at the forums for more then admin tasks in quite a while. You're also best off not following tutorials which give you code. Knowing programming and reading the MC/Forge code yourself would be the best way to go.
    • on my last computer, i had a similar problem with forge/ neoforge mods but instead them launcher screen was black
    • I am trying to make a mod, all it is, a config folder that tells another mod to not require a dependency, pretty simple right.. well, I dont want whoever downloads my mod to have to download 4 other mods and then decide if they want 2 more that they kinda really need.. i want to make my mod basically implement all of these mods, i really dont care how it does it, ive tried putting them in every file location you can think of, ive downloaded intellij, mcreator, and tried vmware but thats eh (had it from school). I downloaded them in hopes theyd create the correct file i needed but honestly im only more lost now. I have gotten my config file to work, if i put all these mods into my own mods folder and the config file into the config and it works (unvbelievably) but i want to share this to everyone else, lets just say this mod will legitimately get 7M downloads.  I tried putting them in a run folder then having it create all the contents in that for a game (mods,config..etc) then i drop the mods in and all the sudden i cant even open the game, like it literally works with my own world i play on, but i cant get it to work on any coding platform, they all have like built in java versions you cant switch, its a nightmare. I am on 1.20.1 I need Java 17 (i dont think the specific versions of 17 matter) I have even tried recreating the mods i want to implement and deleting import things like net.adamsandler.themodsname and replacing it with what mine is. that only creates other problems, where im at right now is i got the thing to start opening then it crashes, closest ive gotten it, then it just says this  exception in thread "main" cpw.mods.niofs.union.unionfilesystem$uncheckedioexception: java.util.zip.zipexception: zip end header not found caused by: java.util.zip.zipexception: zip end header not found basically saying theres something wrong with my java.exe file, so i tried downloading so many different versions of java and putting them all in so many different spots, nothing, someone online says its just a mod that isnt built right so i put the mod into an editor and bunch of errors came up, id post it but i deleted it on accident, i just need help integrating mods
    • Vanilla 1.16.5 Crash Report [#L2KYKaK] - mclo.gs  
  • Topics

×
×
  • Create New...

Important Information

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