Added sorting modes and changing names

This commit is contained in:
cewiko1x 2020-05-06 19:14:29 +02:00
parent 589accfe6f
commit af39caa068
6 changed files with 93 additions and 5 deletions

View File

@ -0,0 +1,48 @@
package me.rigamortis.seppuku.impl.command;
import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.command.Command;
import me.rigamortis.seppuku.api.module.Module;
import net.minecraft.client.Minecraft;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.play.client.CPacketCreativeInventoryAction;
/**
* Author Ice
* 5/06/2020 @ 18:14 PM.
*/
public final class RenameModuleCommand extends Command {
public RenameModuleCommand() {
super("RenameModule", new String[]{"rm", "renamemod", "renamemodule"}, "Rename modules.", "Enchant <Enchantment / All> <Level / Max> ([true/false] Disable Curses)");
}
@Override
public void exec(String input) {
if (!this.clamp(input, 3, 3)) {
this.printUsage();
return;
}
final String[] split = input.split(" ");
final String originalModuleName = split[1];
final String newModuleName = split[2];
if(Seppuku.INSTANCE.getModuleManager().find(originalModuleName) != null) {
Module mod = Seppuku.INSTANCE.getModuleManager().find(originalModuleName);
mod.setDisplayName(newModuleName);
Seppuku.INSTANCE.logChat("Set " + originalModuleName + " custom alias to " + newModuleName);
} else {
Seppuku.INSTANCE.logChat(originalModuleName + " does not exist!");
}
}
}

View File

