Jump to content

[1.12.2] How to make a custom projectile (that behaves similar to a fireball)


Korlimann

Recommended Posts

Just now, Cadiboo said:

The way I would do it would be to extend entity throwable, move the entity & check how long it’s been alive in the onUpdate method and handle collisions (blocks and entities) in the onImpact method

Okay, I think I'll start with that as soon as I'm back home. Thanks! :)

Link to comment
Share on other sites

Can you push your changes to your repo too please?

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

3 hours ago, Cadiboo said:

Can you push your changes to your repo too please?

Alrighty. So I finally arrived home and started working on it and I see the following problem.
I tried setting some fixed values for the motion variables. This stopped the Entity from following my mouse, but now it always shoots in the same direction, no matter which way I'm facing.
I suppose that, for what ever reason, the onUpdate method keeps getting the way the player is facing and updating the motion factors accordingly. I have absolutely no idea how and why this works.
But I did manage to let the Entity despawn by making an int that counts 1 up for every time the onUpdate method get's called. If the counter reaches 100, it despawns (and this should be approx. 100 blocks)
I also fixed the problem that it slowed down and just stood still by deleting the part where the motion get's multiplied by the motionFactor.
Do you maybe have any idea how I can stop the entity from "chasing the cursor"?
I also noticed that, when the motion variables are not fixed, the Entity won't spawn until I hit a second time, and when I do it spawns two of them right after each other.
When having the motion variables fixed, clicking twice with almost no delay makes the second Entity bounce off the first and change direction.
Any ideas?
EDIT: I just noticed that the Entity stops following the cursor when you turn really fast
EDIT 2: I managed to stop the Entity from following the cursor by setting the RayTracerResult only in the constructor and making a private variable to it, so no new RayTracerResult gets created every onUpdate, however, I noticed why you need to click 2 times before it starts flying. The first one apparently get's spawned right were you stand and every Entity that spawns after that collides with the first one and get's shot of in the direction you're looking. If you move fast while clicking, you will have many entities just floating around.

Edited by Korlimann
Link to comment
Share on other sites

You are not creating your throwable entitiy correctly. You need to tell it to be shot into a direction, and you are not telling it to do so. See how vanilla shoots it's projectiles at ItemSnowball for example. Literally every single one of your issues is fixed by adding the EntityProjectile#shoot call. Yes, I've debugged it ;)

If you want to play the "swing" animation return false in your override of Item#onEntitySwing.

Edit: Oh, almost forgot. Instead of doing this

23 minutes ago, Korlimann said:

making an int that counts 1 up for every time the onUpdate method get's called. If the counter reaches 100, it despawns (and this should be approx. 100 blocks)

Store the entity's starting position and check when the distance between the current position and the starting one is greater or equal to 100*100(don't do the check that calculates the sqrt for you that's not needed in this case). Of course you must make sure that your entity won't stop - so it needs to go through all blocks and have a constant velocity.

Edited by V0idWa1k3r
  • Like 1
Link to comment
Share on other sites

Just now, V0idWa1k3r said:

You are not creating your throwable entitiy correctly. You need to tell it to be shot into a direction, and you are not telling it to do so. See how vanilla shoots it's projectiles at ItemSnowball for example. Literally every single one of your issues is fixed by adding the EntityProjectile#shoot call. Yes, I've debugged it ;)

If you want to play the "swing" animation return false in your override of Item#onEntitySwing.

Thanks a bunch! I'm gonna check that out right now. By the way, do you have an idea why exactly the Projectile kept following the Players cursor? I'm curious ?

Link to comment
Share on other sites

3 minutes ago, V0idWa1k3r said:

Store the entity's starting position and check when the distance between the current position and the starting one is greater or equal to 100*100(don't do the check that calculates the sqrt for you that's not needed in this case). Of course you must make sure that your entity won't stop - so it needs to go through all blocks and have a constant velocity.

Thanks, that's actually way smarter

Link to comment
Share on other sites

14 minutes ago, V0idWa1k3r said:

Nope, didn't debug it to that extend but I suspect that is a client-side only glitch anyway.

