Jump to content

[1.10.2] Change Player model and hitbox for different stances


XFactHD

Recommended Posts

I am recreating the FPS Tom Clancy's Rainbow Six Siege as a Minecraft mod. In this game you can stand upright, sneak or go prone. This means that I need to make the player's head be much lower while sneaking (in vanilla MC the head is not really lower than while standing up) and I need to kind of rotate the player hitbox when the player goes prone. While the player is prone, his legs need to go in front of him if he moves backwards and behind him if he goes forward. I also need to make it impossible for the player to look straight up and down but rather with a certain angle and if the player's feet are behind him while he is prone, he should only be able to look upward at a very small angle. My question now is: Is this doable without ASM (I have absolutely no knowledge of that stuff) and which compatibility problems would this have (although I don't really care about compatibility because I don't expect this mod to be used with other mods as it features a complete arena setup including automatic match management and effectively turns MC into a shooter)? If it is not doable without ASM, does someone have enough knowledge of PlayerAPI and RenderPlayerAPI to explain me how to achieve this kind of stuff?

Link to comment
Share on other sites

Okay, well - look: What you described is just an idea, now as to designing it to work properly - I can tell you that aside from rotating hitbox (I haven't checked that one so idk), everything you need it pretty much doable with just Forge.

 

As far as RenderPlayerAPI goes - I am absolutely sure that there is noone who will help you there more than SmartMoving's source (but to understand it you will need to spend some time on in-depth reading/understanding source).

 

Note: As mentioned - Forge allows you to edit entity's data, hitboxes and rendering. RenderPlayerAPI is just an API - it is literally layer over what forge might be able to do and provides more compatibility (not functionality). If you want to go for simple - go with Forge. If you want to somehow get along with other RenderPlayerAPI mods - use that.

 

Now to actual things:

1. Minecraft threads (sides), COMPLETE understanding.

2. Forge events (usage).

3. Rendering and client events, partialTicks, client-only classes.

4. Rendering with GL and models + whole vanilla Render.class system.

5. @Capability (storing player states).

6. SimpleNetworkWrapper (network designs)

7. Network-related events (tracking, dynamic syncing).

8. Understanding hitboxes AABB and OBB if you want (idk if they are possible to implement without ASM, there was a thread about it).

9. Some other stuff such as NBT (saving data) and overall vanilla/forge systems + pretty advanced math (rotating and doing stuff like animation properly).

 

Do tell me - how much do you think you are prepared (considering mentioned above required knowledge)?

 

What do you know nothing about? What you are not sure you know enough?

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

[*]I have the complete understanding of the difference and separation of the server and client thread.

[*]I know how to create an event handler and manipulate the game with it.

[*]I know what partialTicks are, I know the usage of some client events but never worked with most of them, especially those that I might need for this project. In terms of rendering, I have experience with the model system and can do some crazy stuff with it, I already worked with TESRs and animations (the old way) in TESRs, with entity renderers I still have problems, they don't really work for me.

[*]I know how to work with normal models (used in a TESR) but I have little knowledge over the extra functionality a ModelBiped has. I have a basic knowledge of GL but refreshing this wouldn't be bad at all :). I would have to take another look at the render.class system to tell you if I understand it or not.

[*]I know how capabilities work and I am already using them in this mod on an item and the player.

[*]I know how to do networking with thread safety although I am always pretty lazy in terms of cheat safety. Refreshing that would also not be bad.

[*]I don't know what you mean with that.

[*]I have some knowledge of AABBs, I am using them for the hitbix of a block in another mod but it gets highlighted even though I am looking at a part if the block where no hitbox is (don't know if this is directly connected to AABBs) but I do not know what OBBs are.

[*]I am working excessively with NBT already. If you mean the animation and rotation of parts of a ModelBiped, I never worked with that functionality but I know how to rotate parts of those models but I am missing the knowledge as to how to make good animation that don't stutter. As for the vanilla and forge systems, it depends what you mean with that.

 

Thank you that you already gave me such an in depth answer.

Link to comment
Share on other sites

Regarding hitbox, the main hitbox of an entity always has a square base -- at least that was a limitation up until 1.8 when I last tried changing the hitbox. Also, it doesn't rotate but is always square to the world. This is a problem for most interestingly-shaped mobs, since it means there will either be parts of the entity which won't count as a hit, or there will be parts outside the entity which will count as a hit. I believe this limitation is in place to help with path-finding as it would it would cause performance to slow down a lot if Minecraft had to find paths for irregular, rotated hitboxes.

 

So most mods that want more irregular or precise hitboxes tend to make a "multi-part" entity. Basically you can add additional hitboxes by creating invisible entities that follow around the associated entity (in your case the player). If those hitboxes get hit, then you call the same actions as if the main entity got hit.  Look at the ender dragon code to understand what I mean if it is still unclear.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

That makes sense to me. Would it be possible to just add fake entities for the legs, the arms, the body and the head and shrink the player hitbox a bit so that a raytrace won't hit the player's hitbox? Damaging the player is not a problem because I have a custom health system in place to support certain actions from the game I am recreating with this mod.

Link to comment
Share on other sites

Yes, you can add fake entities for all those parts and adjust. Just beware that the hitboxes are still each limited to being square in X, Z, and they can't be rotated. So you wont get a perfect match to your actual model which might be rectangular and rotated. But it should still be much better. And it is important to remember that this is Minecraft after all -- so it isn't a game about precise headshots really. So don't have too high of expectations for making a fully accurate first person shooter.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

You'll need to use math to keep the positions arranged properly. So let's say that the master entity has hit box that is positions where the main body (torso) is. Then depending on how you're crouching and rotated you would move the other hitbox entities into the right places.

 

Note that for debugging it is very useful to use the F3+B hotkey combo which will display all the entity bounding boxes on the screen.

 

But anyway, you'll have to do some trigonometry. Have fun!

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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

    • It does but I'm struggling to see how to make it work in my recipe? (Its structure is the same as OP's, with a serializer subclass)
    • That looks pretty cool, nice!   Sure, so looking at that JSON file I posted, I pretty much made a record class for each "custom" data type in that JSON. The Input is a good example of why ``` "inputs": [ { "ingredient": { "item": "relativedimensions:aberrant_shard" }, "count": 8 } ], ``` So here's the inputs, it's an array, which we can use the Codec builder's builder.listOf to define an array. Each Item is of some arbitrary object with keys "ingredient" (which we know is an Ingredient) and a "count" which is an int. You don't have to have an intermediate class to map this to necessarily but I found that it's just easier to see the data that way, hence the 'ParticleReboundIngredient' represents one of these inputs.   Let me know if that makes sense or not. 
    • Pretty much, although all the recipes im planning to make on it are shapeless. The idea is that the chamber uses energy to "fuse" the items in each of the center slots together, in this case an ingot. The two slots at the sides are fuel. (A special kind of wood in this case). Here is an image of the interface just for reference (The center slot is the output)   As for the code- Can you elaborate a little bit on it? Seeing three different record classes has confused me a lot. (Elaborate as in why make them in three different records. I understand the code itself more or less)
    • Hello im trying to make a mod and the past few days GSON has almost killed me, when i export the mod and then launch it through minecraft launcher i get java.lang.NoSuchMethodError: com.google.gson.JsonParser.parseString(Ljava/lang/String;)Lcom/google/gson/JsonElement; i have literally tried everything here is my build config   dependencies { minecraft("com.mojang:minecraft:1.8.9") mappings("de.oceanlabs.mcp:mcp_stable:22-1.8.9") forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9") compileOnly("cc.polyfrost:oneconfig-1.8.9-forge:0.2.2-alpha+") shadowImpl("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta+") { isTransitive = false exclude(module = "gson") } shadowImpl("org.spongepowered:mixin:0.7.11-SNAPSHOT") { isTransitive = false exclude(module = "gson") } annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT") shadowImpl("org.javassist:javassist:3.15.0-GA") { isTransitive = false exclude(module = "gson") } shadowImpl("com.neovisionaries:nv-i18n:1.28") { isTransitive = false exclude(module = "gson") } shadowImpl("org.apache.commons:commons-lang3:3.4") { isTransitive = false exclude(module = "gson") } shadowImpl("org.apache.httpcomponents:httpcore:4.4.5") { isTransitive = false exclude(module = "gson") } compileOnly("com.google.code.gson:gson:2.8.6") { isTransitive = false } configurations.all { resolutionStrategy { force("com.google.code.gson:gson:2.8.6") } } shadowImpl(fileTree( mapOf( "dir" to "libs", "include" to listOf("*.jar"), "exclude" to listOf( "asm", "asm-commons", "asm-tree", "gson", "unspecified", "nv-i18n" ) ) )) }  
    • @chxr Looks like you're making some sort of a crafting table / furnace hybrid? Are the inputs needing arranging like a shaped recipe, or is it shapeless? I'll assume it's shapeless since that just adds a lot more complexity. In that case I'd probably do something like this { "type": "relativedimensions:particle_rebound", "inputs": [ { "ingredient": { "item": "relativedimensions:aberrant_shard" }, "count": 8 } ], "fuel": { "tag": "relativedimensions:block/aberrant_fuel" }, "output": { "Count": 1, "id": "relativedimensions:aberrant_ingot" } } inputs: A list of ingredients and how many are needed. The count among each input adds up to 8. Since there's only 1 ingredient, the count is set to 8. fuel: Same thing as before but remove the list and just make it an object with a tag. output: Kept the same.   In this case the Codec I would make is public record ParticleReboundIngredient(Ingredient ingredient, int count) { public static final Codec<ParticleReboundIngredient> CODEC = RecordCodecBuilder.create( builder -> builder.group( Ingredient.CODEC.fieldOf("ingredient").forGetter((i) -> i.ingredient), Codec.INT.fieldOf("count").forGetter(i -> i.count) ).apply(builder, ParticleReboundIngredient::new) ); } public record ParticleReboundFuel(String tag) { public static final Codec<ParticleReboundFuel> CODEC = RecordCodecBuilder.create( builder -> builder.group(Codec.STRING.fieldOf("tag").forGetter(f -> f.tag)).apply(builder, ParticleReboundFuel::new) ); public boolean isFuel(ItemStack stack) { // TODO: Check if fuel item matches the tag } } public record ParticleReboundRecipe(List<ParticleReboundIngredient> inputs, ParticleReboundFuel fuel, ItemStack output) { public static final Codec<ParticleReboundRecipe> CODEC = RecordCodecBuilder.create( builder -> builder.group( ParticleReboundIngredient.CODEC.listOf().fieldOf("inputs").forGetter(r -> r.inputs), ParticleReboundFuel.CODEC.fieldOf("fuel").forGetter(r -> r.fuel), ItemStack.CODEC.fieldOf("output").forGetter(r -> r.output) ).apply(builder, ParticleReboundRecipe::new) ); }   There might be a more proper Codec for the fuel and the tag that's built into minecraft / forge, but I didn't look
  • Topics

×
×
  • Create New...

Important Information

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