Posted October 22, 201312 yr I´ve tried the following code for making a block pull away the players, but it also works with the other entitys. How can i make it work only in players?. Thx public class trampa extends Block { public trampa(int id, Material Material) { super(id, Material); } /** * Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been * cleared to be reused) */ public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { float f = 0.125F; return AxisAlignedBB.getAABBPool().getAABB((double)par2, (double)par3, (double)par4, (double)(par2 + 1), (double)((float)(par3 + 1) - f), (double)(par4 + 1)); } /** * Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity */ public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5EntityPlayer) { par5EntityPlayer.motionX *= -10D; par5EntityPlayer.motionZ *= -10D; } }
October 22, 201312 yr Hi you could try if (par5EntityPlayer instanceof EntityPlayer) { par5EntityPlayer.motionX *= -10D; par5EntityPlayer.motionZ *= -10D; } see here for more background information on Entity inheritance hierarchy... http://greyminecraftcoder.blogspot.com.au/2013/10/the-most-important-minecraft-classes_9.html -TGG
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.