Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# eclipse
bin
*.launch
.settings
.metadata
.classpath
.project

# idea
out
*.ipr
*.iws
*.iml
.idea

# gradle
build
.gradle

# other
eclipse
run
63 changes: 63 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
buildscript {
repositories {
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
}
}

apply plugin: 'forge'

version = "2.3.20"
group= "weather2" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "weather2-1.7.10"

minecraft {
version = "1.7.10-10.13.0.1180"
assetDir = "eclipse/assets"
}

dependencies {
// you may put jars on which you depend on in ./libs
// or you may define them like so..
//compile "some.group:artifact:version:classifier"
//compile "some.group:artifact:version"

// real examples
//compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
//compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env

// for more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
compile files("../forge-1.7.10-CoroUtil/build/classes/main/")
}

processResources
{
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version

// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'

// replace version and mcversion
expand 'version':project.version, 'mcversion':project.minecraft.version
}

// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
9 changes: 8 additions & 1 deletion src/main/java/weather2/ClientTickHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;

import org.lwjgl.input.Mouse;
Expand Down Expand Up @@ -61,6 +62,8 @@ public void onRenderScreenTick()
}
}
}


}

public void onTickInGUI(GuiScreen guiscreen)
Expand Down Expand Up @@ -114,6 +117,7 @@ public void onTickInGame()
}
}
}

}

public static void checkClientWeather() {
Expand All @@ -122,7 +126,10 @@ public static void checkClientWeather() {
ClientTickHandler.init(FMLClientHandler.instance().getClient().theWorld);
}
} catch (Exception ex) {
Weather.dbg("Warning, Weather2 client received packet before it was ready to use, and failed to init client weather due to null world");
//always get output for this
System.out.println("Warning, Weather2 weatherManager init failed for some reason, printing stacktrace, report to https://github.com/Corosauce/weather2/issues");
ex.printStackTrace();
//Weather.dbg("Warning, Weather2 client received packet before it was ready to use, and failed to init client weather due to null world");
}
}

Expand Down
19 changes: 19 additions & 0 deletions src/main/java/weather2/EventHandlerFML.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package weather2;

