0
0
mirror of https://github.com/Wurst-Imperium/Wurst7.git synced 2024-09-20 01:12:13 +02:00

Add FeedAuraHack

This commit is contained in:
Alexander01998 2020-11-20 01:35:58 +01:00
parent 81a2f280f6
commit 8c62423069
2 changed files with 232 additions and 0 deletions

View File

@ -80,6 +80,7 @@ public final class HackList implements UpdateListener
public final FastBreakHack fastBreakHack = new FastBreakHack();
public final FastLadderHack fastLadderHack = new FastLadderHack();
public final FastPlaceHack fastPlaceHack = new FastPlaceHack();
public final FeedAuraHack feedAuraHack = new FeedAuraHack();
public final FightBotHack fightBotHack = new FightBotHack();
public final FishHack fishHack = new FishHack();
public final FlightHack flightHack = new FlightHack();

View File

@ -0,0 +1,231 @@
/*
* Copyright (c) 2014-2020 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.hacks;
import java.util.Comparator;
import java.util.function.ToDoubleFunction;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.network.ClientPlayerInteractionManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.EntityHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.wurstclient.Category;
import net.wurstclient.SearchTags;
import net.wurstclient.events.PostMotionListener;
import net.wurstclient.events.RenderListener;
import net.wurstclient.events.UpdateListener;
import net.wurstclient.hack.Hack;
import net.wurstclient.settings.EnumSetting;
import net.wurstclient.settings.SliderSetting;
import net.wurstclient.settings.SliderSetting.ValueDisplay;
import net.wurstclient.util.RenderUtils;
import net.wurstclient.util.RotationUtils;
@SearchTags({"feed aura", "BreedAura", "breed aura", "AutoBreeder",
"auto breeder"})
public final class FeedAuraHack extends Hack
implements UpdateListener, PostMotionListener, RenderListener
{
private final SliderSetting range = new SliderSetting("Range",
"Determines how far FeedAura will reach\n" + "to feed animals.\n"
+ "Anything that is further away than the\n"
+ "specified value will not be fed.",
5, 1, 10, 0.05, ValueDisplay.DECIMAL);
private final EnumSetting<Priority> priority = new EnumSetting<>("Priority",
"Determines which animal will be fed first.\n"
+ "\u00a7lDistance\u00a7r - Feeds the closest animal.\n"
+ "\u00a7lAngle\u00a7r - Feeds the animal that requires\n"
+ "the least head movement.\n"
+ "\u00a7lHealth\u00a7r - Feeds the weakest animal.",
Priority.values(), Priority.ANGLE);
private AnimalEntity target;
private AnimalEntity renderTarget;
public FeedAuraHack()
{
super("FeedAura", "Automatically feeds animals around you.");
setCategory(Category.OTHER);
addSetting(range);
addSetting(priority);
}
@Override
protected void onEnable()
{
// disable other auras
WURST.getHax().clickAuraHack.setEnabled(false);
WURST.getHax().fightBotHack.setEnabled(false);
WURST.getHax().killauraLegitHack.setEnabled(false);
WURST.getHax().multiAuraHack.setEnabled(false);
WURST.getHax().protectHack.setEnabled(false);
WURST.getHax().triggerBotHack.setEnabled(false);
WURST.getHax().tpAuraHack.setEnabled(false);
EVENTS.add(UpdateListener.class, this);
EVENTS.add(PostMotionListener.class, this);
EVENTS.add(RenderListener.class, this);
}
@Override
protected void onDisable()
{
EVENTS.remove(UpdateListener.class, this);
EVENTS.remove(PostMotionListener.class, this);
EVENTS.remove(RenderListener.class, this);
target = null;
renderTarget = null;
}
@Override
public void onUpdate()
{
ClientPlayerEntity player = MC.player;
ItemStack heldStack = player.inventory.getMainHandStack();
double rangeSq = Math.pow(range.getValue(), 2);
Stream<AnimalEntity> stream = StreamSupport
.stream(MC.world.getEntities().spliterator(), true)
.filter(e -> !e.removed).filter(e -> e instanceof AnimalEntity)
.map(e -> (AnimalEntity)e).filter(e -> e.getHealth() > 0)
.filter(e -> player.squaredDistanceTo(e) <= rangeSq)
.filter(e -> e.isBreedingItem(heldStack)).filter(e -> e.canEat());
target = stream.min(priority.getSelected().comparator).orElse(null);
renderTarget = target;
if(target == null)
return;
WURST.getRotationFaker()
.faceVectorPacket(target.getBoundingBox().getCenter());
}
@Override
public void onPostMotion()
{
if(target == null)
return;
ClientPlayerInteractionManager im = MC.interactionManager;
ClientPlayerEntity player = MC.player;
Hand hand = Hand.MAIN_HAND;
EntityHitResult hitResult = new EntityHitResult(target);
ActionResult actionResult =
im.interactEntityAtLocation(player, target, hitResult, hand);
if(!actionResult.isAccepted())
actionResult = im.interactEntity(player, target, hand);
if(actionResult.isAccepted() && actionResult.shouldSwingHand())
player.swingHand(hand);
target = null;
}
@Override
public void onRender(float partialTicks)
{
if(renderTarget == null)
return;
// GL settings
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glEnable(GL11.GL_LINE_SMOOTH);
GL11.glLineWidth(2);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glPushMatrix();
RenderUtils.applyRenderOffset();
Box box = new Box(BlockPos.ORIGIN);
float p = 1;
LivingEntity le = renderTarget;
p = (le.getMaxHealth() - le.getHealth()) / le.getMaxHealth();
float red = p * 2F;
float green = 2 - red;
GL11.glTranslated(
renderTarget.prevX
+ (renderTarget.getX() - renderTarget.prevX) * partialTicks,
renderTarget.prevY
+ (renderTarget.getY() - renderTarget.prevY) * partialTicks,
renderTarget.prevZ
+ (renderTarget.getZ() - renderTarget.prevZ) * partialTicks);
GL11.glTranslated(0, 0.05, 0);
GL11.glScaled(renderTarget.getWidth(), renderTarget.getHeight(),
renderTarget.getWidth());
GL11.glTranslated(-0.5, 0, -0.5);
if(p < 1)
{
GL11.glTranslated(0.5, 0.5, 0.5);
GL11.glScaled(p, p, p);
GL11.glTranslated(-0.5, -0.5, -0.5);
}
GL11.glColor4f(red, green, 0, 0.25F);
RenderUtils.drawSolidBox(box);
GL11.glColor4f(red, green, 0, 0.5F);
RenderUtils.drawOutlinedBox(box);
GL11.glPopMatrix();
// GL resets
GL11.glColor4f(1, 1, 1, 1);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_LINE_SMOOTH);
}
private enum Priority
{
DISTANCE("Distance", e -> MC.player.squaredDistanceTo(e)),
ANGLE("Angle",
e -> RotationUtils
.getAngleToLookVec(e.getBoundingBox().getCenter())),
HEALTH("Health", e -> e instanceof LivingEntity
? ((LivingEntity)e).getHealth() : Integer.MAX_VALUE);
private final String name;
private final Comparator<Entity> comparator;
private Priority(String name, ToDoubleFunction<Entity> keyExtractor)
{
this.name = name;
comparator = Comparator.comparingDouble(keyExtractor);
}
@Override
public String toString()
{
return name;
}
}
}