Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HitboxFix

A plugin that allows expanding player and entity hitboxes server-side. It can be used to restore 1.8 hitboxes for modern clients.

It requires:

  • Bukkit/Spigot/Paper 1.8.8 with modern JDK support, like KigPaper
  • ProtocolLib, version 4.6.0 or higher
  • ViaVersion, version 5.11.0 or higher

Background

When the 1.9 update released, among the many combat-related changes was the removal of the hitbox attack margin for most entities, with the only exception being ghast fireballs. In 1.8 and below, an entity could be attacked up to 0.1 blocks outside of its hitbox, in all six directions. This effectively meant that all entity hitboxes had become smaller, and combat range was also slightly reduced.

This change has been the hardest to work around throughout the years, because it is mostly client side with little to no configuration options available to the server. Some of them get close, but aren't quite enough:

  • The entity_interaction_range attribute effectively increases combat range, but does not allow to hit outside of the hitbox, and also works with spherical distances as opposed to bounding box intersections.
  • The scale attribute can modify the entity's hitbox size, but it also makes entities appear larger visually.

Still to this day, there is no proper entity attribute/setting that allows changing the size of a player's hitbox.

Another change from the 1.9 update is that sneaking players now also get their hitbox shortened furthers. In 1.8, the hitbox of sneaking players would not change.

The attack_range component

In 1.21.11, with the addition of spears, Mojang added the attack_range item component, which allows defining minimum and maximum range, as well as the hitbox margin when using that item.

When this update was released, we quickly added support for it. However, there are a few drawbacks:

  • Because this was designed for spears to use (the default hitbox margin is 0.3, the one used for spears), applying this component to an item changes the way the client picks entities, to a more projectile-oriented approach. Most notably, this reintroduces the 1.8 "mouse delay" bug that was fixed in 1.11 and by mods, see MC-306943.
  • It also changes the way attack range is calculated from the perspective of mods that display the range when hitting, because it is now reported as originating from the regular hitbox and not the expanded one. Even worse, the client may allow picking an entity farther away and cancel the interaction later, which may not be reflected in those mods.
  • Being an item component, this requires an item to benefit from the extra range.
  • This still doesn't fix sneaking players having a different hitbox size.

Design

The plugin uses fake invisible entities that overlap with the real entity to increase the apparent size of the hitbox. When a player interacts with one of the fake entities, the interaction is redirected to the real entity. The same design can be seen on servers like Minemen Club and it is, currently and in our opinion, the best solution to the problem. It also works around the sneaking problem because the fake entities will simply not sneak.

For mobs, the plugin can use the 1.19.4 Interaction entity, which is basically just a phantom hitbox.

For players, a different design is required. When a player attacks another player on their client, there may be side effects on the client (see Entity#hurtClient).
Specifically, if a sprinting player attacks another player, their horizontal motion is reduced by 40%, which doesn't happen when attacking most other mobs. In legacy combat, this is the primary way to reduce knockback taken from attacks. This basically means that to spoof a player's hitbox we have to use fake players. There are other entities that could work, for example boats, minecarts, or shulker bullets, but they're a lot harder to work with due to their exotic dimensions.

The vanilla hitbox size for players is 0.6 blocks in width and 1.8 in height, and we need to increase each dimension by 0.1 in each direction. The default configuration spawns 4 fake players for each real player. They're all scaled 111.111...% (i.e. 2.0/1.8) so that their hitbox height is 2.0, which allows us to spawn them 0.1 blocks below the real player, and have the vertical axis fully covered. For the horizontal directions, the four entities are enough to cover the expanded hitbox when offset by 0.06666..., the player's coordinates are at the center of the hitbox, so that value is derived from 0.1 + the unscaled radius (0.3) - the scaled radius (0.3333...).

The minimum client version for the current implementation is 1.19.4, though this method can work on any version, including 1.9. Newer versions are preferred because:

  • Packet bundles (1.19.4) can guarantee processing of multiple related packets on the same tick
  • The aforementioned Interaction entity (1.19.4) allows for easy expansion of mob hitboxes.
  • Player info entries can be configured to be hidden from the tab list (1.19.3)
    • While this is nice to have, it's not too necessary because a Player Info Remove packet can be added to the bundle.
  • The generic.scale/minecraft:scale entity attribute (1.20.5) drastically reduces the number of fake players needed, the default config goes from 14 to 4

The recommended minimum version is 1.20.5, especially considering the other legacy combat-related improvements found in newer versions, like sword blocking/consumables.

It's also worth noting that this plugin merely serves as proof-of-concept, this does not depend on 1.8 functionality, so it can definitely be implemented on a modern server.

License

This plugin is distributed under the terms of the GPLv3. See LICENSE for details.

About

A plugin to restore the Minecraft 1.8 hitbox margin in newer clients

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages