Jump to content

[1.11.2] Create a custom shot out entity


Camellias

Recommended Posts

So I'm trying to make a thing to fire a custom entity, and currently it fires arrows. My only problems with this is the arrow entity texture that you see, but I can live with, and the fact that arrows fall. So unless there's some unknown way to make the entities fired to not fall without creating an entirely new entity file, I need to figure out how to make a custom entity. I've tried using EntityArrow as a basis, like I did with ItemBow, though I end up with several errors I can't fix without causing a crash when I try and use the item.

 

Code I'm currently using for the revolver

Link to comment
Share on other sites

If you want a projectile to not look like an arrow, you'd need to create a new entity class.

The last time I did that was 1.7: https://github.com/Draco18s/Artifacts/blob/master/main/java/com/draco18s/artifacts/entity/EntitySpecialArrow.java

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Yeah, I have no idea. I attempted making a custom entity, but whenever I try and implement it into the code, these lines either error:

 

if (!worldIn.isRemote)
                    {
                        ItemArrow itemarrow = (ItemArrow)((ItemArrow)(itemstack.getItem() instanceof ItemArrow ? itemstack.getItem() : Items.ARROW));
                        EntityArrow entityarrow = itemarrow.createArrow(worldIn, itemstack, entityplayer);
                        entityarrow.setAim(entityplayer, entityplayer.rotationPitch, entityplayer.rotationYaw, 0.0F, f * 3.0F, 1.0F);

                        if (f == 1.0F)
                        {
                            entityarrow.setIsCritical(true);
                        }

                        stack.damageItem(0, entityplayer);

                        worldIn.spawnEntity(entityarrow);
                    }

 

Or they don't error and the gun does absolutely nothing.

Link to comment
Share on other sites

Well. You're still asking the vanilla arrow item for the entity that it spawns...

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

And the changes I made should have worked when I changed the arrow bits to bullet, yet it still didn't work, even when it should have. Yes, I made the edits within every file. That's when I stopped getting errors. But it still didn't work. 

Link to comment
Share on other sites

"It hurts doctor. It hurts."

 

Please define "doesn't work" in a manner that is actually troubleshootable.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

No need to become a sarcastic asshole. Already have too many of those in my life. 

 

And by doesn't work, I mean it doesn't do anything. It doesn't fire a projectile, it doesn't use the item in my inventory. All it does is use the pullback animation, as I haven't changed that yet. How else would it not work? 

Link to comment
Share on other sites

Well...is your current code posted somewhere?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Haven't had a chance to grab it from my computer and spam pastebin with it. And I've been toying with another idea, as well. Haven't had a chance to test it, but I'm thinking about trying to make the guns hitscan weapons. Meaning they'd actually do melee damage, as soon as they detect an entity other block obstructing a straight path, calculated immediately after you right click. I know it's possible, because it's been done in a mod before. 

Link to comment
Share on other sites

Well you have to actually update the things that need updating.

 
    protected boolean isArrow(ItemStack stack)
    {
        return stack.getItem() instanceof ItemArrow;
    }

You're still consuming arrows in order to consume ammo.

                        ItemArrow itemarrow = (ItemArrow)((ItemArrow)(itemstack.getItem() instanceof ItemArrow ? itemstack.getItem() : Items.ARROW));
                        EntityArrow entityarrow = itemarrow.createArrow(worldIn, itemstack, entityplayer);

And still using arrows to get the entity to spawn.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I can't help you fix code that hasn't been written. Write it, then show it to me along with what it isn't doing. And use a debugger to see what's going wrong.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Go ahead and mark this as solved. I actually got helpful responses from people that actually looked into the code and realized what I was doing wrong and told me what I was doing wrong, without the sass. It works as I want it to, other than the entity being as slow as an arrow, which is fine. It doesn't drop, it does decent damage, it makes the right sounds, etc. No errors, no dealing with people acting like they're superior to me, and no me over here anymore. Cya.

Link to comment
Share on other sites

Some advice, which you can choose to take or ignore: giving you code doesn't help you learn how to apply programming knowledge in the future. On top of that, we can't debug your code if we don't know what your code is. So when we say things like "Try figuring it out yourself first, and if it doesn't work, then show us the code and we'll help" or "We can't help unless you give us your code", that's not sass, it's not superiority, it's us actually trying to help you learn from your mistakes.

And in case it helps you understand our perspective, I currently teach a programming course for adults for a living, so I have a bit of experience in how people learn to code best. Giving you the code will help you get this one thing working, but the next time you encounter a similar (but different) problem, you'll get stuck again. Learning by guided trial-and-error is the best way to understand the logic behind the code and thus help you going forward.

Again, this is just my perspective and advice, you don't have to take it. Good luck with everything.

Whatever Minecraft needs, it is most likely not yet another tool tier.

Link to comment
Share on other sites

6 minutes ago, IceMetalPunk said:

Some advice, which you can choose to take or ignore: giving you code doesn't help you learn how to apply programming knowledge in the future. On top of that, we can't debug your code if we don't know what your code is. So when we say things like "Try figuring it out yourself first, and if it doesn't work, then show us the code and we'll help" or "We can't help unless you give us your code", that's not sass, it's not superiority, it's us actually trying to help you learn from your mistakes.

And in case it helps you understand our perspective, I currently teach a programming course for adults for a living, so I have a bit of experience in how people learn to code best. Giving you the code will help you get this one thing working, but the next time you encounter a similar (but different) problem, you'll get stuck again. Learning by guided trial-and-error is the best way to understand the logic behind the code and thus help you going forward.

Again, this is just my perspective and advice, you don't have to take it. Good luck with everything.

Except I have given the code to you. Several times. And I'm not asking to be given code to fix it, I'm asking to be shown the issues. The reason I couldn't get the bullet working right? It's because I needed to use a comma, not a semi colon, and because the entity was set to being abstract. Two simple things. I wasn't given the code, I was given information I can use later on for other mods I work on. And often times, I figure out how to fix errors on my own. I've had several errors within my code that I simply looked through and discovered the issues without asking anyone. Heck, I have no coding experience, surprise surprise, but coding is logical. Often times I can just look at something and understand the issue. But some things like this issue had to do with defining parameters of the code I didn't know until now. Now, I can encounter different problems that are similar, and can fix it myself. I also intend to be covering several different things in this mod, meaning I'll be exposing myself to different things I've never seen. I don't learn from watching tutorials or classes (not that I can afford those anyways). I learn from shoving myself head in and figuring things out as I go. Heck, by the time this mod is finally finished, there's a good chance I'll be able to figure everything out without ever having been certified in Java, or taking any classes, simply because I decided to expose myself to the stuff directly and learn things as I go. If I could've Googled this issue, everything would've gone faster, but nothing I could find related. Now if someone has the same problem as me, there's evidence on a forum for people to know what is causing their problem and how to fix it, rather than be scared off by the people here because they lose hope on making their mods happen. Honestly, I was tempted to just scrap this whole thing because no one here gave any help on figuring it out. 

 

So, with that, I bid you a good life and good day.

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.