Jump to content

[Solved] .addVelocity() doesnt seem to work without getting damaged


Recommended Posts

public void spawnShockWave() {


	if (this.worldObj.getClosestVulnerablePlayerToEntity(this, 10.0D) != null) {
		EntityLivingBase entityplayer = (EntityLivingBase) this.worldObj.getClosestVulnerablePlayerToEntity(this, 10.0D);

		double x = Math.sin(entityplayer.rotationYaw * Math.PI / 180) * 1.0D;
		double z = Math.cos(entityplayer.rotationYaw * Math.PI / 180) * 1.0D;
		double y = 1.0D;


		double d = Math.random();
		if (d < 0.2) {
			entityplayer.addVelocity(x, y, z);




Well this is my attempt to push the player away from a certain entity.



It gets called where //System.out.println("FIREBALL 2"); is written.(Old code, thats why it isnt written there ^^)


But nothing happens. I use the same at my windaxe:



I also tried to use EntityPlayer. I even get the variables like


- entityplayer.rotationYaw

- entityplayer


but nothing happens to me.



I added right now this "entityplayer.attackEntityFrom(DamageSource.cactus, 0.1F);" under .addVelocity() and suddenly i get thrown away.


Does someone knows why it only works when i get damaged? Or did i make a stupid mistake xD?

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.

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.