Search in sources :

Example 1 with DimensionEffectData

use of org.blockartistry.mod.DynSurround.data.DimensionEffectData in project BetterRain by OreCruncher.

the class WorldHandler method updateWeatherBody.

public static void updateWeatherBody(final World world) {
    if (world.isRemote)
        return;
    final int dimensionId = world.provider.getDimensionId();
    final DimensionEffectData data = DimensionEffectDataFile.get(world);
    final WorldInfo info = world.getWorldInfo();
    // Interesting bit added to 1.8.9
    int i = info.getCleanWeatherTime();
    if (i > 0) {
        --i;
        info.setCleanWeatherTime(i);
        info.setThunderTime(info.isThundering() ? 1 : 2);
        info.setRainTime(info.isRaining() ? 1 : 2);
    }
    i = info.getThunderTime();
    if (i <= 0) {
        info.setThunderTime(nextThunderInterval(info.isThundering()));
    } else {
        --i;
        info.setThunderTime(i);
        if (i <= 0) {
            info.setThundering(!info.isThundering());
        }
    }
    world.prevThunderingStrength = world.thunderingStrength;
    world.thunderingStrength += info.isThundering() ? STRENGTH_ADJUST : -STRENGTH_ADJUST;
    world.thunderingStrength = MathHelper.clamp_float(world.thunderingStrength, 0.0F, 1.0F);
    int j = info.getRainTime();
    if (j <= 0) {
        info.setRainTime(nextRainInterval(info.isRaining()));
    } else {
        --j;
        info.setRainTime(j);
        if (j <= 0) {
            info.setRaining(!info.isRaining());
        }
    }
    if (info.isRaining() && data.getRainIntensity() == 0.0F) {
        data.randomizeRain();
        ModLog.debug(String.format("dim %d rain strength set to %f", dimensionId, data.getRainIntensity()));
    }
    world.prevRainingStrength = world.rainingStrength;
    if (info.isRaining()) {
        if (world.rainingStrength > data.getRainIntensity()) {
            world.rainingStrength -= STRENGTH_ADJUST;
            if (world.rainingStrength < 0.0F)
                world.rainingStrength = 0.0F;
        } else if (world.rainingStrength < data.getRainIntensity()) {
            world.rainingStrength += STRENGTH_ADJUST;
            if (world.rainingStrength > data.getRainIntensity())
                world.rainingStrength = data.getRainIntensity();
        }
    } else if (world.rainingStrength > 0.0F) {
        world.rainingStrength -= STRENGTH_ADJUST;
        if (world.rainingStrength < 0.0F)
            world.rainingStrength = 0.0F;
    } else if (data.getRainIntensity() > 0.0F) {
        data.setRainIntensity(0.0F);
        ModLog.debug(String.format("dim %d rain has stopped", dimensionId));
    }
}
Also used : DimensionEffectData(org.blockartistry.mod.DynSurround.data.DimensionEffectData) WorldInfo(net.minecraft.world.storage.WorldInfo)

Example 2 with DimensionEffectData

use of org.blockartistry.mod.DynSurround.data.DimensionEffectData in project BetterRain by OreCruncher.

the class CommandRain method processCommand.

@Override
public void processCommand(final ICommandSender sender, final String[] parms) {
    try {
        final EntityPlayerMP player = getCommandSenderAsPlayer(sender);
        final World world = player.worldObj;
        final DimensionEffectData data = DimensionEffectData.get(world);
        if (parms.length == 1) {
            if ("status".compareToIgnoreCase(parms[0]) == 0) {
                // Dump out some diagnostics for the currentAurora dimension
                player.addChatMessage(new ChatComponentText(statusOutput(world, data)));
            } else if ("reset".compareToIgnoreCase(parms[0]) == 0) {
                world.provider.resetRainAndThunder();
                player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("msg.RainReset")));
            } else if ("reload".compareToIgnoreCase(parms[0]) == 0) {
                BiomeRegistry.initialize();
                BlockRegistry.initialize();
                player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("msg.BiomeReload")));
            } else {
                final double d = parseDouble(parms[0], 0.0D, 100.0D) / 100.0D;
                data.setRainIntensity((float) d);
                player.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("msg.RainIntensitySet", FORMATTER.format(data.getRainIntensity() * 100))));
            }
        } else if (parms.length == 2) {
            if ("setmin".compareToIgnoreCase(parms[0]) == 0) {
                final double d = parseDouble(parms[1], 0.0D, 100.0D) / 100.0D;
                data.setMinRainIntensity((float) d);
                player.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("msg.MinRainIntensitySet", FORMATTER.format(data.getMinRainIntensity() * 100))));
            } else if ("setmax".compareToIgnoreCase(parms[0]) == 0) {
                final double d = parseDouble(parms[1], 0.0D, 100.0D) / 100.0D;
                data.setMaxRainIntensity((float) d);
                player.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("msg.MaxRainIntensitySet", FORMATTER.format(data.getMaxRainIntensity() * 100))));
            } else {
                throw new CommandException(getCommandUsage(sender));
            }
        } else {
            player.addChatMessage(new ChatComponentText(getCommandUsage(sender)));
        }
    } catch (final Exception ex) {
        ex.printStackTrace();
    }
}
Also used : DimensionEffectData(org.blockartistry.mod.DynSurround.data.DimensionEffectData) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) CommandException(net.minecraft.command.CommandException) World(net.minecraft.world.World) ChatComponentText(net.minecraft.util.ChatComponentText) CommandException(net.minecraft.command.CommandException)

Aggregations

DimensionEffectData (org.blockartistry.mod.DynSurround.data.DimensionEffectData)2 CommandException (net.minecraft.command.CommandException)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 ChatComponentText (net.minecraft.util.ChatComponentText)1 World (net.minecraft.world.World)1 WorldInfo (net.minecraft.world.storage.WorldInfo)1