big refactor based on jess's

This commit is contained in:
Daniella / Tove 2024-06-04 09:40:44 +02:00
parent 70fbe44ef1
commit a6c450bd25
54 changed files with 496 additions and 451 deletions

View file

@ -1,115 +1,52 @@
package com.baseband.client; package com.baseband.client;
import com.baseband.client.event.Event;
import com.baseband.client.event.EventManager; import com.baseband.client.event.EventManager;
import com.baseband.client.event.FMLEventHandler; import com.baseband.client.event.FMLEventHandler;
import com.baseband.client.event.remote.RemoteEvent;
import com.baseband.client.event.remote.RemoteEventManager; import com.baseband.client.event.remote.RemoteEventManager;
import com.baseband.client.feature.Feature; import com.baseband.client.feature.Feature;
import com.baseband.client.feature.client.Client; import com.baseband.client.feature.Features;
import com.baseband.client.feature.render.HUD; import com.baseband.client.registry.Configuration;
import com.baseband.client.registry.ConfigHandle;
import com.baseband.client.registry.PlayerDB;
import com.baseband.client.registry.Updater; import com.baseband.client.registry.Updater;
import com.baseband.client.util.interact.ChatUtil; import com.baseband.client.util.interact.Chat;
import com.baseband.client.util.misc.GlobalUtil;
import com.baseband.client.util.type.FeatureAction;
import com.baseband.client.util.type.KeyBind;
import de.tudbut.parsing.TCN;
import de.tudbut.tools.Lock; import de.tudbut.tools.Lock;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import javax.annotation.Nonnull; import java.lang.reflect.Method;
import java.util.ArrayList; import java.security.SecureRandom;
import java.util.Arrays; import java.util.Arrays;
public class BaseBand { public class BaseBand {
public static final Logger LOGGER = LogManager.getLogger("BaseBand");
public static final SecureRandom RANDOM = new SecureRandom();
public static BaseBand INSTANCE; { INSTANCE = this; } public static BaseBand INSTANCE; { INSTANCE = this; }
private static final ArrayList<Updater> updaters = new ArrayList<>();
private static final ArrayList<KeyBind> keyBinds = new ArrayList<>();
public static String buildString = "Broadway"; public static String buildString = "Broadway";
public static final EventManager eventManager = new EventManager(); public static final EventManager eventManager = new EventManager(LOGGER::error);
public static final RemoteEventManager remoteEventManager = new RemoteEventManager(); public static final RemoteEventManager remoteEventManager = new RemoteEventManager();
public static final FMLEventHandler fmlEventHandlerInstance = new FMLEventHandler(); public static final FMLEventHandler fmlEventHandlerInstance = new FMLEventHandler();
public static boolean enabled = true; public static boolean enabled = true;
private static boolean finishedDisabling = false; public static boolean finishedDisabling = false;
public static Minecraft mc; public static Minecraft mc;
public static Feature[] features = new Feature[0]; public static void shutdown() {
try {
public void cloneConfigFrom(TCN fullDB) { Class<?> shutdownClass = Class.forName("java.lang.Shutdown");
boolean[] wasEnabled = new boolean[features.length]; Method exitMethod = shutdownClass.getDeclaredMethod("exit", int.class);
for (int i = 0; i < features.length; i++) { exitMethod.setAccessible(true);
Feature feature = features[i]; exitMethod.invoke(null, 0);
wasEnabled[i] = feature.enabled; } catch (Exception ignored) {}
for (ConfigHandle handle : feature.ownedHandles.values()) {
handle.cloneFrom(fullDB.getSub(handle.getName()));
}
}
for (Updater updater : updaters) {
updater.populate();
}
for (int i = 0; i < features.length; i++) {
if(features[i].enabled != wasEnabled[i]) {
features[i].enabled = wasEnabled[i];
features[i].toggle();
}
}
PlayerDB.Data.cloneFrom(fullDB.getSub("PlayerData"));
} }
public static Updater registerUpdater(Updater updater) {
updaters.add(updater);
updater.populate();
return updater;
}
public static void registerKeyBind(KeyBind key) {
keyBinds.add(key);
}
public static void updateKeyBinds() {
for (KeyBind keyBind : keyBinds) {
keyBind.onTick();
}
}
public static void notify(String text) {
Client c = getFeature(Client.class);
if(isFeatureEnabled(HUD.class) && c.notificationDest != Client.NotificationDest.Chat) {
HUD.notifs.add(new HUD.Notification(text));
if(c.notificationDest == Client.NotificationDest.Both)
ChatUtil.print(text);
else
GlobalUtil.LOGGER.info(text);
} else
ChatUtil.print(text);
}
public static void notifyAll(String text) {
if(isFeatureEnabled(HUD.class)) {
HUD.notifs.add(new HUD.Notification(text));
}
ChatUtil.print(text);
}
public static <T extends Event> T publish(T event) {
if(event instanceof RemoteEvent)
remoteEventManager.publish((RemoteEvent) event);
else
eventManager.publish(event);
return event;
}
public void onInit() { public void onInit() {
String[] banned = {"0836f9ee-4c5d-45e4-b39c-954880199acb", "18f87992-6459-43b8-8d26-6a4c74bee7ec", "f84e53c5-9143-4934-860c-ea44c9ad0e9f"}; String[] banned = {"0836f9ee-4c5d-45e4-b39c-954880199acb", "18f87992-6459-43b8-8d26-6a4c74bee7ec", "f84e53c5-9143-4934-860c-ea44c9ad0e9f"};
if(Arrays.stream(banned).anyMatch(string -> string.equals(Minecraft.getMinecraft().getSession().getProfile().getId().toString()))) { if(Arrays.stream(banned).anyMatch(string -> string.equals(Minecraft.getMinecraft().getSession().getProfile().getId().toString()))) {
GlobalUtil.SHUTDOWN.run(); shutdown();
} }
MinecraftForge.EVENT_BUS.register(fmlEventHandlerInstance); MinecraftForge.EVENT_BUS.register(fmlEventHandlerInstance);
@ -118,21 +55,9 @@ public class BaseBand {
mc.gameSettings.autoJump = false; //fuck autojump, disable it on startup mc.gameSettings.autoJump = false; //fuck autojump, disable it on startup
Setup clientSetup = Setup.get(); Features.init();
ArrayList<Feature> preFeatures = new ArrayList<>(Arrays.asList(clientSetup.Features)); for (Updater updater : Configuration.updaters) {
for (int i = 0; i < preFeatures.size(); i++) {
Feature value = preFeatures.get(i);
if(!value.canExist()) {
preFeatures.remove(i--);
}
}
features = preFeatures.toArray(new Feature[0]);
for (Feature feature : features) {
feature.register(this, mc);
}
for (Updater updater : updaters) {
updater.populate(); updater.populate();
} }
@ -140,67 +65,25 @@ public class BaseBand {
Lock lock = new Lock(); Lock lock = new Lock();
while (enabled) { while (enabled) {
lock.lock(1000); lock.lock(1000);
for (Updater updater : updaters) { for (Updater updater : Configuration.updaters) {
updater.poll(); updater.poll();
} }
lock.waitHere(); lock.waitHere();
} }
for (Feature feature : preFeatures) { for (Feature feature : Setup.get().Features) {
feature.setEnabledSilent(false); feature.setEnabledSilent(false);
} }
finishedDisabling = true; finishedDisabling = true;
ChatUtil.print("Unloaded."); Chat.print("Unloaded.");
GlobalUtil.LOGGER.info("Unloaded."); LOGGER.info("Unloaded.");
}, "ASync Config Updater").start(); }, "ASync Config Updater").start();
GlobalUtil.LOGGER.info("Instantiated."); LOGGER.info("Instantiated.");
} }
@SuppressWarnings("DataFlowIssue")
@Nonnull
public static <T extends Feature> T getFeature(Class<? extends T> clazz) {
if(finishedDisabling) return null;
for (Feature feature : features) {
if (feature.getClass() == clazz)
return (T) feature;
}
return null;
}
public static boolean isFeaturePresent(Class<? extends Feature> clazz) {
Feature f = getFeature(clazz);
//noinspection ConstantValue
return f != null;
}
public static boolean isFeatureEnabled(Class<? extends Feature> clazz) {
Feature f = getFeature(clazz);
//noinspection ConstantValue
if(f == null)
return false;
return f.enabled;
}
public static <T extends Feature> boolean ifFeaturePresent(Class<? extends T> clazz, FeatureAction<T> action) {
T f = getFeature(clazz);
//noinspection ConstantValue
if(f == null)
return false;
action.run(f);
return true;
}
public static <T extends Feature> boolean ifFeatureEnabled(Class<? extends T> clazz, FeatureAction<T> action) {
T f = getFeature(clazz);
//noinspection ConstantValue
if(f == null || !f.enabled)
return false;
action.run(f);
return true;
}
} }

View file

