Jump to content

problems with onEntityWalking


knokko

Recommended Posts

hello people,

 

I have a different question this time.

I was trying to make a block that gives entities the wither effect if they walk over the block.

but only I get the wither effect if I walk over the block.

 

public void onEntityWalking(World world, int x, int y, int z, Entity entity){

((EntityLivingBase) entity).addPotionEffect(new PotionEffect(20,400,0,false));

 

}

 

Does anybody know why it doesnt work?

Link to comment
Share on other sites

I think there can be only a couple possible causes.  Either you didn't override the function properly, or not all entities call this, or the potion effect isn'w working as expected.

 

It looks like you have the right parameters to override, but you should add the @Override annotation before the method to confirm.  It will give you an error if it is not the right parameter template.

 

For the next thing, you can confirm that onEntityWalking() is called by all entities by using your IDE to trace the "call hierarchy".  I checked and it seems to be called for all entities during their movement, so it should be being called.  To really confirm, I suggest you put a console statement in your method to print out every time there is entity walking on your block.

 

Assuming that you've properly overridden the method, and that all entities actually do call the method, then it must be that the potion effect isn't working as expected.  I don't know a lot about potions, so maybe someone else has ideas there.

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

Link to comment
Share on other sites

I have done what you have said.

And I have used "system.out.printin(anyone walked over the block)"

 

In the console appears everytime any entity walks over the block "anyone walked over the block."

But only I get the wither effect.

 

I have added the @Override annotation but there happens the same as before.

I am going to  look now how the wither gives potion effects to all entities.

 

EDIT:

 

it is now

@Override
public void onEntityWalking(World world, int x, int y, int z, Entity entity){
	((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.wither.id, 20 * 20, 1));
	System.out.println("anyone walked over the block");

}

 

This is the stuff in the EntityWitherSkull class.

But it still only works on me.

please help.

Link to comment
Share on other sites

Are the other entities actually walking over the block or are they just standing still? That method i think is only called when they are moving.

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/

Link to comment
Share on other sites

I have pushed the entities over the block.

But now I have found what goes wrong:

 

every entity that walks over the block get the wither effect.

But I have changed my gamemode to survival and I had the effect, but it didnt hurt me anyway, only my hearts were gray.

And there weren't any particles on me to.

Does anybody know why the wither effect doesn't hurt anyone.

 

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.