Skip to content

Commit

Permalink
Fix up for love tropics for 1.21, update github actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Corosauce committed Nov 20, 2024
1 parent c6c272b commit c18f099
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 15 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Java CI with Gradle

on: [push]
jobs:

jdk17:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: build

- name: Locate built JARfile
id: jar
run: jarfile=$(find build/libs/ -name "*-all.jar" -not -name "*slim*" -not -name "*source*" | tr '\n' ' '); echo "jarfile=$jarfile" >> $GITHUB_OUTPUT

- name: Set Artifact name
id: jarname
run: jarname=$(find build/libs/ -name "*-all.jar" -not -name "*slim*" -not -name "*source*" | sed 's:.*/::' | tr '\n' ' '); echo "jarname=$jarname" >> $GITHUB_OUTPUT

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.jarname.outputs.jarname }}
path: ${{ steps.jar.outputs.jarfile }}

7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ repositories {
maven {
url "https://cursemaven.com"
}
maven { url = "https://api.modrinth.com/maven" }
flatDir {
dir 'libs'
}
Expand Down Expand Up @@ -137,6 +138,12 @@ dependencies {
// The group id is ignored when searching -- in this case, it is "blank"
// implementation "blank:coolmod-${mc_version}:${coolmod_version}"

implementation ('com.lovetropics.ltweather:ltweather-neoforge:1.21-1.0')
implementation ('com.lovetropics.ltextras:LTExtras:1.3.0-release+248-gha')
implementation ('com.tropicraft:Tropicraft:9.7.3-beta+688-gha')
implementation ("com.lovetropics.minigames:LTMinigames:${ltminigames_version}")
//implementation ('maven.modrinth:tropicraft:9.7.3-1.21')

implementation ("com.corosus.coroutil:coroutil-neoforge:${project.minecraft_version}.0-${project.coroutil_version}")
//implementation ("com.github.stephengold:Libbulletjme:$libbulletjme_version")

Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ org.gradle.parallel=true
mod_authors=Corosus
mod_license=All Rights Reserved

ltminigames_version=0.1.0-alpha+1140-gha
2 changes: 1 addition & 1 deletion src/main/java/weather2/ClientTickHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import weather2.util.WindReader;
import weather2.weathersystem.WeatherManagerClient;

@Mod(Weather.MODID)

public class ClientTickHandler
{
public static final ClientTickHandler INSTANCE = new ClientTickHandler();
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/weather2/ClientWeatherProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.world.phys.Vec3;
import weather2.client.SceneEnhancer;
import weather2.ltcompat.ClientWeatherIntegration;
import weather2.ltcompat.ServerWeatherIntegration;
import weather2.weathersystem.storm.StormObject;
import weather2.weathersystem.storm.WeatherObjectParticleStorm;

Expand Down Expand Up @@ -72,6 +73,7 @@ public PrecipitationType getPrecipitationType(Biome biome) {
}

public float getWindSpeed() {
System.out.println("client getWindSpeed" + ClientWeatherIntegration.get().getWindSpeed());
return ClientWeatherIntegration.get().getWindSpeed();
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/weather2/ServerWeatherProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class ServerWeatherProxy {

public static float getWindSpeed(ServerLevel level) {
if (isWeatherEffectsServerSideControlled()) {
//System.out.println("server getWindSpeed" + ServerWeatherIntegration.getWindSpeed(level));
//return 1f;//ServerWeatherIntegration.getWindSpeed(level);
return ServerWeatherIntegration.getWindSpeed(level);
} else {
return -1;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/weather2/client/SceneEnhancer.java
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,8 @@ public void tickEnvironmentalParticleSpawning() {
Random rand = CoroUtilMisc.random();

float windSpeed = windMan.getWindSpeed(posPlayer);
if (world.getGameTime() % 40 == 0)
//System.out.println("client wind speed: " + windSpeed + " - " + windMan.manager.getWorld().dimension() + " - " + windMan);

//funnel.tickGame();

Expand Down
10 changes: 6 additions & 4 deletions src/main/java/weather2/ltcompat/ClientWeatherIntegration.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package weather2.ltcompat;

import weather2.datatypes.PrecipitationType;
import com.lovetropics.weather.ClientWeather;
import com.lovetropics.weather.TypeBridge;

public final class ClientWeatherIntegration {
private static ClientWeatherIntegration instance = new ClientWeatherIntegration();
Expand All @@ -16,7 +18,7 @@ public static void reset() {
instance = new ClientWeatherIntegration();
}

public float getRainAmount() {
/*public float getRainAmount() {
return 0;
}
Expand Down Expand Up @@ -46,12 +48,12 @@ public boolean isSnowstorm() {
public boolean hasWeather() {
return false;
}
}*/

/**
* TODO: for LT, turn back on when LT is needed, activates dependency on LTWeather
*/
/*public float getRainAmount() {
public float getRainAmount() {
return ClientWeather.get().getRainAmount();
}

Expand Down Expand Up @@ -81,5 +83,5 @@ public boolean isSnowstorm() {

public boolean hasWeather() {
return ClientWeather.get().hasWeather();
}*/
}
}
9 changes: 5 additions & 4 deletions src/main/java/weather2/ltcompat/ServerWeatherIntegration.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.Tuple;
import weather2.datatypes.StormState;
import com.lovetropics.weather.TypeBridge;

public class ServerWeatherIntegration {

public static float getWindSpeed(ServerLevel level) {
/*public static float getWindSpeed(ServerLevel level) {
return 0;
}
Expand All @@ -16,12 +17,12 @@ public static StormState getSandstormForEverywhere(ServerLevel level) {
public static StormState getSnowstormForEverywhere(ServerLevel level) {
return null;
}
}*/

/**
* TODO: for LT, turn back on when LT is needed, activates dependency on LTWeather
*/
/*public static float getWindSpeed(ServerLevel level) {
public static float getWindSpeed(ServerLevel level) {
return TypeBridge.getWindSpeed(level);
}

Expand All @@ -33,6 +34,6 @@ public static StormState getSandstormForEverywhere(ServerLevel level) {
public static StormState getSnowstormForEverywhere(ServerLevel level) {
Tuple<Integer, Integer> data = TypeBridge.getSnowstormData(level);
return data != null ? new StormState(data.getA(), data.getB()) : null;
}*/
}

}
4 changes: 2 additions & 2 deletions src/main/java/weather2/weathersystem/WeatherManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public void tick() {
}
}

//tick wind
if (WeatherUtilConfig.listDimensionsWindEffects.contains(getWorld().dimension().location().toString())) {
//tick wind, always tick if love tropics installed, so the override on wind speed updates correctly
if (Weather.isLoveTropicsInstalled() || WeatherUtilConfig.listDimensionsWindEffects.contains(getWorld().dimension().location().toString())) {
wind.tick();
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/weather2/weathersystem/storm/StormObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import net.neoforged.api.distmarker.OnlyIn;
import net.neoforged.fml.LogicalSide;
import net.neoforged.fml.util.thread.EffectiveSide;
import net.tropicraft.core.common.entity.underdasea.SharkEntity;
import weather2.EntityRegistry;
import weather2.ServerTickHandler;
import weather2.Weather;
Expand Down Expand Up @@ -2475,9 +2476,9 @@ public void spinEntityv2(Entity entity) {
if (entHeightFromBase > 90) {
if (Weather.isLoveTropicsInstalled()) {
//TODO: for LT, reenable or make it a soft dependency somehow
/*if (isSharknado() && entity instanceof SharkEntity) {
if (isSharknado() && entity instanceof SharkEntity) {
entity.getPersistentData().putBoolean("tornado_shoot", true);
}*/
}
if (isSharknado() && entity instanceof Dolphin) {
entity.getPersistentData().putBoolean("tornado_shoot", true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ public void tick() {
* TODO: for LT, turn back on when LT is needed, activates dependency on LTWeather / Tropicraft
*/
//ent = new SharkEntity(TropicraftEntities.HAMMERHEAD.get(), level);
} else {
}
if (ent == null) {
ent = new Dolphin(EntityType.DOLPHIN, level);
}
if (ent == null) {
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/weather2/weathersystem/wind/WindManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ public float getWindSpeed(@Nullable BlockPos pos) {
}

public float getWindSpeed(@Nullable BlockPos pos, float extraHeightAmpMax) {
if (pos != null) {
//TODO: rethink use of Weather.isLoveTropicsInstalled() here, this was added just to get wind working in LT again, but theres probably a better way to integrate it
//this is new since adding turbines after last love tropics, so somethings not accounted for correctly
if (pos != null && !Weather.isLoveTropicsInstalled()) {
return getWindSpeedPositional(pos, extraHeightAmpMax);
}
if (windTimeEvent > 0 && (windSpeedEvent > windSpeedGust && windSpeedEvent > windSpeedGlobal)) {
Expand Down Expand Up @@ -338,6 +340,8 @@ public void tick() {
}

float speedOverride = ServerWeatherProxy.getWindSpeed((ServerLevel) manager.getWorld());
//System.out.println("tick wind speed for " + manager.getWorld().dimension() + " - " + speedOverride);
//System.out.println("tick server wind speed for " + manager.getWorld().dimension() + " - " + speedOverride + " - " + this);
if (speedOverride != -1) {
windSpeedGlobal = speedOverride;
}
Expand Down Expand Up @@ -651,6 +655,11 @@ public Vec3 applyWindForceImpl(Vec3 pos, Vec3 motion, float weight, float multip
}

public CompoundTag nbtSyncForClient() {
/*float speedOverride = ServerWeatherProxy.getWindSpeed((ServerLevel) manager.getWorld());
System.out.println("sync wind speed for " + manager.getWorld().dimension() + " - " + speedOverride);
if (speedOverride != -1) {
windSpeedGlobal = speedOverride;
}*/
CompoundTag data = new CompoundTag();

//idea: only sync the wind data client cares about (the active priority wind)
Expand Down Expand Up @@ -681,6 +690,8 @@ public void nbtSyncFromServer(CompoundTag parNBT) {
windTimeEvent = parNBT.getInt("windTimeEvent");*/

windTimeGust = parNBT.getInt("windTimeGust");

//System.out.println("synced client wind speed for " + manager.getWorld().dimension() + " - " + windSpeedGlobal + " - " + this);
}

public Vec3 getWindForce(@Nullable BlockPos pos) {
Expand Down

0 comments on commit c18f099

Please sign in to comment.