Jump to content

Recommended Posts

Posted

I want my entity to stay where it is no matter what collides with it or anything (besides gravity and moving by itself), however, setting #canBePushed to false doesn't do anything. How do I do this?

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Posted

I don't need to post any code. I have an entity with canBePushed set to false. That's it.

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Posted

Dunno if this helps, but there's an attribute called knockback resistance

I might be terribly wrong.. Like really, really wrong. But I'm just trying to help.

Posted

Nope doesn't help. That only comes into effect if you hit it, not web. You collide with it.

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Posted

Well it's not really that hard to accomplish, just override all methods containing collide and or push.

 

Any how, here is the fix:

 

// if your entity is an instance of entityliving, you can disable leashing as well.
@Override
public boolean allowLeashing() {
	return false;
}

// I think this is used when the player has attacked this entity, could be wrong.
@Override
public void onCollideWithPlayer(EntityPlayer entityIn) {}

// this actually allows for damaging the entity, when it get hit it knocks the entity back, 
// if you'd want to prevent that you have to override EnitityLivingBase#knockBack.
@Override
public boolean canBeCollidedWith() {
	return false;
}

// obviously we dont want this
@Override
public boolean canBePushed() {
	return false; 
}

// not any entity can collide. if you want projectiles to still be
// effective, you will have to handle those yourself
@Override
protected void collideWithEntity(Entity p_82167_1_) {}

// checks for any entity within a certain boundingbox, eg minecarts
@Override
protected void collideWithNearbyEntities() {}

Posted

I have tried that, however that makes it so anything can walk through it. I want it to be solid so nothing can go through it and it won't move.

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Posted

I have tried that, however that makes it so anything can walk through it. I want it to be solid so nothing can go through it and it won't move.

 

Nowhere in your thread have you asked for the above, anyway, entities derived from EntityLivingBase can be walked through. By looking at the boats class you can see you can't walk through a boat, rather you walk on top of it like a halfslab. Some collision method(s) in the Entity class does not allow another entity to walk through it, I don't have time to search for it right now, maybe when I get back and remember it I can update this post. But I'd suggest to look into anything related to colliding in the Entity class or better, check what methods are overriden in the EntityLivingBase class containing something relevant to colliding.

 

If you have not found anything, you could do something dirty using the collideWithNearByEntities method. Check for entities in your entity's AABB, if that entity is inside of the AABB 'teleport' it back 1 position in the entity's current position. Something like this could create a jittery effect when the player keeps colliding with your entity, but that's like I said a dirty solution.

Posted

I also think that the collideWithEntity() method might be able to be used (also with canBeCollidedWith returning true) to adjust the position and keep it fixed and bounce the entity back. You could probably copy the code for how an entity collides with a block.

 

Another, different approach might be to create an invisible block at the same location.

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

Posted

I also think that the collideWithEntity() method might be able to be used (also with canBeCollidedWith returning true) to adjust the position and keep it fixed and bounce the entity back. You could probably copy the code for how an entity collides with a block.

 

Another, different approach might be to create an invisible block at the same location.

 

Yes I looked at that, however when the entity that collides with mine runs collideWithEntity(), that entity pushes back both itself and whatever it collided with. So even if I don't push my entity back, the other entity will.

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

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.