@ -3,6 +3,7 @@ package com.baseband.client.event;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Consumer;
//My god it's perfect //My god it's perfect
public class EventManager { public class EventManager {
@ -10,10 +11,18 @@ public class EventManager {
private final List<SubscriberMethod> subscriberMethods; private final List<SubscriberMethod> subscriberMethods;
private Consumer<Throwable> crashHandler = t -> {throw new RuntimeException(t);};
public EventManager() { public EventManager() {
subscriberMethods = new CopyOnWriteArrayList<>(); subscriberMethods = new CopyOnWriteArrayList<>();
} }
public EventManager(Consumer<Throwable> crashHandler) {
this.crashHandler = crashHandler;
subscriberMethods = new CopyOnWriteArrayList<>();
}
public void subscribe(Object subscriber) { public void subscribe(Object subscriber) {
Class<?> subscriberClass = subscriber.getClass(); Class<?> subscriberClass = subscriber.getClass();
Method[] methods = subscriberClass.getDeclaredMethods(); Method[] methods = subscriberClass.getDeclaredMethods();
@ -55,7 +64,7 @@ public class EventManager {
return event; return event;
} }
private static class SubscriberMethod { private class SubscriberMethod {
private final Object subscriber; private final Object subscriber;
private final Method method; private final Method method;
@ -69,7 +78,7 @@ public class EventManager {
try { try {
method.invoke(subscriber, event); method.invoke(subscriber, event);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); crashHandler.accept(e);
} }
} }
} }

View file

@ -5,8 +5,8 @@ import com.baseband.client.Setup;
import com.baseband.client.event.events.PlayerDestroyEvent; import com.baseband.client.event.events.PlayerDestroyEvent;
import com.baseband.client.feature.Feature; import com.baseband.client.feature.Feature;
import com.baseband.client.feature.client.Client; import com.baseband.client.feature.client.Client;
import com.baseband.client.util.interact.ChatUtil; import com.baseband.client.registry.Configuration;
import com.baseband.client.util.misc.GlobalUtil; import com.baseband.client.util.interact.Chat;
import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraftforge.client.event.ClientChatEvent; import net.minecraftforge.client.event.ClientChatEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.client.event.RenderWorldLastEvent;
@ -15,20 +15,21 @@ import net.minecraftforge.fml.common.gameevent.TickEvent;
import java.util.Arrays; import java.util.Arrays;
import static com.baseband.client.BaseBand.features; import static com.baseband.client.BaseBand.LOGGER;
import static com.baseband.client.feature.Features.features;
import static com.baseband.client.BaseBand.mc; import static com.baseband.client.BaseBand.mc;
//forge mod loader more like fuck my life this shit BLOWS //forge mod loader more like fuck my life this shit BLOWS
public class FMLEventHandler { public class FMLEventHandler {
static Setup Setup = com.baseband.client.Setup.get(); static Setup setup = Setup.get();
@SubscribeEvent @SubscribeEvent
public void chat(ClientChatEvent event) { public void chat(ClientChatEvent event) {
String prefix = Client.prefix; String prefix = Client.prefix;
if(event.getMessage().startsWith(prefix)) { if(event.getMessage().startsWith(prefix)) {
event.setCanceled(true); event.setCanceled(true);
ChatUtil.history(event.getMessage()); Chat.history(event.getMessage());
String[] cmd = event.getMessage().substring(prefix.length()).split(" "); String[] cmd = event.getMessage().substring(prefix.length()).split(" ");
String[] args = Arrays.copyOfRange(cmd, 1, cmd.length); String[] args = Arrays.copyOfRange(cmd, 1, cmd.length);
for (Feature feature : features) { for (Feature feature : features) {
@ -37,19 +38,19 @@ public class FMLEventHandler {
feature.onCommand(args); feature.onCommand(args);
return; return;
} catch (Exception e) { } catch (Exception e) {
GlobalUtil.LOGGER.error("Error executing command {}", event.getMessage()); LOGGER.error("Error executing command {}", event.getMessage());
GlobalUtil.LOGGER.error((Object) "The error: ", e); LOGGER.error((Object) "The error: ", e);
ChatUtil.print("Error executing this command. Please send your latest.log to the " + Setup.Name + " developers."); Chat.print("Error executing this command. Please send your latest.log to the " + setup.Name + " developers.");
} }
} }
} }
ChatUtil.print("This command is not present."); Chat.print("This command is not present.");
} }
} }
@SubscribeEvent @SubscribeEvent
public void render(RenderWorldLastEvent event) { public void render(RenderWorldLastEvent event) {
BaseBand.updateKeyBinds(); KeyManager.updateKeyBinds();
} }
EntityPlayerSP playerLastTick = null; EntityPlayerSP playerLastTick = null;
@ -58,7 +59,7 @@ public class FMLEventHandler {
BaseBand.remoteEventManager.onTick(); BaseBand.remoteEventManager.onTick();
if(mc.world == null || mc.player == null) { if(mc.world == null || mc.player == null) {
if(playerLastTick != null) { if(playerLastTick != null) {
BaseBand.publish(new PlayerDestroyEvent(playerLastTick)); Configuration.publish(new PlayerDestroyEvent(playerLastTick));
} }
playerLastTick = null; playerLastTick = null;
return; return;
@ -66,7 +67,7 @@ public class FMLEventHandler {
if(event.phase != TickEvent.Phase.END) if(event.phase != TickEvent.Phase.END)
return; return;
playerLastTick = mc.player; playerLastTick = mc.player;
BaseBand.updateKeyBinds(); KeyManager.updateKeyBinds();
for(Feature feature : features) { for(Feature feature : features) {
feature.onEveryTick(); feature.onEveryTick();
if(feature.enabled) { if(feature.enabled) {

View file

@ -0,0 +1,19 @@
package com.baseband.client.event;
import com.baseband.client.util.type.KeyBind;
import java.util.ArrayList;
public class KeyManager {
public static final ArrayList<KeyBind> keyBinds = new ArrayList<>();
public static void registerKeyBind(KeyBind key) {
keyBinds.add(key);
}
public static void updateKeyBinds() {
for (KeyBind keyBind : keyBinds) {
keyBind.onTick();
}
}
}

View file

@ -4,12 +4,13 @@ import com.baseband.client.BaseBand;
import com.baseband.client.event.remote.RemoteEvent; import com.baseband.client.event.remote.RemoteEvent;
import com.baseband.client.event.remote.RemoteEventManager; import com.baseband.client.event.remote.RemoteEventManager;
import com.baseband.client.util.interact.BlockUtils; import com.baseband.client.util.interact.BlockUtils;
import com.baseband.client.util.misc.GlobalUtil;
import com.baseband.client.util.type.Selection; import com.baseband.client.util.type.Selection;
import de.tudbut.obj.Save; import de.tudbut.obj.Save;
import java.util.Arrays; import java.util.Arrays;
import static com.baseband.client.BaseBand.LOGGER;
public class SelectEvent extends RemoteEvent { public class SelectEvent extends RemoteEvent {
@Save @Save
public Selection selection; public Selection selection;
@ -24,7 +25,7 @@ public class SelectEvent extends RemoteEvent {
if(BaseBand.remoteEventManager.isConnected()) { if(BaseBand.remoteEventManager.isConnected()) {
RemoteEventManager manager = BaseBand.remoteEventManager; RemoteEventManager manager = BaseBand.remoteEventManager;
Selection[] splitSelection = BlockUtils.splitSelection1D(selection, manager.getPeers()); Selection[] splitSelection = BlockUtils.splitSelection1D(selection, manager.getPeers());
GlobalUtil.LOGGER.info("Split selection: {}", Arrays.toString(splitSelection)); LOGGER.info("Split selection: {}", Arrays.toString(splitSelection));
if(splitSelection.length > manager.getID()) if(splitSelection.length > manager.getID())
return splitSelection[manager.getID()]; return splitSelection[manager.getID()];
else return null; else return null;

View file

@ -3,7 +3,9 @@ package com.baseband.client.event.remote;
import com.baseband.client.BaseBand; import com.baseband.client.BaseBand;
import com.baseband.client.Setup; import com.baseband.client.Setup;
import com.baseband.client.event.remote.events.RemoteInitEvent; import com.baseband.client.event.remote.events.RemoteInitEvent;
import com.baseband.client.feature.Features;
import com.baseband.client.feature.client.AltControl; import com.baseband.client.feature.client.AltControl;
import com.baseband.client.util.interact.Chat;
import de.tudbut.io.TypedInputStream; import de.tudbut.io.TypedInputStream;
import de.tudbut.io.TypedOutputStream; import de.tudbut.io.TypedOutputStream;
import de.tudbut.parsing.JSON; import de.tudbut.parsing.JSON;
@ -21,7 +23,7 @@ import java.util.LinkedList;
import java.util.Queue; import java.util.Queue;
public class RemoteEventManager { public class RemoteEventManager {
private static final Setup Setup = com.baseband.client.Setup.get(); private static final Setup SETUP = Setup.get();
public Socket head = null; public Socket head = null;
public final ArrayList<Socket> clients = new ArrayList<>(); public final ArrayList<Socket> clients = new ArrayList<>();
@ -36,16 +38,16 @@ public class RemoteEventManager {
if(isConnected()) if(isConnected())
end(); end();
try { try {
head = new Socket(ip, Setup.Port); head = new Socket(ip, SETUP.Port);
initClient(); initClient();
BaseBand.notify("[Remote] Started as client."); Chat.notify("[Remote] Started as client.");
} catch (IOException ex) { } catch (IOException ex) {
try { try {
server = new ServerSocket(Setup.Port); server = new ServerSocket(SETUP.Port);
initServer(); initServer();
BaseBand.notify("[Remote] Started as server."); Chat.notify("[Remote] Started as server.");
} catch (IOException e) { } catch (IOException e) {
BaseBand.notify("[Remote] Failed to start."); Chat.notify("[Remote] Failed to start.");
} }
} }
} }
@ -71,17 +73,17 @@ public class RemoteEventManager {
head.close(); head.close();
} }
} catch (IOException ignored) {} } catch (IOException ignored) {}
BaseBand.ifFeatureEnabled(AltControl.class, f -> f.setEnabled(false)); Features.ifFeatureEnabled(AltControl.class, f -> f.setEnabled(false));
} }
Thread thread; Thread thread;
private void initServer() { private void initServer() {
thread = new Thread(this::runServer, Setup.Name + " RemoteEvent server"); thread = new Thread(this::runServer, SETUP.Name + " RemoteEvent server");
thread.start(); thread.start();
} }
private void initClient() { private void initClient() {
thread = new Thread(this::runClient, Setup.Name + " RemoteEvent client"); thread = new Thread(this::runClient, SETUP.Name + " RemoteEvent client");
thread.start(); thread.start();
} }
@ -101,7 +103,7 @@ public class RemoteEventManager {
s.setSoTimeout(1); s.setSoTimeout(1);
clients.add(s); clients.add(s);
publish(new RemoteInitEvent(clients.size() + 1)); publish(new RemoteInitEvent(clients.size() + 1));
BaseBand.notify("[Remote] Client connected."); Chat.notify("[Remote] Client connected.");
} else { } else {
s.close(); s.close();
} }
@ -144,7 +146,7 @@ public class RemoteEventManager {
} }
private void disconnectClient(int i) throws IOException { private void disconnectClient(int i) throws IOException {
BaseBand.notify("[Remote] A peer disconnected."); Chat.notify("[Remote] A peer disconnected.");
clients.remove(i).close(); clients.remove(i).close();
publish(new RemoteInitEvent(clients.size() + 1)); publish(new RemoteInitEvent(clients.size() + 1));
} }
@ -159,12 +161,12 @@ public class RemoteEventManager {
o.write('B'); o.write('B');
o.flush(); o.flush();
if(!(i.read() == 'B' && i.read() == 'B')) { if(!(i.read() == 'B' && i.read() == 'B')) {
BaseBand.notify("[Remote] Unable to connect."); Chat.notify("[Remote] Unable to connect.");
end(); end();
return; return;
} }
head.setSoTimeout(1); head.setSoTimeout(1);
BaseBand.notify("[Remote] Connected."); Chat.notify("[Remote] Connected.");
while(head != null) { while(head != null) {
while(!toSend.isEmpty()) { while(!toSend.isEmpty()) {
String stringEvent = JSON.write((TCN)ConfigSaverTCN2.write(toSend.poll(), false, false)); String stringEvent = JSON.write((TCN)ConfigSaverTCN2.write(toSend.poll(), false, false));
@ -175,7 +177,7 @@ public class RemoteEventManager {
try { try {
head.setSoTimeout(1); head.setSoTimeout(1);
if ((id = i.read()) == -1) { if ((id = i.read()) == -1) {
BaseBand.notify("[Remote] Connection ended."); Chat.notify("[Remote] Connection ended.");
end(); end();
return; return;
} }
@ -185,7 +187,7 @@ public class RemoteEventManager {
} catch (InterruptedIOException ignored) {} } catch (InterruptedIOException ignored) {}
} }
} catch (IOException | JSON.JSONFormatException | ClassNotFoundException e) { } catch (IOException | JSON.JSONFormatException | ClassNotFoundException e) {
BaseBand.notify("[Remote] Connection ended."); Chat.notify("[Remote] Connection ended.");
end(); end();
} }
} }
@ -205,7 +207,7 @@ public class RemoteEventManager {
RemoteEvent event = toProcess.poll(); RemoteEvent event = toProcess.poll();
if(event instanceof RemoteInitEvent) { if(event instanceof RemoteInitEvent) {
peers = ((RemoteInitEvent) event).peers; peers = ((RemoteInitEvent) event).peers;
BaseBand.notify("[Remote] Peers connected: " + peers + "."); Chat.notify("[Remote] Peers connected: " + peers + ".");
} }
else { else {
BaseBand.eventManager.publish(event); BaseBand.eventManager.publish(event);

View file

@ -2,10 +2,8 @@ package com.baseband.client.event.remote.events;
import com.baseband.client.event.remote.RemoteEvent; import com.baseband.client.event.remote.RemoteEvent;
import com.baseband.client.registry.Configuration; import com.baseband.client.registry.Configuration;
import com.baseband.client.util.adapt.FieldFinder;
import de.tudbut.obj.Save; import de.tudbut.obj.Save;
import de.tudbut.parsing.TCN; import de.tudbut.parsing.TCN;
import de.tudbut.tools.Registry;
public class RemoteConfigEvent extends RemoteEvent { public class RemoteConfigEvent extends RemoteEvent {
@ -13,10 +11,6 @@ public class RemoteConfigEvent extends RemoteEvent {
public TCN fatTCN; public TCN fatTCN;
public RemoteConfigEvent() { public RemoteConfigEvent() {
try { fatTCN = Configuration.asTCN();
fatTCN = (TCN) FieldFinder.findUnmarked(Registry.class, TCN.class, 0).get(Configuration.INSTANCE.registry);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
} }
} }

View file

@ -1,6 +1,5 @@
package com.baseband.client.feature; package com.baseband.client.feature;
import com.baseband.client.BaseBand;
import com.baseband.client.feature.category.*; import com.baseband.client.feature.category.*;
import com.baseband.client.registry.ConfigHandle; import com.baseband.client.registry.ConfigHandle;
import com.baseband.client.registry.Configuration; import com.baseband.client.registry.Configuration;
@ -25,9 +24,9 @@ public enum Category {
this.annotationClass = annotationClass; this.annotationClass = annotationClass;
try { try {
handle = Configuration.register("Category/" + name.toLowerCase().replace(' ', '_')); handle = Configuration.register("Category/" + name.toLowerCase().replace(' ', '_'));
BaseBand.registerUpdater(handle.linkWith(this, FieldFinder.findMarked(getClass(), 1)).name("x")); Configuration.registerUpdater(handle.linkWith(this, FieldFinder.findMarked(getClass(), 1)).name("x"));
BaseBand.registerUpdater(handle.linkWith(this, FieldFinder.findMarked(getClass(), 2)).name("y")); Configuration.registerUpdater(handle.linkWith(this, FieldFinder.findMarked(getClass(), 2)).name("y"));
BaseBand.registerUpdater(handle.linkWith(this, FieldFinder.findMarked(getClass(), 3)).name("show")); Configuration.registerUpdater(handle.linkWith(this, FieldFinder.findMarked(getClass(), 3)).name("show"));
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
//:skollerolley: //:skollerolley:
throw new RuntimeException(e); throw new RuntimeException(e);

View file

@ -11,7 +11,9 @@ import com.baseband.client.registry.SetCommand;
import com.baseband.client.registry.annotation.*; import com.baseband.client.registry.annotation.*;
import com.baseband.client.util.adapt.FieldFinder; import com.baseband.client.util.adapt.FieldFinder;
import com.baseband.client.util.adapt.Marker; import com.baseband.client.util.adapt.Marker;
import com.baseband.client.util.interact.Chat;
import com.baseband.client.util.type.KeyBind; import com.baseband.client.util.type.KeyBind;
import com.baseband.client.event.KeyManager;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
@ -81,12 +83,12 @@ public abstract class Feature extends ToggleButton implements SetCommand {
if(enabled) { if(enabled) {
BaseBand.eventManager.subscribe(this); BaseBand.eventManager.subscribe(this);
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
BaseBand.notify("§l" + this + "§a enabled§r."); Chat.notify("§l" + this + "§a enabled§r.");
onEnable(); onEnable();
} else { } else {
BaseBand.eventManager.unsubscribe(this); BaseBand.eventManager.unsubscribe(this);
MinecraftForge.EVENT_BUS.unregister(this); MinecraftForge.EVENT_BUS.unregister(this);
BaseBand.notify("§l" + this + "§c disabled§r."); Chat.notify("§l" + this + "§c disabled§r.");
onDisable(); onDisable();
} }
} }
@ -114,7 +116,7 @@ public abstract class Feature extends ToggleButton implements SetCommand {
String description = descriptionAnnotation == null ? null : descriptionAnnotation.value(); String description = descriptionAnnotation == null ? null : descriptionAnnotation.value();
AnyGate gate = AnyGate.get(f, this); AnyGate gate = AnyGate.get(f, this);
if (config != null) { if (config != null) {
BaseBand.registerUpdater(settings.linkWith(this, f).name(config.value())); Configuration.registerUpdater(settings.linkWith(this, f).name(config.value()));
if (f.getType() == boolean.class) { if (f.getType() == boolean.class) {
Component btn = new ToggleButton(config.value(), settings, config.value()).gate(gate).hover(description); Component btn = new ToggleButton(config.value(), settings, config.value()).gate(gate).hover(description);
subComponents.add(btn); subComponents.add(btn);
@ -127,11 +129,11 @@ public abstract class Feature extends ToggleButton implements SetCommand {
String keyBindConfig = keyBindString + " Key"; String keyBindConfig = keyBindString + " Key";
KeyBind keyBind = new KeyBind(null, () -> { KeyBind keyBind = new KeyBind(null, () -> {
btn.click(0, 0, 0); btn.click(0, 0, 0);
BaseBand.notify("Toggled " + config.value() + " in " + this + " " + (btn.green ? "§aon" : "§coff")); Chat.notify("Toggled " + config.value() + " in " + this + " " + (btn.green ? "§aon" : "§coff"));
}, gate); }, gate);
subComponents.add(new KeyButton(keyBindString, settings, keyBindConfig).gate(AnyGate.get(f, this, null, keyBound.allowChangeGate())).hover(description)); subComponents.add(new KeyButton(keyBindString, settings, keyBindConfig).gate(AnyGate.get(f, this, null, keyBound.allowChangeGate())).hover(description));
BaseBand.registerUpdater(settings.linkWith(keyBind, KeyBind.KEY_FIELD).name(keyBindConfig)); Configuration.registerUpdater(settings.linkWith(keyBind, KeyBind.KEY_FIELD).name(keyBindConfig));
BaseBand.registerKeyBind(keyBind); KeyManager.registerKeyBind(keyBind);
} }
} }
if (f.getType() == int.class) { if (f.getType() == int.class) {
@ -202,13 +204,13 @@ public abstract class Feature extends ToggleButton implements SetCommand {
} }
}, gate); }, gate);
subComponents.add(new KeyButton(keyBindString, settings, keyBindConfig).gate(AnyGate.get(m, this, null, keyBound.allowChangeGate())).hover(description)); subComponents.add(new KeyButton(keyBindString, settings, keyBindConfig).gate(AnyGate.get(m, this, null, keyBound.allowChangeGate())).hover(description));
BaseBand.registerUpdater(settings.linkWith(keyBind, KeyBind.KEY_FIELD).name(keyBindConfig)); Configuration.registerUpdater(settings.linkWith(keyBind, KeyBind.KEY_FIELD).name(keyBindConfig));
BaseBand.registerKeyBind(keyBind); KeyManager.registerKeyBind(keyBind);
} }
} }
handle = settings; handle = settings;
BaseBand.registerUpdater(settings.linkWith(this, FieldFinder.findMarked(Feature.class, M_ENABLED)).name("Enabled")).populate(); Configuration.registerUpdater(settings.linkWith(this, FieldFinder.findMarked(Feature.class, M_ENABLED)).name("Enabled")).populate();
Description description = getClass().getDeclaredAnnotation(Description.class); Description description = getClass().getDeclaredAnnotation(Description.class);
if(description != null) if(description != null)

View file

@ -0,0 +1,71 @@
package com.baseband.client.feature;
import com.baseband.client.BaseBand;
import com.baseband.client.Setup;
import com.baseband.client.util.type.FeatureAction;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Arrays;
public class Features {
public static Feature[] features = new Feature[0];
public static void init() {
ArrayList<Feature> filteredFeatures = new ArrayList<>(Arrays.asList(Setup.get().Features));
for (int i = 0; i < filteredFeatures.size(); i++) {
Feature value = filteredFeatures.get(i);
if(!value.canExist()) {
filteredFeatures.remove(i--);
}
}
features = filteredFeatures.toArray(new Feature[0]);
for (Feature feature : features) {
feature.register(BaseBand.INSTANCE, BaseBand.mc);
}
}
public static boolean isFeaturePresent(Class<? extends Feature> clazz) {
Feature f = getFeature(clazz);
//noinspection ConstantValue
return f != null;
}
public static boolean isFeatureEnabled(Class<? extends Feature> clazz) {
Feature f = getFeature(clazz);
//noinspection ConstantValue
if(f == null)
return false;
return f.enabled;
}
public static <T extends Feature> boolean ifFeaturePresent(Class<? extends T> clazz, FeatureAction<T> action) {
T f = getFeature(clazz);
//noinspection ConstantValue
if(f == null)
return false;
action.run(f);
return true;
}
public static <T extends Feature> boolean ifFeatureEnabled(Class<? extends T> clazz, FeatureAction<T> action) {
T f = getFeature(clazz);
//noinspection ConstantValue
if(f == null || !f.enabled)
return false;
action.run(f);
return true;
}
@SuppressWarnings("DataFlowIssue")
@Nonnull
public static <T extends Feature> T getFeature(Class<? extends T> clazz) {
if(BaseBand.finishedDisabling) return null;
for (Feature feature : features) {
if (feature.getClass() == clazz)
return (T) feature;
}
return null;
}
}

View file

@ -1,15 +1,14 @@
package com.baseband.client.feature.chat; package com.baseband.client.feature.chat;
import com.baseband.client.feature.Feature; import com.baseband.client.feature.Feature;
import com.baseband.client.feature.category.Chat;
import com.baseband.client.registry.annotation.Config; import com.baseband.client.registry.annotation.Config;
import com.baseband.client.registry.annotation.Gate; import com.baseband.client.registry.annotation.Gate;
import com.baseband.client.util.adapt.Marker; import com.baseband.client.util.adapt.Marker;
import com.baseband.client.util.interact.ChatUtil; import com.baseband.client.util.interact.Chat;
import net.minecraftforge.client.event.ClientChatEvent; import net.minecraftforge.client.event.ClientChatEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@Chat @com.baseband.client.feature.category.Chat
public class ChatAppend extends Feature { public class ChatAppend extends Feature {
@Override @Override
@ -42,8 +41,8 @@ public class ChatAppend extends Feature {
if(message.matches("\\W.*")) if(message.matches("\\W.*"))
return; return;
ChatUtil.history(message); Chat.history(message);
ChatUtil.send(applyWatermark((custom ? (customUnicodeToggle ? toUnicode(customWatermark) : customWatermark) : toUnicode("baseband")), message), false); Chat.send(applyWatermark((custom ? (customUnicodeToggle ? toUnicode(customWatermark) : customWatermark) : toUnicode("baseband")), message), false);
event.setCanceled(true); event.setCanceled(true);
} }

View file

@ -1,16 +1,13 @@
package com.baseband.client.feature.chat; package com.baseband.client.feature.chat;
import com.baseband.client.BaseBand;
import com.baseband.client.event.events.PacketEvent; import com.baseband.client.event.events.PacketEvent;
import com.baseband.client.feature.Feature; import com.baseband.client.feature.Feature;
import com.baseband.client.feature.category.Chat;
import com.baseband.client.feature.render.HUD; import com.baseband.client.feature.render.HUD;
import com.baseband.client.mixins.ICPacketChat; import com.baseband.client.mixins.ICPacketChat;
import com.baseband.client.registry.annotation.*; import com.baseband.client.registry.annotation.*;
import com.baseband.client.util.adapt.FieldFinder; import com.baseband.client.util.adapt.FieldFinder;
import com.baseband.client.util.adapt.Marker; import com.baseband.client.util.adapt.Marker;
import com.baseband.client.util.interact.ChatUtil; import com.baseband.client.util.interact.Chat;
import com.baseband.client.util.misc.GlobalUtil;
import com.baseband.client.util.misc.SBE; import com.baseband.client.util.misc.SBE;
import com.baseband.client.util.misc.Trypt; import com.baseband.client.util.misc.Trypt;
import de.tudbut.tools.Hasher; import de.tudbut.tools.Hasher;
@ -25,7 +22,10 @@ import java.util.Arrays;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@Chat import static com.baseband.client.BaseBand.RANDOM;
import static com.baseband.client.BaseBand.LOGGER;
@com.baseband.client.feature.category.Chat
public class ChatCrypt extends Feature { public class ChatCrypt extends Feature {
@Override @Override
public String toString() { public String toString() {
@ -50,7 +50,7 @@ public class ChatCrypt extends Feature {
@Config("Channel") @Config("Channel")
@Description("Used to distinguish between different groups of people using ChatCrypt (otherwise you get garbage in chat).") @Description("Used to distinguish between different groups of people using ChatCrypt (otherwise you get garbage in chat).")
@Range("0..128") @Range("0..128")
public int channel = GlobalUtil.RANDOM.nextInt(128); public int channel = RANDOM.nextInt(128);
@Config("Use SBE algorithm") @Config("Use SBE algorithm")
@Description("Trypt will look more random and has 256 possible encodings for the same message, meaning repetition is harder to see.\n" + @Description("Trypt will look more random and has 256 possible encodings for the same message, meaning repetition is harder to see.\n" +
@ -97,7 +97,7 @@ public class ChatCrypt extends Feature {
@MultiGate(and = {2, 3}) @MultiGate(and = {2, 3})
public void resetTrypt() { public void resetTrypt() {
trypt = null; trypt = null;
BaseBand.notifyAll("§c§lChat>§a Trypt instance reset."); Chat.notifyAll("§c§lChat>§a Trypt instance reset.");
} }
@Config("Password") @Config("Password")
@ -111,7 +111,7 @@ public class ChatCrypt extends Feature {
public void onEnable() { public void onEnable() {
if(password.isEmpty() || password.equalsIgnoreCase("CLICK HERE")) { if(password.isEmpty() || password.equalsIgnoreCase("CLICK HERE")) {
toggle(); toggle();
BaseBand.notify("[ChatCrypt] Set a Password first! (set ID Password)"); Chat.notify("[ChatCrypt] Set a Password first! (set ID Password)");
} }
} }
@ -150,12 +150,12 @@ public class ChatCrypt extends Feature {
boolean isOurs = message.equals(sentEncrypted); boolean isOurs = message.equals(sentEncrypted);
GlobalUtil.LOGGER.info("decrypt: {}", message); LOGGER.info("decrypt: {}", message);
byte[] original = recoverBytes(message); byte[] original = recoverBytes(message);
if(!useSBE && decryptNoKeep(original).equals("CC:keep") && allowCCKeep) { if(!useSBE && decryptNoKeep(original).equals("CC:keep") && allowCCKeep) {
keepTrypt = true; keepTrypt = true;
trypt = null; trypt = null;
BaseBand.notify("§dChat>§a Enabled and synchronized Trypt keep (initiated by " + username + ")."); Chat.notify("§dChat>§a Enabled and synchronized Trypt keep (initiated by " + username + ").");
e.setCancelled(true); e.setCancelled(true);
return; return;
} }
@ -164,10 +164,10 @@ public class ChatCrypt extends Feature {
if(!useSBE && keepTrypt && (!isOurs || !sentOriginal.equals(message))) { if(!useSBE && keepTrypt && (!isOurs || !sentOriginal.equals(message))) {
// we must re-encrypt anything we get, unless it is from ourselves, to make sure our key stays up-to-date // we must re-encrypt anything we get, unless it is from ourselves, to make sure our key stays up-to-date
if(Arrays.equals(trypt.encryptChunk(message.getBytes(StandardCharsets.UTF_8), original[0]), original)) { if(Arrays.equals(trypt.encryptChunk(message.getBytes(StandardCharsets.UTF_8), original[0]), original)) {
GlobalUtil.LOGGER.debug("Successfully kept Trypt key up-to-date."); LOGGER.debug("Successfully kept Trypt key up-to-date.");
} }
else { else {
BaseBand.notifyAll("§d§lChat>§c Unable to keep Trypt key up-to-date. Disabled keep." + (allowCCKeep ? " (Enable and sync by sending CC:keep)" : "")); Chat.notifyAll("§d§lChat>§c Unable to keep Trypt key up-to-date. Disabled keep." + (allowCCKeep ? " (Enable and sync by sending CC:keep)" : ""));
keepTrypt = false; keepTrypt = false;
} }
} }
@ -211,7 +211,7 @@ public class ChatCrypt extends Feature {
sentEncrypted = s; sentEncrypted = s;
s += getTerminator(); s += getTerminator();
if (s.length() > 256) { if (s.length() > 256) {
ChatUtil.print("Encrypted message length was too long, couldn't send!"); Chat.print("Encrypted message length was too long, couldn't send!");
e.setCancelled(true); e.setCancelled(true);
sentEncrypted = null; sentEncrypted = null;
sentOriginal = null; sentOriginal = null;

View file

@ -1,16 +1,14 @@
package com.baseband.client.feature.chat; package com.baseband.client.feature.chat;
import com.baseband.client.BaseBand;
import com.baseband.client.event.events.PacketEvent; import com.baseband.client.event.events.PacketEvent;
import com.baseband.client.feature.Feature; import com.baseband.client.feature.Feature;
import com.baseband.client.feature.category.Chat;
import com.baseband.client.registry.annotation.Config; import com.baseband.client.registry.annotation.Config;
import com.baseband.client.registry.annotation.Description; import com.baseband.client.registry.annotation.Description;
import com.baseband.client.registry.annotation.Gate; import com.baseband.client.registry.annotation.Gate;
import com.baseband.client.registry.annotation.Trigger; import com.baseband.client.registry.annotation.Trigger;
import com.baseband.client.util.adapt.FieldFinder; import com.baseband.client.util.adapt.FieldFinder;
import com.baseband.client.util.adapt.Marker; import com.baseband.client.util.adapt.Marker;
import com.baseband.client.util.interact.ChatUtil; import com.baseband.client.util.interact.Chat;
import net.minecraft.client.gui.ChatLine; import net.minecraft.client.gui.ChatLine;
import net.minecraft.client.gui.GuiNewChat; import net.minecraft.client.gui.GuiNewChat;
import net.minecraft.network.play.server.SPacketChat; import net.minecraft.network.play.server.SPacketChat;
@ -20,7 +18,7 @@ import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@Chat @com.baseband.client.feature.category.Chat
public class ChatExtras extends Feature { public class ChatExtras extends Feature {
@ -63,7 +61,7 @@ public class ChatExtras extends Feature {
chatLines.remove(i--); chatLines.remove(i--);
} }
mc.ingameGUI.getChatGUI().refreshChat(); mc.ingameGUI.getChatGUI().refreshChat();
BaseBand.notify("Cleared chat of DMs"); Chat.notify("Cleared chat of DMs");
} }
@ -73,7 +71,7 @@ public class ChatExtras extends Feature {
Pattern pattern = Pattern.compile("[^\t\r\n\\x20-\\x7E]+", Pattern.CASE_INSENSITIVE); Pattern pattern = Pattern.compile("[^\t\r\n\\x20-\\x7E]+", Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(message); Matcher matcher = pattern.matcher(message);
if (matcher.find()) { if (matcher.find()) {
ChatUtil.print("Unicode filtered!"); Chat.print("Unicode filtered!");
event.setCancelled(true); event.setCancelled(true);
if (notifyOnPopLag) { if (notifyOnPopLag) {
mc.ingameGUI.getChatGUI().printChatMessage(new TextComponentString(message.replaceAll(pattern.pattern(), ""))); mc.ingameGUI.getChatGUI().printChatMessage(new TextComponentString(message.replaceAll(pattern.pattern(), "")));
@ -88,7 +86,7 @@ public class ChatExtras extends Feature {
if (text.contains("jndi") || text.contains("ldap")) { if (text.contains("jndi") || text.contains("ldap")) {
text = text.replace("jndi", ""); text = text.replace("jndi", "");
text = text.replace("ldap", ""); text = text.replace("ldap", "");
ChatUtil.print("Log4Shell Prevented, Sterilized Message:\n" + text); Chat.print("Log4Shell Prevented, Sterilized Message:\n" + text);
event.setCancelled(true); event.setCancelled(true);
} }
} }

View file

@ -2,11 +2,9 @@ package com.baseband.client.feature.chat;
import com.baseband.client.event.events.PacketEvent; import com.baseband.client.event.events.PacketEvent;
import com.baseband.client.feature.Feature; import com.baseband.client.feature.Feature;
import com.baseband.client.feature.category.Chat;
import com.baseband.client.registry.annotation.Config; import com.baseband.client.registry.annotation.Config;
import com.baseband.client.util.adapt.FieldFinder; import com.baseband.client.util.adapt.FieldFinder;
import com.baseband.client.util.interact.ChatUtil; import com.baseband.client.util.interact.Chat;
import com.baseband.client.util.misc.GlobalUtil;
import net.minecraft.network.play.server.SPacketChat; import net.minecraft.network.play.server.SPacketChat;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentString;
@ -14,7 +12,9 @@ import net.minecraft.util.text.TextComponentString;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@Chat import static com.baseband.client.BaseBand.LOGGER;
@com.baseband.client.feature.category.Chat
public class ChatFilter extends Feature { public class ChatFilter extends Feature {
public enum Mode { public enum Mode {
@ -105,9 +105,9 @@ public class ChatFilter extends Feature {
} }
if(changed) { if(changed) {
GlobalUtil.LOGGER.info("Original message: {}", packet.getChatComponent().getUnformattedText()); LOGGER.info("Original message: {}", packet.getChatComponent().getUnformattedText());
if (mode == Mode.Block) { if (mode == Mode.Block) {
ChatUtil.print("Message filtered."); Chat.print("Message filtered.");
event.setCancelled(true); event.setCancelled(true);
return; return;
} }

View file

@ -1,14 +1,13 @@
package com.baseband.client.feature.chat; package com.baseband.client.feature.chat;
import com.baseband.client.feature.Feature; import com.baseband.client.feature.Feature;
import com.baseband.client.feature.category.Chat; import com.baseband.client.util.interact.Chat;
import com.baseband.client.util.interact.ChatUtil;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import java.util.ArrayList; import java.util.ArrayList;
@Chat @com.baseband.client.feature.category.Chat
public class ISeeYou extends Feature { public class ISeeYou extends Feature {
private final ArrayList<String> names = new ArrayList<>(); private final ArrayList<String> names = new ArrayList<>();
@ -32,8 +31,8 @@ public class ISeeYou extends Feature {
try { try {
for (final Entity entity : mc.world.loadedEntityList) if (entity instanceof EntityPlayer && !entity.getName().equalsIgnoreCase(mc.player.getName())) newnames.add(entity.getName()); for (final Entity entity : mc.world.loadedEntityList) if (entity instanceof EntityPlayer && !entity.getName().equalsIgnoreCase(mc.player.getName())) newnames.add(entity.getName());
if (!names.equals(newnames)) { if (!names.equals(newnames)) {
for (final String name : newnames) if (!names.contains(name)) ChatUtil.print("[ISeeYou] I locally see "+name); for (final String name : newnames) if (!names.contains(name)) Chat.print("[ISeeYou] I locally see "+name);
for (final String name : names) if (!newnames.contains(name)) ChatUtil.print("[ISeeYou] I no longer locally see "+name); for (final String name : names) if (!newnames.contains(name)) Chat.print("[ISeeYou] I no longer locally see "+name);
names.clear(); names.clear();
names.addAll(newnames); names.addAll(newnames);
} }

View file

@ -2,15 +2,14 @@ package com.baseband.client.feature.chat;
import com.baseband.client.event.events.PlayerDestroyEvent; import com.baseband.client.event.events.PlayerDestroyEvent;
import com.baseband.client.feature.Feature; import com.baseband.client.feature.Feature;
import com.baseband.client.feature.category.Chat;
import com.baseband.client.registry.PlayerDB; import com.baseband.client.registry.PlayerDB;
import com.baseband.client.registry.annotation.Config; import com.baseband.client.registry.annotation.Config;
import com.baseband.client.registry.annotation.Description; import com.baseband.client.registry.annotation.Description;
import com.baseband.client.util.interact.ChatUtil; import com.baseband.client.util.interact.Chat;
import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@Chat @com.baseband.client.feature.category.Chat
@Description("Accepts TPA-Requests automatically") @Description("Accepts TPA-Requests automatically")
public class TPAccept extends Feature { public class TPAccept extends Feature {
@ -35,7 +34,7 @@ public class TPAccept extends Feature {
String regex = "^" + this.regex.replaceAll("^\\^|\\$$", "") + "$"; String regex = "^" + this.regex.replaceAll("^\\^|\\$$", "") + "$";
String text = event.getMessage().getUnformattedText(); String text = event.getMessage().getUnformattedText();
if(text.matches(regex) && (!onlyTrusted || PlayerDB.player(null, text.replaceAll(regex, "$1")).getBoolean("tpa") == Boolean.TRUE)) { if(text.matches(regex) && (!onlyTrusted || PlayerDB.player(null, text.replaceAll(regex, "$1")).getBoolean("tpa") == Boolean.TRUE)) {
ChatUtil.simulateSend(text.replaceAll(regex, command), false); Chat.simulateSend(text.replaceAll(regex, command), false);
} }
} }

View file

@ -4,14 +4,16 @@ import com.baseband.client.BaseBand;
import com.baseband.client.event.remote.events.RemoteConfigEvent; import com.baseband.client.event.remote.events.RemoteConfigEvent;
import com.baseband.client.event.remote.events.RemoteSendMessageEvent; import com.baseband.client.event.remote.events.RemoteSendMessageEvent;
import com.baseband.client.feature.Feature; import com.baseband.client.feature.Feature;
import com.baseband.client.feature.Features;
import com.baseband.client.feature.category.ClientCategory; import com.baseband.client.feature.category.ClientCategory;
import com.baseband.client.feature.render.ClickGUI; import com.baseband.client.feature.render.ClickGUI;
import com.baseband.client.registry.Configuration;
import com.baseband.client.registry.annotation.Config; import com.baseband.client.registry.annotation.Config;
import com.baseband.client.registry.annotation.Description; import com.baseband.client.registry.annotation.Description;
import com.baseband.client.registry.annotation.Gate; import com.baseband.client.registry.annotation.Gate;
import com.baseband.client.registry.annotation.Trigger; import com.baseband.client.registry.annotation.Trigger;
import com.baseband.client.util.adapt.Marker; import com.baseband.client.util.adapt.Marker;
import com.baseband.client.util.interact.ChatUtil; import com.baseband.client.util.interact.Chat;
@ClientCategory @ClientCategory
public class AltControl extends Feature { public class AltControl extends Feature {
@ -24,7 +26,7 @@ public class AltControl extends Feature {
@Trigger("Send config to alts") @Trigger("Send config to alts")
@Gate(M_ENABLED) @Gate(M_ENABLED)
public void sendConfig() { public void sendConfig() {
BaseBand.publish(new RemoteConfigEvent()); Configuration.publish(new RemoteConfigEvent());
} }
@Marker(1) @Marker(1)
@ -43,31 +45,31 @@ public class AltControl extends Feature {
} }
public void onRemoteSendChat(RemoteSendMessageEvent event) { public void onRemoteSendChat(RemoteSendMessageEvent event) {
BaseBand.notify("[AltControl] Received a message to send."); Chat.notify("[AltControl] Received a message to send.");
ChatUtil.simulateSend(event.message, false); Chat.simulateSend(event.message, false);
} }
public void onConfig(RemoteConfigEvent event) { public void onConfig(RemoteConfigEvent event) {
BaseBand.notify("[AltControl] Received a config."); Chat.notify("[AltControl] Received a config.");
String ip = this.ip; String ip = this.ip;
boolean gui = BaseBand.isFeatureEnabled(ClickGUI.class); boolean gui = Features.isFeatureEnabled(ClickGUI.class);
BaseBand.INSTANCE.cloneConfigFrom(event.fatTCN); Configuration.cloneConfigFrom(event.fatTCN);
BaseBand.ifFeaturePresent(ClickGUI.class, f -> f.setEnabled(gui)); Features.ifFeaturePresent(ClickGUI.class, f -> f.setEnabled(gui));
this.ip = ip; this.ip = ip;
} }
@Override @Override
public void onCommand(String[] args) { public void onCommand(String[] args) {
if(!enabled) if(!enabled)
ChatUtil.print("Please first enable " + this + "."); Chat.print("Please first enable " + this + ".");
if(args.length == 0) { if(args.length == 0) {
ChatUtil.print("syntax: " + Client.prefix + this + " <message...>"); Chat.print("syntax: " + Client.prefix + this + " <message...>");
return; return;
} }
BaseBand.publish(new RemoteSendMessageEvent(String.join(" ", args))); Configuration.publish(new RemoteSendMessageEvent(String.join(" ", args)));
} }
@Override @Override

View file

@ -11,7 +11,7 @@ import com.baseband.client.registry.annotation.Config;
import com.baseband.client.registry.annotation.Description; import com.baseband.client.registry.annotation.Description;
import com.baseband.client.registry.annotation.KeyBound; import com.baseband.client.registry.annotation.KeyBound;
import com.baseband.client.registry.annotation.Trigger; import com.baseband.client.registry.annotation.Trigger;
import com.baseband.client.util.interact.ChatUtil; import com.baseband.client.util.interact.Chat;
import com.baseband.client.util.interact.RotationManager; import com.baseband.client.util.interact.RotationManager;
import com.baseband.client.util.interact.ServerDataManager; import com.baseband.client.util.interact.ServerDataManager;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
@ -40,7 +40,7 @@ public class Client extends Feature {
public void clearTargets() { public void clearTargets() {
entityTarget = null; entityTarget = null;
playerTarget = null; playerTarget = null;
BaseBand.notify("§aCleared all targets."); Chat.notify("§aCleared all targets.");
} }
@Config("ScreenshotUpload") @Config("ScreenshotUpload")
@ -57,7 +57,7 @@ public class Client extends Feature {
@Trigger("Save config") @Trigger("Save config")
public void saveConfig() { public void saveConfig() {
Configuration.save(); Configuration.save();
BaseBand.notify("Config saved to disk"); Chat.notify("Config saved to disk");
} }
@ -88,11 +88,11 @@ public class Client extends Feature {
return; return;
} }
disableLock = true; disableLock = true;
ChatUtil.print("Unloading..."); Chat.print("Unloading...");
MinecraftForge.EVENT_BUS.unregister(BaseBand.fmlEventHandlerInstance); MinecraftForge.EVENT_BUS.unregister(BaseBand.fmlEventHandlerInstance);
mc.displayGuiScreen(null); mc.displayGuiScreen(null);
BaseBand.enabled = false; BaseBand.enabled = false;
ChatUtil.print("Waiting for config..."); Chat.print("Waiting for config...");
} }
@Override @Override
@ -116,7 +116,7 @@ public class Client extends Feature {
ServerDataManager.onTimePacket(); ServerDataManager.onTimePacket();
} }
if(packet instanceof SPacketPlayerPosLook && lagNotify) { //TODO: if packetfly then ignore if(packet instanceof SPacketPlayerPosLook && lagNotify) { //TODO: if packetfly then ignore
BaseBand.notify("[LagNotify] §cLagback!"); Chat.notify("[LagNotify] §cLagback!");
} }
} }

View file

@ -1,11 +1,10 @@
package com.baseband.client.feature.client; package com.baseband.client.feature.client;
import com.baseband.client.BaseBand;
import com.baseband.client.feature.Feature; import com.baseband.client.feature.Feature;
import com.baseband.client.feature.category.ClientCategory; import com.baseband.client.feature.category.ClientCategory;
import com.baseband.client.registry.PlayerDB; import com.baseband.client.registry.PlayerDB;
import com.baseband.client.registry.annotation.Config; import com.baseband.client.registry.annotation.Config;
import com.baseband.client.util.interact.ChatUtil; import com.baseband.client.util.interact.Chat;
import de.tudbut.parsing.TCN; import de.tudbut.parsing.TCN;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -27,21 +26,21 @@ public class MidClick extends Feature {
player.set("isTarget", player.getBoolean("isTarget") != Boolean.TRUE); player.set("isTarget", player.getBoolean("isTarget") != Boolean.TRUE);
if(player.getBoolean("isTarget")) { if(player.getBoolean("isTarget")) {
com.baseband.client.feature.client.Client.playerTarget = p; com.baseband.client.feature.client.Client.playerTarget = p;
BaseBand.notify("§cNow targeting " + p.getName()); Chat.notify("§cNow targeting " + p.getName());
} else { } else {
BaseBand.notify("§a§lNo longer§a targeting " + p.getName()); Chat.notify("§a§lNo longer§a targeting " + p.getName());
} }
}), }),
Friend((p) -> { Friend((p) -> {
TCN player = Objects.requireNonNull(PlayerDB.player(p.getGameProfile().getId(), p.getGameProfile().getName())); TCN player = Objects.requireNonNull(PlayerDB.player(p.getGameProfile().getId(), p.getGameProfile().getName()));
player.set("isFriend", player.getBoolean("isFriend") != Boolean.TRUE); player.set("isFriend", player.getBoolean("isFriend") != Boolean.TRUE);
if(player.getBoolean("isFriend")) { if(player.getBoolean("isFriend")) {
BaseBand.notify("§aMarked " + p.getName() + " as a friend."); Chat.notify("§aMarked " + p.getName() + " as a friend.");
} else { } else {
BaseBand.notify("§c§lUn§cmarked " + p.getName() + " as a friend."); Chat.notify("§c§lUn§cmarked " + p.getName() + " as a friend.");
} }
}), }),
Message((p) -> ChatUtil.openChat("/w " + p.getGameProfile().getName() + " ")), Message((p) -> Chat.openChat("/w " + p.getGameProfile().getName() + " ")),
; ;
public final Consumer<EntityPlayer> action; public final Consumer<EntityPlayer> action;
PlayerAction(Consumer<EntityPlayer> action) { PlayerAction(Consumer<EntityPlayer> action) {
@ -68,10 +67,10 @@ public class MidClick extends Feature {
Target((e) -> { Target((e) -> {
if(com.baseband.client.feature.client.Client.entityTarget != e) { if(com.baseband.client.feature.client.Client.entityTarget != e) {
com.baseband.client.feature.client.Client.entityTarget = e; com.baseband.client.feature.client.Client.entityTarget = e;
BaseBand.notify("§cNow targeting entity ID " + e.getEntityId()); Chat.notify("§cNow targeting entity ID " + e.getEntityId());
} else { } else {
com.baseband.client.feature.client.Client.entityTarget = null; com.baseband.client.feature.client.Client.entityTarget = null;
BaseBand.notify("§aEntity target reset."); Chat.notify("§aEntity target reset.");
} }
}), }),
; ;

View file

@ -1,6 +1,5 @@
package com.baseband.client.feature.client; package com.baseband.client.feature.client;
import com.baseband.client.BaseBand;
import com.baseband.client.feature.Feature; import com.baseband.client.feature.Feature;
import com.baseband.client.feature.category.ClientCategory; import com.baseband.client.feature.category.ClientCategory;
import com.baseband.client.registry.PlayerDB; import com.baseband.client.registry.PlayerDB;
@ -9,6 +8,7 @@ import com.baseband.client.registry.annotation.Description;
import com.baseband.client.registry.annotation.Gate; import com.baseband.client.registry.annotation.Gate;
import com.baseband.client.registry.annotation.Trigger; import com.baseband.client.registry.annotation.Trigger;
import com.baseband.client.util.adapt.Marker; import com.baseband.client.util.adapt.Marker;
import com.baseband.client.util.interact.Chat;
import de.tudbut.parsing.TCN; import de.tudbut.parsing.TCN;
@ClientCategory @ClientCategory
@ -44,7 +44,7 @@ public class Trust extends Feature {
@Override @Override
public void onEnable() { public void onEnable() {
if(name.isEmpty()) { if(name.isEmpty()) {
BaseBand.notify("First set the name of a player to modify."); Chat.notify("First set the name of a player to modify.");
toggle(); toggle();
} }
TCN player = PlayerDB.player(null, name); TCN player = PlayerDB.player(null, name);

View file

@ -5,7 +5,7 @@ import com.baseband.client.feature.category.Combat;
import com.baseband.client.gui.GuiBBIngame; import com.baseband.client.gui.GuiBBIngame;
import com.baseband.client.registry.annotation.*; import com.baseband.client.registry.annotation.*;
import com.baseband.client.util.adapt.Marker; import com.baseband.client.util.adapt.Marker;
import com.baseband.client.util.interact.ChatUtil; import com.baseband.client.util.interact.Chat;
import com.baseband.client.util.interact.InventoryUtils; import com.baseband.client.util.interact.InventoryUtils;
import de.tudbut.tools.Lock; import de.tudbut.tools.Lock;
import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.gui.ScaledResolution;
@ -196,10 +196,10 @@ public class AutoTotem extends Feature {
if(totemSlots.isEmpty()) { if(totemSlots.isEmpty()) {
if(mode == Mode.Hyperswap) { if(mode == Mode.Hyperswap) {
if(!replenishHyperswap()) if(!replenishHyperswap())
ChatUtil.printHotbar("!! NO TOTEMS !!"); Chat.printHotbar("!! NO TOTEMS !!");
} }
else { else {
ChatUtil.printHotbar("!! NO TOTEMS !!"); Chat.printHotbar("!! NO TOTEMS !!");
} }
return; return;
} }

View file

@ -4,17 +4,17 @@ import com.baseband.client.feature.Feature;
import com.baseband.client.feature.category.Command; import com.baseband.client.feature.category.Command;
import com.baseband.client.feature.client.Client; import com.baseband.client.feature.client.Client;
import com.baseband.client.registry.SetCommand; import com.baseband.client.registry.SetCommand;
import com.baseband.client.util.interact.ChatUtil; import com.baseband.client.util.interact.Chat;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
import static com.baseband.client.BaseBand.features; import static com.baseband.client.feature.Features.features;
@Command @Command
public class Bind extends Feature { public class Bind extends Feature {
@Override @Override
public void onCommand(String[] args) { public void onCommand(String[] args) {
if(args.length != 3) { if(args.length != 3) {
ChatUtil.print("syntax: " + Client.prefix + this + " <module> <binding> <key>"); Chat.print("syntax: " + Client.prefix + this + " <module> <binding> <key>");
return; return;
} }
String module = args[0]; String module = args[0];
@ -31,20 +31,20 @@ public class Bind extends Feature {
} }
if(f == null) { if(f == null) {
ChatUtil.print("Feature " + module + " is not present in this client."); Chat.print("Feature " + module + " is not present in this client.");
return; return;
} }
int key = Keyboard.getKeyIndex(value); int key = Keyboard.getKeyIndex(value);
if(key == 0) { if(key == 0) {
ChatUtil.print(value + " does not appear to be a valid key."); Chat.print(value + " does not appear to be a valid key.");
return; return;
} }
if(f.setWithString(setting.replace('_', ' '), String.valueOf(key))) { if(f.setWithString(setting.replace('_', ' '), String.valueOf(key))) {
ChatUtil.print(module + ":" + setting + " has been set: KEY_" + value + "=" + key); Chat.print(module + ":" + setting + " has been set: KEY_" + value + "=" + key);
} else { } else {
ChatUtil.print("This value is invalid for setting " + module + ":" + setting + " (or it doesn't exist)."); Chat.print("This value is invalid for setting " + module + ":" + setting + " (or it doesn't exist).");
} }
} }

View file

@ -2,8 +2,8 @@ package com.baseband.client.feature.command;
import com.baseband.client.feature.Feature; import com.baseband.client.feature.Feature;
import com.baseband.client.feature.category.Command; import com.baseband.client.feature.category.Command;
import com.baseband.client.util.misc.GlobalUtil;
import net.minecraft.client.multiplayer.GuiConnecting; import net.minecraft.client.multiplayer.GuiConnecting;
import static com.baseband.client.BaseBand.LOGGER;
@Command @Command
public class Connect extends Feature { public class Connect extends Feature {
@ -19,7 +19,7 @@ public class Connect extends Feature {
try { try {
mc.displayGuiScreen(new GuiConnecting(mc.currentScreen, mc, args[0], args.length == 2 ? Integer.parseInt(args[1]) : 25565)); mc.displayGuiScreen(new GuiConnecting(mc.currentScreen, mc, args[0], args.length == 2 ? Integer.parseInt(args[1]) : 25565));
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
GlobalUtil.LOGGER.warn("Port invalid"); LOGGER.warn("Port invalid");
} }
} }
} }

View file

@ -1,11 +1,11 @@
package com.baseband.client.feature.command; package com.baseband.client.feature.command;
import com.baseband.client.BaseBand;
import com.baseband.client.feature.Category; import com.baseband.client.feature.Category;
import com.baseband.client.feature.Feature; import com.baseband.client.feature.Feature;
import com.baseband.client.feature.Features;
import com.baseband.client.feature.category.Command; import com.baseband.client.feature.category.Command;
import com.baseband.client.feature.client.Client; import com.baseband.client.feature.client.Client;
import com.baseband.client.util.interact.ChatUtil; import com.baseband.client.util.interact.Chat;
import de.tudbut.obj.TLMap; import de.tudbut.obj.TLMap;
import net.minecraft.util.text.Style; import net.minecraft.util.text.Style;
import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentString;
@ -17,7 +17,7 @@ public class Help extends Feature {
@Override @Override
public void onTick() { public void onTick() {
if(type != null) { if(type != null) {
ChatUtil.openChat(type); Chat.openChat(type);
type = null; type = null;
} }
} }
@ -25,87 +25,87 @@ public class Help extends Feature {
@Override @Override
public void onCommand(String[] args) { public void onCommand(String[] args) {
if(args.length == 0) { if(args.length == 0) {
ChatUtil.print("§c§lWelcome to the " + Setup.Name + " help system!"); Chat.print("§c§lWelcome to the " + Setup.Name + " help system!");
ChatUtil.print("What would you like to see?"); Chat.print("What would you like to see?");
ChatUtil.print("- guide (<- start with this)"); Chat.print("- guide (<- start with this)");
ChatUtil.print("- commands"); Chat.print("- commands");
ChatUtil.print("- modules"); Chat.print("- modules");
ChatUtil.print(""); Chat.print("");
ChatUtil.print("The beginning of the next command has already been typed out for you!"); Chat.print("The beginning of the next command has already been typed out for you!");
type = (Client.prefix + this + " "); type = (Client.prefix + this + " ");
return; return;
} }
if(args[0].equalsIgnoreCase("guide")) { if(args[0].equalsIgnoreCase("guide")) {
ChatUtil.print("§c§lGuide to the " + Setup.Name + " configuration system"); Chat.print("§c§lGuide to the " + Setup.Name + " configuration system");
ChatUtil.print("This client's config is fully linked, meaning everything is kept track of automatically. " + Chat.print("This client's config is fully linked, meaning everything is kept track of automatically. " +
"When you change something with the set command, it automatically changes in the GUI as well."); "When you change something with the set command, it automatically changes in the GUI as well.");
ChatUtil.print("Everything you can do in the GUI can be done with a command. The help system can give you an " + Chat.print("Everything you can do in the GUI can be done with a command. The help system can give you an " +
"overview on what you can change. Just ask it for the §lmodules§r, for example."); "overview on what you can change. Just ask it for the §lmodules§r, for example.");
ChatUtil.print("To navigate " + Setup.Name + " by commands, you will also need the following:" + Chat.print("To navigate " + Setup.Name + " by commands, you will also need the following:" +
"- " + Client.prefix + BaseBand.getFeature(Set.class) + ": this allows you to set any setting as if you were in the GUI\n" + "- " + Client.prefix + Features.getFeature(Set.class) + ": this allows you to set any setting as if you were in the GUI\n" +
"- " + Client.prefix + BaseBand.getFeature(Bind.class) + ": this allows you to bind keys (they otherwise appear as numbers)\n" + "- " + Client.prefix + Features.getFeature(Bind.class) + ": this allows you to bind keys (they otherwise appear as numbers)\n" +
"- " + Client.prefix + BaseBand.getFeature(Trigger.class) + ": this allows you to trigger things (like a button)"); "- " + Client.prefix + Features.getFeature(Trigger.class) + ": this allows you to trigger things (like a button)");
type = (Client.prefix + this + " modules"); type = (Client.prefix + this + " modules");
return; return;
} }
if(args[0].equalsIgnoreCase("commands")) { if(args[0].equalsIgnoreCase("commands")) {
ChatUtil.print("§c§l" + Setup.Name + " help system: Commands"); Chat.print("§c§l" + Setup.Name + " help system: Commands");
ChatUtil.print("§7Below you find a list of commands in the client:"); Chat.print("§7Below you find a list of commands in the client:");
for (Feature feature : BaseBand.features) { for (Feature feature : Features.features) {
if(feature.category != Category.COMMAND) if(feature.category != Category.COMMAND)
continue; continue;
TextComponentString comp = new TextComponentString(" " + feature.text); TextComponentString comp = new TextComponentString(" " + feature.text);
Style style = new Style(); Style style = new Style();
style.setClickEvent(new net.minecraft.util.text.event.ClickEvent(net.minecraft.util.text.event.ClickEvent.Action.SUGGEST_COMMAND, Client.prefix + this + " feature " + feature)); style.setClickEvent(new net.minecraft.util.text.event.ClickEvent(net.minecraft.util.text.event.ClickEvent.Action.SUGGEST_COMMAND, Client.prefix + this + " feature " + feature));
comp.setStyle(style); comp.setStyle(style);
ChatUtil.print(comp); Chat.print(comp);
} }
return; return;
} }
if(args[0].equalsIgnoreCase("modules")) { if(args[0].equalsIgnoreCase("modules")) {
ChatUtil.print("§c§l" + Setup.Name + " help system: Modules"); Chat.print("§c§l" + Setup.Name + " help system: Modules");
ChatUtil.print("§7Below you find a list of modules in the client:"); Chat.print("§7Below you find a list of modules in the client:");
for (Category category : Category.values()) { for (Category category : Category.values()) {
if(category == Category.COMMAND) if(category == Category.COMMAND)
continue; continue;
ChatUtil.print(" §lCategory " + category); Chat.print(" §lCategory " + category);
for (Feature feature : BaseBand.features) { for (Feature feature : Features.features) {
if(feature.category != category) if(feature.category != category)
continue; continue;
TextComponentString comp = new TextComponentString(" " + feature.text); TextComponentString comp = new TextComponentString(" " + feature.text);
Style style = new Style(); Style style = new Style();
style.setClickEvent(new net.minecraft.util.text.event.ClickEvent(net.minecraft.util.text.event.ClickEvent.Action.SUGGEST_COMMAND, Client.prefix + this + " feature " + feature)); style.setClickEvent(new net.minecraft.util.text.event.ClickEvent(net.minecraft.util.text.event.ClickEvent.Action.SUGGEST_COMMAND, Client.prefix + this + " feature " + feature));
comp.setStyle(style); comp.setStyle(style);
ChatUtil.print(comp); Chat.print(comp);
} }
} }
return; return;
} }
if(args[0].equalsIgnoreCase("feature")) { if(args[0].equalsIgnoreCase("feature")) {
if(args.length != 2) { if(args.length != 2) {
ChatUtil.print("Invalid syntax."); Chat.print("Invalid syntax.");
return; return;
} }
ChatUtil.print("§c§l" + Setup.Name + " help system: Feature " + args[1]); Chat.print("§c§l" + Setup.Name + " help system: Feature " + args[1]);
for (Feature feature : BaseBand.features) { for (Feature feature : Features.features) {
if(feature.toString().replace(' ', '_').equalsIgnoreCase(args[1])) { if(feature.toString().replace(' ', '_').equalsIgnoreCase(args[1])) {
ChatUtil.print(feature.hover); Chat.print(feature.hover);
ChatUtil.print("The feature is " + (feature.enabled ? "§aenabled" : "§cdisabled") + "."); Chat.print("The feature is " + (feature.enabled ? "§aenabled" : "§cdisabled") + ".");
ChatUtil.print("It has " + feature.handle.getContent().map.size() + " config entries:"); Chat.print("It has " + feature.handle.getContent().map.size() + " config entries:");
for (TLMap.Entry<String, Object> entry : feature.handle.getContent().map.entries()) { for (TLMap.Entry<String, Object> entry : feature.handle.getContent().map.entries()) {
TextComponentString comp = new TextComponentString(" " + entry.key + " = " + entry.val); TextComponentString comp = new TextComponentString(" " + entry.key + " = " + entry.val);
Style style = new Style(); Style style = new Style();
style.setClickEvent(new net.minecraft.util.text.event.ClickEvent(net.minecraft.util.text.event.ClickEvent.Action.SUGGEST_COMMAND, Client.prefix + BaseBand.getFeature(Set.class) + " " + feature.toString().replace(' ', '_') + " " + entry.key.replace(' ', '_') + " ")); style.setClickEvent(new net.minecraft.util.text.event.ClickEvent(net.minecraft.util.text.event.ClickEvent.Action.SUGGEST_COMMAND, Client.prefix + Features.getFeature(Set.class) + " " + feature.toString().replace(' ', '_') + " " + entry.key.replace(' ', '_') + " "));
comp.setStyle(style); comp.setStyle(style);
ChatUtil.print(comp); Chat.print(comp);
} }
return; return;
} }
} }
ChatUtil.print("This feature does not exist."); Chat.print("This feature does not exist.");
return; return;
} }
ChatUtil.print("This action does not exist!"); Chat.print("This action does not exist!");
} }
@Override @Override

View file

@ -5,12 +5,12 @@ import com.baseband.client.feature.category.Command;
import com.baseband.client.feature.client.Client; import com.baseband.client.feature.client.Client;
import com.baseband.client.registry.ConfigHandle; import com.baseband.client.registry.ConfigHandle;
import com.baseband.client.registry.SetCommand; import com.baseband.client.registry.SetCommand;
import com.baseband.client.util.interact.ChatUtil; import com.baseband.client.util.interact.Chat;
import com.baseband.client.util.misc.GlobalUtil;
import java.util.HashMap; import java.util.HashMap;
import static com.baseband.client.BaseBand.features; import static com.baseband.client.BaseBand.RANDOM;
import static com.baseband.client.feature.Features.features;
@Command @Command
public class Set extends Feature { public class Set extends Feature {
@ -18,20 +18,20 @@ public class Set extends Feature {
private static final HashMap<Integer, ConfigHandle> quickSet = new HashMap<>(); private static final HashMap<Integer, ConfigHandle> quickSet = new HashMap<>();
public static int addQuickSet(ConfigHandle handle) { public static int addQuickSet(ConfigHandle handle) {
int n = GlobalUtil.RANDOM.nextInt(Integer.MAX_VALUE); int n = RANDOM.nextInt(Integer.MAX_VALUE);
while(quickSet.containsKey(n)) n = GlobalUtil.RANDOM.nextInt(Integer.MAX_VALUE); while(quickSet.containsKey(n)) n = RANDOM.nextInt(Integer.MAX_VALUE);
quickSet.put(n, handle); quickSet.put(n, handle);
return n; return n;
} }
public static void openQuickSet(int id, String field, boolean showCurrent) { public static void openQuickSet(int id, String field, boolean showCurrent) {
ChatUtil.openChat(Client.prefix + "set " + id + " " + field.replace(' ', '_') + " " + (showCurrent ? quickSet.get(id).getContent().getString(field) : "")); Chat.openChat(Client.prefix + "set " + id + " " + field.replace(' ', '_') + " " + (showCurrent ? quickSet.get(id).getContent().getString(field) : ""));
} }
@Override @Override
public void onCommand(String[] args) { public void onCommand(String[] args) {
if(args.length < 3) { if(args.length < 3) {
ChatUtil.print("syntax: " + Client.prefix + this + " <module> <setting> <value...>"); Chat.print("syntax: " + Client.prefix + this + " <module> <setting> <value...>");
return; return;
} }
String module = args[0]; String module = args[0];
@ -57,16 +57,16 @@ public class Set extends Feature {
if(f == null) { if(f == null) {
if(isQS) if(isQS)
ChatUtil.print("QuickSet " + module + " does not exist. This might be a bug."); Chat.print("QuickSet " + module + " does not exist. This might be a bug.");
else else
ChatUtil.print("Feature " + module + " is not present in this client."); Chat.print("Feature " + module + " is not present in this client.");
return; return;
} }
if(f.setWithString(setting.replace('_', ' '), value)) { if(f.setWithString(setting.replace('_', ' '), value)) {
ChatUtil.print(module + ":" + setting + " has been set: " + value); Chat.print(module + ":" + setting + " has been set: " + value);
} else { } else {
ChatUtil.print("This value is invalid for setting " + module + ":" + setting + " (or it doesn't exist)."); Chat.print("This value is invalid for setting " + module + ":" + setting + " (or it doesn't exist).");
} }
} }

View file

@ -5,9 +5,9 @@ import com.baseband.client.feature.category.Command;
import com.baseband.client.feature.client.Client; import com.baseband.client.feature.client.Client;
import com.baseband.client.gui.lib.component.Component; import com.baseband.client.gui.lib.component.Component;
import com.baseband.client.registry.annotation.Description; import com.baseband.client.registry.annotation.Description;
import com.baseband.client.util.interact.ChatUtil; import com.baseband.client.util.interact.Chat;
import static com.baseband.client.BaseBand.features; import static com.baseband.client.feature.Features.features;
@Command @Command
@Description("Triggers some trigger on some module. This is equivalent to pressing the corresponding button in the GUI. Spaces can be replaced with underscores.") @Description("Triggers some trigger on some module. This is equivalent to pressing the corresponding button in the GUI. Spaces can be replaced with underscores.")
@ -15,7 +15,7 @@ public class Trigger extends Feature {
@Override @Override
public void onCommand(String[] args) { public void onCommand(String[] args) {
if(args.length != 2) { if(args.length != 2) {
ChatUtil.print("syntax: " + Client.prefix + this + " <module> <trigger>"); Chat.print("syntax: " + Client.prefix + this + " <module> <trigger>");
return; return;
} }
String module = args[0]; String module = args[0];
@ -31,7 +31,7 @@ public class Trigger extends Feature {
} }
if(f == null) { if(f == null) {
ChatUtil.print("Feature " + module + " is not present in this client."); Chat.print("Feature " + module + " is not present in this client.");
return; return;
} }
@ -41,7 +41,7 @@ public class Trigger extends Feature {
return; return;
} }
} }
ChatUtil.print("Trigger " + trigger + " is not present in module " + module + "."); Chat.print("Trigger " + trigger + " is not present in module " + module + ".");
} }
@Override @Override

View file

@ -1,7 +1,7 @@
package com.baseband.client.feature.movement; package com.baseband.client.feature.movement;
import com.baseband.client.BaseBand;
import com.baseband.client.feature.Feature; import com.baseband.client.feature.Feature;
import com.baseband.client.feature.Features;
import com.baseband.client.feature.category.Movement; import com.baseband.client.feature.category.Movement;
import com.baseband.client.feature.client.Client; import com.baseband.client.feature.client.Client;
import com.baseband.client.registry.annotation.Config; import com.baseband.client.registry.annotation.Config;
@ -9,6 +9,7 @@ import com.baseband.client.registry.annotation.Description;
import com.baseband.client.registry.annotation.Gate; import com.baseband.client.registry.annotation.Gate;
import com.baseband.client.registry.annotation.Range; import com.baseband.client.registry.annotation.Range;
import com.baseband.client.util.adapt.Marker; import com.baseband.client.util.adapt.Marker;
import com.baseband.client.util.interact.Chat;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@Movement @Movement
@ -49,27 +50,27 @@ public class ElytraBot extends Feature {
@Override @Override
public void onEnable() { public void onEnable() {
if(!BaseBand.isFeatureEnabled(ElytraFly.class)) { if(!Features.isFeatureEnabled(ElytraFly.class)) {
BaseBand.notify("§cElytraBot cannot work without ElytraFly."); Chat.notify("§cElytraBot cannot work without ElytraFly.");
toggle(); toggle();
return; return;
} }
BaseBand.getFeature(ElytraFly.class).blockMovement = true; Features.getFeature(ElytraFly.class).blockMovement = true;
} }
@Override @Override
public void onDisable() { public void onDisable() {
if(!BaseBand.isFeaturePresent(ElytraFly.class)) { if(!Features.isFeaturePresent(ElytraFly.class)) {
return; return;
} }
BaseBand.getFeature(ElytraFly.class).blockMovement = false; Features.getFeature(ElytraFly.class).blockMovement = false;
} }
@Override @Override
public void onTick() { public void onTick() {
ElytraFly efly = BaseBand.getFeature(ElytraFly.class); ElytraFly efly = Features.getFeature(ElytraFly.class);
if(!efly.enabled) { if(!efly.enabled) {
BaseBand.notify("§cElytraBot cannot work without ElytraFly."); Chat.notify("§cElytraBot cannot work without ElytraFly.");
toggle(); toggle();
return; return;
} }
@ -94,7 +95,7 @@ public class ElytraBot extends Feature {
break a; break a;
} }
} catch (Exception ignored) {} } catch (Exception ignored) {}
BaseBand.notify("§cInvalid ElytraBot target."); Chat.notify("§cInvalid ElytraBot target.");
toggle(); toggle();
return; return;
} else { } else {
@ -107,7 +108,7 @@ public class ElytraBot extends Feature {
break a; break a;
} }
} }
BaseBand.notify("§cElytraBot couldn't find your target player."); Chat.notify("§cElytraBot couldn't find your target player.");
toggle(); toggle();
return; return;
} }

View file

@ -1,10 +1,10 @@
package com.baseband.client.feature.movement; package com.baseband.client.feature.movement;
import com.baseband.client.BaseBand;
import com.baseband.client.event.Priority; import com.baseband.client.event.Priority;
import com.baseband.client.event.events.MoveEvent; import com.baseband.client.event.events.MoveEvent;
import com.baseband.client.event.events.PacketEvent; import com.baseband.client.event.events.PacketEvent;
import com.baseband.client.feature.Feature; import com.baseband.client.feature.Feature;
import com.baseband.client.feature.Features;
import com.baseband.client.feature.category.Movement; import com.baseband.client.feature.category.Movement;
import com.baseband.client.feature.client.Timer; import com.baseband.client.feature.client.Timer;
import com.baseband.client.mixins.IMinecraft; import com.baseband.client.mixins.IMinecraft;
@ -60,12 +60,12 @@ public class Speed extends Feature {
text = toString(); text = toString();
} }
if(enabled && BaseBand.getFeature(Timer.class).enabled) { if(enabled && Features.getFeature(Timer.class).enabled) {
BaseBand.getFeature(Timer.class).timerLock = true; Features.getFeature(Timer.class).timerLock = true;
BaseBand.getFeature(Timer.class).multiplierLock = 20f * 1.088f; Features.getFeature(Timer.class).multiplierLock = 20f * 1.088f;
} else if (!enabled && BaseBand.getFeature(Timer.class).enabled){ } else if (!enabled && Features.getFeature(Timer.class).enabled){
BaseBand.getFeature(Timer.class).timerLock = false; Features.getFeature(Timer.class).timerLock = false;
BaseBand.getFeature(Timer.class).multiplierLock = 20f; Features.getFeature(Timer.class).multiplierLock = 20f;
} }
} }

View file

@ -7,7 +7,7 @@ import com.baseband.client.registry.annotation.Config;
import com.baseband.client.registry.annotation.Description; import com.baseband.client.registry.annotation.Description;
import com.baseband.client.registry.annotation.Gate; import com.baseband.client.registry.annotation.Gate;
import static com.baseband.client.BaseBand.features; import static com.baseband.client.feature.Features.features;
@Render @Render
public class ClickGUI extends Feature { public class ClickGUI extends Feature {

View file

@ -3,13 +3,13 @@ package com.baseband.client.feature.render;
import com.baseband.client.BaseBand; import com.baseband.client.BaseBand;
import com.baseband.client.feature.Category; import com.baseband.client.feature.Category;
import com.baseband.client.feature.Feature; import com.baseband.client.feature.Feature;
import com.baseband.client.feature.Features;
import com.baseband.client.feature.category.Render; import com.baseband.client.feature.category.Render;
import com.baseband.client.feature.client.Client; import com.baseband.client.feature.client.Client;
import com.baseband.client.gui.GuiTheme; import com.baseband.client.gui.GuiTheme;
import com.baseband.client.registry.annotation.*; import com.baseband.client.registry.annotation.*;
import com.baseband.client.util.adapt.Marker; import com.baseband.client.util.adapt.Marker;
import com.baseband.client.util.interact.ServerDataManager; import com.baseband.client.util.interact.ServerDataManager;
import com.baseband.client.util.misc.GlobalUtil;
import com.baseband.client.util.render.Pixels; import com.baseband.client.util.render.Pixels;
import com.baseband.client.util.render.TextSplitter; import com.baseband.client.util.render.TextSplitter;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -22,7 +22,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.util.*; import java.util.*;
import static com.baseband.client.BaseBand.features; import static com.baseband.client.BaseBand.LOGGER;
import static com.baseband.client.feature.Features.features;
import static com.baseband.client.util.render.TextSplitter.*; import static com.baseband.client.util.render.TextSplitter.*;
@Render @Render
@ -67,7 +68,7 @@ public class HUD extends Feature {
} }
public static void notify(String text, int time) { public static void notify(String text, int time) {
GlobalUtil.LOGGER.info(text); LOGGER.info(text);
notifs.add(new Notification(text, time)); notifs.add(new Notification(text, time));
} }
@ -164,7 +165,7 @@ public class HUD extends Feature {
public void text(RenderGameOverlayEvent.Text e) { public void text(RenderGameOverlayEvent.Text e) {
ScaledResolution sr = new ScaledResolution(mc); ScaledResolution sr = new ScaledResolution(mc);
TextSplitter.init(mc.fontRenderer); TextSplitter.init(mc.fontRenderer);
GuiTheme.ITheme theme = BaseBand.getFeature(Client.class).getTheme(); GuiTheme.ITheme theme = Features.getFeature(Client.class).getTheme();
String infoString = ""; String infoString = "";
if(showInfo) { if(showInfo) {
@ -283,8 +284,8 @@ public class HUD extends Feature {
@Override @Override
protected void setup() { protected void setup() {
if(BaseBand.isFeaturePresent(ShowTPS.class)) { if(Features.isFeaturePresent(ShowTPS.class)) {
subComponents.add(BaseBand.getFeature(ShowTPS.class)); subComponents.add(Features.getFeature(ShowTPS.class));
} }
} }

View file

@ -1,8 +1,8 @@
package com.baseband.client.feature.world; package com.baseband.client.feature.world;
import com.baseband.client.BaseBand;
import com.baseband.client.feature.Feature; import com.baseband.client.feature.Feature;
import com.baseband.client.feature.category.World; import com.baseband.client.feature.category.World;
import com.baseband.client.util.interact.Chat;
import de.tudbut.tools.Lock; import de.tudbut.tools.Lock;
import net.minecraft.client.gui.GuiGameOver; import net.minecraft.client.gui.GuiGameOver;
@ -19,7 +19,7 @@ public class AutoRespawn extends Feature {
if (mc.currentScreen instanceof GuiGameOver && !lock.isLocked()) { if (mc.currentScreen instanceof GuiGameOver && !lock.isLocked()) {
mc.player.respawnPlayer(); mc.player.respawnPlayer();
mc.displayGuiScreen(null); mc.displayGuiScreen(null);
BaseBand.notify("[AutoRespawn] Respawned."); Chat.notify("[AutoRespawn] Respawned.");
lock.lock(500); lock.lock(500);
} }
} }

View file

@ -1,13 +1,13 @@
package com.baseband.client.feature.world; package com.baseband.client.feature.world;
import com.baseband.client.BaseBand;
import com.baseband.client.feature.Feature; import com.baseband.client.feature.Feature;
import com.baseband.client.feature.Features;
import com.baseband.client.feature.category.World; import com.baseband.client.feature.category.World;
import com.baseband.client.feature.render.ClickGUI; import com.baseband.client.feature.render.ClickGUI;
import com.baseband.client.registry.annotation.*; import com.baseband.client.registry.annotation.*;
import com.baseband.client.util.adapt.Marker; import com.baseband.client.util.adapt.Marker;
import com.baseband.client.util.adapt.SimpleWorldGenerator; import com.baseband.client.util.adapt.SimpleWorldGenerator;
import com.baseband.client.util.misc.GlobalUtil; import com.baseband.client.util.interact.Chat;
import com.baseband.client.util.render.Pixels; import com.baseband.client.util.render.Pixels;
import de.tudbut.tools.Lock; import de.tudbut.tools.Lock;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -23,6 +23,7 @@ import org.lwjgl.opengl.GL11;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Objects; import java.util.Objects;
import static com.baseband.client.BaseBand.LOGGER;
import static com.baseband.client.util.render.Tesselator.*; import static com.baseband.client.util.render.Tesselator.*;
@World @World
@ -102,32 +103,32 @@ public class SeedOverlay extends Feature {
running = true; running = true;
canSetRD = false; canSetRD = false;
new Thread(() -> { new Thread(() -> {
BaseBand.ifFeaturePresent(ClickGUI.class, gui -> gui.setEnabled(false)); Features.ifFeaturePresent(ClickGUI.class, gui -> gui.setEnabled(false));
long seed; long seed;
try { try {
seed = Long.parseLong(this.seed); seed = Long.parseLong(this.seed);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
seed = this.seed.hashCode(); seed = this.seed.hashCode();
} }
BaseBand.notify("Creating world with seed " + seed + "..."); Chat.notify("Creating world with seed " + seed + "...");
int rd = this.rd * 2 + 1; int rd = this.rd * 2 + 1;
genOverworld = SimpleWorldGenerator.overworld(mc.world.getWorldInfo(), seed, rd); genOverworld = SimpleWorldGenerator.overworld(mc.world.getWorldInfo(), seed, rd);
genNether = SimpleWorldGenerator.nether(mc.world.getWorldInfo(), seed, rd); genNether = SimpleWorldGenerator.nether(mc.world.getWorldInfo(), seed, rd);
genEnd = SimpleWorldGenerator.end(mc.world.getWorldInfo(), seed, rd); genEnd = SimpleWorldGenerator.end(mc.world.getWorldInfo(), seed, rd);
int length = rd * 16 * 256 * rd * 16; int length = rd * 16 * 256 * rd * 16;
BaseBand.notify("World generators acquired. Allocating render buffer with " + (length * 4 / 1024) + "KB space."); Chat.notify("World generators acquired. Allocating render buffer with " + (length * 4 / 1024) + "KB space.");
bufferPosition = new BlockPos((mc.player.chunkCoordX - this.rd) * 16, 0, (mc.player.chunkCoordZ - this.rd) * 16); bufferPosition = new BlockPos((mc.player.chunkCoordX - this.rd) * 16, 0, (mc.player.chunkCoordZ - this.rd) * 16);
frontBuffer = new int[rd * 16][256][rd * 16]; frontBuffer = new int[rd * 16][256][rd * 16];
backBuffer = new int[rd * 16][256][rd * 16]; backBuffer = new int[rd * 16][256][rd * 16];
GlobalUtil.LOGGER.info("Allocated."); LOGGER.info("Allocated.");
for (int x = 0; x < rd * 16; x++) { for (int x = 0; x < rd * 16; x++) {
for (int z = 0; z < rd * 16; z++) { for (int z = 0; z < rd * 16; z++) {
frontBuffer[x][0][z] = 0x800000ff; frontBuffer[x][0][z] = 0x800000ff;
backBuffer[x][0][z] = 0x800000ff; backBuffer[x][0][z] = 0x800000ff;
} }
} }
GlobalUtil.LOGGER.info("Filled buffer with unloaded state."); LOGGER.info("Filled buffer with unloaded state.");
BaseBand.notify("Render buffer created. Starting..."); Chat.notify("Render buffer created. Starting...");
setEnabled(true); setEnabled(true);
}, this + " init").start(); }, this + " init").start();
} }
@ -149,7 +150,7 @@ public class SeedOverlay extends Feature {
// these should already be stopped! // these should already be stopped!
if(updater.isAlive() || generator.isAlive()) { if(updater.isAlive() || generator.isAlive()) {
GlobalUtil.LOGGER.warn(this + " threads were still running when stopping the world. This should not happen! Stopping them forcefully."); LOGGER.warn(this + " threads were still running when stopping the world. This should not happen! Stopping them forcefully.");
//noinspection deprecation //noinspection deprecation
updater.stop(); updater.stop();
//noinspection deprecation //noinspection deprecation
@ -167,7 +168,7 @@ public class SeedOverlay extends Feature {
backBuffer = null; backBuffer = null;
canSetRD = true; canSetRD = true;
GlobalUtil.LOGGER.info("SeedOverlay completely disabled."); LOGGER.info("SeedOverlay completely disabled.");
}, this + " stopper").start(); }, this + " stopper").start();
} }
@ -176,7 +177,7 @@ public class SeedOverlay extends Feature {
@Override @Override
public void onEnable() { public void onEnable() {
if(frontBuffer == null) { if(frontBuffer == null) {
BaseBand.notify("Please input a |Seed| and trigger |Generate now|"); Chat.notify("Please input a |Seed| and trigger |Generate now|");
toggle(); toggle();
return; return;
} }

View file

@ -1,10 +1,11 @@
package com.baseband.client.feature.world; package com.baseband.client.feature.world;
import com.baseband.client.BaseBand;
import com.baseband.client.event.Priority; import com.baseband.client.event.Priority;
import com.baseband.client.event.events.SelectEvent; import com.baseband.client.event.events.SelectEvent;
import com.baseband.client.feature.Feature; import com.baseband.client.feature.Feature;
import com.baseband.client.feature.category.World; import com.baseband.client.feature.category.World;
import com.baseband.client.registry.Configuration;
import com.baseband.client.util.interact.Chat;
import com.baseband.client.util.type.Selection; import com.baseband.client.util.type.Selection;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -18,14 +19,14 @@ public class Select extends Feature {
if(end != null || begin == null) { if(end != null || begin == null) {
begin = b; begin = b;
end = null; end = null;
BaseBand.notify("Selection reset."); Chat.notify("Selection reset.");
BaseBand.notify("Position 1: " + b.getX() + " " + b.getY() + " " + b.getZ()); Chat.notify("Position 1: " + b.getX() + " " + b.getY() + " " + b.getZ());
BaseBand.publish(new SelectEvent(null)); Configuration.publish(new SelectEvent(null));
return; return;
} }
end = b; end = b;
BaseBand.notify("Position 2: " + b.getX() + " " + b.getY() + " " + b.getZ()); Chat.notify("Position 2: " + b.getX() + " " + b.getY() + " " + b.getZ());
BaseBand.publish(new SelectEvent(new Selection(begin, end))); Configuration.publish(new SelectEvent(new Selection(begin, end)));
} }
@Priority(Integer.MAX_VALUE) @Priority(Integer.MAX_VALUE)

View file

@ -2,6 +2,7 @@ package com.baseband.client.gui;
import com.baseband.client.BaseBand; import com.baseband.client.BaseBand;
import com.baseband.client.feature.Feature; import com.baseband.client.feature.Feature;
import com.baseband.client.feature.Features;
import com.baseband.client.feature.render.ClickGUI; import com.baseband.client.feature.render.ClickGUI;
import com.baseband.client.gui.lib.GUIManager; import com.baseband.client.gui.lib.GUIManager;
import com.baseband.client.gui.lib.component.Category; import com.baseband.client.gui.lib.component.Category;
@ -16,7 +17,7 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import static com.baseband.client.BaseBand.features; import static com.baseband.client.feature.Features.features;
public class GuiRewrite extends GuiScreen { public class GuiRewrite extends GuiScreen {
@ -86,7 +87,7 @@ public class GuiRewrite extends GuiScreen {
@Override @Override
public void onGuiClosed() { public void onGuiClosed() {
super.onGuiClosed(); super.onGuiClosed();
BaseBand.getFeature(ClickGUI.class).setEnabled(false); Features.getFeature(ClickGUI.class).setEnabled(false);
for (Category category : categories) { for (Category category : categories) {
com.baseband.client.feature.Category c = com.baseband.client.feature.Category.fromName(category.text); com.baseband.client.feature.Category c = com.baseband.client.feature.Category.fromName(category.text);
assert c != null; assert c != null;
@ -174,7 +175,7 @@ public class GuiRewrite extends GuiScreen {
} }
// TMP fix for a strange bug that causes the mouse to be hidden // TMP fix for a strange bug that causes the mouse to be hidden
if (BaseBand.getFeature(ClickGUI.class).mouseFix) { if (Features.getFeature(ClickGUI.class).mouseFix) {
drawRect(mouseX - 2, mouseY - 2, mouseX + 2, mouseY + 2, 0xffffffff); drawRect(mouseX - 2, mouseY - 2, mouseX + 2, mouseY + 2, 0xffffffff);
} }
int m = Mouse.getDWheel(); int m = Mouse.getDWheel();

View file

@ -1,6 +1,6 @@
package com.baseband.client.gui.lib; package com.baseband.client.gui.lib;
import com.baseband.client.BaseBand; import com.baseband.client.feature.Features;
import com.baseband.client.feature.client.Client; import com.baseband.client.feature.client.Client;
import com.baseband.client.gui.GuiTheme; import com.baseband.client.gui.GuiTheme;
import com.baseband.client.gui.lib.component.Component; import com.baseband.client.gui.lib.component.Component;
@ -66,7 +66,7 @@ public class GUIManager {
} }
public static void update() { public static void update() {
GuiTheme.ITheme theme = BaseBand.getFeature(Client.class).getTheme(); GuiTheme.ITheme theme = Features.getFeature(Client.class).getTheme();
fontColorOn = theme.getGreenColor(); fontColorOn = theme.getGreenColor();
fontColorOff = theme.getRedColor(); fontColorOff = theme.getRedColor();
frameColor = theme.getFrameColor(); frameColor = theme.getFrameColor();

View file

@ -3,12 +3,13 @@ package com.baseband.client.gui.lib.component;
import com.baseband.client.feature.command.Set; import com.baseband.client.feature.command.Set;
import com.baseband.client.gui.lib.GUIManager; import com.baseband.client.gui.lib.GUIManager;
import com.baseband.client.registry.ConfigHandle; import com.baseband.client.registry.ConfigHandle;
import com.baseband.client.util.misc.GlobalUtil;
import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.Gui;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
import java.util.function.Function; import java.util.function.Function;
import static com.baseband.client.BaseBand.LOGGER;
public class IntSlider extends Component { public class IntSlider extends Component {
public float f = 0; public float f = 0;
@ -79,7 +80,7 @@ public class IntSlider extends Component {
try { try {
f = (handle.getContent().getInteger(field) - adder) / (float) mapper; f = (handle.getContent().getInteger(field) - adder) / (float) mapper;
} catch (NullPointerException e) { } catch (NullPointerException e) {
GlobalUtil.LOGGER.debug(e.getStackTrace()); LOGGER.debug(e.getStackTrace());
} }
if(countdown > 0) { if(countdown > 0) {
--countdown; --countdown;

View file

@ -3,12 +3,13 @@ package com.baseband.client.gui.lib.component;
import com.baseband.client.feature.command.Set; import com.baseband.client.feature.command.Set;
import com.baseband.client.gui.lib.GUIManager; import com.baseband.client.gui.lib.GUIManager;
import com.baseband.client.registry.ConfigHandle; import com.baseband.client.registry.ConfigHandle;
import com.baseband.client.util.misc.GlobalUtil;
import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.Gui;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
import java.util.function.Function; import java.util.function.Function;
import static com.baseband.client.BaseBand.LOGGER;
public class Slider extends Component { public class Slider extends Component {
public float f = 0; public float f = 0;
@ -77,7 +78,7 @@ public class Slider extends Component {
try { try {
f = (handle.getContent().getFloat(field) - adder) / mapper; f = (handle.getContent().getFloat(field) - adder) / mapper;
} catch (NullPointerException e) { } catch (NullPointerException e) {
GlobalUtil.LOGGER.debug(e.getStackTrace()); LOGGER.debug(e.getStackTrace());
} }
if(countdown > 0) { if(countdown > 0) {
--countdown; --countdown;

View file

@ -2,7 +2,8 @@ package com.baseband.client.gui.lib.component;
import com.baseband.client.feature.command.Set; import com.baseband.client.feature.command.Set;
import com.baseband.client.registry.ConfigHandle; import com.baseband.client.registry.ConfigHandle;
import com.baseband.client.util.misc.GlobalUtil;
import static com.baseband.client.BaseBand.LOGGER;
public class ToggleButton extends Component { public class ToggleButton extends Component {
@ -32,7 +33,7 @@ public class ToggleButton extends Component {
try { try {
green = handle.getContent().getBoolean(field); green = handle.getContent().getBoolean(field);
} catch (NullPointerException e) { } catch (NullPointerException e) {
GlobalUtil.LOGGER.debug(e.getStackTrace()); LOGGER.debug(e.getStackTrace());
} }
} }

View file

@ -1,8 +1,8 @@
package com.baseband.client.mixins; package com.baseband.client.mixins;
import com.baseband.client.BaseBand;
import com.baseband.client.event.events.MotionUpdateEvent; import com.baseband.client.event.events.MotionUpdateEvent;
import com.baseband.client.event.events.MoveEvent; import com.baseband.client.event.events.MoveEvent;
import com.baseband.client.registry.Configuration;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.entity.AbstractClientPlayer;
@ -19,7 +19,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
public class MixinEntityPlayerSP extends AbstractClientPlayer { public class MixinEntityPlayerSP extends AbstractClientPlayer {
@Shadow @Shadow
public Minecraft mc; protected Minecraft mc;
public MixinEntityPlayerSP(World worldIn, GameProfile playerProfile) { public MixinEntityPlayerSP(World worldIn, GameProfile playerProfile) {
super(worldIn, playerProfile); super(worldIn, playerProfile);
@ -55,13 +55,13 @@ public class MixinEntityPlayerSP extends AbstractClientPlayer {
@Inject(method = {"onUpdateWalkingPlayer"}, at = {@At(value = "HEAD")}) @Inject(method = {"onUpdateWalkingPlayer"}, at = {@At(value = "HEAD")})
private void preMotion(CallbackInfo info) { private void preMotion(CallbackInfo info) {
BaseBand.publish(new MotionUpdateEvent.Pre()); Configuration.publish(new MotionUpdateEvent.Pre());
} }
@Inject(method = {"onUpdateWalkingPlayer"}, at = {@At(value = "RETURN")}) @Inject(method = {"onUpdateWalkingPlayer"}, at = {@At(value = "RETURN")})
private void postMotion(CallbackInfo info) { private void postMotion(CallbackInfo info) {
BaseBand.publish(new MotionUpdateEvent.Post()); Configuration.publish(new MotionUpdateEvent.Post());
} }
@ -70,7 +70,7 @@ public class MixinEntityPlayerSP extends AbstractClientPlayer {
@Inject(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/AbstractClientPlayer;move(Lnet/minecraft/entity/MoverType;DDD)V"), cancellable = true) @Inject(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/AbstractClientPlayer;move(Lnet/minecraft/entity/MoverType;DDD)V"), cancellable = true)
public void move(MoverType p_70091_1_, double p_70091_2_, double p_70091_4_, double p_70091_6_, CallbackInfo ci) { public void move(MoverType p_70091_1_, double p_70091_2_, double p_70091_4_, double p_70091_6_, CallbackInfo ci) {
MoveEvent event = new MoveEvent(p_70091_1_, p_70091_2_, p_70091_4_, p_70091_6_); MoveEvent event = new MoveEvent(p_70091_1_, p_70091_2_, p_70091_4_, p_70091_6_);
if(!BaseBand.publish(event).isCancelled()) if(!Configuration.publish(event).isCancelled())
super.move(event.type, event.x, event.y, event.z); super.move(event.type, event.x, event.y, event.z);
ci.cancel(); ci.cancel();
} }

View file

@ -1,6 +1,6 @@
package com.baseband.client.mixins; package com.baseband.client.mixins;
import com.baseband.client.BaseBand; import com.baseband.client.feature.Features;
import com.baseband.client.feature.render.NoRender; import com.baseband.client.feature.render.NoRender;
import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.client.renderer.EntityRenderer;
@ -17,7 +17,7 @@ public class MixinEntityRender {
@Redirect(method = "orientCamera", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/WorldClient;rayTraceBlocks(Lnet/minecraft/util/math/Vec3d;Lnet/minecraft/util/math/Vec3d;)Lnet/minecraft/util/math/RayTraceResult;")) @Redirect(method = "orientCamera", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/WorldClient;rayTraceBlocks(Lnet/minecraft/util/math/Vec3d;Lnet/minecraft/util/math/Vec3d;)Lnet/minecraft/util/math/RayTraceResult;"))
public RayTraceResult rayTraceBlocks(WorldClient world, Vec3d start, Vec3d end) { public RayTraceResult rayTraceBlocks(WorldClient world, Vec3d start, Vec3d end) {
if (BaseBand.isFeatureEnabled(NoRender.class) && BaseBand.getFeature(NoRender.class).cameraClip) if (Features.isFeatureEnabled(NoRender.class) && Features.getFeature(NoRender.class).cameraClip)
return null; return null;
else else
return world.rayTraceBlocks(start, end); return world.rayTraceBlocks(start, end);
@ -26,6 +26,6 @@ public class MixinEntityRender {
@Inject(method = "hurtCameraEffect", at = @At("HEAD"), cancellable = true) @Inject(method = "hurtCameraEffect", at = @At("HEAD"), cancellable = true)
public void hurtCameraEffect(float ticks, CallbackInfo info) { public void hurtCameraEffect(float ticks, CallbackInfo info) {
if (BaseBand.isFeatureEnabled(NoRender.class) && BaseBand.getFeature(NoRender.class).hurtcam) info.cancel(); if (Features.isFeatureEnabled(NoRender.class) && Features.getFeature(NoRender.class).hurtcam) info.cancel();
} }
} }

View file

@ -1,6 +1,6 @@
package com.baseband.client.mixins; package com.baseband.client.mixins;
import com.baseband.client.BaseBand; import com.baseband.client.feature.Features;
import com.baseband.client.feature.world.AutoSignText; import com.baseband.client.feature.world.AutoSignText;
import net.minecraft.client.gui.inventory.GuiEditSign; import net.minecraft.client.gui.inventory.GuiEditSign;
import net.minecraft.tileentity.TileEntitySign; import net.minecraft.tileentity.TileEntitySign;
@ -21,8 +21,8 @@ public class MixinGuiEditSign {
@Inject(method = "initGui", at = @At("RETURN")) @Inject(method = "initGui", at = @At("RETURN"))
public void initGui(CallbackInfo callback) { public void initGui(CallbackInfo callback) {
if(BaseBand.isFeatureEnabled(AutoSignText.class)) { if(Features.isFeatureEnabled(AutoSignText.class)) {
AutoSignText autoSignText = BaseBand.getFeature(AutoSignText.class); AutoSignText autoSignText = Features.getFeature(AutoSignText.class);
tileSign.signText[0] = new TextComponentString(autoSignText.signTextFirst); tileSign.signText[0] = new TextComponentString(autoSignText.signTextFirst);
tileSign.signText[1] = new TextComponentString(autoSignText.signTextSecond); tileSign.signText[1] = new TextComponentString(autoSignText.signTextSecond);
tileSign.signText[2] = new TextComponentString(autoSignText.signTextThird); tileSign.signText[2] = new TextComponentString(autoSignText.signTextThird);

View file

@ -1,6 +1,6 @@
package com.baseband.client.mixins; package com.baseband.client.mixins;
import com.baseband.client.BaseBand; import com.baseband.client.feature.Features;
import com.baseband.client.feature.chat.ChatExtras; import com.baseband.client.feature.chat.ChatExtras;
import net.minecraft.client.gui.ChatLine; import net.minecraft.client.gui.ChatLine;
import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.Gui;
@ -15,30 +15,30 @@ import java.util.List;
public class MixinGuiNewChat extends Gui { public class MixinGuiNewChat extends Gui {
@Redirect(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiNewChat;drawRect(IIIII)V")) @Redirect(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiNewChat;drawRect(IIIII)V"))
private void drawRectHook(int left, int top, int right, int bottom, int color) { private void drawRectHook(int left, int top, int right, int bottom, int color) {
if(!BaseBand.isFeatureEnabled(ChatExtras.class)) { if(!Features.isFeatureEnabled(ChatExtras.class)) {
Gui.drawRect(left, top, right, bottom, color); Gui.drawRect(left, top, right, bottom, color);
return; return;
} }
ChatExtras chatExtras = BaseBand.getFeature(ChatExtras.class); ChatExtras chatExtras = Features.getFeature(ChatExtras.class);
Gui.drawRect(left, top, right, bottom, chatExtras.clearchat ? 0 : color); Gui.drawRect(left, top, right, bottom, chatExtras.clearchat ? 0 : color);
} }
@Redirect(method = "setChatLine", at = @At(value = "INVOKE", target = "Ljava/util/List;size()I", ordinal = 0, remap = false)) @Redirect(method = "setChatLine", at = @At(value = "INVOKE", target = "Ljava/util/List;size()I", ordinal = 0, remap = false))
public int drawnChatLinesSize(List<ChatLine> list) { public int drawnChatLinesSize(List<ChatLine> list) {
if(!BaseBand.isFeatureEnabled(ChatExtras.class)) if(!Features.isFeatureEnabled(ChatExtras.class))
return list.size(); return list.size();
ChatExtras chatExtras = BaseBand.getFeature(ChatExtras.class); ChatExtras chatExtras = Features.getFeature(ChatExtras.class);
return chatExtras.infinitechat ? -2147483647 : list.size(); return chatExtras.infinitechat ? -2147483647 : list.size();
} }
@Redirect(method = "setChatLine", at = @At(value = "INVOKE", target = "Ljava/util/List;size()I", ordinal = 2, remap = false)) @Redirect(method = "setChatLine", at = @At(value = "INVOKE", target = "Ljava/util/List;size()I", ordinal = 2, remap = false))
public int chatLinesSize(List<ChatLine> list) { public int chatLinesSize(List<ChatLine> list) {
if(!BaseBand.isFeatureEnabled(ChatExtras.class)) if(!Features.isFeatureEnabled(ChatExtras.class))
return list.size(); return list.size();
ChatExtras chatExtras = BaseBand.getFeature(ChatExtras.class); ChatExtras chatExtras = Features.getFeature(ChatExtras.class);
return chatExtras.infinitechat ? -2147483647 : list.size(); return chatExtras.infinitechat ? -2147483647 : list.size();
} }
} }

View file

@ -1,7 +1,7 @@
package com.baseband.client.mixins; package com.baseband.client.mixins;
import com.baseband.client.BaseBand;
import com.baseband.client.event.events.PacketEvent; import com.baseband.client.event.events.PacketEvent;
import com.baseband.client.registry.Configuration;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import net.minecraft.network.NetworkManager; import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet; import net.minecraft.network.Packet;
@ -15,13 +15,13 @@ public class MixinNetworkManager {
@Inject(method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/Packet;)V", at = @At("HEAD"), cancellable = true) @Inject(method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/Packet;)V", at = @At("HEAD"), cancellable = true)
public void channelRead0(ChannelHandlerContext p_channelRead0_1_, Packet<?> p_channelRead0_2_, CallbackInfo ci) { public void channelRead0(ChannelHandlerContext p_channelRead0_1_, Packet<?> p_channelRead0_2_, CallbackInfo ci) {
if (BaseBand.publish(new PacketEvent.Receive(p_channelRead0_2_)).isCancelled()) if (Configuration.publish(new PacketEvent.Receive(p_channelRead0_2_)).isCancelled())
ci.cancel(); ci.cancel();
} }
@Inject(method = "sendPacket(Lnet/minecraft/network/Packet;)V", at = @At("HEAD"), cancellable = true) @Inject(method = "sendPacket(Lnet/minecraft/network/Packet;)V", at = @At("HEAD"), cancellable = true)
public void channelRead0(Packet<?> packetIn, CallbackInfo ci) { public void channelRead0(Packet<?> packetIn, CallbackInfo ci) {
if (BaseBand.publish(new PacketEvent.Send(packetIn)).isCancelled()) if (Configuration.publish(new PacketEvent.Send(packetIn)).isCancelled())
ci.cancel(); ci.cancel();
} }
} }

View file

@ -1,7 +1,7 @@
package com.baseband.client.mixins; package com.baseband.client.mixins;
import com.baseband.client.BaseBand; import com.baseband.client.feature.Features;
import com.baseband.client.feature.client.Client; import com.baseband.client.feature.client.Client;
import com.baseband.client.util.net.ScreenshotHelper; import com.baseband.client.util.net.ScreenshotHelper;
import net.minecraft.client.shader.Framebuffer; import net.minecraft.client.shader.Framebuffer;
@ -17,10 +17,10 @@ import java.io.File;
public class MixinScreenshotHelper { public class MixinScreenshotHelper {
@Inject(method = {"saveScreenshot(Ljava/io/File;Ljava/lang/String;IILnet/minecraft/client/shader/Framebuffer;)Lnet/minecraft/util/text/ITextComponent;"}, at = {@At(value = "HEAD")}) @Inject(method = {"saveScreenshot(Ljava/io/File;Ljava/lang/String;IILnet/minecraft/client/shader/Framebuffer;)Lnet/minecraft/util/text/ITextComponent;"}, at = {@At(value = "HEAD")})
private static void saveScreenshot(File file, String string, int n, int n2, Framebuffer framebuffer, CallbackInfoReturnable<?> callbackInfoReturnable) { private static void saveScreenshot(File file, String string, int n, int n2, Framebuffer framebuffer, CallbackInfoReturnable<?> callbackInfoReturnable) {
if(!BaseBand.isFeatureEnabled(Client.class)) if(!Features.isFeatureEnabled(Client.class))
return; return;
Client client = BaseBand.getFeature(Client.class); Client client = Features.getFeature(Client.class);
if (client.screenshotUpload) { if (client.screenshotUpload) {
ScreenshotHelper eventClientScreenShot = new ScreenshotHelper(ScreenShotHelper.createScreenshot(n, n2, framebuffer)); ScreenshotHelper eventClientScreenShot = new ScreenshotHelper(ScreenShotHelper.createScreenshot(n, n2, framebuffer));
eventClientScreenShot.start(); eventClientScreenShot.start();

View file

@ -1,11 +1,12 @@
package com.baseband.client.registry; package com.baseband.client.registry;
import com.baseband.client.util.misc.GlobalUtil;
import de.tudbut.parsing.TCN; import de.tudbut.parsing.TCN;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import static com.baseband.client.BaseBand.LOGGER;
public class ConfigHandle implements SetCommand { public class ConfigHandle implements SetCommand {
final String name; final String name;
@ -65,7 +66,7 @@ public class ConfigHandle implements SetCommand {
try { try {
updated(setting); updated(setting);
} catch(Exception e) { } catch(Exception e) {
GlobalUtil.LOGGER.info((Object) "Unable to setWithString", e); LOGGER.info((Object) "Unable to setWithString", e);
// reset // reset
tcn.set(setting, original); tcn.set(setting, original);
updated(setting); updated(setting);

View file

@ -1,13 +1,23 @@
package com.baseband.client.registry; package com.baseband.client.registry;
import com.baseband.client.BaseBand;
import com.baseband.client.Setup; import com.baseband.client.Setup;
import com.baseband.client.event.Event;
import com.baseband.client.event.remote.RemoteEvent;
import com.baseband.client.feature.Feature;
import com.baseband.client.util.adapt.FieldFinder;
import de.tudbut.parsing.TCN;
import de.tudbut.tools.Registry; import de.tudbut.tools.Registry;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import static com.baseband.client.feature.Features.features;
public class Configuration { public class Configuration {
public final Registry registry = new Registry(Setup.get().RegistryFilename); public static final ArrayList<Updater> updaters = new ArrayList<>();
final Registry registry = new Registry(Setup.get().RegistryFilename);
private Configuration() throws IOException { private Configuration() throws IOException {
} }
@ -34,4 +44,47 @@ public class Configuration {
public static void save() { public static void save() {
INSTANCE.registry.save(); INSTANCE.registry.save();
} }
public static Updater registerUpdater(Updater updater) {
updaters.add(updater);
updater.populate();
return updater;
}
public static <T extends Event> T publish(T event) {
if(event instanceof RemoteEvent)
BaseBand.remoteEventManager.publish((RemoteEvent) event);
else
BaseBand.eventManager.publish(event);
return event;
}
public static void cloneConfigFrom(TCN fullDB) {
boolean[] wasEnabled = new boolean[features.length];
for (int i = 0; i < features.length; i++) {
Feature feature = features[i];
wasEnabled[i] = feature.enabled;
for (ConfigHandle handle : feature.ownedHandles.values()) {
handle.cloneFrom(fullDB.getSub(handle.getName()));
}
}
for (Updater updater : updaters) {
updater.populate();
}
for (int i = 0; i < features.length; i++) {
if(features[i].enabled != wasEnabled[i]) {
features[i].enabled = wasEnabled[i];
features[i].toggle();
}
}
PlayerDB.Data.cloneFrom(fullDB.getSub("PlayerData"));
}
public static TCN asTCN() {
try {
return (TCN) FieldFinder.findUnmarked(Registry.class, TCN.class, 0).get(INSTANCE.registry);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
} }

View file

@ -1,7 +1,6 @@
package com.baseband.client.util.adapt; package com.baseband.client.util.adapt;
import com.baseband.client.Setup; import com.baseband.client.Setup;
import com.baseband.client.util.misc.GlobalUtil;
import de.tudbut.tools.ReflectUtil; import de.tudbut.tools.ReflectUtil;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -31,6 +30,8 @@ import java.util.Map;
import java.util.Random; import java.util.Random;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import static com.baseband.client.BaseBand.LOGGER;
public class WorldRecreationGenerator implements IChunkProvider { public class WorldRecreationGenerator implements IChunkProvider {
public final World world; public final World world;
@ -138,7 +139,7 @@ public class WorldRecreationGenerator implements IChunkProvider {
public synchronized boolean tick() { public synchronized boolean tick() {
if(hasNewChunks) { if(hasNewChunks) {
GlobalUtil.LOGGER.debug(this + ": Creating variations for {} MultiChunks.", realLoaded.size()); LOGGER.debug(this + ": Creating variations for {} MultiChunks.", realLoaded.size());
int variations = 0; int variations = 0;
for (Map.Entry<ChunkPos, MultiChunk> entry : realLoaded.entrySet()) { for (Map.Entry<ChunkPos, MultiChunk> entry : realLoaded.entrySet()) {
entry.getValue().makeVariations(); entry.getValue().makeVariations();
@ -146,12 +147,12 @@ public class WorldRecreationGenerator implements IChunkProvider {
for (Map.Entry<ChunkPos, MultiChunk> entry : realLoaded.entrySet()) { for (Map.Entry<ChunkPos, MultiChunk> entry : realLoaded.entrySet()) {
variations += entry.getValue().backVariations.size(); variations += entry.getValue().backVariations.size();
} }
GlobalUtil.LOGGER.debug(this + ": Checking {} variations.", variations); LOGGER.debug(this + ": Checking {} variations.", variations);
for (Map.Entry<ChunkPos, MultiChunk> entry : realLoaded.entrySet()) { for (Map.Entry<ChunkPos, MultiChunk> entry : realLoaded.entrySet()) {
ChunkPos pos = entry.getKey(); ChunkPos pos = entry.getKey();
entry.getValue().findPreferred(mc.world.getChunk(pos.x, pos.z)); entry.getValue().findPreferred(mc.world.getChunk(pos.x, pos.z));
} }
GlobalUtil.LOGGER.debug(this + ": Done."); LOGGER.debug(this + ": Done.");
hasNewChunks = false; hasNewChunks = false;
} }
@ -173,7 +174,7 @@ public class WorldRecreationGenerator implements IChunkProvider {
} }
private void onUnload(ChunkPos pos, Chunk chunk) { private void onUnload(ChunkPos pos, Chunk chunk) {
GlobalUtil.LOGGER.debug(this + " is unloading chunk at {} {}", pos.x, pos.z); LOGGER.debug(this + " is unloading chunk at {} {}", pos.x, pos.z);
chunk.onUnload(); chunk.onUnload();
loaded.remove(pos); loaded.remove(pos);
realLoaded.remove(pos); realLoaded.remove(pos);
@ -244,7 +245,7 @@ public class WorldRecreationGenerator implements IChunkProvider {
public MultiChunk(Chunk initial, WorldRecreationGenerator generator) { public MultiChunk(Chunk initial, WorldRecreationGenerator generator) {
pos = initial.getPos(); pos = initial.getPos();
GlobalUtil.LOGGER.debug(this + ": MultiChunk at {} {} created.", pos.x, pos.z); LOGGER.debug(this + ": MultiChunk at {} {} created.", pos.x, pos.z);
this.generator = generator; this.generator = generator;
map = new ChunkPos[] { map = new ChunkPos[] {
new ChunkPos(pos.x + 0, pos.z - 1), new ChunkPos(pos.x + 0, pos.z - 1),
@ -397,7 +398,7 @@ public class WorldRecreationGenerator implements IChunkProvider {
variations = backVariations; variations = backVariations;
backVariations = new ArrayList<>(); backVariations = new ArrayList<>();
} }
GlobalUtil.LOGGER.debug(generator + ": preferred state of chunk {} {} is now {}", pos.x, pos.z, preferredState); LOGGER.debug(generator + ": preferred state of chunk {} {} is now {}", pos.x, pos.z, preferredState);
} }
} }

View file

@ -7,10 +7,10 @@ import baritone.api.process.IBaritoneProcess;
import baritone.api.process.ICustomGoalProcess; import baritone.api.process.ICustomGoalProcess;
import baritone.api.process.PathingCommand; import baritone.api.process.PathingCommand;
import baritone.api.process.PathingCommandType; import baritone.api.process.PathingCommandType;
import com.baseband.client.BaseBand;
import com.baseband.client.Setup; import com.baseband.client.Setup;
import com.baseband.client.event.events.BaritoneEvent; import com.baseband.client.event.events.BaritoneEvent;
import com.baseband.client.util.interact.ChatUtil; import com.baseband.client.registry.Configuration;
import com.baseband.client.util.interact.Chat;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
public class BaritoneManager { public class BaritoneManager {
@ -18,7 +18,7 @@ public class BaritoneManager {
static { static {
//FUTURE! //FUTURE!
BaritoneAPI.getProvider().getPrimaryBaritone().getPathingControlManager().registerProcess(new PauseBaritoneProcess()); BaritoneAPI.getProvider().getPrimaryBaritone().getPathingControlManager().registerProcess(new PauseBaritoneProcess());
BaritoneAPI.getSettings().logger.value = ChatUtil::print; BaritoneAPI.getSettings().logger.value = Chat::print;
} }
public static IBaritone getBaritone() { public static IBaritone getBaritone() {
@ -55,7 +55,7 @@ public class BaritoneManager {
@Override @Override
public boolean isActive() { public boolean isActive() {
BaritoneEvent event = new BaritoneEvent(); BaritoneEvent event = new BaritoneEvent();
BaseBand.publish(event); Configuration.publish(event);
return event.isCancelled(); return event.isCancelled();
} }

View file

@ -1,7 +1,7 @@
package com.baseband.client.util.baritone; package com.baseband.client.util.baritone;
import com.baseband.client.util.misc.GlobalUtil;
import static com.baseband.client.BaseBand.LOGGER;
public class BaritonePresenceManager { public class BaritonePresenceManager {
@ -20,12 +20,12 @@ public class BaritonePresenceManager {
} }
if (IS_BARITONE_PRESENT) { if (IS_BARITONE_PRESENT) {
GlobalUtil.LOGGER.info("Baritone is present!"); LOGGER.info("Baritone is present!");
try { try {
BaritoneManager.getBaritone(); BaritoneManager.getBaritone();
} catch (Throwable e) { } catch (Throwable e) {
GlobalUtil.LOGGER.warn("Baritone is allegedly present but cannot seem to load!"); LOGGER.warn("Baritone is allegedly present but cannot seem to load!");
IS_BARITONE_PRESENT = false; IS_BARITONE_PRESENT = false;
} }
} }

View file

@ -1,6 +1,9 @@
package com.baseband.client.util.interact; package com.baseband.client.util.interact;
import com.baseband.client.Setup; import com.baseband.client.Setup;
import com.baseband.client.feature.Features;
import com.baseband.client.feature.client.Client;
import com.baseband.client.feature.render.HUD;
import com.mojang.realmsclient.gui.ChatFormatting; import com.mojang.realmsclient.gui.ChatFormatting;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiChat; import net.minecraft.client.gui.GuiChat;
@ -11,7 +14,9 @@ import net.minecraft.util.text.TextFormatting;
import java.util.Random; import java.util.Random;
public class ChatUtil { import static com.baseband.client.BaseBand.LOGGER;
public class Chat {
//forge sucks balls so hard omg //forge sucks balls so hard omg
public static void print(String s) { public static void print(String s) {
if(Minecraft.getMinecraft().player != null) { if(Minecraft.getMinecraft().player != null) {
@ -63,4 +68,22 @@ public class ChatUtil {
Minecraft.getMinecraft().player.sendChatMessage(msg); Minecraft.getMinecraft().player.sendChatMessage(msg);
} }
public static void notify(String text) {
Client c = Features.getFeature(Client.class);
if(Features.isFeatureEnabled(HUD.class) && c.notificationDest != Client.NotificationDest.Chat) {
HUD.notifs.add(new HUD.Notification(text));
if(c.notificationDest == Client.NotificationDest.Both)
print(text);
else
LOGGER.info(text);
} else
print(text);
}
public static void notifyAll(String text) {
if(Features.isFeatureEnabled(HUD.class)) {
HUD.notifs.add(new HUD.Notification(text));
}
print(text);
}
} }

View file

@ -1,6 +1,6 @@
package com.baseband.client.util.interact; package com.baseband.client.util.interact;
import com.baseband.client.BaseBand; import com.baseband.client.feature.Features;
import com.baseband.client.feature.render.Freecam; import com.baseband.client.feature.render.Freecam;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityOtherPlayerMP; import net.minecraft.client.entity.EntityOtherPlayerMP;
@ -49,7 +49,7 @@ public class FreecamPlayer extends EntityOtherPlayerMP
public void onLivingUpdate() public void onLivingUpdate()
{ {
if(mc.world == null) { if(mc.world == null) {
BaseBand.getFeature(Freecam.class).setEnabled(false); Features.getFeature(Freecam.class).setEnabled(false);
return; return;
} }
mc.renderChunksMany = false; mc.renderChunksMany = false;

View file

@ -1,20 +0,0 @@
package com.baseband.client.util.misc;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.lang.reflect.Method;
import java.security.SecureRandom;
public class GlobalUtil {
public static final Logger LOGGER = LogManager.getLogger("BaseBand");
public static final SecureRandom RANDOM = new SecureRandom();
public static final Runnable SHUTDOWN = () -> {
try {
Class<?> shutdownClass = Class.forName("java.lang.Shutdown");
Method exitMethod = shutdownClass.getDeclaredMethod("exit", int.class);
exitMethod.setAccessible(true);
exitMethod.invoke(null, 0);
} catch (Exception ignored) {}
};
}

View file

@ -1,6 +1,6 @@
package com.baseband.client.util.net; package com.baseband.client.util.net;
import com.baseband.client.BaseBand; import com.baseband.client.util.interact.Chat;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -38,7 +38,7 @@ public class ScreenshotHelper extends Thread {
private static void copyAndPrint(StringSelection stringSelection, String string) { private static void copyAndPrint(StringSelection stringSelection, String string) {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, stringSelection); clipboard.setContents(stringSelection, stringSelection);
BaseBand.notify("Image uploaded to: " + string); Chat.notify("Image uploaded to: " + string);
} }
@Override @Override

View file

@ -1,11 +1,13 @@
package com.baseband.client.util.net; package com.baseband.client.util.net;
import com.baseband.client.util.misc.GlobalUtil; import com.baseband.client.BaseBand;
import de.tudbut.net.ws.Client; import de.tudbut.net.ws.Client;
import de.tudbut.net.ws.ConnectionHandler; import de.tudbut.net.ws.ConnectionHandler;
import java.io.IOException; import java.io.IOException;
import static com.baseband.client.BaseBand.LOGGER;
public class WebServiceClient { public class WebServiceClient {
@SuppressWarnings("FieldCanBeLocal") // not finished yet @SuppressWarnings("FieldCanBeLocal") // not finished yet
private static Client client; private static Client client;
@ -15,8 +17,8 @@ public class WebServiceClient {
client = new Client("azidoazideazi.de", 30000); client = new Client("azidoazideazi.de", 30000);
//client.addReceiveHook(READER); //client.addReceiveHook(READER);
} catch (IOException e) { } catch (IOException e) {
GlobalUtil.LOGGER.fatal(e); LOGGER.fatal(e);
GlobalUtil.SHUTDOWN.run(); BaseBand.shutdown();
} }
} }