Skip to content

Commit

Permalink
Tridents with 1 durability cannot be used
Browse files Browse the repository at this point in the history
  • Loading branch information
SamB440 committed Aug 22, 2024
1 parent 1238555 commit 24a51d9
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.github.retrooper.packetevents.protocol.player.InteractionHand;
import com.github.retrooper.packetevents.protocol.world.BlockFace;
import com.github.retrooper.packetevents.wrapper.play.client.*;
import org.bukkit.Bukkit;

public class PacketPlayerDigging extends PacketListenerAbstract {

Expand Down Expand Up @@ -103,7 +104,10 @@ public static void handleUseItem(GrimPlayer player, ItemStack item, InteractionH
}

// The client and server don't agree on trident status because mojang is incompetent at netcode.
if (material == ItemTypes.TRIDENT && (player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_13_2) || player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8))) {
if (material == ItemTypes.TRIDENT
&& item.getDamageValue() < item.getMaxDamage() - 1 // Player can't use item if it's "about to break"
&& (player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_13_2)
|| player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8))) {
player.packetStateData.setSlowedByUsingItem(item.getEnchantmentLevel(EnchantmentTypes.RIPTIDE, PacketEvents.getAPI().getServerManager().getVersion().toClientVersion()) <= 0);
player.packetStateData.eatingHand = hand;
}
Expand Down

0 comments on commit 24a51d9

Please sign in to comment.