@ -36,6 +36,11 @@ public class ModuleConfig extends Configurable {
if (entry.getKey().equalsIgnoreCase("Keybind")) {
module.setKey(entry.getValue().getAsString());
}
if (entry.getKey().equalsIgnoreCase("Alias")) {
module.setDisplayName(entry.getValue().getAsString());
}
// Check if we are already enabled
if (entry.getKey().equalsIgnoreCase("Enabled") && !module.isEnabled() && module.getType() != Module.ModuleType.HIDDEN) {
if (entry.getValue().getAsBoolean()) {
@ -67,6 +72,7 @@ public class ModuleConfig extends Configurable {
public void onSave() {
JsonObject moduleJsonObject = new JsonObject();
moduleJsonObject.addProperty("Name", module.getDisplayName());
moduleJsonObject.addProperty("Alias", module.getCustomAlias());
moduleJsonObject.addProperty("Color", Integer.toHexString(module.getColor()).toUpperCase());
moduleJsonObject.addProperty("Hidden", module.isHidden());
moduleJsonObject.addProperty("Keybind", (module.getKey() != null) ? module.getKey() : "NONE");

View File

@ -4,12 +4,15 @@ import com.mojang.realmsclient.gui.ChatFormatting;
import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.gui.hud.component.DraggableHudComponent;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.impl.module.render.HudModule;
import net.minecraft.client.Minecraft;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import static me.rigamortis.seppuku.impl.module.render.HudModule.Mode.*;
/**
* Author Seth
* 7/25/2019 @ 7:24 AM.
@ -39,7 +42,28 @@ public final class ArrayListComponent extends DraggableHudComponent {
return dif != 0 ? (int) dif : secondName.compareTo(firstName);
};
mods.sort(comparator);
final Comparator<Module> lengthComparator = (first, second) -> {
final String firstName = first.getDisplayName() + (first.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + first.getMetaData().toLowerCase() + ChatFormatting.GRAY + "]" : "");
final String secondName = second.getDisplayName() + (second.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + second.getMetaData().toLowerCase() + ChatFormatting.GRAY + "]" : "");
final float dif = Minecraft.getMinecraft().fontRenderer.getStringWidth(secondName) - Minecraft.getMinecraft().fontRenderer.getStringWidth(firstName);
return dif != 0 ? (int) dif : secondName.compareTo(firstName);
};
final Comparator<Module> alphabeticalComparator = (first, second) -> {
final String firstName = first.getDisplayName() + (first.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + first.getMetaData().toLowerCase() + ChatFormatting.GRAY + "]" : "");
final String secondName = second.getDisplayName() + (second.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + second.getMetaData().toLowerCase() + ChatFormatting.GRAY + "]" : "");
return firstName.compareToIgnoreCase(secondName);
};
Object sorting_mode = Seppuku.INSTANCE.getModuleManager().find(HudModule.class).find("Sorting Mode").getValue();
if (LENGTH.equals(sorting_mode)) {
mods.sort(lengthComparator);
} else if (ALPHABET.equals(sorting_mode)) {
mods.sort(alphabeticalComparator);
} else if (UNSORTED.equals(sorting_mode)) {
}
float xOffset = 0;
float yOffset = 0;
@ -47,7 +71,8 @@ public final class ArrayListComponent extends DraggableHudComponent {
for (Module mod : mods) {
if (mod != null && mod.getType() != Module.ModuleType.HIDDEN && mod.isEnabled() && !mod.isHidden()) {
final String name = mod.getDisplayName() + (mod.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + mod.getMetaData().toLowerCase() + ChatFormatting.GRAY + "]" : "");
String name = (Boolean)Seppuku.INSTANCE.getModuleManager().find(HudModule.class).find("Custom Aliases").getValue() ? mod.getCustomAlias() != null ? mod.getCustomAlias() : mod.getDisplayName() + (mod.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + mod.getMetaData().toLowerCase() + ChatFormatting.GRAY + "]" : "") : mod.getDisplayName() + (mod.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + mod.getMetaData().toLowerCase() + ChatFormatting.GRAY + "]" : "");
final float width = Minecraft.getMinecraft().fontRenderer.getStringWidth(name);

View File

@ -60,6 +60,7 @@ public final class CommandManager {
this.commandList.add(new JoinDateCommand());
this.commandList.add(new EnchantCommand());
this.commandList.add(new RenameCommand());
this.commandList.add(new RenameModuleCommand());
this.commandList.add(new SpawnEggCommand());
this.commandList.add(new StackSizeCommand());
this.commandList.add(new CrashSlimeCommand());

View File

@ -163,13 +163,15 @@ public final class ElytraFlyModule extends Module {
break;
case CONTROL:
final double[] directionSpeedControl = MathUtil.directionSpeed(this.speed.getValue());
mc.player.motionY = -this.idlefall.getValue();
// TODO
// mc.player.motionY = -this.idlefall.getValue();
mc.player.motionX = 0;
mc.player.motionZ = 0;
if (mc.player.movementInput.jump) {
mc.player.motionY = this.upspd.getValue();
// mc.player.motionY = this.upspd.getValue();
} else if (mc.player.movementInput.sneak) {
mc.player.motionY = -this.downspd.getValue();
// mc.player.motionY = -this.downspd.getValue();
}
if (mc.player.movementInput.moveStrafe != 0 || mc.player.movementInput.moveForward != 0) {
mc.player.motionX = directionSpeedControl[0];

View File

@ -9,6 +9,7 @@ import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.api.value.Value;
import me.rigamortis.seppuku.impl.gui.hud.GuiHudEditor;
import me.rigamortis.seppuku.impl.gui.hud.anchor.AnchorPoint;
import me.rigamortis.seppuku.impl.module.movement.FlightModule;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
@ -19,6 +20,7 @@ import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
*/
public final class HudModule extends Module {
public final Value<HudModule.Mode> mode = new Value<HudModule.Mode>("Sorting Mode", new String[]{"Sorting", "sort"}, "Changes arraylist sorting.", HudModule.Mode.LENGTH);
public final Value<Boolean> hidePotions = new Value<Boolean>("HidePotions", new String[]{"HidePotions", "HidePots", "Hide_Potions"}, "Hides the Vanilla potion hud (at the top right of the screen).", true);
public HudModule() {
@ -68,4 +70,8 @@ public final class HudModule extends Module {
event.setCanceled(true);
}
}
public enum Mode {
LENGTH, ALPHABET, UNSORTED;
}
}