add config backups
All checks were successful
/ Build BaseBand DSM & Broadway (push) Successful in 2m13s

This commit is contained in:
Daniella / Tove 2024-06-18 19:16:16 +02:00
parent a9168696fb
commit 666d4fc03e
Signed by: TudbuT
GPG key ID: B3CF345217F202D3
4 changed files with 34 additions and 6 deletions

View file

@ -14,6 +14,8 @@ import de.com.baseband.client.registry.annotation.Trigger;
import de.com.baseband.client.util.interact.Chat; import de.com.baseband.client.util.interact.Chat;
import de.com.baseband.client.util.interact.RotationManager; import de.com.baseband.client.util.interact.RotationManager;
import de.com.baseband.client.util.interact.ServerDataManager; import de.com.baseband.client.util.interact.ServerDataManager;
import de.tudbut.io.StreamReader;
import de.tudbut.parsing.JSON;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.network.Packet; import net.minecraft.network.Packet;
import net.minecraft.network.play.server.SPacketPlayerPosLook; import net.minecraft.network.play.server.SPacketPlayerPosLook;
@ -22,6 +24,10 @@ import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
@ClientCategory @ClientCategory
public class Client extends Feature { public class Client extends Feature {
@ -60,6 +66,29 @@ public class Client extends Feature {
BaseBand.notify("Config saved to disk"); BaseBand.notify("Config saved to disk");
} }
@Trigger("Save backup")
public void saveBackup() {
try(FileOutputStream stream = new FileOutputStream("baseband.db.bak")) {
stream.write(JSON.writeReadable(Configuration.asTCN()).getBytes());
BaseBand.notify("§aCreated backup of config");
} catch (IOException e) {
e.printStackTrace();
BaseBand.notify("§cFailed to back up config");
}
}
@Trigger("Load backup")
public void loadBackup() {
try(FileInputStream stream = new FileInputStream("baseband.db.bak")) {
String s = new StreamReader(stream).readAllAsString();
Configuration.cloneConfigFrom(JSON.read(s));
BaseBand.notify("§aLoaded backup of config");
} catch (IOException | JSON.JSONFormatException e) {
e.printStackTrace();
BaseBand.notify("§cFailed to load backup of config");
}
}
public GuiTheme.ITheme getTheme() { public GuiTheme.ITheme getTheme() {
return theme; return theme;

View file

@ -57,7 +57,7 @@ public class ElytraFly extends Feature {
"With correct settings, this should only require a single normal-height jump at normal speed to take off.\n" + "With correct settings, this should only require a single normal-height jump at normal speed to take off.\n" +
"With okay ping, this can also take off in 1x2 tunnels.") "With okay ping, this can also take off in 1x2 tunnels.")
@Marker(1) @Marker(1)
public boolean autoTakeoff = false; public boolean autoTakeoff = true;
@Config("Post-Takeoff Motion") @Config("Post-Takeoff Motion")
@Description("Applies some amount of motion to the player after takeoff is complete, just in case the server resets the elytra again due to bad ping.\n" + @Description("Applies some amount of motion to the player after takeoff is complete, just in case the server resets the elytra again due to bad ping.\n" +
@ -71,7 +71,7 @@ public class ElytraFly extends Feature {
"and higher ones might be more forgiving to bad Gate settings.") "and higher ones might be more forgiving to bad Gate settings.")
@Range("1..40") @Range("1..40")
@Gate(1) @Gate(1)
public int takeoffTicks = 1; public int takeoffTicks = 5;
@Config("Takeoff Gate Mode") @Config("Takeoff Gate Mode")
@Description("Advanced: How the begin of a fall should be detected. Packet is almost always the better option and can't be misconfigured. Only try changing if something doesn't work.") @Description("Advanced: How the begin of a fall should be detected. Packet is almost always the better option and can't be misconfigured. Only try changing if something doesn't work.")

View file

@ -34,8 +34,8 @@ public class NoRender extends Feature {
@Config("ItemFrame") @Config("ItemFrame")
public boolean itemFrame; public boolean itemFrame;
@Config("NoPotionIcon") @Config("PotionIcon")
public boolean noPotion; public boolean potionIcon;
@SubscribeEvent @SubscribeEvent
@ -48,7 +48,7 @@ public class NoRender extends Feature {
@SubscribeEvent @SubscribeEvent
public void overlayGameRenderEvent(RenderGameOverlayEvent event) { public void overlayGameRenderEvent(RenderGameOverlayEvent event) {
if (noPotion && event.getType() == RenderGameOverlayEvent.ElementType.POTION_ICONS) if (potionIcon && event.getType() == RenderGameOverlayEvent.ElementType.POTION_ICONS)
event.setCanceled(true); event.setCanceled(true);
} }

View file

@ -12,7 +12,6 @@ public class BlockUtils {
Vec3i size = selection.size(); Vec3i size = selection.size();
int selSideLength = selection.longestSideH(); int selSideLength = selection.longestSideH();
int sectionSideLength = (selSideLength - 1) / amount + 1; // rounded up int sectionSideLength = (selSideLength - 1) / amount + 1; // rounded up
System.out.println(sectionSideLength);
Selection[] selections = new Selection[(int) ((selSideLength - 1) / sectionSideLength + 1)]; // rounded up Selection[] selections = new Selection[(int) ((selSideLength - 1) / sectionSideLength + 1)]; // rounded up
int xSideLength = 0; int xSideLength = 0;
int zSideLength = 0; int zSideLength = 0;