gnembon / carpet-extra

Extra Features for Carpet Mod
GNU Lesser General Public License v3.0
291 stars 62 forks source link

Improve dispensersToggleThings Note block comparability with Fabrication #283

Closed ringprod closed 1 year ago

ringprod commented 1 year ago

Fabrication has a few features that use the PlayerEntity from the onUse function. Specifically, "Exact note block tuning," which, if right clicked with a stack of sticks, sets the pitch of the note block to the size of the stack minus one. I thought this would work perfectly with dispensersToggleThings because it requires a stick to toggle things, but it would crash due to passing in a null for PlayerEntity.

altrisi commented 1 year ago

Completely missed this PR, creating a player entity for this was looked at when adding this rule, but it was discarded because it seemed expensive to initialize a PlayerEntity for this (#17).

I see you reuse one, wondering if that has implications, the PlayerEntity constructor seems to do a bunch of stuff when creating a player. Also I'd move the instance to a static final in the fake player class instead so you can remove the lazy init.

One thing to note is that that single instance is using the world from the first activation, don't know if that may cause issues if later activating a dispenser in another dimension.

What do you think?

altrisi commented 1 year ago

Going to do this in a different way.

ringprod commented 1 year ago

https://gitlab.com/supersaiyansubtlety/dispenser_configurator/ this might be worth looking at as well