Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-04 23:30:24 +01:00
Hitbox fix options
Dieser Commit ist enthalten in:
Ursprung
89a01b3997
Commit
e38bdffc84
@ -0,0 +1,73 @@
|
||||
package us.myles.ViaVersion.bukkit.listeners.multiversion;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
||||
import us.myles.ViaVersion.ViaVersionPlugin;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||
import us.myles.ViaVersion.bukkit.listeners.ViaBukkitListener;
|
||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class PlayerSneakListener extends ViaBukkitListener {
|
||||
private Method getHandle;
|
||||
private Method setSize;
|
||||
private boolean is1_9Fix;
|
||||
private boolean is1_14Fix;
|
||||
|
||||
public PlayerSneakListener(ViaVersionPlugin plugin, boolean is1_9Fix, boolean is1_14Fix) {
|
||||
super(plugin, null);
|
||||
this.is1_9Fix = is1_9Fix;
|
||||
this.is1_14Fix = is1_14Fix;
|
||||
try {
|
||||
getHandle = Class.forName(plugin.getServer().getClass().getPackage().getName() + ".entity.CraftPlayer").getMethod("getHandle");
|
||||
setSize = Class.forName(plugin.getServer().getClass().getPackage().getName()
|
||||
.replace("org.bukkit.craftbukkit", "net.minecraft.server") + ".EntityPlayer").getMethod("setSize", Float.TYPE, Float.TYPE);
|
||||
} catch (ClassNotFoundException | NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
getPlugin().getServer().getScheduler().runTaskTimer(getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player onlinePlayer : getPlugin().getServer().getOnlinePlayers()) {
|
||||
try {
|
||||
final Object handle = getHandle.invoke(onlinePlayer);
|
||||
final Class<?> aClass = Class.forName(getPlugin().getServer().getClass().getPackage().getName()
|
||||
.replace("org.bukkit.craftbukkit", "net.minecraft.server") + ".EntityPlayer");
|
||||
System.out.println(aClass.getField("length").get(handle));
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 1, 1);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void playerToggleSneak(final PlayerToggleSneakEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final int protocolVersion = getUserConnection(player).get(ProtocolInfo.class).getProtocolVersion();
|
||||
if (is1_14Fix && protocolVersion >= ProtocolVersion.v1_14.getId()) {
|
||||
setHight(player, event.isSneaking() ? 1.5F : 1.8F);
|
||||
} else if (is1_9Fix && protocolVersion >= ProtocolVersion.v1_9.getId()) {
|
||||
setHight(player, event.isSneaking() ? 1.6F : 1.8F);
|
||||
}
|
||||
}
|
||||
|
||||
private void setHight(Player player, float hight) {
|
||||
try {
|
||||
setSize.invoke(getHandle.invoke(player), 0.6F, hight);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -254,8 +254,19 @@ public class BukkitViaConfig extends Config implements ViaVersionConfig {
|
||||
public boolean isTruncate1_14Books() {
|
||||
return getBoolean("truncate-1_14-books", false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isLeftHandedHandling() {
|
||||
return getBoolean("left-handed-handling", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean is1_9HitboxFix() {
|
||||
return getBoolean("change-1_9-hitbox", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean is1_14HitboxFix() {
|
||||
return getBoolean("change-1_14-hitbox", false);
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||
import us.myles.ViaVersion.bukkit.classgenerator.ClassGenerator;
|
||||
import us.myles.ViaVersion.bukkit.listeners.UpdateListener;
|
||||
import us.myles.ViaVersion.bukkit.listeners.multiversion.PlayerSneakListener;
|
||||
import us.myles.ViaVersion.bukkit.listeners.protocol1_9to1_8.*;
|
||||
import us.myles.ViaVersion.bukkit.providers.BukkitBlockConnectionProvider;
|
||||
import us.myles.ViaVersion.bukkit.providers.BukkitInventoryQuickMoveProvider;
|
||||
@ -76,6 +77,13 @@ public class BukkitViaLoader implements ViaPlatformLoader {
|
||||
storeListener(new DeathListener(plugin)).register();
|
||||
storeListener(new BlockListener(plugin)).register();
|
||||
|
||||
if (ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_14.getId()) {
|
||||
boolean use1_9Fix = plugin.getConf().is1_9HitboxFix() && ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_9.getId();
|
||||
if (use1_9Fix || plugin.getConf().is1_14HitboxFix()) {
|
||||
storeListener(new PlayerSneakListener(plugin, use1_9Fix, plugin.getConf().is1_14HitboxFix())).register();
|
||||
}
|
||||
}
|
||||
|
||||
if ((Bukkit.getVersion().toLowerCase().contains("paper")
|
||||
|| Bukkit.getVersion().toLowerCase().contains("taco")
|
||||
|| Bukkit.getVersion().toLowerCase().contains("torch"))
|
||||
|
@ -10,7 +10,7 @@ import java.net.URL;
|
||||
import java.util.*;
|
||||
|
||||
public class BungeeViaConfig extends Config implements ViaVersionConfig {
|
||||
private static List<String> UNSUPPORTED = Arrays.asList("nms-player-ticking", "item-cache", "anti-xray-patch", "quick-move-action-fix", "velocity-ping-interval", "velocity-ping-save", "velocity-servers", "blockconnection-method");
|
||||
private static List<String> UNSUPPORTED = Arrays.asList("nms-player-ticking", "item-cache", "anti-xray-patch", "quick-move-action-fix", "velocity-ping-interval", "velocity-ping-save", "velocity-servers", "blockconnection-method", "change-1_9-hitbox", "change-1_14-hitbox");
|
||||
|
||||
public BungeeViaConfig(File configFile) {
|
||||
super(new File(configFile, "config.yml"));
|
||||
@ -307,8 +307,19 @@ public class BungeeViaConfig extends Config implements ViaVersionConfig {
|
||||
public boolean isTruncate1_14Books() {
|
||||
return getBoolean("truncate-1_14-books", false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isLeftHandedHandling() {
|
||||
return getBoolean("left-handed-handling", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean is1_9HitboxFix() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean is1_14HitboxFix() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public abstract class ViaListener {
|
||||
protected boolean isOnPipe(UUID uuid) {
|
||||
UserConnection userConnection = getUserConnection(uuid);
|
||||
return userConnection != null &&
|
||||
userConnection.get(ProtocolInfo.class).getPipeline().contains(requiredPipeline);
|
||||
(requiredPipeline == null || userConnection.get(ProtocolInfo.class).getPipeline().contains(requiredPipeline));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -316,11 +316,25 @@ public interface ViaVersionConfig {
|
||||
* @return True if enabled
|
||||
*/
|
||||
boolean isTruncate1_14Books();
|
||||
|
||||
|
||||
/**
|
||||
* Handles left handed info by using unused bit 7 on Client Settings packet
|
||||
*
|
||||
* @return True if enabled
|
||||
*/
|
||||
boolean isLeftHandedHandling();
|
||||
|
||||
/**
|
||||
* Fixes velocity bugs due to different hitbox for 1.9-1.13 clients on 1.8 servers.
|
||||
*
|
||||
* @return True if enabled
|
||||
*/
|
||||
boolean is1_9HitboxFix();
|
||||
|
||||
/**
|
||||
* Fixes velocity bugs due to different hitbox for 1.14+ clients on sub 1.14 servers.
|
||||
*
|
||||
* @return True if enabled
|
||||
*/
|
||||
boolean is1_14HitboxFix();
|
||||
}
|
||||
|
@ -120,6 +120,12 @@ disable-1_13-auto-complete: false
|
||||
fix-low-snow-collision: false
|
||||
# In 1.14 the client page limit has been upped to 100 (from 50). Some anti-exploit plugins ban when clients go higher than 50. This option cuts edited books to 50 pages.
|
||||
truncate-1_14-books: false
|
||||
# This prevents clients using 1.9-1.13 on 1.8 servers from receiving no knockback/having velocity bugs whilst sneaking under a block.
|
||||
change-1_9-hitbox: false
|
||||
# Similar to the above, but for 1.14+ players on 1.8-1.13 servers.
|
||||
# WARNING: This gives 1.14+ players the ability to sneak under blocks, that players under that version cannot (sneaking in places that are only 1.5 blocks high)!
|
||||
# Another thing to remember is that those players might be missed by projectiles and other hits directed at the very top of their head whilst sneaking.
|
||||
change-1_14-hitbox: false
|
||||
#
|
||||
# Enable serverside block-connections for 1.13+ clients
|
||||
serverside-blockconnections: false
|
||||
|
@ -13,7 +13,7 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class SpongeViaConfig extends Config implements ViaVersionConfig {
|
||||
private static List<String> UNSUPPORTED = Arrays.asList("anti-xray-patch", "bungee-ping-interval", "bungee-ping-save", "bungee-servers", "velocity-ping-interval", "velocity-ping-save", "velocity-servers", "quick-move-action-fix");
|
||||
private static List<String> UNSUPPORTED = Arrays.asList("anti-xray-patch", "bungee-ping-interval", "bungee-ping-save", "bungee-servers", "velocity-ping-interval", "velocity-ping-save", "velocity-servers", "quick-move-action-fix", "change-1_9-hitbox", "change-1_14-hitbox");
|
||||
private final PluginContainer pluginContainer;
|
||||
|
||||
public SpongeViaConfig(PluginContainer pluginContainer, File configFile) {
|
||||
@ -260,8 +260,19 @@ public class SpongeViaConfig extends Config implements ViaVersionConfig {
|
||||
public boolean isTruncate1_14Books() {
|
||||
return getBoolean("truncate-1_14-books", false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isLeftHandedHandling() {
|
||||
return getBoolean("left-handed-handling", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean is1_9HitboxFix() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean is1_14HitboxFix() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import java.net.URL;
|
||||
import java.util.*;
|
||||
|
||||
public class VelocityViaConfig extends Config implements ViaVersionConfig {
|
||||
private static List<String> UNSUPPORTED = Arrays.asList("nms-player-ticking", "item-cache", "anti-xray-patch", "quick-move-action-fix", "bungee-ping-interval", "bungee-ping-save", "bungee-servers", "blockconnection-method");
|
||||
private static List<String> UNSUPPORTED = Arrays.asList("nms-player-ticking", "item-cache", "anti-xray-patch", "quick-move-action-fix", "bungee-ping-interval", "bungee-ping-save", "bungee-servers", "blockconnection-method", "change-1_9-hitbox", "change-1_14-hitbox");
|
||||
|
||||
public VelocityViaConfig(File configFile) {
|
||||
super(new File(configFile, "config.yml"));
|
||||
@ -312,8 +312,20 @@ public class VelocityViaConfig extends Config implements ViaVersionConfig {
|
||||
public boolean isTruncate1_14Books() {
|
||||
return getBoolean("truncate-1_14-books", false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isLeftHandedHandling() {
|
||||
return getBoolean("left-handed-handling", true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean is1_9HitboxFix() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean is1_14HitboxFix() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren