forked from ChomeNS/chipmunkmod
Add core gui module (breaks current configs!!!)
This commit is contained in:
parent
9260fb46b2
commit
98ec1f7741
5 changed files with 94 additions and 9 deletions
|
@ -12,7 +12,6 @@ import java.util.HashMap;
|
||||||
|
|
||||||
public class Configuration {
|
public class Configuration {
|
||||||
public CommandManager commands = new CommandManager();
|
public CommandManager commands = new CommandManager();
|
||||||
public CommandCore core = new CommandCore();
|
|
||||||
public Bots bots = new Bots();
|
public Bots bots = new Bots();
|
||||||
public CustomChat customChat = new CustomChat();
|
public CustomChat customChat = new CustomChat();
|
||||||
public AntiSpam antiSpam = new AntiSpam();
|
public AntiSpam antiSpam = new AntiSpam();
|
||||||
|
@ -26,10 +25,6 @@ public class Configuration {
|
||||||
public String prefix = ".";
|
public String prefix = ".";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class CommandCore {
|
|
||||||
public SimpleBlockArea relativeArea = new SimpleBlockArea(new SimpleBlockPos(0, 0, 0), new SimpleBlockPos(15, 0, 15));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Bots {
|
public static class Bots {
|
||||||
public BotInfo hbot = new BotInfo("#", null);
|
public BotInfo hbot = new BotInfo("#", null);
|
||||||
public BotInfo sbot = new BotInfo(":", null);
|
public BotInfo sbot = new BotInfo(":", null);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||||
import land.chipmunk.chipmunkmod.data.BlockArea;
|
import land.chipmunk.chipmunkmod.data.BlockArea;
|
||||||
import land.chipmunk.chipmunkmod.listeners.Listener;
|
import land.chipmunk.chipmunkmod.listeners.Listener;
|
||||||
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
||||||
|
import land.chipmunk.chipmunkmod.testclient.modules.other.CommandCoreModule;
|
||||||
import land.chipmunk.chipmunkmod.util.MathUtilities;
|
import land.chipmunk.chipmunkmod.util.MathUtilities;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.CommandBlock;
|
import net.minecraft.block.CommandBlock;
|
||||||
|
@ -50,6 +51,7 @@ public class CommandCore {
|
||||||
|
|
||||||
final TimerTask task = new TimerTask() {
|
final TimerTask task = new TimerTask() {
|
||||||
public void run () {
|
public void run () {
|
||||||
|
if(!CommandCoreModule.INSTANCE.isEnabled) return;
|
||||||
tick();
|
tick();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -57,6 +59,7 @@ public class CommandCore {
|
||||||
final TimerTask refillTask = new TimerTask() {
|
final TimerTask refillTask = new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if(!CommandCoreModule.INSTANCE.isEnabled) return;
|
||||||
if (clientPlayerEntityFilled) {
|
if (clientPlayerEntityFilled) {
|
||||||
clientPlayerEntityFilled = false;
|
clientPlayerEntityFilled = false;
|
||||||
return;
|
return;
|
||||||
|
@ -94,7 +97,10 @@ public class CommandCore {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadRelativeArea () {
|
public void reloadRelativeArea () {
|
||||||
noPos = ChipmunkMod.CONFIG.core.relativeArea.toBlockArea();
|
noPos = new BlockArea(new BlockPos(0, 0, 0),
|
||||||
|
new BlockPos(CommandCoreModule.INSTANCE.coreSizeX.optionValue-1,
|
||||||
|
CommandCoreModule.INSTANCE.coreSizeY.optionValue-1,
|
||||||
|
CommandCoreModule.INSTANCE.coreSizeZ.optionValue-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void check () {
|
public void check () {
|
||||||
|
@ -217,12 +223,12 @@ public class CommandCore {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run (String command) {
|
public void run (String command) {
|
||||||
|
// should probably throw an illegalstateexception but i dont feel like handling it everywhere
|
||||||
|
if(!CommandCoreModule.INSTANCE.isEnabled) return;
|
||||||
final ClientConnection connection = client.getNetworkHandler().getConnection();
|
final ClientConnection connection = client.getNetworkHandler().getConnection();
|
||||||
|
|
||||||
if (block == null) return;
|
if (block == null) return;
|
||||||
|
|
||||||
System.out.println(command);
|
|
||||||
|
|
||||||
if (KaboomCheck.INSTANCE.isKaboom) {
|
if (KaboomCheck.INSTANCE.isKaboom) {
|
||||||
connection.send(
|
connection.send(
|
||||||
new UpdateCommandBlockC2SPacket(
|
new UpdateCommandBlockC2SPacket(
|
||||||
|
@ -262,6 +268,7 @@ public class CommandCore {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<NbtCompound> runTracked (String command) {
|
public CompletableFuture<NbtCompound> runTracked (String command) {
|
||||||
|
if(!CommandCoreModule.INSTANCE.isEnabled) return CompletableFuture.failedFuture(new IllegalStateException("The core is disabled!"));
|
||||||
final ClientConnection connection = client.getNetworkHandler().getConnection();
|
final ClientConnection connection = client.getNetworkHandler().getConnection();
|
||||||
|
|
||||||
if (block == null) return new CompletableFuture<>();
|
if (block == null) return new CompletableFuture<>();
|
||||||
|
|
|
@ -10,6 +10,7 @@ import land.chipmunk.chipmunkmod.testclient.modules.lag_prevention.AntiParticleK
|
||||||
import land.chipmunk.chipmunkmod.testclient.modules.lag_prevention.AntiTextObfuscationLagModule;
|
import land.chipmunk.chipmunkmod.testclient.modules.lag_prevention.AntiTextObfuscationLagModule;
|
||||||
import land.chipmunk.chipmunkmod.testclient.modules.lag_prevention.BlockGuardianParticlesModule;
|
import land.chipmunk.chipmunkmod.testclient.modules.lag_prevention.BlockGuardianParticlesModule;
|
||||||
import land.chipmunk.chipmunkmod.testclient.modules.anti_annoyances.AntiTeleportModule;
|
import land.chipmunk.chipmunkmod.testclient.modules.anti_annoyances.AntiTeleportModule;
|
||||||
|
import land.chipmunk.chipmunkmod.testclient.modules.other.CommandCoreModule;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.client.gui.Drawable;
|
import net.minecraft.client.gui.Drawable;
|
||||||
|
@ -175,6 +176,9 @@ Gui extends Screen{
|
||||||
.withModule(RainbowNameModule.INSTANCE)
|
.withModule(RainbowNameModule.INSTANCE)
|
||||||
.withModule(CustomChatModule.INSTANCE)
|
.withModule(CustomChatModule.INSTANCE)
|
||||||
.register();
|
.register();
|
||||||
|
new Category("Other")
|
||||||
|
.withModule(CommandCoreModule.INSTANCE)
|
||||||
|
.register();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
package land.chipmunk.chipmunkmod.testclient.gui.components.options;
|
||||||
|
|
||||||
|
import land.chipmunk.chipmunkmod.testclient.gui.components.Option;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
public class IntTextFieldOption extends Option<Integer> {
|
||||||
|
TextFieldWidget textFieldWidget = new TextFieldWidget(MinecraftClient.getInstance().textRenderer, 200, 20, Text.empty());
|
||||||
|
|
||||||
|
public IntTextFieldOption(String name, Integer defaultValue) {
|
||||||
|
super(name, defaultValue);
|
||||||
|
textFieldWidget.setText(defaultValue.toString());
|
||||||
|
textFieldWidget.setChangedListener(text -> {
|
||||||
|
try {
|
||||||
|
IntTextFieldOption.this.optionValue = Integer.valueOf(text);
|
||||||
|
} catch(NumberFormatException ignored) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.widget = textFieldWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntTextFieldOption(String name, Integer defaultValue, Consumer<Integer> onChanged) {
|
||||||
|
super(name, defaultValue);
|
||||||
|
textFieldWidget.setText(defaultValue.toString());
|
||||||
|
textFieldWidget.setChangedListener(text -> {
|
||||||
|
try {
|
||||||
|
int i = Integer.parseInt(text);
|
||||||
|
IntTextFieldOption.this.optionValue = i;
|
||||||
|
onChanged.accept(i);
|
||||||
|
} catch(NumberFormatException ignored) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.widget = textFieldWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setValueFromString(String string) {
|
||||||
|
setOptionValue(Integer.valueOf(string));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getValueAsString() {
|
||||||
|
return optionValue.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setOptionValue(Integer optionValue) {
|
||||||
|
this.optionValue = optionValue;
|
||||||
|
textFieldWidget.setText(optionValue.toString());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package land.chipmunk.chipmunkmod.testclient.modules.other;
|
||||||
|
|
||||||
|
import land.chipmunk.chipmunkmod.modules.CommandCore;
|
||||||
|
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
|
||||||
|
import land.chipmunk.chipmunkmod.testclient.gui.components.options.IntTextFieldOption;
|
||||||
|
|
||||||
|
public class CommandCoreModule extends Module {
|
||||||
|
public static final CommandCoreModule INSTANCE = new CommandCoreModule();
|
||||||
|
public IntTextFieldOption coreSizeX = new IntTextFieldOption("Core size X", 16, ignored -> {
|
||||||
|
CommandCore.INSTANCE.reloadRelativeArea();
|
||||||
|
});
|
||||||
|
public IntTextFieldOption coreSizeY = new IntTextFieldOption("Core size X", 1, ignored -> {
|
||||||
|
CommandCore.INSTANCE.reloadRelativeArea();
|
||||||
|
});
|
||||||
|
public IntTextFieldOption coreSizeZ = new IntTextFieldOption("Core size X", 16, ignored -> {
|
||||||
|
CommandCore.INSTANCE.reloadRelativeArea();
|
||||||
|
});
|
||||||
|
|
||||||
|
public CommandCoreModule() {
|
||||||
|
super("Core");
|
||||||
|
withOption(coreSizeX);
|
||||||
|
withOption(coreSizeY);
|
||||||
|
withOption(coreSizeZ);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue