Jump to content

Increase player speed


somarani

Recommended Posts

Replace

player.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.5d);

with

player.moveEntityWithHeading(player.moveStrafing, player.moveForward * timesFaster);

where "timesFaster" is how many times faster you want the player to be. For example, 1.5 for the player to be 50% faster, or 2 for the player to be 100% faster.

Link to comment
Share on other sites

@MikaXD - this method does work but the problem with it is that even after I take the armor off the player still walks at the faster speed, I'm not sure how to fix that.

 

@MrIbby - your method works pretty well, and the effect stops after you take the boots off, but the problem with it is that it affects jumping and makes it that you land very fast after jumping, is there a way to address that?

 

Thanks to both of you!

Link to comment
Share on other sites

For MikaXD's -

 

You could set the Player speed back to default using an event of some sort, when the Player removes the boots. It's simple and I haven't tried it myself so I couldn't tell you how efficient or nonefficient it might be.

 

For MrIbby's -

 

I could be wrong, but I think there's a jump...thing in attributes too, or maybe in the 'capabilities' constructor. As I said, I'm about 95% sure I'm wrong, but I suppose it can't hurt to look, you never know. Also it helps to open the packages up in Minecraft and look directly for the type of file you want. It's helped me out dozens of times.

 

http://www.dreamspand.com/

DreamSpand Gaming, a co-owned web site centered around Minecraft and its mods. We host servers and give out mods, plugins, schematics, saves, skins, and much more. Soon, we're going to have our server database synced to our site database. Then, a whole new plethora of possibilities will unveil themselves to us, at which time we will greet them with dedication and excitement.

 

We're very user-friendly and we love to help - no one will treat you badly. :)

Link to comment
Share on other sites

@Alpha wolf, What you're saying makes sense but the problem is I dont know where I should reset the speed, does anyone know what method I can put it in?

You could use player.capabilities.setPlayerWalkSpeed(1), which sets it back to its original speed. :) It's simple, but should, should work.

http://www.dreamspand.com/

DreamSpand Gaming, a co-owned web site centered around Minecraft and its mods. We host servers and give out mods, plugins, schematics, saves, skins, and much more. Soon, we're going to have our server database synced to our site database. Then, a whole new plethora of possibilities will unveil themselves to us, at which time we will greet them with dedication and excitement.

 

We're very user-friendly and we love to help - no one will treat you badly. :)

Link to comment
Share on other sites

I know, but WHERE do I put that is the question. I currently have things in the onArmorTickUpdate, but when the armor is off that method doesn't get called anymore and it never gets set back. I need a method that runs everytime armor is taken of, does anyone know of a method like that?

Link to comment
Share on other sites

Thanks to all your help I was able to get everything working fine, with the speed going back to normal after armor is off. However, when I ran the mod on a server, It kicked me out immediately after putting on the armor, here is the log

 

[23:05:30] [server thread/WARN]: Failed to handle packet for /127.0.0.1:55671
net.minecraft.util.ReportedException: Ticking player
at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:417) ~[EntityPlayerMP.class:?]
at net.minecraft.network.NetHandlerPlayServer.processPlayer(NetHandlerPlayServer.java:334) ~[NetHandlerPlayServer.class:?]
at net.minecraft.network.play.client.C03PacketPlayer.processPacket(C03PacketPlayer.java:37) ~[C03PacketPlayer.class:?]
at net.minecraft.network.play.client.C03PacketPlayer$C06PacketPlayerPosLook.processPacket(C03PacketPlayer.java:218) ~[C03PacketPlayer$C06PacketPlayerPosLook.class:?]
at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:242) ~[NetworkManager.class:?]
at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:190) [NetworkSystem.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:763) [MinecraftServer.class:?]
at net.minecraft.server.dedicated.DedicatedServer.updateTimeLightAndEntities(DedicatedServer.java:341) [DedicatedServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:651) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:530) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:788) [MinecraftServer$2.class:?]
Caused by: java.lang.NoSuchMethodError: net.minecraft.entity.player.PlayerCapabilities.setPlayerWalkSpeed(F)V
at somarani.soulcraft.armor.ArmorSetSoul2.onArmorTick(ArmorSetSoul2.java:111) ~[ArmorSetSoul2.class:?]
at net.minecraft.entity.player.InventoryPlayer.decrementAnimations(InventoryPlayer.java:365) ~[inventoryPlayer.class:?]
at net.minecraft.entity.player.EntityPlayer.onLivingUpdate(EntityPlayer.java:643) ~[EntityPlayer.class:?]
at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1856) ~[EntityLivingBase.class:?]
at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:360) ~[EntityPlayer.class:?]
at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:363) ~[EntityPlayerMP.class:?]
... 10 more

