Posted June 22, 20196 yr Not really sure how to search for this since my searches come up with stuff I'm not looking for. When an entity collides with a block, is there a simple way to get the face of the block that it collided with (i.e. North South East West Up Down)? I was overriding "onEntityCollidedWithBlock" but I could put it somewhere else if it's easier to get elsewhere. Any ideas? I guess one option would be to get the position of the entity and see if it's NSEWUD compared to the block? Edited June 22, 20196 yr by stepsword
June 22, 20196 yr Author Or, if anyone knows where the code is for shields reflecting arrows? The only related thing I can find in Shields is EntityLivingBase.knockback but that does not apply to arrows.
June 23, 20196 yr Author Thanks, @diesieben07. I did see that part of the code, namely this: if (amount > 0.0F && this.canBlockDamageSource(source)) { this.damageShield(amount); amount = 0.0F; if (!source.isProjectile()) { Entity entity = source.getImmediateSource(); if (entity instanceof EntityLivingBase) { this.blockUsingShield((EntityLivingBase)entity); } } flag = true; } But blockUsingShield doesn't actually redirect the arrow - it only calls .knockback() if the damage source is a living entity. It may be obvious from my above posts but I was trying to reflect arrows off a block, so I wanted to see how shields coded the "bounce" part (and for some reason I cannot find the code for that animation anywhere), and then I could manually do the NSEWUD check. But anyway I ended up finding the problem that was preventing bounces - ArrowEntity sets a private variable "inGround" which as far as I can tell can't be modified by any setter methods, and it seems to prevents the arrow from moving once it's buried in a block. Ended up using ObfuscationReflectionHelper to change it - I don't really like that "solution" since it seems hacky, but I'll keep it til I find something better if it exists. Edited June 23, 20196 yr by stepsword
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.