Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added OldESP the worst way possible #435

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

@RegisterMod
public class WaifuESP extends ToggleMod {
public class CarpinchoESP extends ToggleMod {

public WaifuESP() {
super(Category.RENDER, "WaifuESP", false, "overlay cute animes over players");
public CarpinchoESP() {
super(Category.RENDER, "CarpinchoESP", false, "overlay cute capybaras over players");
}

public final Setting<Boolean> noRenderPlayers =
Expand All @@ -40,13 +40,13 @@ public WaifuESP() {
.defaultTo(false)
.build();

// private final ResourceLocation waifu = new ResourceLocation("textures/forgehax/waifu1.png");
private ResourceLocation waifu;
// private final ResourceLocation carpincho = new ResourceLocation("textures/forgehax/carpincho.png");
private ResourceLocation carpincho;

private final String waifuUrl = "https://raw.githubusercontent.com/forgehax/assets/master/img/waifu_v01.png";
private final String carpinchoUrl = "https://cdn.discordapp.com/attachments/932122296863322172/1050581091259531284/carpincho.png";

private final File waifuCache =
Helper.getFileManager().getBaseResolve("cache/waifu.png").toFile();
private final File carpinchoCache =
Helper.getFileManager().getBaseResolve("cache/carpincho.png").toFile();

private <T> BufferedImage getImage(T source, ThrowingFunction<T, BufferedImage> readFunction) {
try {
Expand All @@ -66,7 +66,7 @@ private boolean shouldDraw(EntityLivingBase entity) {

@SubscribeEvent(priority = EventPriority.LOWEST)
public void onRenderGameOverlayEvent(RenderGameOverlayEvent.Text event) {
if (waifu == null) {
if (carpincho == null) {
return;
}

Expand All @@ -87,8 +87,8 @@ public void onRenderGameOverlayEvent(RenderGameOverlayEvent.Text event) {
(int) (top.x - (width / 1.8)); // normally 2.0 but lowering it shifts it to the left
int y = top.y;

// draw waifu
MC.renderEngine.bindTexture(waifu);
// draw carpincho
MC.renderEngine.bindTexture(carpincho);

GlStateManager.color(255, 255, 255);
Gui.drawScaledCustomSizeModalRect(
Expand All @@ -111,26 +111,26 @@ public void onLoad() {
() -> {
try {
BufferedImage image;
if (waifuCache.exists()) { // TODO: download async
image = getImage(waifuCache, ImageIO::read); // from cache
if (carpinchoCache.exists()) { // TODO: download async
image = getImage(carpinchoCache, ImageIO::read); // from cache
} else {
image = getImage(new URL(waifuUrl), ImageIO::read); // from internet
image = getImage(new URL(carpinchoUrl), ImageIO::read); // from internet
if (image != null) {
try {
ImageIO.write(image, "png", waifuCache);
ImageIO.write(image, "png", carpinchoCache);
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
if (image == null) {
LOGGER.warn("Failed to download waifu image");
LOGGER.warn("Failed to download carpincho image");
return;
}

DynamicTexture dynamicTexture = new DynamicTexture(image);
dynamicTexture.loadTexture(MC.getResourceManager());
waifu = MC.getTextureManager().getDynamicTextureLocation("WAIFU", dynamicTexture);
carpincho = MC.getTextureManager().getDynamicTextureLocation("CARPINCHO", dynamicTexture);
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import java.util.UUID;

@RegisterMod
// TODO: rename this
public class ThisModIsDedicatedToUfoCrossing extends ToggleMod {
// TODO: rename this DONE, nolongerdedicatedtoufocrossing
public class MessageAura extends ToggleMod {

private final Setting<String> message =
getCommandStub()
Expand All @@ -26,8 +26,8 @@ public class ThisModIsDedicatedToUfoCrossing extends ToggleMod {
.defaultTo("hello uwu")
.build();

public ThisModIsDedicatedToUfoCrossing() {
super(Category.MISC, "ThisModIsDedicatedToUfoCrossing", false, "Automatically send a message to whoever comes into render distance");
public MessageAura() {
super(Category.MISC, "MessageAura", false, "Automatically send a message to whoever comes into render distance");
}

@SubscribeEvent
Expand Down
244 changes: 244 additions & 0 deletions src/main/java/com/matt/forgehax/mods/OldESP.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
package com.matt.forgehax.mods;

import com.google.common.collect.Lists;
import com.matt.forgehax.util.OldUtils;
import com.matt.forgehax.util.command.Setting;
import com.matt.forgehax.util.draw.SurfaceUtils;
import com.matt.forgehax.util.entity.EnchantmentUtils;
import com.matt.forgehax.util.entity.OldEntityUtils;
import com.matt.forgehax.util.entity.LocalPlayerUtilsESP;
import com.matt.forgehax.util.math.VectorUtilsESP;
import com.matt.forgehax.util.mod.Category;
import com.matt.forgehax.util.mod.ToggleMod;
import com.matt.forgehax.util.mod.loader.RegisterMod;
import java.util.List;
import java.util.Objects;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.Vec3d;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderLivingEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

@RegisterMod
public class OldESP extends ToggleMod {
private static final int HEALTHBAR_WIDTH = 15;
private static final int HEALTHBAR_HEIGHT = 3;

public enum DrawOptions {
DISABLED,
NAME,
SIMPLE,
ADVANCED,
}

public enum ArmorOptions {
DISABLED,
SIMPLE,
ENCHANTMENTS
}

public final Setting<Integer> players =
getCommandStub()
.builders()
.<Integer>newSettingBuilder()
.name("players")
.description("Enables players")
.defaultTo(DrawOptions.NAME.ordinal())
.min(0)
.max(DrawOptions.values().length - 1)
.build();

public final Setting<Integer> mobs_hostile =
getCommandStub()
.builders()
.<Integer>newSettingBuilder()
.name("mobs_hostile")
.description("Enables hostile mobs")
.defaultTo(DrawOptions.NAME.ordinal())
.min(0)
.max(DrawOptions.values().length - 1)
.build();

public final Setting<Integer> mobs_friendly =
getCommandStub()
.builders()
.<Integer>newSettingBuilder()
.name("mobs_friendly")
.description("Enables friendly mobs")
.defaultTo(DrawOptions.NAME.ordinal())
.min(0)
.max(DrawOptions.values().length - 1)
.build();

public final Setting<Integer> armor =
getCommandStub()
.builders()
.<Integer>newSettingBuilder()
.name("armor")
.description("Draws armor")
.defaultTo(ArmorOptions.ENCHANTMENTS.ordinal())
.min(0)
.max(ArmorOptions.values().length)
.build();

public final Setting<Boolean> distance =
getCommandStub()
.builders()
.<Boolean>newSettingBuilder()
.name("distance")
.description("Draws distance")
.defaultTo(false)
.build();

public OldESP() {
super(Category.RENDER, "OldESP", false, "Shows entity locations and info");
}

private Setting<Integer> getCorrespondingSetting(Entity entity) {
return OldEntityUtils.isHostileMob(entity)
? mobs_hostile
: (OldEntityUtils.isPlayer(entity) ? players : mobs_friendly);
}

/** Check if we should draw the entity */
private boolean shouldDraw(EntityLivingBase entity) {
return LocalPlayerUtilsESP.isTargetEntity(entity)
|| (!entity.equals(MC.player)
&& OldEntityUtils.isAlive(entity)
&& OldEntityUtils.isValidEntity(entity)
&& ((mobs_hostile.get() > 0 && OldEntityUtils.isHostileMob(entity))
|| // check this first
(players.get() > 0 && OldEntityUtils.isPlayer(entity))
|| (mobs_friendly.get() > 0 && OldEntityUtils.isFriendlyMob(entity))));
}

@SubscribeEvent
public void onRenderPlayerNameTag(RenderLivingEvent.Specials.Pre event) {
if (OldEntityUtils.isPlayer(event.getEntity())) event.setCanceled(true);
}

@SubscribeEvent(priority = EventPriority.LOW)
public void onRenderGameOverlayEvent(RenderGameOverlayEvent.Text event) {
if (event.getType().equals(RenderGameOverlayEvent.ElementType.TEXT)) {
for (Entity entity : MC.world.loadedEntityList) {
if (OldEntityUtils.isLiving(entity) && shouldDraw((EntityLivingBase) entity)) {
EntityLivingBase living = (EntityLivingBase) (entity);
Vec3d bottomVec = OldEntityUtils.getInterpolatedPos(living, event.getPartialTicks());
Vec3d topVec =
bottomVec.add(new Vec3d(0, (entity.getRenderBoundingBox().maxY - entity.posY), 0));
VectorUtilsESP.ScreenPos top = VectorUtilsESP.toScreen(topVec.x, topVec.y, topVec.z);
VectorUtilsESP.ScreenPos bot =
VectorUtilsESP.toScreen(bottomVec.x, bottomVec.y, bottomVec.z);
if (top.isVisible || bot.isVisible) {
Setting<Integer> enabled = getCorrespondingSetting(living);

int topX = top.x;
int topY = top.y + 1;
int botX = bot.x;
int botY = bot.y + 1;
int height = (bot.y - top.y);
int width = height;

// optical esp
// drawMode == null means they are the target but the esp is disabled for them
if (LocalPlayerUtilsESP.isTargetEntity(entity) || enabled.get() > 0) {
int x = (top.x - (width / 2));
int y = top.y;
int w = width;
int h = height;
// outer
SurfaceUtils.drawOutlinedRect(x - 1, y - 1, w + 2, h + 2, OldUtils.Colors.BLACK, 2.f);
// inner
SurfaceUtils.drawOutlinedRect(x, y, w, h, OldEntityUtils.getDrawColor(living), 2.f);
// outer
SurfaceUtils.drawOutlinedRect(x + 1, y + 1, w - 2, h - 2, OldUtils.Colors.BLACK, 2.f);
}

// ----TOP ESP----

// health esp
if (enabled.get() == (DrawOptions.ADVANCED.ordinal())
|| enabled.get() == (DrawOptions.SIMPLE.ordinal())) {
double hp = (living.getHealth() / living.getMaxHealth());
int posX = topX - (HEALTHBAR_WIDTH / 2);
int posY = topY - HEALTHBAR_HEIGHT - 2;
SurfaceUtils.drawRect(
posX, posY, HEALTHBAR_WIDTH, HEALTHBAR_HEIGHT, OldUtils.toRGBA(0, 0, 0, 255));
SurfaceUtils.drawRect(
posX + 1,
posY + 1,
(int) ((float) (HEALTHBAR_WIDTH - 2) * hp),
HEALTHBAR_HEIGHT - 2,
OldUtils.toRGBA((int) ((255 - hp) * 255), (int) (255 * hp), 0, 255));
topY -= HEALTHBAR_HEIGHT + 1;
}

// name esp
if (enabled.get() == DrawOptions.ADVANCED.ordinal()
|| enabled.get() == (DrawOptions.SIMPLE.ordinal())
|| enabled.get() == (DrawOptions.NAME.ordinal())) {
String text = living.getDisplayName().getFormattedText();
if (distance.get()
&& (enabled.get() == DrawOptions.SIMPLE.ordinal()
|| enabled.get() == (DrawOptions.ADVANCED.ordinal()))) {
text +=
String.format(
" (%.1f)",
living.getPositionVector().distanceTo(MC.player.getPositionVector()));
}
SurfaceUtils.drawTextShadow(
text,
topX - (SurfaceUtils.getTextWidth(text) / 2),
topY - SurfaceUtils.getTextHeight() - 1,
OldUtils.toRGBA(255, 255, 255, 255));
topY -= SurfaceUtils.getTextHeight() + 1;
}

// ----BOTTOM ESP----

// armor esp
if (enabled.get() == (DrawOptions.ADVANCED.ordinal()) && armor.get() > 0) {
List<ItemStack> armor = Lists.newArrayList();
for (ItemStack stack : living.getEquipmentAndArmor())
if (stack != null
|| Objects.equals(stack, ItemStack.EMPTY)) // only add non-null items
armor.add(0, stack);
if (armor.size() > 0) {
int endY = botY + 16;
int posX = topX - ((16 * armor.size()) / 2);
for (int i = 0; i < armor.size(); i++) {
ItemStack stack = armor.get(i);
int startX = posX + (i * 16);
int startY = botY;
SurfaceUtils.drawItemWithOverlay(stack, startX, startY);
// enchantment esp
if (this.armor.get() == (ArmorOptions.ENCHANTMENTS.ordinal())) {
List<EnchantmentUtils.EntityEnchantment> enchantments =
EnchantmentUtils.getEnchantmentsSorted(stack.getEnchantmentTagList());
if (enchantments != null) {
for (EnchantmentUtils.EntityEnchantment enchant : enchantments) {
SurfaceUtils.drawTextShadow(
enchant.getShortName(),
startX,
startY,
OldUtils.toRGBA(255, 255, 255, 255),
0.50D);
startY += SurfaceUtils.getTextHeight(0.50D);
if (startY > endY) endY = startY;
}
}
}
}
botY = endY + 1;
}
}
}
}
}
}
}
}

Loading