mirror of
https://github.com/GTNewHorizons/MagicBees.git
synced 2026-11-19 03:49:13 +00:00
More things!
This commit is contained in:
1 parent
6ae6a8afc0
commit
bc596ee3a6
83 files changed
No files matched your search
@@ -0,0 +1,59 @@
|
||||
package magicbees.main.utils;
|
||||
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Class to abstract the moon phase from the world time a bit.
|
||||
*/
|
||||
public enum MoonPhase
|
||||
{
|
||||
FULL("full"),
|
||||
WANING_GIBBOUS("gibbousWaning"),
|
||||
WANING_HALF("halfWaning"),
|
||||
WANING_CRESCENT("crescentWaning"),
|
||||
NEW("new"),
|
||||
WAXING_CRESCENT("crecentWaxing"),
|
||||
WAXING_HALF("halfWaxing"),
|
||||
WAXING_GIBBOUS("gibbousWaxing");
|
||||
|
||||
private String phaseName;
|
||||
private MoonPhase(String name)
|
||||
{
|
||||
this.phaseName = name;
|
||||
}
|
||||
|
||||
public boolean isBetween(MoonPhase first, MoonPhase second)
|
||||
{
|
||||
boolean flag = false;
|
||||
|
||||
if (first.ordinal() <= second.ordinal())
|
||||
{
|
||||
// Straightforward.
|
||||
flag = first.ordinal() <= this.ordinal() && this.ordinal() <= second.ordinal();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Wraps around the boundary.
|
||||
flag = (first.ordinal() <= this.ordinal() && this.ordinal() <= WAXING_GIBBOUS.ordinal()) ||
|
||||
(FULL.ordinal() <= this.ordinal() && this.ordinal() <= second.ordinal());
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
public String getLocalizedName()
|
||||
{
|
||||
return LocalizationManager.getLocalizedString("tb.moon." + this.phaseName);
|
||||
}
|
||||
|
||||
public static MoonPhase getMoonPhase(World w)
|
||||
{
|
||||
return getMoonPhaseFromTime(w.getWorldTime());
|
||||
}
|
||||
|
||||
public static MoonPhase getMoonPhaseFromTime(long time)
|
||||
{
|
||||
return MoonPhase.values()[(int)((time - 6000) / 24000L) % 8];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user