Sign in to follow this  
joedobo

[ABANDONED] Let anyone use season_override

Recommended Posts

This is abandoned. Use this instead: 

 

 

 

 

This mod lets you use the season_override setting to force a certain season for your client. This is not a server mod, it only changes what graphics single client uses. All I basically did was remove some code logic that only allowed entities with developer or higher permission to use this setting.

 

 

 

 

...PlayerFiles\configs\default\gamesettings.txt

 

 

in this file is "season_override=". This can be 5 different numbers and they mean: 0 override off (normal cycling), 1 is always Winter, 2 is always Spring, 3 is alway Summer, 4 is always fall.

 

 

 

 

 

To make this work:

 

 

1. You can not be running the WU client during the changes. The launcher/server selection window is part of WU. An instance of the dedicated server should be okay as it's a different program.

 

 

2. Make a copy of client.jar. You want a backup of the original unmodified client.jar.

 

 

3. get this modified version of SeasonManager.class...https://dl.dropboxusercontent.com/u/27144902/SeasonManager.7z

 

 

4. open the client.jar in something like 7-zip.  Mine is at: C:\Program Files (x86)\Steam\SteamApps\common\Wurm Unlimited\WurmLauncher

 

 

5. Now, in the client.jar navigate to the game folder -> com\wurmonline\client\game\

 

 

6. Open the SeasonManager.7z and client.jar should still be open in another window.

 

 

7. Select all the classes from SeasonManager.7z.

 

 

8 Drag and drop the selected files from SeasonManager into the game folder of client.jar.

 

 

9. say yes to the replace/override message.

 

 

10. close everything and your done. You don't need to save anything.

 

 

11. go into gamesettings.txt and set the "season_override=".

 

 

 

 

 

Here is the code. I just removed the "isdev()" code from the update method. I had to fill in some spots because the decompiler didn't like the switch tables and the last method.

 

 


 

 


//

// Source code recreated from a .class file by IntelliJ IDEA

// (powered by Fernflower decompiler)

//


package com.wurmonline.client.game;


import com.wurmonline.client.game.World;

import com.wurmonline.client.options.Options;

import com.wurmonline.client.renderer.terrain.weather.Weather;

import java.util.Random;


public final class SeasonManager {

    private static final int DAY = 86400;

    private static final int YEAR = 29030400;

    private final World world;

    private float averageTemperature = 9.0F;

    private float dayNightDeltaT = 12.0F;

    private float summerWinterDeltaT = 24.0F;

    private float currentTemperature;

    private SeasonManager.Season currentSeason;

    private SeasonManager.SeasonProperties seasonProperties;

    private float elevation;


    public SeasonManager(World aWorld) {

        this.currentSeason = SeasonManager.Season.SUMMER;

        this.seasonProperties = (new SeasonManager.SeasonProperties.Builder()).build();

        this.elevation = 0.0F;

        this.world = aWorld;

    }


    public void initialize(long time, float playerHeight) {

        Random random = new Random();

        random.setSeed(time / 29030400L);

        this.averageTemperature += random.nextFloat() - 0.5F;

        this.summerWinterDeltaT += random.nextFloat() - 0.5F;

        this.updateAvgTemperature(time);

        this.playerMoved(playerHeight);

        this.update(time, true);

    }


    public void tick(long time) {

        this.updateAvgTemperature(time);

        this.updateWeather();

        this.update(time, false);

    }


    private void updateAvgTemperature(long time) {

        this.currentTemperature = this.getDayNightCycleTemp(time) + this.getYearCycleTemp(time);

    }


    public void playerMoved(float playerElevation) {

        this.elevation = playerElevation;

        this.updateWeather();

    }


    private void updateWeather() {

        Weather.getInstance().setTemperature(this.getTemperature(this.elevation));

    }


