Posted July 3, 201411 yr I'm trying to make boots which speed up the player when worn. I don't want it to be a potion effect (because speed potion changes FOV). I tried doing this: http://pastebin.com/FQXDdKxb but this makes my screen go crazy, it keeps zooming in and out. Does anyone know a better way of doing this?
July 3, 201411 yr player.capabilities.setPlayerWalkSpeed(2); But be careful, this will increase the speed very strong!
July 3, 201411 yr 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.
July 3, 201411 yr Author @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!
July 3, 201411 yr 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.
July 3, 201411 yr Author @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?
July 3, 201411 yr @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.
July 3, 201411 yr Author 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?
July 3, 201411 yr Author Do you mean a TickHandler class? I made one of those but for some reason I cant get it to work. Could you please explain more? Thank you
July 5, 201411 yr Author 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
July 5, 201411 yr Try making sure it id only called server or client side to figure out what the problem is.
July 5, 201411 yr Author Making it CLIENT only I get no errors, but it also doesn't speed me up at all. If I make it SERVER side it still kicks me out immediately with the same error.
July 5, 201411 yr 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. http://i.imgur.com/NdrFdld.png[/img]
July 5, 201411 yr Author 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); }
July 6, 201411 yr Author Does anyone know of a way I can fix this, or another approach that wont give me troubles? Thanks
July 6, 201411 yr 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). http://i.imgur.com/NdrFdld.png[/img]
July 6, 201411 yr Author I tried the sharedmonsterattributes, but the problem with that is when I change the speed that way, my screen goes crazy. It starts zooming in and out.
July 6, 201411 yr 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. http://i.imgur.com/NdrFdld.png[/img]
July 6, 201411 yr Author Do you mind showing me some of your code to speed up the player, I would really appreciate that!
July 6, 201411 yr 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. http://i.imgur.com/NdrFdld.png[/img]
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.