|
@@ -42,7 +42,6 @@ import java.io.FileInputStream;
|
|
import java.io.FileOutputStream;
|
|
import java.io.FileOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.text.DecimalFormat;
|
|
import java.text.DecimalFormat;
|
|
-import java.util.Map;
|
|
|
|
import java.util.Properties;
|
|
import java.util.Properties;
|
|
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
@OnlyIn(Dist.CLIENT)
|
|
@@ -58,10 +57,11 @@ public class LightOverlay {
|
|
private static final DecimalFormat FORMAT = new DecimalFormat("#.#");
|
|
private static final DecimalFormat FORMAT = new DecimalFormat("#.#");
|
|
private static KeyBinding enableOverlay, increaseReach, decreaseReach, increaseLineWidth, decreaseLineWidth;
|
|
private static KeyBinding enableOverlay, increaseReach, decreaseReach, increaseLineWidth, decreaseLineWidth;
|
|
private static boolean enabled = false;
|
|
private static boolean enabled = false;
|
|
- private static int reach = 12;
|
|
|
|
|
|
+ private static int reach = 7;
|
|
private static EntityType<Entity> testingEntityType;
|
|
private static EntityType<Entity> testingEntityType;
|
|
private static float lineWidth = 1.0F;
|
|
private static float lineWidth = 1.0F;
|
|
private static File configFile = new File(new File(Minecraft.getInstance().gameDir, "config"), "lightoverlay.properties");
|
|
private static File configFile = new File(new File(Minecraft.getInstance().gameDir, "config"), "lightoverlay.properties");
|
|
|
|
+ private static Color yellowColor = Color.yellow, redColor = Color.red;
|
|
|
|
|
|
public LightOverlay() {
|
|
public LightOverlay() {
|
|
// Load Config
|
|
// Load Config
|
|
@@ -190,7 +190,7 @@ public class LightOverlay {
|
|
CrossType type = LightOverlay.getCrossType(pos, world, playerEntity);
|
|
CrossType type = LightOverlay.getCrossType(pos, world, playerEntity);
|
|
if (type != CrossType.NONE) {
|
|
if (type != CrossType.NONE) {
|
|
VoxelShape shape = world.getBlockState(pos).getCollisionShape(world, pos);
|
|
VoxelShape shape = world.getBlockState(pos).getCollisionShape(world, pos);
|
|
- Color color = type == CrossType.RED ? Color.RED : Color.YELLOW;
|
|
|
|
|
|
+ Color color = type == CrossType.RED ? redColor : yellowColor;
|
|
LightOverlay.renderCross(world, pos, color, playerEntity);
|
|
LightOverlay.renderCross(world, pos, color, playerEntity);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -208,46 +208,64 @@ public class LightOverlay {
|
|
|
|
|
|
private void loadConfig(File file) {
|
|
private void loadConfig(File file) {
|
|
try {
|
|
try {
|
|
|
|
+ redColor = Color.red;
|
|
|
|
+ yellowColor = Color.yellow;
|
|
if (!file.exists() || !file.canRead())
|
|
if (!file.exists() || !file.canRead())
|
|
saveConfig(file);
|
|
saveConfig(file);
|
|
FileInputStream fis = new FileInputStream(file);
|
|
FileInputStream fis = new FileInputStream(file);
|
|
Properties properties = new Properties();
|
|
Properties properties = new Properties();
|
|
properties.load(fis);
|
|
properties.load(fis);
|
|
fis.close();
|
|
fis.close();
|
|
- for(Map.Entry<Object, Object> entry : properties.entrySet()) {
|
|
|
|
- if (entry.getKey() instanceof String && entry.getValue() instanceof String) {
|
|
|
|
- String key = (String) entry.getKey();
|
|
|
|
- String value = (String) entry.getValue();
|
|
|
|
- if (key.equals("reach")) {
|
|
|
|
- try {
|
|
|
|
- reach = Integer.valueOf(value);
|
|
|
|
- } catch (NumberFormatException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- reach = 12;
|
|
|
|
- }
|
|
|
|
- } else if (key.equals("lineWidth")) {
|
|
|
|
- try {
|
|
|
|
- lineWidth = Float.valueOf(value);
|
|
|
|
- } catch (NumberFormatException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- lineWidth = 1.0F;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ reach = Integer.parseInt((String) properties.computeIfAbsent("reach", a -> "7"));
|
|
|
|
+ lineWidth = Float.valueOf((String) properties.computeIfAbsent("lineWidth", a -> "1"));
|
|
|
|
+ {
|
|
|
|
+ int r, g, b;
|
|
|
|
+ r = Integer.parseInt((String) properties.computeIfAbsent("yellowColorRed", a -> "255"));
|
|
|
|
+ g = Integer.parseInt((String) properties.computeIfAbsent("yellowColorGreen", a -> "255"));
|
|
|
|
+ b = Integer.parseInt((String) properties.computeIfAbsent("yellowColorBlue", a -> "0"));
|
|
|
|
+ yellowColor = new Color(r, g, b);
|
|
|
|
+ }
|
|
|
|
+ {
|
|
|
|
+ int r, g, b;
|
|
|
|
+ r = Integer.parseInt((String) properties.computeIfAbsent("redColorRed", a -> "255"));
|
|
|
|
+ g = Integer.parseInt((String) properties.computeIfAbsent("redColorGreen", a -> "0"));
|
|
|
|
+ b = Integer.parseInt((String) properties.computeIfAbsent("redColorBlue", a -> "0"));
|
|
|
|
+ redColor = new Color(r, g, b);
|
|
}
|
|
}
|
|
saveConfig(file);
|
|
saveConfig(file);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
- reach = 12;
|
|
|
|
|
|
+ reach = 7;
|
|
lineWidth = 1.0F;
|
|
lineWidth = 1.0F;
|
|
|
|
+ redColor = Color.red;
|
|
|
|
+ yellowColor = Color.yellow;
|
|
|
|
+ try {
|
|
|
|
+ saveConfig(file);
|
|
|
|
+ } catch (IOException ex) {
|
|
|
|
+ ex.printStackTrace();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private void saveConfig(File file) throws IOException {
|
|
private void saveConfig(File file) throws IOException {
|
|
FileOutputStream fos = new FileOutputStream(file, false);
|
|
FileOutputStream fos = new FileOutputStream(file, false);
|
|
|
|
+ fos.write("# Light Overlay Config".getBytes());
|
|
|
|
+ fos.write("\n".getBytes());
|
|
fos.write(("reach=" + String.valueOf(reach)).getBytes());
|
|
fos.write(("reach=" + String.valueOf(reach)).getBytes());
|
|
fos.write("\n".getBytes());
|
|
fos.write("\n".getBytes());
|
|
fos.write(("lineWidth=" + FORMAT.format(lineWidth)).getBytes());
|
|
fos.write(("lineWidth=" + FORMAT.format(lineWidth)).getBytes());
|
|
|
|
+ fos.write("\n".getBytes());
|
|
|
|
+ fos.write(("yellowColorRed=" + String.valueOf(yellowColor.getRed())).getBytes());
|
|
|
|
+ fos.write("\n".getBytes());
|
|
|
|
+ fos.write(("yellowColorGreen=" + String.valueOf(yellowColor.getGreen())).getBytes());
|
|
|
|
+ fos.write("\n".getBytes());
|
|
|
|
+ fos.write(("yellowColorBlue=" + String.valueOf(yellowColor.getBlue())).getBytes());
|
|
|
|
+ fos.write("\n".getBytes());
|
|
|
|
+ fos.write(("redColorRed=" + String.valueOf(redColor.getRed())).getBytes());
|
|
|
|
+ fos.write("\n".getBytes());
|
|
|
|
+ fos.write(("redColorGreen=" + String.valueOf(redColor.getGreen())).getBytes());
|
|
|
|
+ fos.write("\n".getBytes());
|
|
|
|
+ fos.write(("redColorBlue=" + String.valueOf(redColor.getBlue())).getBytes());
|
|
fos.close();
|
|
fos.close();
|
|
}
|
|
}
|
|
|
|
|