    private void update(long time, boolean changeSeason) {

        if(Options.seasonOverride.value() > 0) {

            this.currentSeason = SeasonManager.Season.values()[Options.seasonOverride.value() - 1];

            this.seasonProperties = this.buildSeasonProperties(this.currentSeason, 20.0F, 0.0F);

        } else if(this.world.getServerName() != null && this.world.getServerName().equals("Golden Valley")) {

            this.currentSeason = SeasonManager.Season.SUMMER;

            this.seasonProperties = this.buildSeasonProperties(this.currentSeason, 20.0F, 0.0F);

        } else {

            SeasonManager.Season oldSeason = this.currentSeason;

            float yearCycleTemp = this.getYearCycleTemp(time);

            float dT = yearCycleTemp - this.getYearCycleTemp(time - 86400L);

            if(changeSeason) {

                this.currentSeason = this.selectSeason(yearCycleTemp, dT);

            }


            this.seasonProperties = this.buildSeasonProperties(this.currentSeason, yearCycleTemp, dT);

        }

    }


    private SeasonManager.Season selectSeason(float yearCycleTemp, float dT) {

        SeasonManager.Season newSeason;

        if(yearCycleTemp > 10.0F) {

            newSeason = SeasonManager.Season.SUMMER;

        } else if(yearCycleTemp < -2.0F) {

            newSeason = SeasonManager.Season.WINTER;

        } else if(dT > 0.0F) {

            newSeason = SeasonManager.Season.SPRING;

        } else {

            newSeason = SeasonManager.Season.FALL;

        }


        return newSeason;

    }


    private SeasonManager.SeasonProperties buildSeasonProperties(SeasonManager.Season season, float temp, float dT) {

        SeasonManager.SeasonProperties.Builder builder = new SeasonManager.SeasonProperties.Builder();

        switch(season) {

            case WINTER:

                builder.leafRate(0.1F).flowerRate(0.0F).birdRate(0.2F).grassScale(0.75F);

                break;

            case SPRING:

                builder.insectRate(1.0F).flowerRate(1.0F).birdRate(1.0F).grassScale(0.6F);

                break;

            case SUMMER:

                float fireflyRate = 0.0F;

                if(temp > 18.0F && temp < 22.0F && dT < 0.0F) {

                    fireflyRate = 1.0F - Math.abs(temp - 20.0F) / 2.0F;

                }


                builder.insectRate(0.6F).fireflyRate(fireflyRate).leafRate(0.2F).flowerRate(0.3F).birdRate(0.8F).grassScale(0.8F);

                break;

            case FALL:

                builder.insectRate(0.2F).leafRate(1.0F).flowerRate(0.1F).birdRate(0.7F).grassScale(1.0F);

        }


        return builder.build();

    }


    private float getDayNightCycleTemp(long wurmtime) {

        float hour = (float)wurmtime % 86400.0F / 3600.0F;

        float dayFraction = (hour - 3.5F) / 24.0F;

        float amplitude = this.dayNightDeltaT * 0.5F * (1.0F - 0.3F * Weather.getInstance().getCloudiness());

        return amplitude * (float)(-Math.cos(6.283185307179586D * (double)dayFraction));

    }


    private float getYearCycleTemp(long wurmtime) {

        float yearFraction = (float)wurmtime % 2.90304E7F / 2.90304E7F;

        return this.averageTemperature + this.summerWinterDeltaT * 0.5F * (float)(-Math.cos(6.283185307179586D * (double)yearFraction));

    }


    private float getTemperature(float height) {

        return this.currentTemperature - 0.0064999997F * height;

    }


    public String getSeasonAppendix() {

        return this.currentSeason.getMapping();

    }


    public SeasonManager.Season getSeason() {

        return this.currentSeason;

    }


    public SeasonManager.SeasonProperties getSeasonProperties() {

        return this.seasonProperties;

    }


    public static enum Season {

        WINTER(".winter"),

        SPRING(".spring"),

        SUMMER(".summer"),

        FALL(".fall");


        private final String mapping;


        private Season(String mapping) {

            this.mapping = mapping;

        }


        public String getMapping() {

            return this.mapping;

        }

    }


    public static final class SeasonProperties {

        private final float insectRate;

        private final float leafRate;

        private final float flowerRate;

        private final float birdRate;

        private final float grassScale;

        private final float fireflyRate;


        private SeasonProperties(SeasonManager.SeasonProperties.Builder builder) {

            this.insectRate = builder.insectRate;

            this.fireflyRate = builder.fireflyRate;

            this.leafRate = builder.leafRate;

            this.flowerRate = builder.flowerRate;

            this.birdRate = builder.birdRate;

            this.grassScale = builder.grassScale;

        }


