Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f42f824ed | ||
|
|
97f8b47946 | ||
|
|
5966e7ca73 | ||
|
|
757a35e064 | ||
|
|
cd779a9d91 | ||
|
|
b21c31dd5e | ||
|
|
ebfc3f4b22 | ||
|
|
70a37506f7 | ||
|
|
906498456d |
No files matched your search
@@ -0,0 +1,25 @@
|
||||
Minecraft doesn’t factor in network latency when determining a player's actions on the server.
|
||||
This causes the server to receive outdated information that doesn’t reflect the player's clientside position.
|
||||
As a result, players take negative velocity when they're on the ground clientside, but not serverside.
|
||||
|
||||
This plugin handles knockback as if it were calculated clientside, ensuring that no player is at a disadvantage,
|
||||
regardless of their own or their opponent’s connection.
|
||||
|
||||
## Frequently Asked Questions (FAQ)
|
||||
|
||||
### Does this change put high ping players at a disadvantage?
|
||||
**It depends on the player.** Some may notice a difference if they're used to relying on high ping to reduce knockback. For others, it could actually be an advantage.
|
||||
|
||||
### How does this change benefit high ping players?
|
||||
**Knockback control.** For example, it will be easier to escape crit chains and punish crit.
|
||||
|
||||
### Why was the configurability of ping offset removed?
|
||||
**It promotes consistency across all servers.** Extensive testing with top players has shown that an offset of 20 provides a balanced experience for everyone.
|
||||
|
||||
### How do I change the ping offset?
|
||||
**You must run a modified build of KnockbackSync.** The variable can be changed inside of the [PlayerData](src/main/java/me/caseload/knockbacksync/manager/PlayerData.java) class.
|
||||
|
||||
## License
|
||||
GNU General Public License v3.0 or later
|
||||
|
||||
See [COPYING](COPYING) to see the full text.
|
||||
@@ -8,7 +8,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
@@ -37,15 +36,4 @@ public class PlayerJoinQuitListener implements Listener {
|
||||
|
||||
PlayerDataManager.removePlayerData(uuid);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerKick(PlayerKickEvent event) {
|
||||
UUID uuid = event.getPlayer().getUniqueId();
|
||||
PlayerData playerData = PlayerDataManager.getPlayerData(uuid);
|
||||
|
||||
if (playerData.isInCombat())
|
||||
playerData.quitCombat(true);
|
||||
|
||||
PlayerDataManager.removePlayerData(uuid);
|
||||
}
|
||||
}
|
||||
@@ -37,14 +37,18 @@ public class PlayerKnockbackListener implements Listener {
|
||||
|
||||
Vector velocity = victim.getVelocity();
|
||||
Double verticalVelocity = playerData.getVerticalVelocity();
|
||||
|
||||
if (verticalVelocity == null || !playerData.isOnGround(velocity.getY()))
|
||||
return;
|
||||
|
||||
Long lastAdjustment = playerData.getLastAdjustment();
|
||||
if (lastAdjustment != null && System.currentTimeMillis() - lastAdjustment < 250)
|
||||
return;
|
||||
|
||||
Vector adjustedVelocity = velocity.clone().setY(
|
||||
verticalVelocity
|
||||
);
|
||||
|
||||
victim.setVelocity(adjustedVelocity);
|
||||
playerData.setLastAdjustment(System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
@@ -2,17 +2,16 @@ package me.caseload.knockbacksync.manager;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class CombatManager {
|
||||
|
||||
private static final Set<UUID> combatPlayers = new HashSet<>();
|
||||
private static final Set<UUID> combatPlayers = ConcurrentHashMap.newKeySet();
|
||||
|
||||
public static @NotNull Set<UUID> getPlayers() {
|
||||
return Collections.unmodifiableSet(combatPlayers);
|
||||
return combatPlayers;
|
||||
}
|
||||
|
||||
public static void addPlayer(UUID uuid) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import me.caseload.knockbacksync.KnockbackSync;
|
||||
import me.caseload.knockbacksync.util.MathUtil;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
@@ -40,7 +41,7 @@ public class PlayerData {
|
||||
private BukkitTask combatTask;
|
||||
|
||||
@Nullable @Setter
|
||||
private Long ping, previousPing;
|
||||
private Long ping, previousPing, lastAdjustment;
|
||||
|
||||
@Nullable @Setter
|
||||
private Double verticalVelocity;
|
||||
@@ -74,14 +75,10 @@ public class PlayerData {
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the Player is on the ground, either serverside or clientside.
|
||||
* Determines if the Player is on the ground clientside, but not serverside
|
||||
* <p>
|
||||
* Returns <code>ping ≥ (tMax + tFall)</code> and <code>gDist ≤ 1.3</code>
|
||||
* <p>
|
||||
* Returns <code>true</code> if:
|
||||
* <ul>
|
||||
* <li>Clientside: <code>ping ≥ (tMax + tFall)</code> and <code>gDist ≤ 1.3</code></li>
|
||||
* <li>Serverside: <code>gDist ≤ 0</code></li>
|
||||
* </ul>
|
||||
*
|
||||
* Where:
|
||||
* <ul>
|
||||
* <li><code>ping</code>: Estimated latency</li>
|
||||
@@ -104,7 +101,7 @@ public class PlayerData {
|
||||
|
||||
double gDist = getDistanceToGround();
|
||||
if (gDist <= 0)
|
||||
return true;
|
||||
return false; // prevent player from taking adjusted knockback when on ground serverside
|
||||
|
||||
int tMax = verticalVelocity > 0 ? MathUtil.calculateTimeToMaxVelocity(verticalVelocity) : 0;
|
||||
double mH = verticalVelocity > 0 ? MathUtil.calculateDistanceTraveled(verticalVelocity, tMax) : 0;
|
||||
@@ -172,6 +169,10 @@ public class PlayerData {
|
||||
yAxis -= resistanceFactor;
|
||||
}
|
||||
|
||||
// vertical velocity is always 0.4 when you have knockback level higher than 0
|
||||
if (attacker.getInventory().getItemInMainHand().getEnchantmentLevel(Enchantment.KNOCKBACK) > 0)
|
||||
yAxis = 0.4;
|
||||
|
||||
return yAxis;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user