Jump to content

Recommended Posts

Posted (edited)

I'm trying to apply my own knock back to any item with one of my custom attribute modifiers. I've came up with a few ways, but all of them either do half of what I want or don't work at all.

My most successful attempt was trying to cancel the LivingAttackEvent, checking if the entity was hit beforehand using a capability, saving the entity's motion, dealing damage, restoring the entity's motion and applying my own knock back. This did work, but since forge is so underdeveloped the LivingAttackEvent posts twice for any player, because EntityPlayer's attackEntityFrom posts the event and calls super which also posts the event. This caused the knock back (and perhaps the damage) to be applied twice. But in certain cases (ray-traced extended reach) the event posts once so it's hard to predict how many times it will post. Here's the code. Checking if the entity was hit before is necessary to prevent recursion.

I tried using AttackEntityEvent, but that method also posts 2 (sometimes 3) times and I have no idea why.

I also though about using ASM or reflection, but I don't know how to use the former and don't think the latter will help much.

Thanks in advance.

Edited by Melonslise
Posted
8 minutes ago, Melonslise said:

underdeveloped

Snrk.

Hardly.

 

9 minutes ago, Melonslise said:

the LivingAttackEvent posts twice for any player, because EntityPlayer's attackEntityFrom posts the event and calls super which also posts the event

File a bug report. Better yet, make a Pull Request fixing the problem.

 

https://github.com/MinecraftForge/MinecraftForge

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.

Posted (edited)
1 hour ago, Draco18s said:

Snrk.

Hardly.

 

File a bug report. Better yet, make a Pull Request fixing the problem.

 

https://github.com/MinecraftForge/MinecraftForge

That's not quite the answer I was expecting. The feature, if even added, will take a long time to be implemented and will only be included in the latest versions of forge (if I understand correctly).

Edited by Melonslise
Posted
41 minutes ago, Melonslise said:

and will only be included in the latest versions of forge

Which you should always be using, so this wouldn't be an issue.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

Ok so I forked the repo, downloaded the 1.12 branch, built forge, modified only the forge project and generated the patches. How do I submit pr now? How do I merge the branch I downloaded with my forked repo?

Posted
3 hours ago, Melonslise said:

Done. I had to clone the repo to github desktop instead of downloading it as a zip. Here's the pull if anyone is interested.

BTW, it'll take a while to get accepted and you'll probably feel like you're being abused with needing to make changes. Its not personal.

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.

Posted (edited)
17 hours ago, Draco18s said:

BTW, it'll take a while to get accepted and you'll probably feel like you're being abused with needing to make changes. Its not personal.

Right now the feedback comes pretty promptly and if it is a straightforward bug it can be accepted quickly. But you're right that the first time you make a PR it feels like a lot of nit-picks. Basically not only does your PR have to work, but it also has to be formatted properly, have a very targeted test mod, and of course be implemented in a way agreeable to reviewers. I spent a lot of time on my first PRs just trying to get the whitespace right...

 

16 hours ago, diesieben07 said:

*twitch*

I know that "real men" use git by command line, but honestly it is the year 2017 and graphical interfaces (I prefer SourceTree) can be pretty decent.

Edited by jabelar

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

Posted
                double d = target.posX - attacker.posX;
		double d1;
 
	    	for (d1 = t.posZ - a.posZ; d * d + d1 * d1 < 0.0001D; d1 = (Math.random() - Math.random()) * 0.01D)
	    	{
	    	    d = (Math.random() - Math.random()) * 0.01D;
    		}
 
    		float f = MathHelper.sqrt_double(d * d + d1 * d1);
        	float f1 = 0.4F;
 
        	target.isAirBorne = true;
    	        target.motionX /= 2D;
        	target.motionY /= 2D;
        	target.motionZ /= 2D;
        	target.motionX += (d / (double)f) * (double)f1 * 2;
	    	target.motionY += 0.40000000596046448D;
	    	target.motionZ += (d1 / (double)f) * (double)f1 * 2;
 
	    	if (target.motionY > 0.40000000596046448D)
	    	{
		    target.motionY = 0.40000000596046448D;
		}

You insert this in the attack event, if this is what you are looking for.

However, you have to modify to your liking.

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.