        public float getInsectRate() {

            return this.insectRate;

        }


        public float getFireflyRate() {

            return this.fireflyRate;

        }


        public float getLeafRate() {

            return this.leafRate;

        }


        public float getFlowerRate() {

            return this.flowerRate;

        }


        public float getBirdRate() {

            return this.birdRate;

        }


        public float getGrassScale() {

            return this.grassScale;

        }


        public static final class Builder {

            private float insectRate = 0.0F;

            private float fireflyRate = 0.0F;

            private float leafRate = 0.0F;

            private float flowerRate = 0.0F;

            private float birdRate = 0.0F;

            private float grassScale = 0.0F;


            public Builder() {

            }


            public SeasonManager.SeasonProperties.Builder insectRate(float rate) {

                this.insectRate = rate;

                return this;

            }


            public SeasonManager.SeasonProperties.Builder fireflyRate(float rate) {

                this.fireflyRate = rate;

                return this;

            }


            public SeasonManager.SeasonProperties.Builder leafRate(float rate) {

                this.leafRate = rate;

                return this;

            }


            public SeasonManager.SeasonProperties.Builder flowerRate(float rate) {

                this.flowerRate = rate;

                return this;

            }


            public SeasonManager.SeasonProperties.Builder birdRate(float rate) {

                this.birdRate = rate;

                return this;

            }


            public SeasonManager.SeasonProperties.Builder grassScale(float s) {

                this.grassScale = s;

                return this;

            }


            public SeasonManager.SeasonProperties build() {

                return new SeasonManager.SeasonProperties(Builder.this);

            }

        }

    }

}

 

 

 

 

 

 

 

Wet me know if there are any issues or of folks have suggestion. I'm a total noob so I expect some criticism.

 

Edited by joedobo
  • Like 3

Share this post


Link to post
Share on other sites

I was hoping to be able to set my single player WU world to "always summer" so it is good to read that there is this way to do it. This procedure does seem a bit complicated to me though, so hopefully more comments will be made that can perhaps simplify it some. Good work on figuring this out anyway.


 


=Ayes=


Share this post


Link to post
Share on other sites

I was hoping to be able to set my single player WU world to "always summer" so it is good to read that there is this way to do it. This procedure does seem a bit complicated to me though, so hopefully more comments will be made that can perhaps simplify it some. Good work on figuring this out anyway.

 

=Ayes=

Share this post


Link to post
Share on other sites

Just tried it and it works great. 


 


I did find one bug. It seems that my quit button on the top is now 3 dots that don't do anything


Share this post


Link to post
Share on other sites

Since i cannot copy and paste from zipped archieves, i guess i have not only open, but unzip both, before i transfer the season-files to the client-files ?


Share this post


Link to post
Share on other sites

Since i cannot copy and paste from zipped archieves, i guess i have not only open, but unzip both, before i transfer the season-files to the client-files ?

select classes in one archive. Drag and drop them into the other archive. I fixed the instruction for this. Thank you for the information.

Share this post


Link to post
Share on other sites

I did as you stated now and when i try to drop the season-files into the game-file of the client-jar i get the message from 7zip: "not implemented".


 


What do i do wrong ?


Edited by Sizan

Share this post


Link to post
Share on other sites

It works fine for me and I have no idea what "not implemented" is. One thing is make sure you're not running WU. A dedicated server instance is okay. The launcher/server selection counts as the WU client.


Share this post


Link to post
Share on other sites

It works fine for me and I have no idea what "not implemented" is. One thing is make sure you're not running WU. A dedicated server instance is okay. The launcher/server selection counts as the WU client.

 

WU wasn't running, guess that was it then, thanks.

 

 

Isn't there a way to do all this without srewing around in zipped files ? Because that is the main problem, when i could just transfer files and overwrite others it would be not a problem.

Edited by Sizan

Share this post


Link to post
Share on other sites

Have another idea: can someone eventually send me his winter-client.jar attached to email ? Maybe this would work better then. Not sure if i can post my email here so if you send me a PM i will send it to you gladly.


Share this post


Link to post
Share on other sites

I LOVE this.  My old eyes thank you so much for getting rid of winter.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this