mirror of
https://github.com/Wurst-Imperium/Wurst7.git
synced 2024-09-19 17:02:13 +02:00
Add PlayerAttacksEntityEvent for Criticals
This commit is contained in:
parent
90092c1097
commit
3bcec2d807
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2014-2024 Wurst-Imperium and contributors.
|
||||
*
|
||||
* This source code is subject to the terms of the GNU General Public
|
||||
* License, version 3. If a copy of the GPL was not distributed with this
|
||||
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
*/
|
||||
package net.wurstclient.events;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.client.network.ClientPlayerInteractionManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.wurstclient.event.Event;
|
||||
import net.wurstclient.event.Listener;
|
||||
|
||||
/**
|
||||
* Fired at the beginning of
|
||||
* {@link ClientPlayerInteractionManager#attackEntity(PlayerEntity, Entity)}.
|
||||
*/
|
||||
public interface PlayerAttacksEntityListener extends Listener
|
||||
{
|
||||
/**
|
||||
* Fired at the beginning of
|
||||
* {@link ClientPlayerInteractionManager#attackEntity(PlayerEntity, Entity)}.
|
||||
*/
|
||||
public void onPlayerAttacksEntity(Entity target);
|
||||
|
||||
/**
|
||||
* Fired at the beginning of
|
||||
* {@link ClientPlayerInteractionManager#attackEntity(PlayerEntity, Entity)}.
|
||||
*/
|
||||
public static class PlayerAttacksEntityEvent
|
||||
extends Event<PlayerAttacksEntityListener>
|
||||
{
|
||||
private final Entity target;
|
||||
|
||||
public PlayerAttacksEntityEvent(Entity target)
|
||||
{
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fire(ArrayList<PlayerAttacksEntityListener> listeners)
|
||||
{
|
||||
for(PlayerAttacksEntityListener listener : listeners)
|
||||
listener.onPlayerAttacksEntity(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<PlayerAttacksEntityListener> getListenerType()
|
||||
{
|
||||
return PlayerAttacksEntityListener.class;
|
||||
}
|
||||
}
|
||||
}
|
@ -136,7 +136,6 @@ public final class ClickAuraHack extends Hack
|
||||
.sendPlayerLookPacket();
|
||||
|
||||
// attack entity
|
||||
WURST.getHax().criticalsHack.doCritical();
|
||||
MC.interactionManager.attackEntity(player, target);
|
||||
player.swingHand(Hand.MAIN_HAND);
|
||||
speed.resetTimer();
|
||||
|
@ -7,19 +7,19 @@
|
||||
*/
|
||||
package net.wurstclient.hacks;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
|
||||
import net.minecraft.util.hit.EntityHitResult;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import net.wurstclient.Category;
|
||||
import net.wurstclient.SearchTags;
|
||||
import net.wurstclient.events.LeftClickListener;
|
||||
import net.wurstclient.events.PlayerAttacksEntityListener;
|
||||
import net.wurstclient.hack.Hack;
|
||||
import net.wurstclient.settings.EnumSetting;
|
||||
|
||||
@SearchTags({"Crits"})
|
||||
public final class CriticalsHack extends Hack implements LeftClickListener
|
||||
public final class CriticalsHack extends Hack
|
||||
implements PlayerAttacksEntityListener
|
||||
{
|
||||
private final EnumSetting<Mode> mode = new EnumSetting<>("Mode",
|
||||
"\u00a7lPacket\u00a7r mode sends packets to server without actually moving you at all.\n\n"
|
||||
@ -43,30 +43,19 @@ public final class CriticalsHack extends Hack implements LeftClickListener
|
||||
@Override
|
||||
protected void onEnable()
|
||||
{
|
||||
EVENTS.add(LeftClickListener.class, this);
|
||||
EVENTS.add(PlayerAttacksEntityListener.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDisable()
|
||||
{
|
||||
EVENTS.remove(LeftClickListener.class, this);
|
||||
EVENTS.remove(PlayerAttacksEntityListener.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLeftClick(LeftClickEvent event)
|
||||
public void onPlayerAttacksEntity(Entity target)
|
||||
{
|
||||
if(MC.crosshairTarget == null
|
||||
|| MC.crosshairTarget.getType() != HitResult.Type.ENTITY
|
||||
|| !(((EntityHitResult)MC.crosshairTarget)
|
||||
.getEntity() instanceof LivingEntity))
|
||||
return;
|
||||
|
||||
doCritical();
|
||||
}
|
||||
|
||||
public void doCritical()
|
||||
{
|
||||
if(!isEnabled())
|
||||
if(!(target instanceof LivingEntity))
|
||||
return;
|
||||
|
||||
if(WURST.getHax().maceDmgHack.isEnabled()
|
||||
|
@ -216,7 +216,6 @@ public final class FightBotHack extends Hack
|
||||
return;
|
||||
|
||||
// attack entity
|
||||
WURST.getHax().criticalsHack.doCritical();
|
||||
MC.interactionManager.attackEntity(MC.player, entity);
|
||||
swingHand.swing(Hand.MAIN_HAND);
|
||||
speed.resetTimer();
|
||||
|
@ -192,7 +192,6 @@ public final class KillauraHack extends Hack
|
||||
if(target == null)
|
||||
return;
|
||||
|
||||
WURST.getHax().criticalsHack.doCritical();
|
||||
MC.interactionManager.attackEntity(MC.player, target);
|
||||
swingHand.swing(Hand.MAIN_HAND);
|
||||
|
||||
|
@ -224,7 +224,6 @@ public final class KillauraLegitHack extends Hack implements UpdateListener,
|
||||
return;
|
||||
|
||||
// attack entity
|
||||
WURST.getHax().criticalsHack.doCritical();
|
||||
MC.interactionManager.attackEntity(MC.player, target);
|
||||
swingHand.swing(Hand.MAIN_HAND);
|
||||
speed.resetTimer(speedRandMS.getValue());
|
||||
|
@ -122,7 +122,6 @@ public final class MultiAuraHack extends Hack implements UpdateListener
|
||||
.getNeededRotations(entity.getBoundingBox().getCenter())
|
||||
.sendPlayerLookPacket();
|
||||
|
||||
WURST.getHax().criticalsHack.doCritical();
|
||||
MC.interactionManager.attackEntity(MC.player, entity);
|
||||
}
|
||||
|
||||
|
@ -285,7 +285,6 @@ public final class ProtectHack extends Hack
|
||||
return;
|
||||
|
||||
// attack enemy
|
||||
WURST.getHax().criticalsHack.doCritical();
|
||||
MC.interactionManager.attackEntity(MC.player, enemy);
|
||||
swingHand.swing(Hand.MAIN_HAND);
|
||||
speed.resetTimer();
|
||||
|
@ -134,7 +134,6 @@ public final class TpAuraHack extends Hack implements UpdateListener
|
||||
RotationUtils.getNeededRotations(entity.getBoundingBox().getCenter())
|
||||
.sendPlayerLookPacket();
|
||||
|
||||
WURST.getHax().criticalsHack.doCritical();
|
||||
MC.interactionManager.attackEntity(player, entity);
|
||||
swingHand.swing(Hand.MAIN_HAND);
|
||||
speed.resetTimer();
|
||||
|
@ -157,7 +157,6 @@ public final class TriggerBotHack extends Hack
|
||||
return;
|
||||
|
||||
WURST.getHax().autoSwordHack.setSlot(target);
|
||||
WURST.getHax().criticalsHack.doCritical();
|
||||
|
||||
if(simulateMouseClick.isChecked())
|
||||
{
|
||||
|
@ -20,6 +20,7 @@ import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.client.network.ClientPlayerInteractionManager;
|
||||
import net.minecraft.client.network.SequencedPacketCreator;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
|
||||
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket.Action;
|
||||
@ -33,6 +34,7 @@ import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.wurstclient.event.EventManager;
|
||||
import net.wurstclient.events.BlockBreakingProgressListener.BlockBreakingProgressEvent;
|
||||
import net.wurstclient.events.PlayerAttacksEntityListener.PlayerAttacksEntityEvent;
|
||||
import net.wurstclient.events.StopUsingItemListener.StopUsingItemEvent;
|
||||
import net.wurstclient.mixinterface.IClientPlayerInteractionManager;
|
||||
|
||||
@ -61,6 +63,17 @@ public abstract class ClientPlayerInteractionManagerMixin
|
||||
EventManager.fire(StopUsingItemEvent.INSTANCE);
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"),
|
||||
method = "attackEntity(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/entity/Entity;)V")
|
||||
private void onAttackEntity(PlayerEntity player, Entity target,
|
||||
CallbackInfo ci)
|
||||
{
|
||||
if(player != client.player)
|
||||
return;
|
||||
|
||||
EventManager.fire(new PlayerAttacksEntityEvent(target));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowClick_PICKUP(int slot)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user