Jump to content

Requesting An Example of the code of a Custom Projectile


Tadpoling

Recommended Posts

Hi!

For the past few days I've tried looking for a good example or guide from which I could understand how to make a new Projectile, but it has largely been unsuccessful. I've searched Youtube for guides, the internet for examples, I tried looking up source code of some mods, but I still largely don't get what's required. 

So I'd greatly appreciate it if anyone could share some (simple) custom made projectile, and how they add it to the registry, or alternatively some guide that shows what's necessary so that I can base my own custom projectile off of. 

Thanks a lot 

Link to comment
Share on other sites

Projectiles are just special Entities that extend the Projectile class or one of its subclasses like AbstractArrow.

So tutorials for creating entities will get you a lot of the way there. e.g. registering your EntityType and EntityRenderer

For the actual implementation, look at one of the vanilla projectiles or a mod that does something close to what you want.

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

Well I tried doing as you said, copying a Projectile From Minecraft

I basically Copied the LamaSpit Class with some minor edits to make it work:

The important Parts of the ProjectileCopy Class: As in the two constructors(There are no other constructors)

https://imgur.com/a/uPbkOrz

Registering the Projectile:

https://imgur.com/a/qZestoE

 

the error under the constructor says that "Cannot resolve constructor 'ProjectileCopy' " 

Which I know means it cant find the correct constructor, because it wants a constructor that Accepts the parameters (EntityType<Entity>, Level)

But trying to make that constructor doesn't work, well rather calling to the father's constructor doesnt work because it requires a Class that inherits from Projectile, rather than Entity, which is what we gave it

 

https://imgur.com/a/3EEpKDm

Here's an example of what I did(Only to demonstrate the Issue, 

because keeping this constructor conflicts with the second constructor from above)

Thank for you for your time!

 

Link to comment
Share on other sites

First, please don't post code in images. Either paste the code snippets using the <> option or put your code on github if it is large.

 

Your question is a misunderstanding of lambdas again, like with the BlockEntity problem you had. But this time with generics.

 

Your constructor needs to mention the actual entity class as the generic parameter, not Entity.

public class ProjectileCopy extends Projectile {
   public ProjectileCopy(EntityType<? extends ProjectileCopy> entityType, Level level) {
Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

The other constructor that takes a Llama as a parameter, you obviously don't need.

Unless you want to do something similar to Llama.spit() but then it won't be a Llama for your projectile.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

NOTE: I wrote "? extends ProjectileCopy" in case you want a subclass in future, otherwise it can just be ProjectileCopy.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

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.



×
×
  • Create New...

Important Information

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