-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
still issues with hex decoding
- Loading branch information
Showing
18 changed files
with
137 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,112 +1,69 @@ | ||
package com.goby56.wakes.config; | ||
|
||
import blue.endless.jankson.Jankson; | ||
import blue.endless.jankson.JsonObject; | ||
import blue.endless.jankson.api.SyntaxError; | ||
import com.goby56.wakes.WakesClient; | ||
import com.goby56.wakes.config.enums.EffectSpawningRule; | ||
import com.goby56.wakes.config.enums.Resolution; | ||
import com.goby56.wakes.render.enums.RenderType; | ||
import com.goby56.wakes.render.enums.WakeColor; | ||
import com.google.gson.Gson; | ||
import com.google.common.collect.Lists; | ||
import eu.midnightdust.lib.config.MidnightConfig; | ||
|
||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.util.*; | ||
|
||
public class WakesConfig { | ||
|
||
public ArrayList<Float> wakeGradientRanges = new ArrayList<>(List.of(0.1f, 0.3f, 0.6f, 0.8f)); | ||
public ArrayList<WakeColor> wakeColors = new ArrayList<>(List.of( | ||
new WakeColor(255, 0, 0, 255), | ||
new WakeColor(255, 0, 0, 255), | ||
new WakeColor(255, 0, 0, 255), | ||
new WakeColor(255, 0, 0, 255), | ||
new WakeColor(255, 0, 0, 255) | ||
)); | ||
|
||
// Spawning | ||
public Map<String, EffectSpawningRule> effectSpawningRules = new HashMap<>(Map.of( | ||
"boat", EffectSpawningRule.SIMULATION_AND_PLANES, | ||
"player", EffectSpawningRule.ONLY_SIMULATION, | ||
"other_players", EffectSpawningRule.ONLY_SIMULATION, | ||
"mobs", EffectSpawningRule.ONLY_SIMULATION, | ||
"items", EffectSpawningRule.ONLY_SIMULATION | ||
)); | ||
|
||
// Behaviour | ||
public float wavePropagationFactor = 0.95f; | ||
public float waveDecayFactor = 0.5f; | ||
public int initialStrength = 20; | ||
public int paddleStrength = 100; | ||
public int splashStrength = 100; | ||
public boolean spawnParticles = true; | ||
import java.util.List; | ||
|
||
public class WakesConfig extends MidnightConfig { | ||
public static final String GENERAL = "general"; | ||
public static final String APPEARANCE = "appearance"; | ||
public static final String DEBUG = "debug"; | ||
// Debug | ||
public boolean disableMod = false; | ||
public int floodFillDistance = 2; | ||
public int ticksBeforeFill = 2; | ||
public boolean pickBoat = true; | ||
public RenderType renderType = RenderType.AUTO; | ||
public boolean debugColors = false; | ||
public boolean drawDebugBoxes = false; | ||
public boolean showDebugInfo = false; | ||
public float shaderLightPassthrough = 0.5f; | ||
|
||
// Appearance | ||
public Resolution wakeResolution = Resolution.SIXTEEN; | ||
public float wakeOpacity = 1f; | ||
public boolean firstPersonSplashPlane = false; | ||
@Entry(category = GENERAL) public static boolean disableMod = false; // TODO SWITCH TO ENABLE MOD TOGGLE | ||
@Entry(category = GENERAL) public static boolean pickBoat = true; | ||
|
||
@Hidden() public static List<Float> wakeGradientRanges = Lists.newArrayList(0.1f, 0.4f, 0.6f, 0.8f); | ||
@Hidden() public static List<String> wakeColors = Lists.newArrayList( | ||
"#ffff00ff", | ||
"#ffff00ff", | ||
"#ffff00ff", | ||
"#ffff00ff", | ||
"#ffff00ff" | ||
); | ||
|
||
// Spawning | ||
@Entry(category = GENERAL) public static EffectSpawningRule boatSpawning = EffectSpawningRule.SIMULATION_AND_PLANES; | ||
@Entry(category = GENERAL) public static EffectSpawningRule playerSpawning = EffectSpawningRule.ONLY_SIMULATION; | ||
@Entry(category = GENERAL) public static EffectSpawningRule otherPlayersSpawning = EffectSpawningRule.ONLY_SIMULATION; | ||
@Entry(category = GENERAL) public static EffectSpawningRule mobSpawning = EffectSpawningRule.ONLY_SIMULATION; | ||
@Entry(category = GENERAL) public static EffectSpawningRule itemSpawning = EffectSpawningRule.ONLY_SIMULATION; | ||
|
||
// // Behaviour | ||
@Entry(category = GENERAL) public static float wavePropagationFactor = 0.95f; | ||
@Entry(category = GENERAL) public static float waveDecayFactor = 0.5f; | ||
@Entry(category = GENERAL) public static int initialStrength = 20; | ||
@Entry(category = GENERAL) public static int paddleStrength = 100; | ||
@Entry(category = GENERAL) public static int splashStrength = 100; | ||
@Entry(category = GENERAL) public static boolean spawnParticles = true; | ||
|
||
@Entry(category = APPEARANCE) public static Resolution wakeResolution = Resolution.SIXTEEN; | ||
@Entry(category = APPEARANCE) public static float wakeOpacity = 1f; | ||
@Entry(category = APPEARANCE) public static boolean firstPersonSplashPlane = false; | ||
|
||
// Splash plane | ||
public float splashPlaneWidth = 2f; | ||
public float splashPlaneHeight = 1.5f; | ||
public float splashPlaneDepth = 3f; | ||
public float splashPlaneOffset = -0.2f; | ||
public float splashPlaneGap = 1f; | ||
public int splashPlaneResolution = 5; | ||
public float maxSplashPlaneVelocity = 0.5f; | ||
public float splashPlaneScale = 0.8f; | ||
|
||
public static WakesConfig loadConfig() { | ||
Jankson jankson = Jankson.builder().build(); | ||
try { | ||
File configFile = new File(WakesClient.CONFIG_PATH); | ||
if (!configFile.exists()) { | ||
WakesClient.LOGGER.info(String.format("No config file found for wakes-%s. Creating one...", WakesClient.METADATA.getVersion().getFriendlyString())); | ||
WakesConfig config = new WakesConfig(); | ||
config.saveConfig(); | ||
return config; | ||
} | ||
|
||
JsonObject configJson = jankson.load(configFile); | ||
String normalized = configJson.toJson(false, false); | ||
|
||
// return jankson.fromJson(configJson, WakesConfig.class); | ||
return new Gson().fromJson(normalized, WakesConfig.class); | ||
} catch (IOException | SyntaxError e) { | ||
e.printStackTrace(); | ||
return new WakesConfig(); | ||
} | ||
} | ||
|
||
public void saveConfig() { | ||
File configFile = new File(WakesClient.CONFIG_PATH); | ||
Jankson jankson = Jankson.builder().build(); | ||
String result = jankson.toJson(this).toJson(true, true); | ||
|
||
try { | ||
boolean usable = configFile.exists() || configFile.createNewFile(); | ||
if (!usable) return; | ||
|
||
FileOutputStream out = new FileOutputStream(configFile, false); | ||
out.write(result.getBytes()); | ||
out.flush(); | ||
out.close(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
@Entry(category = APPEARANCE) public static float splashPlaneWidth = 2f; | ||
@Entry(category = APPEARANCE) public static float splashPlaneHeight = 1.5f; | ||
@Entry(category = APPEARANCE) public static float splashPlaneDepth = 3f; | ||
@Entry(category = APPEARANCE) public static float splashPlaneOffset = -0.2f; | ||
@Entry(category = APPEARANCE) public static float splashPlaneGap = 1f; | ||
@Entry(category = APPEARANCE) public static int splashPlaneResolution = 5; | ||
@Entry(category = APPEARANCE) public static float maxSplashPlaneVelocity = 0.5f; | ||
@Entry(category = APPEARANCE) public static float splashPlaneScale = 0.8f; | ||
|
||
@Entry(category = DEBUG) public static boolean debugColors = false; | ||
@Entry(category = DEBUG) public static int floodFillDistance = 2; | ||
@Entry(category = DEBUG) public static int ticksBeforeFill = 2; | ||
@Entry(category = DEBUG) public static RenderType renderType = RenderType.AUTO; | ||
@Entry(category = DEBUG) public static boolean drawDebugBoxes = false; | ||
@Entry(category = DEBUG) public static boolean showDebugInfo = false; | ||
@Entry(category = DEBUG) public static float shaderLightPassthrough = 0.5f; | ||
|
||
public static WakeColor getWakeColor(int i) { | ||
return new WakeColor(wakeColors.get(i)); | ||
} | ||
} |
53 changes: 0 additions & 53 deletions
53
src/main/java/com/goby56/wakes/config/WakesMidnightConfig.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.