import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import weather2.client.SceneEnhancer;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent;
import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.WorldTickEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class EventHandlerFML {

Expand All @@ -27,6 +33,9 @@ public void tickServer(ServerTickEvent event) {
if (event.phase == Phase.START) {
//System.out.println("tick weather2");
ServerTickHandler.onTickInGame();

/*System.out.println("total: " + DimensionManager.getWorld(0).getTotalWorldTime());
System.out.println("not: " + DimensionManager.getWorld(0).getWorldTime());*/
}

}
Expand All @@ -38,10 +47,20 @@ public void tickClient(ClientTickEvent event) {
}
}

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void tickRenderScreen(RenderTickEvent event) {
if (event.phase == Phase.END) {
ClientProxy.clientTickHandler.onRenderScreenTick();
} else if (event.phase == Phase.START) {
//fix for sky flicker with global overcast on and transitioning between vanilla weather states
Minecraft mc = Minecraft.getMinecraft();
if (mc != null && mc.thePlayer != null && mc.theWorld != null) {
EntityPlayer entP = mc.thePlayer;
float curRainStr = SceneEnhancer.getRainStrengthAndControlVisuals(entP, true);
curRainStr = Math.abs(curRainStr);
mc.theWorld.setRainStrength(curRainStr);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/weather2/Weather.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import cpw.mods.fml.common.network.NetworkRegistry;

//@NetworkMod(channels = { "WeatherData", "EZGuiData" }, clientSideRequired = true, serverSideRequired = true, packetHandler = WeatherPacketHandler.class)
@Mod(modid = "weather2", name="weather2", version="v2.3.10")
@Mod(modid = "weather2", name="weather2", version="v2.3.19")
public class Weather {

@Mod.Instance( value = "weather2" )
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/weather2/client/SceneEnhancer.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public synchronized void trySoundPlaying()
soundTimeLocations.put(cCor, System.currentTimeMillis() + 2500 + rand.nextInt(50));
//mc.getSoundHandler().playSound(Weather.modID + ":waterfall", cCor.posX, cCor.posY, cCor.posZ, (float)ConfigMisc.volWaterfallScale, 0.75F + (rand.nextFloat() * 0.05F));
mc.theWorld.playSound(cCor.posX, cCor.posY, cCor.posZ, Weather.modID + ":env.waterfall", (float)ConfigMisc.volWaterfallScale, 0.75F + (rand.nextFloat() * 0.05F), false);
System.out.println("play waterfall at: " + cCor.posX + " - " + cCor.posY + " - " + cCor.posZ);
//System.out.println("play waterfall at: " + cCor.posX + " - " + cCor.posY + " - " + cCor.posZ);
} else if (cCor.block == SOUNDMARKER_LEAVES) {


Expand Down Expand Up @@ -422,6 +422,8 @@ public static float getRainStrengthAndControlVisuals(EntityPlayer entP, boolean
StormObject storm = null;

ClientTickHandler.checkClientWeather();

if (ClientTickHandler.weatherManager == null) return 0;

storm = ClientTickHandler.weatherManager.getClosestStorm(plPos, maxStormDist, StormObject.STATE_FORMING, true);

Expand Down Expand Up @@ -636,12 +638,12 @@ public void profileSurroundings()
return;
}

if (threadLastWorldTickTime == worldRef.getWorldTime())
if (threadLastWorldTickTime == worldRef.getTotalWorldTime())
{
return;
}

threadLastWorldTickTime = worldRef.getWorldTime();
threadLastWorldTickTime = worldRef.getTotalWorldTime();

Random rand = new Random();

Expand Down
18 changes: 18 additions & 0 deletions src/main/java/weather2/config/ConfigMisc.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ public class ConfigMisc implements IConfigCategory {
public static int lockServerWeatherMode = 0; //is only used if overcastMode is off
public static boolean preventServerThunderstorms = true;

//Server tick rates
@ConfigComment("How often in ticks the clients should check the server's weather status")
public static int tickerRateSyncWeatherCheckVanilla = 400;
@ConfigComment("How often in ticks to sync low-wind storm data between server and clients. Might want to increase this for dedicated servers.")
public static int tickerRateSyncWeatherLowWind = 40;
@ConfigComment("How often in ticks to sync high-wind storm data between server and clients. Might want to increase this for dedicated servers.")
public static int tickerRateSyncWeatherHighWind = 2;
@ConfigComment("How often in ticks to sync volcano data between server and clients.")
public static int tickerRateSyncVolcanos = 40;
@ConfigComment("How often in ticks to sync wind data and do other IMC stuff between server and clients.")
public static int tickerRateSyncWindAndIMC = 60;
@ConfigComment("How often in ticks to run the storm spawn/remove checks. CHANGING THIS WILL CHANGE STORM FREQUENCY BY THE SAME FACTOR e.g. doubling this will make storms twice as rare (but will also take twice as long to 'remove' storms that are 'dead').")
public static int tickerRateSyncStormSpawnOrRemoveChecks = 20;

//tornado
@ConfigComment("Grab player or not")
public static boolean Storm_Tornado_grabPlayer = true;
Expand Down Expand Up @@ -66,6 +80,7 @@ public class ConfigMisc implements IConfigCategory {

//storm
public static boolean Storm_FlyingBlocksHurt = true;
@ConfigComment("Maximum possible stormfronts (or, more corrently, cloud formations) per player. Reducing this will improve network bandwidth.")
public static int Storm_MaxPerPlayerPerLayer = 20;
public static int Storm_Deadly_CollideDistance = 128;
public static int Storm_LightningStrikeBaseValueOddsTo1 = 200;
Expand Down Expand Up @@ -170,6 +185,9 @@ public void hookUpdatedValues() {
//Weather.dbg("block list processing disabled");
WeatherUtil.doBlockList();
WeatherUtilConfig.processLists();
if (Storm_MaxRadius < 1) {
Storm_MaxRadius = 1;
}
}

}
2 changes: 1 addition & 1 deletion src/main/java/weather2/entity/EntityIceBall.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ protected void onImpact(MovingObjectPosition movingobjectposition)

}
} else {
movingobjectposition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, getThrower()), damage);
movingobjectposition.entityHit.attackEntityFrom(DamageSource.fallingBlock, damage);
}

/*if (movingobjectposition.entityHit instanceof EntityLiving) {
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/weather2/util/WeatherUtilParticle.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ public class WeatherUtilParticle {
//weather2: not sure what will happen to this in 1.7, copied over for convinience
public static int getParticleAge(EntityFX ent)
{
return (Integer) OldUtil.getPrivateValueBoth(EntityFX.class, ent, "field_70546_d", "particleAge");
if (OldUtil.getPrivateValueBoth(EntityFX.class, ent, "field_70546_d", "particleAge") != null) {
return (Integer) OldUtil.getPrivateValueBoth(EntityFX.class, ent, "field_70546_d", "particleAge");
} else {
return 0;
}
}

//weather2: not sure what will happen to this in 1.7, copied over for convinience
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,89 +18,24 @@

public class EntityRendererProxyWeather2Mini extends EntityRenderer
{
private Minecraft mc;
private Random random = new Random();
public int rendererUpdateCount;
public long lastWorldTime = 0;

private int rainSoundCounter = 0;

public boolean basicRain = false;
public int rainRate = 50;

/** Rain X coords */
public float[] rainXCoords;

/** Rain Y coords */
public float[] rainYCoords;

private static final ResourceLocation resRain = new ResourceLocation("textures/environment/rain.png");
private static final ResourceLocation resSnow = new ResourceLocation("textures/environment/snow.png");

public EntityRendererProxyWeather2Mini(Minecraft var1, IResourceManager resMan)
{
super(var1, resMan);
this.mc = var1;
rendererUpdateCount = 0;
}

@Override
public void updateCameraAndRender(float var1)
{
super.updateCameraAndRender(var1);
//ModLoader.OnTick(var1, this.game);
}

public void disableLightMap2(double var1)
{
GL13.glClientActiveTexture(GL13.GL_TEXTURE1);
GL13.glActiveTexture(GL13.GL_TEXTURE1);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL13.glClientActiveTexture(GL13.GL_TEXTURE0);
GL13.glActiveTexture(GL13.GL_TEXTURE0);
}/*

@Override
public void setupFog(int par1, float par2)
{
super.setupFog(par1, par2);
System.out.println("woooooo");
}*/

public boolean isPaused() {
return WeatherUtil.isPaused();
}

@Override
protected void renderRainSnow(float par1)
{

boolean overrideOn = ConfigMisc.Misc_proxyRenderOverrideEnabled/* && ConfigMisc.Misc_takeControlOfGlobalRain*/;
boolean overrideOn = ConfigMisc.Misc_proxyRenderOverrideEnabled;

if (!overrideOn) {
super.renderRainSnow(par1);
return;
} else {

Minecraft mc = FMLClientHandler.instance().getClient();
EntityPlayer entP = mc.thePlayer;
if (entP != null) {
//convert to absolute (positive) value for old effects
float curRainStr = Math.abs(SceneEnhancer.getRainStrengthAndControlVisuals(entP, true));

//convert to abs for snow being rain
curRainStr = Math.abs(curRainStr);

//Weather.dbg("curRainStr: " + curRainStr);

//if (!ConfigMisc.overcastMode) {
mc.theWorld.setRainStrength(curRainStr);
//}

//TEMP
//mc.theWorld.setRainStrength(0.5F);
}

//note, the overcast effect change will effect vanilla non particle rain distance too, particle rain for life!
if (!ConfigMisc.Particle_RainSnow) {
super.renderRainSnow(par1);
Expand Down
Loading