Link to comment
Share on other sites

By SERVER side, you mean when !world.isRemote and not @SideOnly(Side.SERVER), right? The first would be the correct syntax.

 

If that's not your problem, then is it possible the server is running an older version of Forge than your mod requires? What I mean is, perhaps the setWalkingSpeed method is still obfuscated on the server's version. Just a thought.

 

An alternate solution, one that I use, is to apply a speed modifier based on SharedMonsterAttributes. You can do this either as a value you add directly to your armor in getItemAttributeModifiers, which would be applied even while holding the armor in hand, not just when worn, or by applying (and removing) the same attribute modifier via your tick handler to get the 'only when equipped' effect.

Link to comment
Share on other sites

Both world.isRemote and SIDE yield the same results. When its client side only, the custom effects aren't implemented, when its server side, I get kicked out as soon as armor is on.

 

Here is the code If its of any help

 

 
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack)
    {
	      
    	        float bootsOn = 0;
		float legsOn = 0;
		float chestOn = 0;
		float helmOn = 0;

		if(player.getCurrentArmor(0) != null ){

			ItemStack boots = player.getCurrentArmor(0);
			if(boots.getItem() == SoulCraft.soulBoots2)  bootsOn = 0.1f;


                         }

		player.stepHeight = 1;

		if(player.getCurrentArmor(1) != null ){ 

			ItemStack legs = player.getCurrentArmor(1);
			if(legs.getItem() == SoulCraft.soulLeggings2) legsOn = 0.05f;

		}

		if(player.getCurrentArmor(2) != null ){

			ItemStack chest = player.getCurrentArmor(2);
			if(chest.getItem() == SoulCraft.soulChest2) chestOn = 0.05f;

		}

		if(player.getCurrentArmor(3) != null ){

			ItemStack helm = player.getCurrentArmor(3);
			if(helm.getItem() == SoulCraft.soulHelmet2) helmOn = 0.05f;

		}


		if (player.isSprinting()) player.capabilities.setPlayerWalkSpeed(0.1f + bootsOn + legsOn + chestOn + helmOn);

		else player.capabilities.setPlayerWalkSpeed(0.1f);


    }

 

 

 

Link to comment
Share on other sites

Does anyone know of a way I can fix this, or another approach that wont give me troubles? Thanks

