Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix automatic rotate for attached entities #12392

Merged
merged 1 commit into from
Jul 17, 2022

Conversation

appgurueu
Copy link
Contributor

@appgurueu appgurueu commented May 31, 2022

Trivial fix to make automatic rotation work for attached entities.

How to test

minetest.register_entity("testentities:spinner", {
	initial_properties = {
		visual = "cube",
		textures = {"a", "a", "a", "a", "a", "a"},
		automatic_rotate = math.pi,
	},
	on_activate = function(self)
		self.object:set_armor_groups({punch_operable = 1})
	end,
	on_punch = function(self, puncher)
		self.object:set_attach(puncher)
	end
})

then /spawnentity testentities:spinner and punch it to attach

@sfan5
Copy link
Member

sfan5 commented May 31, 2022

This is so trivial it's suspicious. Can you try to find out why it was disabled for attached entities?

@sfan5 sfan5 added the Bugfix 🐛 PRs that fix a bug label May 31, 2022
@appgurueu
Copy link
Contributor Author

appgurueu commented May 31, 2022

  1. b22168d initially introduced this feature for dropped items; attachments didn't exist back then
  2. 52fcb0b#diff-4e878b8f5e372f965d18fca8ef0492cacbd881af375263277e55ef2e6c138728L1050 added this check but no reason seems to be given; at that time the automatic rotation was implemented over set_yaw however which means it couldn't possibly work for attachments
  3. Make automatic_rotate relative, allow setting rotation #8468 changed the implementation to use the scene node, which means removing the check now works fine (at least from my brief testing of this PR); the PR author @pgimeno already anticipated that, but apparently planned a separate PR?

What is not covered by this patch is rotation of attachments. This means that e.g. a propeller attached to a plane is not possible without adding a new property. Current plans are to submit a separate PR for that.

With all this in mind it's worth noting that at the time this check was added it was reasonable because setting the yaw would've taken no effect either way; I just wonder why @pgimeno's PR didn't remove it and would like to hear his input on this.

That said this PR seems to work fine and I believe extensive testing of this is worth more than trying to dig up the past.

@erlehmann
Copy link
Contributor

removing the check now works fine (at least from my brief testing of this PR)

What exactly did you test? Given that the possible attachment chains can be as hilarious “a player with arrows in them sits on a mob that is in a boat that is in a minecart”, I am as suspicious of this as @sfan5 is.

@appgurueu
Copy link
Contributor Author

appgurueu commented Jun 3, 2022

removing the check now works fine (at least from my brief testing of this PR)

What exactly did you test? Given that the possible attachment chains can be as hilarious “a player with arrows in them sits on a mob that is in a boat that is in a minecart”, I am as suspicious of this as @sfan5 is.

Then please test it.

Copy link
Member

@sfan5 sfan5 left a comment

Choose a reason for hiding this comment

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

Works as advertised

@appgurueu
Copy link
Contributor Author

appgurueu commented Jul 21, 2022

@corarona @erlehmann turns out MCL2 relies on this being broken; wielditems have started spinning since they have automatic rotate set...

See the following video by @rollerozxa: https://media.discordapp.net/attachments/369123125021114369/999773166656290846/2022-07-21_22-21-42.mp4

The fix is trivial: Just remove the line https://git.minetest.land/MineClone2/MineClone2/src/commit/69d1c26a155af0d7315ac29cd37060928b9cde24/mods/PLAYER/mcl_wieldview/init.lua#L87

@erlehmann
Copy link
Contributor

erlehmann commented Jul 22, 2022

@appgurueu wait, why is it set there though?

This is so trivial it's suspicious.

Wise words.

@erlehmann
Copy link
Contributor

@EliasFleckenstein03 according to git blame you added the automatic_rotate = 1.5 there. Why did you do it?

@rubenwardy can we get a CDB search for automatic_rotate to determine what else this might have affected?

@rubenwardy
Copy link
Member

@appgurueu
Copy link
Contributor Author

@appgurueu wait, why is it set there though?

This is so trivial it's suspicious.

What's suspicious is that modders have been cargo-culting arbitrary automatic_rotate values in their object properties.

@LizzyFleckenstein03
Copy link
Contributor

@EliasFleckenstein03 according to git blame you added the automatic_rotate = 1.5 there. Why did you do it?

When I rewrote the wieldview mod I copied some of the old code. No idea what automatic_rotate does tbh.

@erlehmann
Copy link
Contributor

What's suspicious is that modders have been cargo-culting arbitrary automatic_rotate values in their object properties.

For future reference: Full recognition before processing (i.e. following LANGSEC principles) would have prevented this.

@appgurueu appgurueu deleted the fix-auto-rot branch March 31, 2024 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants