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
1 parent
ebea275
commit b9fc05e
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
src/main/java/org/auioc/mcmod/arnicalib/game/world/position/SpeedUnit.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,33 @@ | ||
package org.auioc.mcmod.arnicalib.game.world.position; | ||
|
||
import org.auioc.mcmod.arnicalib.base.function.DoubleToDoubleFunction; | ||
|
||
public enum SpeedUnit { | ||
|
||
METRES_PER_TICK("metres per tick", "m/t", (v) -> v), // | ||
METRES_PER_SECOND("metres per second", "m/s", (v) -> v * 20.0D), // | ||
KILOMETRES_PER_HOUR("kilometres per hour", "km/h", (v) -> v * 72.0D); | ||
|
||
private final String name; | ||
private final String symbol; | ||
private final DoubleToDoubleFunction converter; | ||
|
||
private SpeedUnit(String name, String symbol, DoubleToDoubleFunction converter) { | ||
this.name = name; | ||
this.symbol = symbol; | ||
this.converter = converter; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getSymbol() { | ||
return symbol; | ||
} | ||
|
||
public double convertFrom(double metresPreTick) { | ||
return converter.applyAsDouble(metresPreTick); | ||
} | ||
|
||
} |