initial commit
This commit is contained in:
39
src/main/java/com/example/pvpmod/features/TriggerBot.java
Normal file
39
src/main/java/com/example/pvpmod/features/TriggerBot.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package com.example.pvpmod.features;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.phys.EntityHitResult;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
|
||||
public class TriggerBot {
|
||||
private final Minecraft mc = Minecraft.getInstance();
|
||||
private long lastAttackTime = 0;
|
||||
private static final long ATTACK_DELAY = 100; // milliseconds
|
||||
|
||||
public void onTick() {
|
||||
if (mc.player == null || mc.level == null) return;
|
||||
|
||||
// Check if we're looking at an entity
|
||||
HitResult hitResult = mc.hitResult;
|
||||
if (hitResult == null || hitResult.getType() != HitResult.Type.ENTITY) return;
|
||||
|
||||
EntityHitResult entityHit = (EntityHitResult) hitResult;
|
||||
if (!(entityHit.getEntity() instanceof LivingEntity target)) return;
|
||||
|
||||
// Don't attack ourselves
|
||||
if (target == mc.player) return;
|
||||
|
||||
// Check if target is alive
|
||||
if (target.isDeadOrDying()) return;
|
||||
|
||||
// Attack with delay to prevent spam
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if (currentTime - lastAttackTime >= ATTACK_DELAY) {
|
||||
if (mc.player.getAttackStrengthScale(0.5f) > 0.9f) {
|
||||
mc.gameMode.attack(mc.player, target);
|
||||
mc.player.swing(mc.player.getUsedItemHand());
|
||||
lastAttackTime = currentTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user