Posted September 15, 201510 yr Hi, Whenever I shoot the custom arrow I made, using the custom bow, in survival mod (which is interesting), it has a slight issue. When shoot the arrow far enough, it's okay, but if I shoot the arrow to a close range, this happens: I'm really not sure what does that. This is the custom arrow class - https://github.com/xJon/Jons-Useless-Mod/blob/master/src/main/java/xjon/jum/entity/projectile/EntityUselessArrow.java Any help is appreciated. Thanks! Why are you reading this?
September 19, 201510 yr xjon.jum.init.UselessEntities#register(): Try setting updateFrequency for arrow to 3. Right now you have 5 which combined with this fact: xjon.jum.entity.projectile.EntityUselessArrow : 246 if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) Might be causing problem. But I doubt this is real problem :C I mean, from logical side it shouldn't happen, but worth a shot. You can always extend to e.g: this.ticksInAir >= 10 1.7.10 is no longer supported by forge, you are on your own.
September 19, 201510 yr Arrows have some special code to set the shooting entity on the client side when they spawn, which is what let's the arrow know not to hit the shooter right away. Your issue is partially that the client doesn't know about that, so the client arrow immediately hits the shooting player while the server arrow goes on its merry way. To fix it, implement IEntityAdditionalSpawnData and send the shooting entity's ID, then fetch the entity from the world when reading the data and set it as the shooting entity. Also, anything extending EntityArrow should have a tracking update frequency of 20; most other projectiles have a frequency of 10. Furthermore, I suggest you do not simply copy/paste entire vanilla classes - things like private static final String __OBFID = "CL_00001715"; and parameter names like 'p_12326_a' really hint at sloppy coding / lack of effort to understand what's going on in the class. http://i.imgur.com/NdrFdld.png[/img]
September 19, 201510 yr Author xjon.jum.init.UselessEntities#register(): Try setting updateFrequency for arrow to 3. Right now you have 5 which combined with this fact: xjon.jum.entity.projectile.EntityUselessArrow : 246 if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) Might be causing problem. But I doubt this is real problem :C I mean, from logical side it shouldn't happen, but worth a shot. You can always extend to e.g: this.ticksInAir >= 10 Tried to change it - it didn't really work. Arrows have some special code to set the shooting entity on the client side when they spawn, which is what let's the arrow know not to hit the shooter right away. Your issue is partially that the client doesn't know about that, so the client arrow immediately hits the shooting player while the server arrow goes on its merry way. To fix it, implement IEntityAdditionalSpawnData and send the shooting entity's ID, then fetch the entity from the world when reading the data and set it as the shooting entity. Also, anything extending EntityArrow should have a tracking update frequency of 20; most other projectiles have a frequency of 10. Furthermore, I suggest you do not simply copy/paste entire vanilla classes - things like private static final String __OBFID = "CL_00001715"; and parameter names like 'p_12326_a' really hint at sloppy coding / lack of effort to understand what's going on in the class. I changed everything as you said and implemented IEntityAdditionalSpawnData. The problem is that my writeSpawnData & readSpawnData aren't working really - the arrow is invisible. I tried to follow what you said but I probably did something wrong. Here's the code: @Override public void writeSpawnData(ByteBuf buffer) { buffer.writeInt(this.shootingEntity.getEntityId()); } @Override public void readSpawnData(ByteBuf additionalData) { this.shootingEntity.setEntityId(additionalData.readInt()); } Also, could you explain how is this issue not happening in creative mode? I really can't understand that. Thanks for the reply! Why are you reading this?
September 19, 201510 yr That's not at all how the #readSpawnData method should look... you are supposed to find the actual player ENTITY, not assign an ID to it - it already has an ID, and it's the same one that you are reading in from the packet. Entity shooter = worldObj.getEntityByID(buffer.readInt()); if (shooter instanceof EntityLivingBase) { shootingEntity = (EntityLivingBase) shooter; } http://i.imgur.com/NdrFdld.png[/img]
September 20, 201510 yr based only in mi personal experience i could say -you have not register the arrow entity in the tracking entitys (Dont doid it just make it worst) -you are shoting two arrows one in the server side and one in the local side and the one from the local side is the one bouncing back to fix this i have to add in the code of the onUpdate() a pieze of (chapuza) to kill the local side arrow only when hit some entity, and there is other problem that hapens when you break the block where the arrow hits, soo i have to add another (chapuza) to kill the server side arrow only when hit a block an enter in onground state and thast only two of the troubles you gonna get
September 20, 201510 yr Author That's not at all how the #readSpawnData method should look... you are supposed to find the actual player ENTITY, not assign an ID to it - it already has an ID, and it's the same one that you are reading in from the packet. Entity shooter = worldObj.getEntityByID(buffer.readInt()); if (shooter instanceof EntityLivingBase) { shootingEntity = (EntityLivingBase) shooter; } That fixed everything! But just so I'll understand, why are we setting the shootingEntity as an EntityLivingBase? Also, could you explain to me why did the issue happen only in survival mode? Thank you so much! Why are you reading this?
September 20, 201510 yr For arrows - because not only players can shoot arrows (skeletons?) and probably any other EntityLivingBase that you make shoot arrows with your mod. Why in survival? No idea, probably some hidden if statement. 1.7.10 is no longer supported by forge, you are on your own.
September 20, 201510 yr It only happens in survival because of this bit of code: if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer)this.shootingEntity).canAttackPlayer(entityplayer)) { movingobjectposition = null; } That's where the arrow has found a potential target, i.e. the player at < 5 ticks, but if the player is immune to damage due to being in creative mode, it completely ignores the impact and keeps going. http://i.imgur.com/NdrFdld.png[/img]
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.