I am having a bit of trouble with a World War 2 mod I am making. I want to make it as realistic as possible, with every warship, tank, and plane that fought, even nation selection and npcs, it's not just going to be another flans mod. In any case, I have been trying to make it so that if you sneak with a gun, instead you crouch. I will also be adding lying down, but first I must get crouch done. So far, I have been doing pretty good on the crouching, I have already made it so that your viewpoint is lower, and the player is posed differently when crouched. But the problem is, I can't quite get the size of the player to change, so that you can fit under a bit smaller blocks. Even stranger, it appears to work when I set it to a bigger size of the player, but not a smaller. I have been changing the size by manipulating the setSize method in a server and client tick handler. Been trying all the different kind of ticks such as RENDER, CLIENT, WORLD, etc, but none will work to make the size smaller, it will only work if I try to make the player bigger. However, when I press f3 + b I can see that the hitbox of the player has been reduced, but I still can't walk under smaller spaces nomatter how small I put the hitbox.
Any ideas?
EDIT: I figured it out! I switched World Tick to Player Tick and added this line:
player.boundingBox.maxY = player.boundingBox.minY + (height);
I'm just speculating here, but are you setting the height to exactly 1 block? If so you might need to set it to slightly below one block since the block is 1 block tall. The player might not be able to pass under it as it still doesn't fit, but it is very close. Again I'm just speculating.
Hmm... since morph mod changes player size I decided to look at the source. It seems I am doing it the same, in tick handlers for client and server. Strange that it's not working for me... I will look a bit closer in the source code. If anyone else thinks of something, please tell me.
CoolAlias! I call upon you! I need your help in this dark time!
Haha. If you see this, I want to thank you for all the times you helped me before. Maybe soon I will be able to return the favor, this summer when coding becomes my job.
Youll need to use reflection to access the vanilla file, its the exact way i add new potion effects to mc and also how the morph mod changes the player height.
On the login, respawn and change dimension events you will have to reset the size and eye height to make sure its correct but unless another mod is also effecting the player size such as morph or Tinkers Construct(It has something to do with armour) may cause you to take damage when you go under small spaces.
Take a look at these 2 specific files from the morph mod
This contains examples of how the code is used and what needs to be changed.
Yes, I use reflection quite often, and that is what I have been doing. I did notice that what I didn't do was add the set size to login, respawn, and change dimension events, but would that make a difference for me not being able to go underneath blocks? Because for those events it would be set to the normal size, since the player would no longer be crouching.
After looking at his code, I changed my version of the force set size method to his to see if that made a difference, but it seems mine already did pretty much the same. I had it print into the console the value of the height for both the server and the client, and it is printing the correct value. When I press F3 + B I can even tell the hitbox has changed, but I can't even walk under a space 1 1/2 blocks tall. Like I said before, for some reason it works when I set it to a larger height that requires more block space to walk through...
I think the method you need to scrutinize is the Entity#moveEntity() method. It is the one that checks for bounding box collisions and prevents movement. It is a pretty long method so I don't have time/interest to sort through it, but you should probably try to debug trace it or maybe study it so you can see if there is any reason it is preventing the movement in your case.
I'm not really sure why that solution works. The setSize() method pretty much just sets the same maxY field. At least it does in 1.7.10. Maybe in 1.6.4 it is different.. And in 1.8 there is a setEntityBoundingBox() function that keeps this info directly in a bounding box instead.
Hello everyone,
I am having a bit of trouble with a World War 2 mod I am making. I want to make it as realistic as possible, with every warship, tank, and plane that fought, even nation selection and npcs, it's not just going to be another flans mod. In any case, I have been trying to make it so that if you sneak with a gun, instead you crouch. I will also be adding lying down, but first I must get crouch done. So far, I have been doing pretty good on the crouching, I have already made it so that your viewpoint is lower, and the player is posed differently when crouched. But the problem is, I can't quite get the size of the player to change, so that you can fit under a bit smaller blocks. Even stranger, it appears to work when I set it to a bigger size of the player, but not a smaller. I have been changing the size by manipulating the setSize method in a server and client tick handler. Been trying all the different kind of ticks such as RENDER, CLIENT, WORLD, etc, but none will work to make the size smaller, it will only work if I try to make the player bigger. However, when I press f3 + b I can see that the hitbox of the player has been reduced, but I still can't walk under smaller spaces nomatter how small I put the hitbox.
Any ideas?
EDIT: I figured it out! I switched World Tick to Player Tick and added this line:
player.boundingBox.maxY = player.boundingBox.minY + (height);
Check out my other mods on MinecraftForum or my old 1.6.4 mods here: http://www.planetminecraft.com/member/beardielover/ Working on updating them to 1.7, once that is done will upload them here.
I'm just speculating here, but are you setting the height to exactly 1 block? If so you might need to set it to slightly below one block since the block is 1 block tall. The player might not be able to pass under it as it still doesn't fit, but it is very close. Again I'm just speculating.
I set the height to 0.9 first, then 0.6, and I can't even go under a 1 1/2 block space. Default height is 1.8
Check out my other mods on MinecraftForum or my old 1.6.4 mods here: http://www.planetminecraft.com/member/beardielover/ Working on updating them to 1.7, once that is done will upload them here.
Hmm... since morph mod changes player size I decided to look at the source. It seems I am doing it the same, in tick handlers for client and server. Strange that it's not working for me... I will look a bit closer in the source code. If anyone else thinks of something, please tell me.
Check out my other mods on MinecraftForum or my old 1.6.4 mods here: http://www.planetminecraft.com/member/beardielover/ Working on updating them to 1.7, once that is done will upload them here.
CoolAlias! I call upon you! I need your help in this dark time!
Haha. If you see this, I want to thank you for all the times you helped me before. Maybe soon I will be able to return the favor, this summer when coding becomes my job.
Check out my other mods on MinecraftForum or my old 1.6.4 mods here: http://www.planetminecraft.com/member/beardielover/ Working on updating them to 1.7, once that is done will upload them here.
Youll need to use reflection to access the vanilla file, its the exact way i add new potion effects to mc and also how the morph mod changes the player height.
On the login, respawn and change dimension events you will have to reset the size and eye height to make sure its correct but unless another mod is also effecting the player size such as morph or Tinkers Construct(It has something to do with armour) may cause you to take damage when you go under small spaces.
Take a look at these 2 specific files from the morph mod
This contains examples of how the code is used and what needs to be changed.
https://github.com/sekwah41/Morph/blob/master/java/morph/common/core/EventHandler.java
If you take a look at the forceSetSize method it shows you how the reflection works.
https://github.com/sekwah41/Morph/blob/master/java/morph/common/core/ObfHelper.java
Yes, I use reflection quite often, and that is what I have been doing. I did notice that what I didn't do was add the set size to login, respawn, and change dimension events, but would that make a difference for me not being able to go underneath blocks? Because for those events it would be set to the normal size, since the player would no longer be crouching.
After looking at his code, I changed my version of the force set size method to his to see if that made a difference, but it seems mine already did pretty much the same. I had it print into the console the value of the height for both the server and the client, and it is printing the correct value. When I press F3 + B I can even tell the hitbox has changed, but I can't even walk under a space 1 1/2 blocks tall. Like I said before, for some reason it works when I set it to a larger height that requires more block space to walk through...
Check out my other mods on MinecraftForum or my old 1.6.4 mods here: http://www.planetminecraft.com/member/beardielover/ Working on updating them to 1.7, once that is done will upload them here.
I think the method you need to scrutinize is the Entity#moveEntity() method. It is the one that checks for bounding box collisions and prevents movement. It is a pretty long method so I don't have time/interest to sort through it, but you should probably try to debug trace it or maybe study it so you can see if there is any reason it is preventing the movement in your case.
You know what? I bet you are right! Great thinking! I will try that right now! I will get back to you later and tell you how it goes!
EDIT: Hmm I see a problem though.. the fact that it works when I set it to a bigger size. I will try it anyways though.
Check out my other mods on MinecraftForum or my old 1.6.4 mods here: http://www.planetminecraft.com/member/beardielover/ Working on updating them to 1.7, once that is done will upload them here.
Nevermind I got it!
Check out my other mods on MinecraftForum or my old 1.6.4 mods here: http://www.planetminecraft.com/member/beardielover/ Working on updating them to 1.7, once that is done will upload them here.
Could you tell the 176 people who have viewed this message how you solved this?
I am curious :-)
[url=2482915-wip-arkcraft-survival-evolved-dinos-taming]
Already did, my good sir! There is an edit in the OP!
Check out my other mods on MinecraftForum or my old 1.6.4 mods here: http://www.planetminecraft.com/member/beardielover/ Working on updating them to 1.7, once that is done will upload them here.
I'm not really sure why that solution works. The setSize() method pretty much just sets the same maxY field. At least it does in 1.7.10. Maybe in 1.6.4 it is different.. And in 1.8 there is a setEntityBoundingBox() function that keeps this info directly in a bounding box instead.
That's what I thought was strange too... Either way, it works.
Check out my other mods on MinecraftForum or my old 1.6.4 mods here: http://www.planetminecraft.com/member/beardielover/ Working on updating them to 1.7, once that is done will upload them here.
Thanks, I didn't see the edit in the first, message.
[url=2482915-wip-arkcraft-survival-evolved-dinos-taming]