I mentioned earlier about SharedMonsterAttributes and AttributeModifiers, try using those instead of setPlayerWalkSpeed. Take a look at the sprinting mechanic as an example (specifically, see EntityLivingBase#setSprinting method and the related fields).

Link to comment
Share on other sites

FOV is affected (slightly) by the player's current speed - if your screen was going crazy, then perhaps consider toning down your speed boost? I haven't looked at the setPlayerWalkingSpeed method, so I'm not sure how much that affects the player speed relative to something like sprinting, but in my own mod, I've created various items that in combination can will boost the player's speed by about as much as though they were sprinting x 3 or 4, and the player can sprint on top of that, which brings the player up to a pretty ridiculous speed yet without any extremely jarring zoom effect. If you go much faster than that, new chunks will have a very difficult time loading quickly enough and you will probably encounter other errors.

Link to comment
Share on other sites

Sure. You can view my entire source on Github (sorry, it's the 1.6.4 version of my mod on there still!), and here is a relevant snippet from the 1.7.x version (which is pretty much unchanged from 1.6):

 

 

/** Movement bonus for wearing Pegasus Boots */
private static final UUID pegasusBootsMoveBonusUUID = UUID.fromString("36A0FC05-50EB-460B-8961-615633A6D813");

private static final AttributeModifier pegasusBootsMoveBonus = (new AttributeModifier(pegasusBootsMoveBonusUUID, "Pegasus Boots Speed Bonus", 0.3D, 2)).setSaved(false);

// whenever the player changes footwear, a method is called with this code:
IAttributeInstance movement = player.getEntityAttribute(SharedMonsterAttributes.movementSpeed);

if (movement.getModifier(pegasusBootsMoveBonusUUID) != null) {
movement.removeModifier(pegasusBootsMoveBonus);
}
// remove other possible modifiers

ItemStack boots = player.getCurrentArmor(0);
if (stack != null) {
if (stack.getItem() == ZSSItems.bootsPegasus) {
movement.applyModifier(pegasusBootsMoveBonus);
}
// other boots 
}

 

 

That's pretty much all you need. I use the exact same modifier value of 0.3D and operator '2' (which adds 30% of the current speed value, see the wiki) for almost all of my speed enhancing items and effects; using multiple of these at the same time, sprinting or running, has not yet caused any problems for me.

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Slot BANK BCA adalah pilihan tergacor untuk memulai bermain slot judi Online dimuka bumi saat ini. Jika anda mempunyai BANK BCA, Anda berkesempatan mendapatkan Akun Pro atau ID pro untuk bermain slot. Tunggu apa lagi? Segera daftarkan diri anda sekarang dan dapatkan kemewahan menang maxwin di Museumbola.
    • SLOT SCATTER HITAM : SLOT MAHJONG SCATTER HITAM - MAHJONG WAYS SCATTER HITAM - SLOT PRAGMATIC SCATTER HITAM KLIK DISINI DAFTAR DISINI SLOT VVIP << KLIK DISINI DAFTAR DISINI SLOT VVIP << KLIK DISINI DAFTAR DISINI SLOT VVIP << KLIK DISINI DAFTAR DISINI SLOT VVIP << SITUS SLOT GACOR 88 MAXWIN X500 HARI INI TERBAIK DAN TERPERCAYA GAMPANG MENANG Dunia Game gacor terus bertambah besar seiring berjalannya waktu, dan sudah tentu dunia itu terus berkembang serta merta bersamaan dengan berkembangnya SLOT GACOR sebagai website number #1 yang pernah ada dan tidak pernah mengecewakan sekalipun. Dengan banyaknya member yang sudah mempercayakan untuk terus menghasilkan uang bersama dengan SLOT GACOR pastinya mereka sudah percaya untuk bermain Game online bersama dengan kami dengan banyaknya testimoni yang sudah membuktikan betapa seringnya member mendapatkan jackpot besar yang bisa mencapai ratusan juta rupiah. Best online Game website that give you more money everyday, itu lah slogan yang tepat untuk bermain bersama SLOT GACOR yang sudah pasti menang setiap harinya dan bisa menjadikan bandar ini sebagai patokan untuk mendapatkan penghasilan tambahan yang efisien dan juga sesuatu hal yang fix setiap hari nya. Kami juga mendapatkan julukan sebagai Number #1 website bocor yang berarti terus memberikan member uang asli dan jackpot setiap hari nya, tidak lupa bocor itu juga bisa diartikan dalam bentuk berbagi promosi untuk para official member yang terus setia bermain bersama dengan kami. Berbagai provider Game terus bertambah banyak setiap harinya dan terus melakukan support untuk membuat para official member terus bisa menang dan terus maxwin dalam bentuk apapun maka itu langsung untuk feel free to try yourself, play with SLOT GACOR now or never !
    • SLOT 1000 : SLOT1000 DEPOSIT 1000 VIA DANA - SLOT 1000 VIA QRIS - SLOT DEPOSIT QRIS 1000 - SLOT DEPO 1K - SLOT 1000 BET KECIL KLIK DISINI DAFTAR DISINI SLOT VVIP << KLIK DISINI DAFTAR DISINI SLOT VVIP << KLIK DISINI DAFTAR DISINI SLOT VVIP << KLIK DISINI DAFTAR DISINI SLOT VVIP << SITUS SLOT GACOR 88 MAXWIN X500 HARI INI TERBAIK DAN TERPERCAYA GAMPANG MENANG Dunia Game gacor terus bertambah besar seiring berjalannya waktu, dan sudah tentu dunia itu terus berkembang serta merta bersamaan dengan berkembangnya SLOT GACOR sebagai website number #1 yang pernah ada dan tidak pernah mengecewakan sekalipun. Dengan banyaknya member yang sudah mempercayakan untuk terus menghasilkan uang bersama dengan SLOT GACOR pastinya mereka sudah percaya untuk bermain Game online bersama dengan kami dengan banyaknya testimoni yang sudah membuktikan betapa seringnya member mendapatkan jackpot besar yang bisa mencapai ratusan juta rupiah. Best online Game website that give you more money everyday, itu lah slogan yang tepat untuk bermain bersama SLOT GACOR yang sudah pasti menang setiap harinya dan bisa menjadikan bandar ini sebagai patokan untuk mendapatkan penghasilan tambahan yang efisien dan juga sesuatu hal yang fix setiap hari nya. Kami juga mendapatkan julukan sebagai Number #1 website bocor yang berarti terus memberikan member uang asli dan jackpot setiap hari nya, tidak lupa bocor itu juga bisa diartikan dalam bentuk berbagi promosi untuk para official member yang terus setia bermain bersama dengan kami. Berbagai provider Game terus bertambah banyak setiap harinya dan terus melakukan support untuk membuat para official member terus bisa menang dan terus maxwin dalam bentuk apapun maka itu langsung untuk feel free to try yourself, play with SLOT GACOR now or never !
    • SLOT DEMO PRINCESS 1000 : DEMO SLOT STARLIGHT PRINCESS x 1000 RUPIAH GRATIS TANPA DEPOSIT KLIK DISINI DAFTAR DISINI SLOT VVIP << KLIK DISINI DAFTAR DISINI SLOT VVIP << KLIK DISINI DAFTAR DISINI SLOT VVIP << KLIK DISINI DAFTAR DISINI SLOT VVIP << SITUS SLOT GACOR 88 MAXWIN X500 HARI INI TERBAIK DAN TERPERCAYA GAMPANG MENANG Dunia Game gacor terus bertambah besar seiring berjalannya waktu, dan sudah tentu dunia itu terus berkembang serta merta bersamaan dengan berkembangnya SLOT GACOR sebagai website number #1 yang pernah ada dan tidak pernah mengecewakan sekalipun. Dengan banyaknya member yang sudah mempercayakan untuk terus menghasilkan uang bersama dengan SLOT GACOR pastinya mereka sudah percaya untuk bermain Game online bersama dengan kami dengan banyaknya testimoni yang sudah membuktikan betapa seringnya member mendapatkan jackpot besar yang bisa mencapai ratusan juta rupiah. Best online Game website that give you more money everyday, itu lah slogan yang tepat untuk bermain bersama SLOT GACOR yang sudah pasti menang setiap harinya dan bisa menjadikan bandar ini sebagai patokan untuk mendapatkan penghasilan tambahan yang efisien dan juga sesuatu hal yang fix setiap hari nya. Kami juga mendapatkan julukan sebagai Number #1 website bocor yang berarti terus memberikan member uang asli dan jackpot setiap hari nya, tidak lupa bocor itu juga bisa diartikan dalam bentuk berbagi promosi untuk para official member yang terus setia bermain bersama dengan kami. Berbagai provider Game terus bertambah banyak setiap harinya dan terus melakukan support untuk membuat para official member terus bisa menang dan terus maxwin dalam bentuk apapun maka itu langsung untuk feel free to try yourself, play with SLOT GACOR now or never !
    • FREEBET SLOT : SLOT FREEBET TANPA DEPOSIT FREECHIP 20K 30K 50K TO KECIL RENDAH x2 x3 x4 x5 - SLOT GRATIS TANPA DEPOSIT KLIK DISINI DAFTAR DISINI SLOT VVIP << KLIK DISINI DAFTAR DISINI SLOT VVIP << KLIK DISINI DAFTAR DISINI SLOT VVIP << KLIK DISINI DAFTAR DISINI SLOT VVIP << SITUS SLOT GACOR 88 MAXWIN X500 HARI INI TERBAIK DAN TERPERCAYA GAMPANG MENANG Dunia Game gacor terus bertambah besar seiring berjalannya waktu, dan sudah tentu dunia itu terus berkembang serta merta bersamaan dengan berkembangnya SLOT GACOR sebagai website number #1 yang pernah ada dan tidak pernah mengecewakan sekalipun. Dengan banyaknya member yang sudah mempercayakan untuk terus menghasilkan uang bersama dengan SLOT GACOR pastinya mereka sudah percaya untuk bermain Game online bersama dengan kami dengan banyaknya testimoni yang sudah membuktikan betapa seringnya member mendapatkan jackpot besar yang bisa mencapai ratusan juta rupiah. Best online Game website that give you more money everyday, itu lah slogan yang tepat untuk bermain bersama SLOT GACOR yang sudah pasti menang setiap harinya dan bisa menjadikan bandar ini sebagai patokan untuk mendapatkan penghasilan tambahan yang efisien dan juga sesuatu hal yang fix setiap hari nya. Kami juga mendapatkan julukan sebagai Number #1 website bocor yang berarti terus memberikan member uang asli dan jackpot setiap hari nya, tidak lupa bocor itu juga bisa diartikan dalam bentuk berbagi promosi untuk para official member yang terus setia bermain bersama dengan kami. Berbagai provider Game terus bertambah banyak setiap harinya dan terus melakukan support untuk membuat para official member terus bisa menang dan terus maxwin dalam bentuk apapun maka itu langsung untuk feel free to try yourself, play with SLOT GACOR now or never !
  • Topics

×
×
  • Create New...

Important Information

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