-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
880 additions
and
122 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
4 changes: 2 additions & 2 deletions
4
src/main/generated/.cache/cabcb80d088276cffde41e74584028f1c00b99b8
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,2 +1,2 @@ | ||
// 1.21.3 2024-11-14T20:23:33.392554 cookies-mod/Language (en_us) | ||
6b9d87aa8fb48ba3b4695f5acf5f091d2e8d2309 assets/cookies-mod/lang/en_us.json | ||
// 1.21.3 2024-11-16T10:39:51.468308 cookies-mod/Language (en_us) | ||
e62a557eb365acc40bf06ab25327f14f87a7fd60 assets/cookies-mod/lang/en_us.json |
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
26 changes: 26 additions & 0 deletions
26
src/main/java/codes/cookies/mod/config/categories/mining/ShaftConfig.java
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package codes.cookies.mod.config.categories.mining; | ||
|
||
import codes.cookies.mod.config.system.Foldable; | ||
import codes.cookies.mod.config.system.options.BooleanOption; | ||
import codes.cookies.mod.config.system.options.ColorOption; | ||
import codes.cookies.mod.translations.TranslationKeys; | ||
import codes.cookies.mod.utils.cookies.Constants; | ||
|
||
import java.awt.*; | ||
|
||
public class ShaftConfig extends Foldable { | ||
|
||
public BooleanOption enable = new BooleanOption(TranslationKeys.CONFIG_MINING_SHAFT_ENABLE, true); | ||
public BooleanOption text = new BooleanOption(TranslationKeys.CONFIG_MINING_SHAFT_TEXT, true).onlyIf(enable); | ||
public BooleanOption box = new BooleanOption(TranslationKeys.CONFIG_MINING_SHAFT_BOX, true).onlyIf(enable); | ||
public BooleanOption beam = new BooleanOption(TranslationKeys.CONFIG_MINING_SHAFT_BEAM, true).onlyIf(enable); | ||
public ColorOption color = new ColorOption( | ||
TranslationKeys.CONFIG_MINING_SHAFT_COLOR, | ||
new Color(Constants.MAIN_COLOR)) | ||
.withAlpha().onlyIf(enable); | ||
|
||
@Override | ||
public String getName() { | ||
return TranslationKeys.CONFIG_MINING_SHAFT; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/codes/cookies/mod/config/categories/mining/powder/PauseTime.java
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package codes.cookies.mod.config.categories.mining.powder; | ||
|
||
public enum PauseTime { | ||
|
||
TEN_SEC(10), THIRTY_SEC(30), ONE_MIN(60), TWO_MIN(120), FIVE_MIN(300), TEN_MIN(600); | ||
|
||
private final int timeInSec; | ||
|
||
PauseTime(int timeInSec) { | ||
this.timeInSec = timeInSec; | ||
} | ||
|
||
public long getTimeInMilliseconds() { | ||
return timeInSec * 1000L; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...main/java/codes/cookies/mod/config/categories/mining/powder/PowderTrackerHudFoldable.java
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package codes.cookies.mod.config.categories.mining.powder; | ||
|
||
import codes.cookies.mod.config.categories.mining.MiningConfig; | ||
import codes.cookies.mod.config.system.Foldable; | ||
import codes.cookies.mod.config.system.HudSetting; | ||
import codes.cookies.mod.config.system.options.BooleanOption; | ||
import codes.cookies.mod.config.system.options.EnumCycleOption; | ||
import codes.cookies.mod.features.mining.PowderHud; | ||
|
||
public class PowderTrackerHudFoldable extends Foldable { | ||
|
||
public static PowderTrackerHudFoldable getConfig() { | ||
return MiningConfig.getInstance().powderTrackerHud; | ||
} | ||
|
||
@HudSetting(PowderHud.class) | ||
public BooleanOption enableHud = new BooleanOption(CONFIG_MINING_POWDER_TRACKER_ENABLED, true); | ||
public BooleanOption showMs = new BooleanOption(CONFIG_MINING_POWDER_TRACKER_SHOW_MS, false); | ||
@HudSetting(PowderHud.class) | ||
public BooleanOption pauseTimer = new BooleanOption(CONFIG_MINING_POWDER_TRACKER_PAUSE, true); | ||
@HudSetting(PowderHud.class) | ||
public EnumCycleOption<PauseTime> pauseAfter = new EnumCycleOption<>(CONFIG_MINING_POWDER_TRACKER_PAUSE_VALUE, PauseTime.TEN_SEC); | ||
@HudSetting(PowderHud.class) | ||
public BooleanOption showExtraData = new BooleanOption(CONFIG_MINING_POWDER_TRACKER_EXTRA_DATA, true); | ||
@HudSetting(PowderHud.class) | ||
public EnumCycleOption<ShaftTrackingType> trackingType = new EnumCycleOption<>(CONFIG_MINING_POWDER_TRACKER_SHAFT_TRACKING, ShaftTrackingType.ENTER); | ||
@HudSetting(PowderHud.class) | ||
public EnumCycleOption<TimeoutTime> timeoutTime = new EnumCycleOption<>(CONFIG_MINING_POWDER_TRACKER_TIMEOUT, TimeoutTime.TEN_MIN); | ||
|
||
{ | ||
// registering here because order of registration equals call order | ||
pauseAfter.onlyIf(pauseTimer).onlyIf(enableHud); | ||
trackingType.onlyIf(showExtraData).onlyIf(enableHud); | ||
|
||
pauseTimer.onlyIf(enableHud); | ||
timeoutTime.onlyIf(enableHud); | ||
showExtraData.onlyIf(enableHud); | ||
} | ||
public long getTimeoutTime() { | ||
return Math.max(pauseAfter.getValue().getTimeInMilliseconds(), timeoutTime.getValue().getTimeInMilliseconds()); | ||
} | ||
|
||
public long getPauseTime() { | ||
return pauseAfter.getValue().getTimeInMilliseconds(); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return CONFIG_MINING_POWDER_TRACKER; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/codes/cookies/mod/config/categories/mining/powder/ShaftTrackingType.java
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package codes.cookies.mod.config.categories.mining.powder; | ||
|
||
public enum ShaftTrackingType { | ||
|
||
ENTER, FIND | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/codes/cookies/mod/config/categories/mining/powder/TimeoutTime.java
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package codes.cookies.mod.config.categories.mining.powder; | ||
|
||
public enum TimeoutTime { | ||
|
||
ONE_MIN(1), TWO_MINE(2), FIVE_MIN(5), TEN_MIN(10), TWENTY_MIN(20); | ||
|
||
private final int timeInMinutes; | ||
|
||
TimeoutTime(int timeInMinutes) { | ||
this.timeInMinutes = timeInMinutes; | ||
} | ||
|
||
public long getTimeInMilliseconds() { | ||
return timeInMinutes * 60 * 1000L; | ||
} | ||
|
||
} |
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
67 changes: 67 additions & 0 deletions
67
src/main/java/codes/cookies/mod/data/mining/PowderData.java
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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package codes.cookies.mod.data.mining; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import codes.cookies.mod.events.mining.PowderUpdateEvent; | ||
import codes.cookies.mod.utils.json.CodecJsonSerializable; | ||
import com.mojang.serialization.Codec; | ||
import org.slf4j.Logger; | ||
|
||
public class PowderData implements CodecJsonSerializable<Map<PowderType, Integer>> { | ||
|
||
public static final Codec<Map<PowderType, Integer>> CODEC = Codec.unboundedMap(PowderType.CODEC, Codec.INT); | ||
private final Map<PowderType, Integer> trackedPowder = new HashMap<>(); | ||
|
||
public void update(PowderType powderType, int amount) { | ||
if (trackedPowder.containsKey(powderType)) { | ||
final int old = this.remove(powderType); | ||
int delta = amount - old; | ||
trackedPowder.put(powderType, amount); | ||
this.broadcastUpdate(powderType, amount, delta); | ||
return; | ||
} | ||
|
||
this.trackedPowder.put(powderType, amount); | ||
this.broadcastUpdate(powderType, amount, 0); | ||
} | ||
|
||
private void broadcastUpdate(PowderType powderType, int amount, int delta) { | ||
if (delta == 0) { | ||
return; | ||
} | ||
PowderUpdateEvent.EVENT.invoker().update(powderType, amount, delta); | ||
} | ||
|
||
private int remove(PowderType powderType) { | ||
final Integer remove = trackedPowder.remove(powderType); | ||
if (remove == null) { | ||
return 0; | ||
} | ||
return remove; | ||
} | ||
|
||
@Override | ||
public Codec<Map<PowderType, Integer>> getCodec() { | ||
return CODEC; | ||
} | ||
|
||
@Override | ||
public void load(Map<PowderType, Integer> value) { | ||
trackedPowder.putAll(value); | ||
} | ||
|
||
@Override | ||
public Map<PowderType, Integer> getValue() { | ||
return trackedPowder; | ||
} | ||
|
||
@Override | ||
public Logger getLogger() { | ||
return logger; | ||
} | ||
|
||
public void reset() { | ||
this.trackedPowder.clear(); | ||
} | ||
} |
Oops, something went wrong.