resent-1.8/src/main/java/dev/resent/module/base/Mod.java

85 lines
2.2 KiB
Java
Raw Normal View History

2023-01-12 14:10:43 -08:00
package dev.resent.module.base;
2023-01-14 07:56:36 -08:00
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
2023-01-19 11:36:49 -08:00
2023-01-31 20:40:17 -08:00
import dev.resent.annotation.Module;
2023-01-20 13:15:54 -08:00
import dev.resent.module.setting.Setting;
2023-02-02 15:03:08 -08:00
import dev.resent.ui.Theme;
2023-01-19 11:36:49 -08:00
import dev.resent.util.render.RenderUtils;
2023-01-12 14:10:43 -08:00
import net.minecraft.client.Minecraft;
2023-02-02 08:07:00 -08:00
public abstract class Mod {
2023-01-12 14:10:43 -08:00
2023-01-14 07:56:36 -08:00
public Minecraft mc = Minecraft.getMinecraft();
public int keyCode;
public String name;
public Category category;
public boolean enabled = false;
public boolean hasSetting;
public List<Setting> settings = new ArrayList<>();
2023-01-31 20:40:17 -08:00
public Mod(){
Module modInfo;
if(getClass().isAnnotationPresent(Module.class)){
modInfo = getClass().getAnnotation(Module.class);
this.name = modInfo.name();
this.category = modInfo.category();
this.hasSetting = modInfo.hasSetting();
2023-02-02 08:05:40 -08:00
}
2023-01-31 20:40:17 -08:00
}
2023-02-04 14:59:09 -08:00
public void addSetting(final Setting... settings) {
2023-01-14 07:56:36 -08:00
this.settings.addAll(Arrays.asList(settings));
}
public void onEnable() {}
public void onDisable() {}
public void toggle() {
this.enabled = !this.enabled;
if (this.enabled) {
onEnable();
} else {
onDisable();
}
}
2023-02-04 14:59:09 -08:00
protected void drawRect(final int left, final int top, final int right, final int bottom, final int color){
2023-02-02 08:05:40 -08:00
RenderUtils.drawRoundedRect(left, top, right, bottom, 4, color, Theme.getRounded());
2023-01-19 11:36:49 -08:00
}
2023-02-04 14:59:09 -08:00
protected int drawString(final String text, final int x, final int y, final int color, final boolean idk){
2023-01-30 16:41:01 -08:00
if(color == 6942069){
RenderUtils.drawChromaString(text, x, y, idk);
}else {
Minecraft.getMinecraft().fontRendererObj.drawString(text, x, y, color, idk);
}
return x;
}
2023-02-04 14:59:09 -08:00
public void setEnabled(final boolean state) {
2023-01-14 07:56:36 -08:00
this.enabled = state;
if (this.enabled) onEnable(); else onDisable();
}
2023-02-02 19:18:34 -08:00
public enum Category {
HUD("Hud"),
MISC("Misc");
public final String name;
2023-02-04 15:51:17 -08:00
public int i;
2023-02-04 14:59:09 -08:00
Category(final String name) {
2023-02-02 19:18:34 -08:00
this.name = name;
}
}
2023-01-23 14:45:04 -08:00
2023-01-19 11:36:49 -08:00
public boolean isEnabled() { return enabled; }
public String getName() { return name; }
2023-01-14 07:56:36 -08:00
2023-01-12 14:10:43 -08:00
}