I am currently working on a firewall block which will only allow player entity to walk through while other entities will be knocked back and set on fire.
I need to make the block so that other entities will still calculate pathfinding through the block, not around it while also making the block push them out when in contact. I may be able to do this in the onEntityCollidedWithBlock func. However, what code do i use to push other entities back and acting as if they have been melee attacked?
Ok, I have successfully made a walkthrough block that pushes back and set entities on fire, however, the ai still chooses to go around my block, how can I make the pathfinding AI ignore my block? I have tried to set isCollidable to false, set block bounds to 0 but its still not working
I looked at the code from the cobweb block and then replaced on entity collided with my own code. I'm sorry if the code is messy, I'm a newbie in minecraft modding:
@Override
public void onEntityCollidedWithBlock(World p_149670_1_, int x,
int y, int z, Entity entity) {
if (!(entity instanceof EntityPlayer)){
entity.setFire(5);
float damage = 5;
double moveX = entity.posX, moveZ = entity.posZ;
entity.attackEntityFrom(DamageSource.generic, damage);
if ((float)entity.posX > x)
moveX += 1;
else if ((float)entity.posX < x)
moveX -= 1;
if ((float)entity.posZ > z)
moveZ += 1;
else if ((float)entity.posY <z)
moveZ -= 1;
entity.setPosition(moveX, entity.posY, moveZ);
}
super.onEntityCollidedWithBlock(p_149670_1_, x, y,
z, entity);
}
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I need to make the block so that other entities will still calculate pathfinding through the block, not around it while also making the block push them out when in contact. I may be able to do this in the onEntityCollidedWithBlock func. However, what code do i use to push other entities back and acting as if they have been melee attacked?
reply if any of you want the code
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumHelp modders out by contributing to the Forge Ore Dictionary List! http://mce626.wix.com/odnlist
@Override
public void onEntityCollidedWithBlock(World p_149670_1_, int x,
int y, int z, Entity entity) {
if (!(entity instanceof EntityPlayer)){
entity.setFire(5);
float damage = 5;
double moveX = entity.posX, moveZ = entity.posZ;
entity.attackEntityFrom(DamageSource.generic, damage);
if ((float)entity.posX > x)
moveX += 1;
else if ((float)entity.posX < x)
moveX -= 1;
if ((float)entity.posZ > z)
moveZ += 1;
else if ((float)entity.posY <z)
moveZ -= 1;
entity.setPosition(moveX, entity.posY, moveZ);
}
super.onEntityCollidedWithBlock(p_149670_1_, x, y,
z, entity);
}