sp614x / optifine

1.81k stars 416 forks source link

[Suggestion] Block Mining Boundaries by Resource Packs #2809

Open ZwipZwapZapony opened 5 years ago

ZwipZwapZapony commented 5 years ago

When looking at a block, a black box outline thing is shown around its edges. Looking "within" those "edges" allows you to mine a block, and looking "beside" those "edges" allows you to mine a block or attack an entity behind it.

I suggest allowing resource packs to change this shape. For example, a resource pack could be used to make this "block boundary" conform to the exact shape of a fence block (allowing players to click on something behind/between the two horizontal planks of connected fences), or shrink its size for torches/bamboo blocks to match the exact block size, or have it match some "sticking out" bits of custom 3D block models.

If Minecraft only handles "precise sub-block block boundary" checks if you're looking within the single block's "16x16x16 pixel" space, the custom resource pack block boundary things should be limited to being within the whole block. If not, I'd say that it should be limited to a 3x3x3 block region (just like custom 3D block models themselves).

~~Besides exposing this to/reading this from resource packs itself, I can think of two complications that might arise. 1 - If "block mining ray-tracing", to determine which block a player mines, is handled server-side, not client-side, this wouldn't work so well (at least not without a server mod, which is outside OptiFine's scope). That would hinder this from becoming a reality at all. 2 - If the collisions of a block is based on the same stuff as the "block mining" boundary, that could lead to some problems with client-side movement prediction. That should be fixable by separating those two concepts, only allowing the "block mining" boundary to be edited while the collision for entities would stay vanilla.~~ Edit: Block mining is handled client-side (the server only checks if the block is too far away, not if there's an obstruction), so 1 isn't an issue, and vanilla Minecraft has different world collision and "block mining" boundaries for bamboo blocks, so 2 (hopefully) isn't an issue.

~

TL;DR: I suggest for resource packs to be able to change the "block mining" boundary thing for blocks.

Stereo528 commented 5 years ago

optifine can't really do that, especially for servers where optifine cant be a mod there and it would be different for every single pack, either this would be a separate mod or something vanilla adds, and it doesn't really fit the style of opti since that means changing something major, opti is more focused on optimization of the game for more FPS and the optional Resource Pack visual, not physical which even in vanilla they cant change physical things only textures.

ZwipZwapZapony commented 5 years ago

I've received confirmation from two Minecraft modders that block mining (and therefore (probably?) also entity attacking, though they didn't confirm or deny that directly) is handled client-side, with the server just verifying that the block isn't too far away (while not checking for any obstructions or such), which means that it should be possible to allow client-side block-mining hitbox changes.

I understand that OptiFine implementing this can be a large risk for multiplayer servers (e.g. a "click through the middle of blocks to attack entities through them" resource pack or such), but I, myself, would still like to do this in resource packs for non-griefing reasons (e.g. making the mining hitbox of a torch or a rail match the visual block more closely).

sp614x commented 5 years ago

Hit detection (hitbox check) is done on the client side. The server could only do some general checks to detect hacked clients, for example check the hand reach. In vanilla the hitboxes are hardcoded, but OptiFine could probably make them configurable. However hitboxes are part of the game mechanics. For example: can the player walk between two blocks is decided by the hitboxes of the blocks and the distance between them. Changing the game mechanics with a resource pack is generally a bad idea. For example changing the slab hitbox height could break some contraptions designed to stop mobs. Separating click hit detection from movement hit detection is too complicated to be considered realistic. Even if only click hit detection is implemented, it could still be problematic with custom maps where the client can reach places that are designed to be unreachable.

ZwipZwapZapony commented 5 years ago

Question related to "Separating click hit detection from movement hit detection is too complicated to be considered realistic.": Bamboo blocks have the mining hitbox going 2 or 3 "pixels" farther out than the (vanilla / non-resource-packed) visual element, but a player/mob can stand right up against the visual element (meaning that a player/mob can be 2 or 3 "pixels" inside of the block mining boundary). This means that world collision and mining ray-tracing doesn't necessarily have the same shape even in vanilla Minecraft (at least not for bamboo blocks). Does that mean that it'd be feasible to allow client-side mining ray-tracing shape changes without having to make too much hacky stuff?

~

As for "changing the slab hitbox height" and such, I specifically don't want to be able to change the world collision shapes (that could lead to cheating), just mining ray-tracing shapes (that could also lead to cheating, but less directly?).

I do understand that this is a "moral grey area" when it comes to usage on competitive multiplayer servers. I'd however still appreciate being able to tailor mining ray-tracing shapes to fit custom 3D models, if possible.

"it could still be problematic with custom maps" Yes, but if they use a resource pack specifically to cheat on custom maps, that's a user choice, and they could find other ways to cheat anyway. And if they don't use a resource pack specifically to cheat, the chance of their other resource packs allowing cheating a custom map (e.g. by clicking through holes in a door and clicking on something important) is existent, yes, but small (in my opinion), a little more so if a custom map provides its own resource pack to use (though I understand that a lower-priority resource pack's custom mining shapes would still shine through).

~

To summarize, I'd like to be able to change the mining ray-tracing shape of blocks, and specifically not be able to change world collision shapes, while vanilla Minecraft already has an example of the two being separate (bamboo blocks). With that in mind, I'd like if you could reconsider your decision on not doing this, but if you still decide to not do it, I'm okay with that.