Skip to content

Commit

Permalink
Revert
Browse files Browse the repository at this point in the history
  • Loading branch information
Aspw-w committed Mar 13, 2024
1 parent b5cdf61 commit 2963d99
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.aspw.client.features.module.Module;

import java.io.*;
import java.util.Iterator;
import java.util.Map;

/**
Expand All @@ -30,7 +31,9 @@ protected void loadConfig() throws IOException {
if (jsonElement instanceof JsonNull)
return;

for (final Map.Entry<String, JsonElement> entry : jsonElement.getAsJsonObject().entrySet()) {
final Iterator<Map.Entry<String, JsonElement>> entryIterator = jsonElement.getAsJsonObject().entrySet().iterator();
while (entryIterator.hasNext()) {
final Map.Entry<String, JsonElement> entry = entryIterator.next();
final Module module = Launch.moduleManager.getModule(entry.getKey());

if (module != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.aspw.client.visual.client.altmanager.menus.GuiTheAltening;

import java.io.*;
import java.util.Iterator;
import java.util.Map;

/**
Expand All @@ -35,7 +36,9 @@ protected void loadConfig() throws IOException {

final JsonObject jsonObject = (JsonObject) jsonElement;

for (final Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
final Iterator<Map.Entry<String, JsonElement>> iterator = jsonObject.entrySet().iterator();
while (iterator.hasNext()) {
final Map.Entry<String, JsonElement> entry = iterator.next();
if (entry.getKey().equalsIgnoreCase("macros")) {
final JsonArray jsonValue = entry.getValue().getAsJsonArray();
for (final JsonElement macroElement : jsonValue) {
Expand All @@ -58,7 +61,7 @@ protected void loadConfig() throws IOException {
if (module != null) {
final JsonObject jsonModule = (JsonObject) entry.getValue();

for (final Value<?> moduleValue : module.getValues()) {
for (final Value moduleValue : module.getValues()) {
final JsonElement element = jsonModule.get(moduleValue.getName());

if (element != null) moduleValue.fromJson(element);
Expand Down
57 changes: 0 additions & 57 deletions src/main/java/net/aspw/client/features/api/ColorElement.java

This file was deleted.

35 changes: 17 additions & 18 deletions src/main/java/net/aspw/client/features/api/PacketManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,6 @@ public class PacketManager extends MinecraftInstance implements Listenable {
private int preSend = 0;
private int preReceive = 0;

public static boolean shouldStopRender(Entity entity) {
return (EntityUtils.isMob(entity) ||
EntityUtils.isAnimal(entity) ||
entity.isInvisible() ||
entity instanceof EntityBoat ||
entity instanceof EntityMinecart ||
entity instanceof EntityItemFrame ||
entity instanceof EntityTNTPrimed ||
entity instanceof EntityArmorStand) &&
entity != mc.thePlayer && mc.thePlayer.getDistanceToEntity(entity) > 45.0f;
}

private int getArmSwingAnimationEnd() {
int speed = mc.thePlayer instanceof EntityPlayerSP ? 2 + (20 - Animations.SpeedSwing.get() - 16) : 6;
return mc.thePlayer.isPotionActive(Potion.digSpeed) ? speed - (1 + mc.thePlayer.getActivePotionEffect(Potion.digSpeed).getAmplifier()) : (mc.thePlayer.isPotionActive(Potion.digSlowdown) ? speed + (1 + mc.thePlayer.getActivePotionEffect(Potion.digSlowdown).getAmplifier()) * 2 : speed);
}


@EventTarget
public void onWorld(WorldEvent event) {
if (Objects.requireNonNull(Launch.moduleManager.getModule(BetterView.class)).getState())
Expand Down Expand Up @@ -213,6 +195,23 @@ public void onPacket(PacketEvent event) {
}
}

public static boolean shouldStopRender(Entity entity) {
return (EntityUtils.isMob(entity) ||
EntityUtils.isAnimal(entity) ||
entity.isInvisible() ||
entity instanceof EntityBoat ||
entity instanceof EntityMinecart ||
entity instanceof EntityItemFrame ||
entity instanceof EntityTNTPrimed ||
entity instanceof EntityArmorStand) &&
entity != mc.thePlayer && mc.thePlayer.getDistanceToEntity(entity) > 45.0f;
}

private int getArmSwingAnimationEnd() {
int speed = mc.thePlayer instanceof EntityPlayerSP ? 2 + (20 - Animations.SpeedSwing.get() - 16) : 6;
return mc.thePlayer.isPotionActive(Potion.digSpeed) ? speed - (1 + mc.thePlayer.getActivePotionEffect(Potion.digSpeed).getAmplifier()) : (mc.thePlayer.isPotionActive(Potion.digSlowdown) ? speed + (1 + mc.thePlayer.getActivePotionEffect(Potion.digSlowdown).getAmplifier()) * 2 : speed);
}

@Override
public boolean handleEvents() {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ public void drawScreen(int mouseX, int mouseY, final float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
}

@Override
public void handleMouseInput() throws IOException {
super.handleMouseInput();

Expand All @@ -158,8 +157,8 @@ public void handleMouseInput() throws IOException {
protected void mouseClicked(int mouseX, int mouseY, final int mouseButton) throws IOException {
final double scale = Objects.requireNonNull(Launch.moduleManager.getModule(Gui.class)).scaleValue.get() - 0.1765;

mouseX /= (int) scale;
mouseY /= (int) scale;
mouseX /= scale;
mouseY /= scale;

for (int i = panels.size() - 1; i >= 0; i--) {
if (panels.get(i).mouseClicked(mouseX, mouseY, mouseButton)) {
Expand Down Expand Up @@ -193,8 +192,8 @@ protected void mouseClicked(int mouseX, int mouseY, final int mouseButton) throw
protected void mouseReleased(int mouseX, int mouseY, final int state) {
final double scale = Objects.requireNonNull(Launch.moduleManager.getModule(Gui.class)).scaleValue.get() - 0.1765;

mouseX /= (int) scale;
mouseY /= (int) scale;
mouseX /= scale;
mouseY /= scale;

for (final Panel panel : panels) {
panel.mouseReleased(mouseX, mouseY, state);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public static NewUi getInstance() {
return instance == null ? instance = new NewUi() : instance;
}

@Override
public void initGui() {
Keyboard.enableRepeatEvents(true);
for (final CategoryElement ce : categoryElements) {
Expand All @@ -56,7 +55,6 @@ public void initGui() {
super.initGui();
}

@Override
public void onGuiClosed() {
for (final CategoryElement ce : categoryElements) {
if (ce.getFocused())
Expand All @@ -65,7 +63,6 @@ public void onGuiClosed() {
Keyboard.enableRepeatEvents(false);
}

@Override
public void drawScreen(final int mouseX, final int mouseY, final float partialTicks) {
drawFullSized(mouseX, mouseY, partialTicks, Objects.requireNonNull(Launch.moduleManager.getModule(Gui.class)).generateColor());
}
Expand Down Expand Up @@ -149,7 +146,6 @@ private void drawFullSized(final int mouseX, final int mouseY, final float parti
super.drawScreen(mouseX, mouseY, partialTicks);
}

@Override
protected void mouseClicked(final int mouseX, final int mouseY, final int mouseButton) throws IOException {
if (MouseUtils.mouseWithinBounds(mouseX, mouseY, this.width - 54F, 30F, this.width - 30F, 50F)) {
mc.displayGuiScreen(null);
Expand All @@ -170,7 +166,6 @@ protected void mouseClicked(final int mouseX, final int mouseY, final int mouseB
}
}

@Override
protected void keyTyped(final char typedChar, final int keyCode) throws IOException {
for (final CategoryElement ce : categoryElements) {
if (ce.getFocused()) {
Expand All @@ -183,7 +178,6 @@ protected void keyTyped(final char typedChar, final int keyCode) throws IOExcept
super.keyTyped(typedChar, keyCode);
}

@Override
protected void mouseReleased(final int mouseX, final int mouseY, final int state) {
searchElement.handleMouseRelease(mouseX, mouseY, state, 230, 50, width - 260, height - 80, categoryElements);
if (!searchElement.isTyping())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SearchElement(val xPos: Float, val yPos: Float, val width: Float, val heig
if (searchBox.isFocused) {
RenderUtils.newDrawRect(xPos, yPos + height - 1F, xPos + width, yPos + height, accentColor.rgb)
searchBox.drawTextBox()
} else if (searchBox.text.length <= 0) {
} else if (searchBox.text.isEmpty()) {
searchBox.text = "Search..."
searchBox.drawTextBox()
searchBox.text = ""
Expand All @@ -43,7 +43,7 @@ class SearchElement(val xPos: Float, val yPos: Float, val width: Float, val heig
Stencil.dispose()
GlStateManager.disableAlpha()
GlStateManager.enableAlpha()
return searchBox.text.length > 0
return searchBox.text.isNotEmpty()
}

fun drawPanel(
Expand Down Expand Up @@ -76,10 +76,10 @@ class SearchElement(val xPos: Float, val yPos: Float, val width: Float, val heig
for (ce in ces) {
for (me in ce.moduleElements) {
if (me.module.name.startsWith(searchBox.text, true)) {
if (startY + animScrollHeight > y + h || startY + animScrollHeight + 40F + me.animHeight < y + 50F)
startY += 40F + me.animHeight
startY += if (startY + animScrollHeight > y + h || startY + animScrollHeight + 40F + me.animHeight < y + 50F)
40F + me.animHeight
else
startY += me.drawElement(mX, mouseY, x, startY + animScrollHeight, w, 40F, accentColor)
me.drawElement(mX, mouseY, x, startY + animScrollHeight, w, 40F, accentColor)
}
}
}
Expand Down Expand Up @@ -132,7 +132,7 @@ class SearchElement(val xPos: Float, val yPos: Float, val width: Float, val heig
val mouseX = mX
var mouseY = mY
searchBox.mouseClicked(mouseX, mouseY, mouseButton)
if (searchBox.text.length <= 0) return
if (searchBox.text.isEmpty()) return
if (mouseY < y + 40F || mouseY >= y + h)
mouseY = -1
var startY = y + 40F
Expand Down Expand Up @@ -178,7 +178,7 @@ class SearchElement(val xPos: Float, val yPos: Float, val width: Float, val heig
ces: List<CategoryElement>
): Boolean {
searchBox.textboxKeyTyped(typedChar, keyCode)
if (searchBox.text.length <= 0) return false
if (searchBox.text.isEmpty()) return false
for (ce in ces)
for (me in ce.moduleElements)
if (me.module.name.startsWith(searchBox.text, true))
Expand All @@ -187,6 +187,6 @@ class SearchElement(val xPos: Float, val yPos: Float, val width: Float, val heig
return false
}

fun isTyping(): Boolean = (searchBox.text.length > 0)
fun isTyping(): Boolean = (searchBox.text.isNotEmpty())

}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected BufferedImage generateFontImage(final Font font, final boolean antiAli
return bufferedImage;
}

protected void drawChar(final CharData[] chars, final char c, final float x, final float y) throws ArrayIndexOutOfBoundsException {
public void drawChar(final CharData[] chars, final char c, final float x, final float y) throws ArrayIndexOutOfBoundsException {
try {
this.drawQuad(x, y, chars[c].width, chars[c].height, chars[c].storedX, chars[c].storedY, chars[c].width,
chars[c].height);
Expand Down

0 comments on commit 2963d99

Please sign in to comment.