Skip to content

Commit

Permalink
wowee!
Browse files Browse the repository at this point in the history
  • Loading branch information
AnAwesomGuy committed Oct 1, 2024
1 parent ed37bd7 commit 63aa7d8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,17 @@ public final class BreakingBedrock {

public static final float DESTROY_TIME;
public static final float EXPLOSION_RESIST;
public static final int MINING_TIER;

static {
LOGGER.info("Initializing Breaking Bedrock. This mod overwrites bedrock, and may break with other mods that do the same!");
Properties properties = new Properties();
float destroyTime, explosionResist;
int miningLevel;
File configFile = configDir().resolve(BreakingBedrock.MOD_ID + ".properties").toFile();
try {
Properties temp = new Properties();
temp.load(new FileInputStream(configFile));
String time = temp.getProperty("destroy_time"),
resist = temp.getProperty("explosion_resist"),
level = temp.getProperty("mining_level");
resist = temp.getProperty("explosion_resist");
if (time == null || !((destroyTime = Float.parseFloat(time)) > -1) || destroyTime == Float.POSITIVE_INFINITY) {
properties.setProperty("destroy_time", "100");
destroyTime = 100F;
Expand All @@ -41,37 +38,28 @@ public final class BreakingBedrock {
explosionResist = 3600000F;
LOGGER.debug("Correcting invalid config value {}!", resist);
} else properties.setProperty("explosion_resist", resist);
if (level == null || !((miningLevel = Integer.parseInt(level)) > 0)) {
properties.setProperty("mining_level", "4");
miningLevel = 4;
LOGGER.debug("Correcting invalid config value {}!", level);
} else properties.setProperty("mining_level", level);
} catch (IOException | IllegalArgumentException e) {
LOGGER.info("Couldn't read config file (likely corrupted or missing)! Attempting to (re)create it.");
properties.setProperty("destroy_time", "100");
properties.setProperty("explosion_resist", "3600000");
properties.setProperty("mining_level", "4");
destroyTime = 100F;
explosionResist = 3600000F;
miningLevel = 4;
}

EXPLOSION_RESIST = explosionResist;
DESTROY_TIME = destroyTime;
MINING_TIER = miningLevel;

try {
properties.store(new FileOutputStream(configFile),
"""
destroy_time: The destroy time for bedrock. (obsidian is 50, stone is 1.5, -1 is indestructible)
explosion_resist: The explosion resistance for bedrock. (stone is 6, glass is 0.3)
mining_level: The mining level required to mine bedrock. (netherite is 4)
""");
} catch (IOException e) {
LOGGER.error("Unable to create/modify config file!", e);
}

LOGGER.debug("Config initialized with values: destroyTime={}, explosionResist={}, miningLevel={}", destroyTime, explosionResist, miningLevel);
LOGGER.debug("Config initialized with values: destroyTime={}, explosionResist={}", destroyTime, explosionResist);
}

@ExpectPlatform
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ minecraft_version=1.21.1
enabled_platforms=fabric,neoforge

mod_id=breakingbedrock
mod_version=1.1.0
mod_version=1.1.1
maven_group=net.anawesomguy.breakingbedrock
description=Allow bedrock to be mined with a netherite pickaxe!
github=AnAwesomGuy/breakingbedrock
Expand All @@ -15,7 +15,7 @@ fabric_api_version=0.105.0+1.21.1

neoforge_version=21.1.63

changelog=port to 1.21!
changelog=this is kinda stupid ngl
curseforge_id=1017910
modrinth_id=s0tNTkDN

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"neoforge:conditions": [
{
"type": "neoforge:false"
}
],
"values": [
"bedrock"
]
Expand Down

0 comments on commit 63aa7d8

Please sign in to comment.