Skip to content

Conversation

ekedaigle
Copy link

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


// let vanilla run
super.onUpdate();
if (!isDead) return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

ACGaming referenced this pull request in ACGaming/OpenBlocksReopened Sep 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Item Cannon Can't shoot in the correct direction when aiming south

2 participants