Conversation
src/main/java/openblocks/common/tileentity/TileEntityCannon.java
Outdated
Show resolved
Hide resolved
|
|
||
| // let vanilla run | ||
| super.onUpdate(); | ||
| if (!isDead) return; |
There was a problem hiding this comment.
It was supposed to be isDead, then whole thing becomes more sensible.
Basically, purpose of this code was to let super.onUpdate handle all state changes, then overwrite movement with our own. Restoring just motion before update leads to numerical errors, which would cause mismatch with canon targeting algorithm (not that it was super precise in first place though).
There was a problem hiding this comment.
Yea, although with isDead instead it was double-moving the item, so that would have to get fixed too. It's basically a choice between the way I've got it, which is a a bit of a hack no doubt, and duplicating half the code inside EntityItem.onUpdate. If you'd prefer it the other way, that's fine by me. I wouldn't worry about the numerical errors though--these values are all doubles pretty close to 1, so back-of-the-envelope calculation says worst case is an acceleration of about 4.5e-15 blocks/s^2.
Based on changes by @ekedaigle
This fixes a couple bugs with ItemCannons:
The location of the spawned items could collide with the blocks surrounding the cannon in certain directions. This was fixed by making the items spawn roughly where the tip of the cannon barrel is.
The overridden code in EntityItemProjectile wasn't actually running due to the "!isDead()" check. This was causing the items to be effected by air drag.
EntityItemProjectile was calling move() and super.onUpdate(), which also calls move. This was causing the velocity to be added twice.
This should close #995