Ah, okay. Either way, quite interesting, I think

 

Okay, so I followed your advice and it works a lot better now, although on every click, it spawns two entities at once now which seem to lay perfectly on each other. I experimented a little bit and when shooting through a wall, those two entities seem to change their direction a little, so you can actually see that it spawns twice everytime. I pushed my changes. Any idea why it get's spawned twice?

Edited by Korlimann
Link to comment
Share on other sites

30 minutes ago, Korlimann said:

it spawns two entities at once now which seem to lay perfectly on each other. I experimented a little bit and when shooting through a wall, those two entities seem to change their direction a little, so you can actually see that it spawns twice everytime. I pushed my changes. Any idea why it get's spawned twice?

Are you sure about that? I can't replicate the issue. In fact I have debugged the entities and can confirm that there only exists one entity instance per respective side after the swing.

Link to comment
Share on other sites

2 hours ago, V0idWa1k3r said:

Are you sure about that? I can't replicate the issue. In fact I have debugged the entities and can confirm that there only exists one entity instance per respective side after the swing.

Sorry for the wait, I wasn't at home. I tried to replicate the issue https://imgur.com/JTOstpO
I hope you can see it here in the gif. When shooting through the wall, most of the times it (seems to) split up into two entities, I don't know though if this description is accurate. But when simply shooting in any direction, it looks like there's only one.
EDIT: Just to clarify, I haven't changed any of the code since the last push.

Edited by Korlimann
Link to comment
Share on other sites

22 hours ago, Cadiboo said:

You can take a look at this implementation which renders an item, or this implementation which renders a textured cuboid

Hey there again :)
I'm now in the process of trying to get my Entity to render correctly and had a few question regarding the classes you sent.

So, I saw that the GlStateManager has a rotate() mehod, and I need my Model to be turned so that the blade will be horizontal to the player.

Furthermore, you get an ItemStack from your Dagger which appears really complicated to me. I tried to get it to work by simply creating the class and registering it in my ModItems and ItemRegistry Class. I was able to replace the green square by a block with no textures that rotates weirdly when shot.

So in order to maybe get the block to work, I replaced the TextureMap.LOCATION_BLOCKS_TEXTURE with the path to my textures, but the only thing that changed is that the block now has complete black textures instead of just the "missing textures" texture. What does the TextureMap actually do, and how can I get the Renderer to render my custom model?

Link to comment
Share on other sites

1 minute ago, Korlimann said:

I replaced the TextureMap.LOCATION_BLOCKS_TEXTURE with the path to my textures

Don't do this if your trying to render an actual model

2 minutes ago, Korlimann said:

What does the TextureMap actually do

It stores all the normal textures of the game (Block & Item textures) in 1 texture for performance and a number of other reasons

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

7 minutes ago, Cadiboo said:

Don't do this if your trying to render an actual model

It stores all the normal textures of the game (Block & Item textures) in 1 texture for performance and a number of other reasons

Ah, thanks! So stuff like a chest or similar use Texturemaps?

And, do you know how the rotation method works?

Link to comment
Share on other sites

4 minutes ago, Korlimann said:

So stuff like a chest or similar use Texturemaps?

Chests are a TileEntity, not a normal block. What do you mean by "or similar"?

4 minutes ago, Korlimann said:

how the rotation method works?

It rotates the current GL matrix with the values you specify. The values are angle (in degrees), x (either 1 or -1), y (either 1 or -1), z (either 1 or -1).

Heres a (very) technical explanation

Edited by Cadiboo

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

14 minutes ago, Cadiboo said:

Chests are a TileEntity, not a normal block. What do you mean by "or similar"?

It rotates the current GL matrix with the values you specify. The values are angle (in degrees), x (either 1 or -1), y (either 1 or -1), z (either 1 or -1).

Heres a (very) technical explanation

Thanks a lot! I think I confused what you meant with Texturemaps, sorry.

I just pushed all my changes. I still get a block with no textures though. Do you maybe have an idea why it won't render correctly?

Edited by Korlimann
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



×
×
  • Create New...

Important Information

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