bright module fix, add midclick, add notifications

This commit is contained in:
Daniella / Tove 2024-05-24 17:52:40 +02:00
parent 6e5a437620
commit a0f875878f
13 changed files with 274 additions and 7 deletions

View file

@ -15,7 +15,6 @@ public class Button extends Component {
public void click(int x, int y, int mouseButton) {
super.click(x, y, mouseButton);
if(mouseButton == 0) {
green = true;
event.click(this);
}
if(mouseButton == 2) {

View file

@ -129,9 +129,6 @@ public abstract class Component {
public void update() { }
public void click(int x, int y, int mouseButton) {
if(mouseButton == 0) {
green = !green;
}
if(mouseButton == 1) {
subComponentsShown = !subComponentsShown;
}

View file

@ -35,7 +35,6 @@ public class EnumButton extends Component {
@Override
public void click(int x, int y, int mouseButton) {
super.click(x, y, mouseButton);
green = true;
if(mouseButton == 2) {
Set.openQuickSet(Set.addQuickSet(handle), field);
}

View file

@ -88,7 +88,6 @@ public class IntSlider extends Component {
@Override
public synchronized void click(int x, int y, int mouseButton) {
super.click(x, y, mouseButton);
green = true;
if(mouseButton == 2) {
Set.openQuickSet(Set.addQuickSet(handle), field);
return;

View file

@ -86,7 +86,6 @@ public class Slider extends Component {
@Override
public synchronized void click(int x, int y, int mouseButton) {
super.click(x, y, mouseButton);
green = true;
if(mouseButton == 2) {
Set.openQuickSet(Set.addQuickSet(handle), field);
return;

View file

@ -44,6 +44,7 @@ public class ToggleButton extends Component {
return;
}
if(mouseButton == 0) {
green = !green;
handle.getContent().set(field, green);
handle.updated(field);
if(lambda != null)

View file

@ -5,6 +5,7 @@ import com.baseband.client.module.chat.ChatAppend;
import com.baseband.client.module.chat.ChatCrypt;
import com.baseband.client.module.chat.ExtraChat;
import com.baseband.client.module.client.Client;
import com.baseband.client.module.client.MidClick;
import com.baseband.client.module.combat.AutoKill;
import com.baseband.client.module.combat.AutoTotem;
import com.baseband.client.module.command.Set;
@ -14,6 +15,7 @@ import com.baseband.client.module.movement.NoSlowDown;
import com.baseband.client.module.movement.Velocity;
import com.baseband.client.module.render.*;
import com.baseband.client.module.world.AutoSignText;
import com.baseband.client.module.world.Selection;
/**
* @author TudbuT
@ -47,6 +49,8 @@ public class Setup {
AutoKill.INSTANCE.autoHit,
AutoKill.INSTANCE.autoCrystal,
new Bright(),
new MidClick(),
new Selection(),
};

View file

@ -16,6 +16,7 @@ import net.minecraftforge.common.MinecraftForge;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.function.Consumer;
/**
* @author TudbuT
@ -108,6 +109,14 @@ public abstract class Feature extends ToggleButton implements SetCommand {
MultiGate mgate = f.getDeclaredAnnotation(MultiGate.class);
AnyGate gate = new AnyGate(sgate, mgate, this);
if (config != null) {
if(Button.ClickEvent.class.isAssignableFrom(f.getType())) {
try {
subComponents.add(new Button(config.value(), ((Button.ClickEvent) f.get(this))).gate(gate));
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
continue;
}
BaseBand.registerUpdater(settings.linkWith(this, f).name(config.value()));
if (f.getType() == boolean.class) {
subComponents.add(new ToggleButton(config.value(), settings, config.value()).gate(gate));

View file

@ -0,0 +1,110 @@
package com.baseband.client.module.client;
import com.baseband.client.configuration.annotation.Config;
import com.baseband.client.module.Feature;
import com.baseband.client.module.category.Client;
import com.baseband.client.module.combat.AutoKill;
import com.baseband.client.module.world.Selection;
import com.baseband.client.util.config.PlayerDB;
import com.baseband.client.util.ingame.ChatUtil;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import org.lwjgl.input.Mouse;
import java.util.function.Consumer;
@Client
public class MidClick extends Feature {
public enum PlayerAction {
None((p) -> {}),
Target((p) -> {
PlayerDB.player(p.getGameProfile().getId(), p.getGameProfile().getName()).set("isTarget", true);
}),
Friend((p) -> {
PlayerDB.player(p.getGameProfile().getId(), p.getGameProfile().getName()).set("isFriend", true);
}),
Message((p) -> {
ChatUtil.openChat("/w " + p.getGameProfile().getName() + " ");
}),
;
public Consumer<EntityPlayer> action;
PlayerAction(Consumer<EntityPlayer> action) {
this.action = action;
}
}
public enum BlockAction {
None((b) -> {}),
Select((b) -> {
Selection.begin = b;
Selection.end = b;
}),
Corner((b) -> {
Selection.select(b);
}),
;
public Consumer<BlockPos> action;
BlockAction(Consumer<BlockPos> action) {
this.action = action;
}
}
public enum EntityAction {
None((e) -> {}),
Target((e) -> {
AutoKill.prioritizedTarget = e;
}),
;
public Consumer<EntityLivingBase> action;
EntityAction(Consumer<EntityLivingBase> action) {
this.action = action;
}
}
@Config("PlayerAction")
public PlayerAction playerAction = PlayerAction.Message;
@Config("BlockAction")
public BlockAction blockAction = BlockAction.Corner;
@Config("EntityAction")
public EntityAction entityAction = EntityAction.Target;
public void onRender(RenderWorldLastEvent event) {
doCheck();
}
@Override
public void onTick() {
doCheck();
}
private void doCheck() {
if(Mouse.isButtonDown(2)) {
RayTraceResult hover = mc.objectMouseOver;
if(hover.entityHit != null) {
if(hover.entityHit instanceof EntityPlayer) {
playerAction.action.accept(((EntityPlayer) hover.entityHit));
return;
}
if(hover.entityHit instanceof EntityLivingBase) {
entityAction.action.accept(((EntityLivingBase) hover.entityHit));
return;
}
}
if(hover.getBlockPos() != null) {
blockAction.action.accept(hover.getBlockPos());
}
}
}
@Override
public String toString() {
return "MidClick";
}
}

View file

@ -16,6 +16,7 @@ import java.util.ArrayList;
@Combat
public class AutoKill extends Feature {
public static EntityLivingBase prioritizedTarget;
public AutoHit autoHit = new AutoHit();
public AutoCrystal autoCrystal = new AutoCrystal();

View file

@ -19,6 +19,7 @@ public class Bright extends Feature {
@Override
public void onDisable() {
if(test()) return;
mc.player.removeActivePotionEffect(MobEffects.NIGHT_VISION);
}
}

View file

@ -1,31 +1,148 @@
package com.baseband.client.module.render;
import com.baseband.client.configuration.annotation.*;
import com.baseband.client.gui.lib.component.Button;
import com.baseband.client.init.BaseBand;
import com.baseband.client.module.Category;
import com.baseband.client.module.Feature;
import com.baseband.client.module.category.Render;
import com.baseband.client.module.client.Client;
import com.baseband.client.util.misc.Marker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Date;
@Render
public class HUD extends Feature {
public static ArrayList<Notification> notifs = new ArrayList<>();
public static class Notification {
public String text;
private final int time;
private final long start = new Date().getTime();
public Notification(String text) {
this(text, 5000);
}
public Notification(String text, int ms) {
this.text = text;
this.time = ms;
}
}
public static void notify(String text) {
notifs.add(new Notification(text));
}
public static void notify(String text, int time) {
notifs.add(new Notification(text, time));
}
public enum NotificationLocation {
Left, Center, Right
}
@Config("Notifications")
@Marker(1)
public boolean notifications = true;
@Config("Notification location")
@Gate(1)
public NotificationLocation nLocation = NotificationLocation.Center;
@Config("Advanced")
@Gate(1)
@Marker(2)
public boolean advancedNotifs = false;
@Config("Notification size X")
@Range("2..6")
@MultiGate(and = {1, 2})
public int nSize = 3;
@Config("Notification size Y")
@Range("1..4")
@MultiGate(and = {1, 2})
public int nVSize = 2;
@Config("Notification spacing")
@Range("0..20")
@MultiGate(and = {1, 2})
public int nVSpace = 5;
@Config("Test!")
@Gate(1)
public final Button.ClickEvent testBtn = btn -> notify(btn.text + " " + System.currentTimeMillis());
@Override
public String toString() {
return "HUD";
}
@Override
public void onTick() {
for (int i = 0; i < notifs.size(); i++) {
Notification notif = notifs.get(i);
if(new Date().getTime() - notif.start >= notif.time) {
notifs.remove(i);
i--;
}
}
}
@SubscribeEvent
public void text(RenderGameOverlayEvent.Text e) {
ScaledResolution sr = new ScaledResolution(mc);
mc.fontRenderer.drawStringWithShadow("BaseBand - \"" + BaseBand.buildString + "\"", 2,2, BaseBand.getModule(Client.class).getTheme().getGreenColor());
int y = 11;
for (Feature f : Arrays.stream(Setup.Features).filter(m -> m.enabled && m.category != Category.COMMAND && m.category != Category.CLIENT && !m.toString().equals("HUD")).sorted(Comparator.comparingDouble(value -> -Minecraft.getMinecraft().fontRenderer.getStringWidth(value.toString()))).toArray(Feature[]::new)) {
mc.fontRenderer.drawStringWithShadow(f.toString(), 2, y, BaseBand.getModule(Client.class).getTheme().getGreenColor());
y = y + mc.fontRenderer.FONT_HEIGHT;
}
if(notifications) {
int xSize = this.nSize * 100;
int ySize = this.nVSize * 10;
int textOffset = (ySize / 2 - (9 / 2));
int x = 2;
if(nLocation == NotificationLocation.Center) {
x = sr.getScaledWidth() / 2 - (xSize / 2);
y = sr.getScaledHeight() / 4;
} else {
if(nLocation == NotificationLocation.Right) {
y = -5;
x = sr.getScaledWidth() - x - xSize;
}
y += 5;
y += nVSpace;
}
Notification[] notifs = HUD.notifs.toArray(new Notification[0]);
for (int i = notifs.length - 1; i >= 0; i--) {
Notification notif = notifs[i];
Gui.drawRect(x, y, x + xSize, y + ySize, 0x80202040);
drawStringL(notif.text, x + textOffset, y + textOffset, 0xffffffff);
y += (ySize + nVSpace) * (nLocation == NotificationLocation.Center ? -1 : 1);
}
}
}
private void drawString(String s, int x, int y, int color) {
drawStringL(s, x - mc.fontRenderer.getStringWidth(s), y, color);
}
private void drawStringL(String s, int x, int y, int color) {
mc.fontRenderer.drawStringWithShadow(s, (float)x, (float)y, color);
}
}

View file

@ -0,0 +1,31 @@
package com.baseband.client.module.world;
import com.baseband.client.module.Feature;
import com.baseband.client.module.category.World;
import com.baseband.client.module.render.HUD;
import net.minecraft.util.math.BlockPos;
@World
public class Selection extends Feature {
public static BlockPos begin, end;
public static void select(BlockPos b) {
if(begin != null) {
end = b;
HUD.notify("Position 2: " + b.getX() + " " + b.getY() + " " + b.getZ());
return;
}
if(end != null) {
begin = b;
HUD.notify("Selection reset.");
HUD.notify("Position 1: " + b.getX() + " " + b.getY() + " " + b.getZ());
return;
}
}
@Override
public String toString() {
return "Selection";
}
}