Fabric API

Fabric API

106M Downloads

Side-aware Block.getPickStack

fnuecke opened this issue ยท 6 comments

commented

For some blocks it is necessary to know the side when trying to get the ItemStack via middle-click to return the expected result. Thinking one step further, the hit information or at least x/y/z offset might be nice, as well, I guess. Possibly an interface Blocks can implement?

My current (as I've been told evil) mixin looks like this. Will try to get rid of the @Redirect at least, until this makes it in...

commented

The issue I'd see with this is that getPickStack may be called (by mods) on any block, not just the one the player is looking at. Using the global player hitResult is potentially unexpected implicit behaviour.

commented

I looked into this a couple of days ago, and then realised it was possible to get the current hit result with MinecraftClient.getInstance().hitResult.

I'm not sure how much it's worth adding a variant of getPickStack which accepts a HitResult, given that it can be emulated pretty easily. However, there may be some use-cases I'm missing.

commented

Is getPickStack client-side-only?

commented

Yes.

commented

Well then, once we add environment stripping that settles it, doesn't it?... At least for now

commented

Solved in 0.2.0.