Jump to content

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


Recommended Posts

Posted

public void spawnShockWave() {

	//System.out.println("Spawned");

	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;

		//System.out.println(entityplayer);

		double d = Math.random();
		if (d < 0.2) {
			//System.out.println("PUSH");
			entityplayer.addVelocity(x, y, z);
		}

	}

}

 

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

 

https://bitbucket.org/Dragonisser/cobaltmod/src/2a6e45c02444af95fc11af6b881cea78c633b164/cobaltmod/entity/EntityCobaltGuardian.java?at=master#cl-230

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:

https://bitbucket.org/Dragonisser/cobaltmod/src/2a6e45c02444af95fc11af6b881cea78c633b164/cobaltmod/items/ItemWindAxe.java?at=master#cl-119

 

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?

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.