add experimental features
All checks were successful
/ Build BaseBand DSM & Broadway (push) Successful in 2m31s
/ Build BaseBand Loader (push) Successful in 1m41s

This commit is contained in:
Daniella / Tove 2024-06-25 19:31:29 +02:00
parent 87f01f596f
commit e5376425ea
Signed by: TudbuT
GPG key ID: B3CF345217F202D3
10 changed files with 88 additions and 5 deletions

View file

@ -33,6 +33,7 @@ public class DevStub implements IFMLLoadingPlugin {
LoadHandler.data.set("release-branch", false); LoadHandler.data.set("release-branch", false);
LoadHandler.data.set("branch", "[dev]"); LoadHandler.data.set("branch", "[dev]");
LoadHandler.data.set("username", "root"); LoadHandler.data.set("username", "root");
LoadHandler.data.set("load-experimental", true);
LoadHandler.data.set("disabled-modules", new TCNArray()); LoadHandler.data.set("disabled-modules", new TCNArray());
TCNArray array = new TCNArray(); TCNArray array = new TCNArray();
LoadHandler.data.set("do-not-join", array); LoadHandler.data.set("do-not-join", array);

View file

@ -7,6 +7,8 @@ import de.com.baseband.client.feature.modules.chat.*;
import de.com.baseband.client.feature.modules.client.*; import de.com.baseband.client.feature.modules.client.*;
import de.com.baseband.client.feature.modules.combat.AutoKill; import de.com.baseband.client.feature.modules.combat.AutoKill;
import de.com.baseband.client.feature.modules.combat.AutoTotem; import de.com.baseband.client.feature.modules.combat.AutoTotem;
import de.com.baseband.client.feature.modules.experimental.NoParticles;
import de.com.baseband.client.feature.modules.experimental.PlayerSelector;
import de.com.baseband.client.feature.modules.movement.*; import de.com.baseband.client.feature.modules.movement.*;
import de.com.baseband.client.feature.modules.ingame.AutoRespawn; import de.com.baseband.client.feature.modules.ingame.AutoRespawn;
import de.com.baseband.client.feature.modules.ingame.InteractionTweaks; import de.com.baseband.client.feature.modules.ingame.InteractionTweaks;
@ -65,10 +67,12 @@ public class Setup {
new MidClick(), new MidClick(),
new Nametags(), new Nametags(),
new NoFall(), new NoFall(),
new NoParticles(),
new NoRender(), new NoRender(),
new NoSlowDown(), new NoSlowDown(),
new Notifier(), new Notifier(),
new Ping(), new Ping(),
new PlayerSelector(),
new RenderFun(), new RenderFun(),
new Say(), new Say(),
new SeedOverlay(), new SeedOverlay(),

View file

@ -17,6 +17,7 @@ public enum Category {
RENDER("Render", Render.class), RENDER("Render", Render.class),
INGAME("World & Interactions", Ingame.class), INGAME("World & Interactions", Ingame.class),
CLIENT("Client", ClientCategory.class), CLIENT("Client", ClientCategory.class),
EXPERIMENTAL("Experimental", Experimental.class),
COMMAND("Commands", Command.class, false), COMMAND("Commands", Command.class, false),
BACKGROUND("Background", Background.class, false), BACKGROUND("Background", Background.class, false),
; ;

View file

@ -55,6 +55,11 @@ public abstract class Feature extends ToggleButton implements SetCommand {
required.addAll(Arrays.asList(requiredAnnotation.value())); required.addAll(Arrays.asList(requiredAnnotation.value()));
} }
final void preInit() {
category = Category.fromCategory(getClass());
enabled = defaultEnable();
}
// feature methods // feature methods
protected boolean defaultEnable() { protected boolean defaultEnable() {
@ -110,9 +115,6 @@ public abstract class Feature extends ToggleButton implements SetCommand {
public final void register(Minecraft mc) { public final void register(Minecraft mc) {
this.mc = mc; this.mc = mc;
category = Category.fromCategory(getClass());
enabled = defaultEnable();
this.text = toString(); this.text = toString();
subComponents.clear(); subComponents.clear();
@ -324,7 +326,7 @@ public abstract class Feature extends ToggleButton implements SetCommand {
protected boolean tryEnable() { protected boolean tryEnable() {
for (Class<? extends Feature> feature : required) { for (Class<? extends Feature> feature : required) {
if(!Features.isFeatureEnabled(feature)) { if(!Features.isFeatureEnabled(feature)) {
BaseBand.notify("§c" + this + " cannot work without " + feature + "."); BaseBand.notify("§c" + this + " cannot work without " + Features.getFeature(feature) + ".");
return false; return false;
} }
} }
@ -342,6 +344,8 @@ public abstract class Feature extends ToggleButton implements SetCommand {
public boolean canExist() { public boolean canExist() {
if(LoadHandler.data.getArray("disabled-modules").contains(toString())) if(LoadHandler.data.getArray("disabled-modules").contains(toString()))
return false; return false;
if(category == Category.EXPERIMENTAL && LoadHandler.data.getBoolean("load-experimental") != Boolean.TRUE)
return false;
for (Class<? extends Feature> feature : required) { for (Class<? extends Feature> feature : required) {
if(!Features.willFeatureExist(feature)) { if(!Features.willFeatureExist(feature)) {
return false; return false;

View file

@ -15,7 +15,8 @@ public class Features {
ArrayList<Feature> filteredFeatures = new ArrayList<>(Arrays.asList(Setup.get().Features)); ArrayList<Feature> filteredFeatures = new ArrayList<>(Arrays.asList(Setup.get().Features));
for (int i = 0; i < filteredFeatures.size(); i++) { for (int i = 0; i < filteredFeatures.size(); i++) {
Feature value = filteredFeatures.get(i); Feature value = filteredFeatures.get(i);
value.Setup = de.com.baseband.client.Setup.get(); value.Setup = Setup.get();
value.preInit();
try { try {
if (!value.canExist()) { if (!value.canExist()) {
filteredFeatures.remove(i--); filteredFeatures.remove(i--);

View file

@ -0,0 +1,11 @@
package de.com.baseband.client.feature.category;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface Experimental {
}

View file

@ -0,0 +1,21 @@
package de.com.baseband.client.feature.modules.experimental;
import de.com.baseband.client.event.events.PacketEvent;
import de.com.baseband.client.feature.Feature;
import de.com.baseband.client.feature.category.Experimental;
import net.minecraft.network.play.server.SPacketParticles;
@Experimental
public class NoParticles extends Feature {
public void onPacket(PacketEvent.Receive event) {
if(event.getPacket() instanceof SPacketParticles) {
event.setCancelled(true);
}
}
@Override
public String toString() {
return "TBM:NoParticles";
}
}

View file

@ -0,0 +1,16 @@
package de.com.baseband.client.feature.modules.experimental;
import de.com.baseband.client.feature.Feature;
import de.com.baseband.client.feature.category.Experimental;
import de.com.baseband.client.feature.modules.render.HUD;
import de.com.baseband.client.registry.annotation.Requires;
@Experimental
@Requires(HUD.class)
public class PlayerSelector extends Feature {
@Override
public String toString() {
return "PlayerSelector";
}
}

View file

@ -158,6 +158,12 @@ public class Loader implements Util {
.option("Configure BaseBand", x -> { .option("Configure BaseBand", x -> {
x.data.setIfAbsent("disabled-modules", new TCNArray()); x.data.setIfAbsent("disabled-modules", new TCNArray());
x.newScreen() x.newScreen()
.option(ClientBootUtil.toggleLabel(x.data.getBoolean("load-experimental") == Boolean.TRUE, "Experimental features"),
ClientBootUtil.toggle(
() -> x.data.getBoolean("load-experimental"),
"Experimental features",
() -> x.data.set("load-experimental", true),
() -> x.data.set("load-experimental", false)))
.option(ClientBootUtil.moduleToggleLabel(x, "Spotify"), ClientBootUtil.moduleToggle("Spotify")) .option(ClientBootUtil.moduleToggleLabel(x, "Spotify"), ClientBootUtil.moduleToggle("Spotify"))
.option(ClientBootUtil.moduleToggleLabel(x, "Baritone"), ClientBootUtil.moduleToggle("Baritone")) .option(ClientBootUtil.moduleToggleLabel(x, "Baritone"), ClientBootUtil.moduleToggle("Baritone"))
.option(ClientBootUtil.moduleToggleLabel(x, "AltControl"), ClientBootUtil.moduleToggle("AltControl")) .option(ClientBootUtil.moduleToggleLabel(x, "AltControl"), ClientBootUtil.moduleToggle("AltControl"))

View file

@ -4,8 +4,26 @@ import de.com.baseband.clientboot.CBCallback;
import de.com.baseband.clientboot.ClientBoot; import de.com.baseband.clientboot.ClientBoot;
import de.tudbut.parsing.TCNArray; import de.tudbut.parsing.TCNArray;
import java.util.function.Supplier;
public class ClientBootUtil { public class ClientBootUtil {
public static String toggleLabel(boolean cond, String name) {
return !cond ? "Enable " + name : "Disable " + name;
}
public static CBCallback toggle(Supplier<Boolean> condition, String name, Runnable enable, Runnable disable) {
return x -> {
if(condition.get() == Boolean.TRUE) {
x.currentOption().name = name + " disabled.";
disable.run();
} else {
x.currentOption().name = name + " enabled.";
enable.run();
}
};
}
public static CBCallback moduleToggle(String module) { public static CBCallback moduleToggle(String module) {
return x -> { return x -> {
TCNArray disabledModules = x.data.getArray("disabled-modules"); TCNArray disabledModules = x.data.getArray("disabled-modules");