Added temperature modifiers for the time and a few player states
This commit is contained in:
parent
1e997725a5
commit
1b5217d370
4 changed files with 66 additions and 19 deletions
|
@ -2,7 +2,9 @@ package tan.core;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import tan.api.temperature.TemperatureRegistry;
|
import tan.api.temperature.TemperatureRegistry;
|
||||||
|
import tan.temperaturemodifiers.TemperaturePlayerStateModifier;
|
||||||
import tan.temperaturemodifiers.TemperatureSourceModifier;
|
import tan.temperaturemodifiers.TemperatureSourceModifier;
|
||||||
|
import tan.temperaturemodifiers.TemperatureTimeModifier;
|
||||||
|
|
||||||
public class TANTemperature
|
public class TANTemperature
|
||||||
{
|
{
|
||||||
|
@ -15,6 +17,8 @@ public class TANTemperature
|
||||||
private static void registerTemperatureModifiers()
|
private static void registerTemperatureModifiers()
|
||||||
{
|
{
|
||||||
TemperatureRegistry.registerTemperatureModifier(new TemperatureSourceModifier());
|
TemperatureRegistry.registerTemperatureModifier(new TemperatureSourceModifier());
|
||||||
|
TemperatureRegistry.registerTemperatureModifier(new TemperatureTimeModifier());
|
||||||
|
TemperatureRegistry.registerTemperatureModifier(new TemperaturePlayerStateModifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerTemperatureSources()
|
private static void registerTemperatureSources()
|
||||||
|
|
|
@ -62,6 +62,10 @@ public class TemperatureStat extends TANStat
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.println("Aimed Temp " + aimedTemperature);
|
||||||
|
System.out.println("Rain/Speed " + temperatureRainfall[1]);
|
||||||
|
System.out.println("Current Temp " + temperature);
|
||||||
|
|
||||||
if (temperature != originalTemperature)
|
if (temperature != originalTemperature)
|
||||||
{
|
{
|
||||||
|
@ -93,7 +97,10 @@ public class TemperatureStat extends TANStat
|
||||||
|
|
||||||
averageAimedEnvironmentTemperature += ((biome.temperature / 2) * 20) + 27;
|
averageAimedEnvironmentTemperature += ((biome.temperature / 2) * 20) + 27;
|
||||||
|
|
||||||
rainfall = (biome.rainfall / 2) / 10;
|
if (biome.rainfall != 0F)
|
||||||
|
{
|
||||||
|
rainfall = biome.rainfall / 2;
|
||||||
|
}
|
||||||
|
|
||||||
environmentDivider++;
|
environmentDivider++;
|
||||||
}
|
}
|
||||||
|
@ -106,24 +113,6 @@ public class TemperatureStat extends TANStat
|
||||||
return temperatureRainfall;
|
return temperatureRainfall;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDay()
|
|
||||||
{
|
|
||||||
float celestialAngle = world.getCelestialAngle(0.0F);
|
|
||||||
|
|
||||||
if (celestialAngle >= 0.75F && celestialAngle <= 1.0F || celestialAngle >= 0.0F && celestialAngle <= 0.25F) return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isNight()
|
|
||||||
{
|
|
||||||
float celestialAngle = world.getCelestialAngle(0.0F);
|
|
||||||
|
|
||||||
if (celestialAngle >= 0.25F && celestialAngle <= 0.75F) return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDefaults()
|
public void setDefaults()
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package tan.temperaturemodifiers;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import tan.api.temperature.ITemperatureModifier;
|
||||||
|
|
||||||
|
public class TemperaturePlayerStateModifier implements ITemperatureModifier
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public float modifyTemperature(World world, EntityPlayerMP player)
|
||||||
|
{
|
||||||
|
float modifier = 0F;
|
||||||
|
|
||||||
|
if (player.isSprinting()) modifier += 2.25F;
|
||||||
|
if (player.isWet()) modifier -= 2.5F;
|
||||||
|
if (player.isBurning()) modifier += 4F;
|
||||||
|
|
||||||
|
return modifier;
|
||||||
|
}
|
||||||
|
}
|
34
common/tan/temperaturemodifiers/TemperatureTimeModifier.java
Normal file
34
common/tan/temperaturemodifiers/TemperatureTimeModifier.java
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
package tan.temperaturemodifiers;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import tan.api.temperature.ITemperatureModifier;
|
||||||
|
|
||||||
|
public class TemperatureTimeModifier implements ITemperatureModifier
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public float modifyTemperature(World world, EntityPlayerMP player)
|
||||||
|
{
|
||||||
|
if (isNight(world)) return -2F;
|
||||||
|
|
||||||
|
return 0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDay(World world)
|
||||||
|
{
|
||||||
|
float celestialAngle = world.getCelestialAngle(0.0F);
|
||||||
|
|
||||||
|
if (celestialAngle >= 0.75F && celestialAngle <= 1.0F || celestialAngle >= 0.0F && celestialAngle <= 0.25F) return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNight(World world)
|
||||||
|
{
|
||||||
|
float celestialAngle = world.getCelestialAngle(0.0F);
|
||||||
|
|
||||||
|
if (celestialAngle >= 0.25F && celestialAngle <= 0.75F) return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue