Skip to content

Commit

Permalink
Merge branch '1.20.2' into 1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaargolo authored Sep 27, 2024
2 parents dc474f2 + b039f40 commit 887ae39
Show file tree
Hide file tree
Showing 20 changed files with 283 additions and 122 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- run: |
chmod +x ./gradlew
./gradlew build
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: build/libs/
path: build/libs/
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# User-specific stuff
.vscode/
.idea/

*.iml
Expand Down Expand Up @@ -101,6 +102,7 @@ $RECYCLE.BIN/
*.lnk

.gradle
bin/
build/

# Ignore Gradle GUI config
Expand Down
18 changes: 9 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
org.gradle.jvmargs=-Xmx4G

# Gradle Plugins
loom_version=1.4-SNAPSHOT
loom_version=1.7-SNAPSHOT
grgit_version=5.0.0
cursegradle_version=1.4.0
modrinth_version=2.7.3
modrinth_version=2.8.7
github_api_version=1.314

# Mod Properties
mod_version=2.3+1.20.2
mod_version=2.4-BETA+1.20.2
maven_group=io.github.lucaargolo

# Fabric Properties
minecraft_version=1.20.2
yarn_mappings=1.20.2+build.2
loader_version=0.14.22
yarn_mappings=1.20.2+build.4
loader_version=0.16.5

#Fabric api
fabric_version=0.89.2+1.20.2
# Fabric API
fabric_version=0.91.6+1.20.2

#Libraries
modmenu_version=8.0.0
rei_version=13.0.666
modmenu_version=8.0.1
rei_version=13.1.773

#Publishing
curseforge_id=413523
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
110 changes: 43 additions & 67 deletions src/main/java/io/github/lucaargolo/seasons/FabricSeasons.java
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ else if (m == 12 && d > 20)
}

private static final TagKey<Biome> IGNORED_CATEGORIES_TAG = TagKey.of(RegistryKeys.BIOME, new Identifier(FabricSeasons.MOD_ID, "ignored"));
private static final TagKey<Biome> JUNGLE_LIKE_TAG = TagKey.of(RegistryKeys.BIOME, new Identifier(FabricSeasons.MOD_ID, "jungle_like"));

public static void injectBiomeTemperature(RegistryEntry<Biome> entry, World world) {
if(entry.isIn(IGNORED_CATEGORIES_TAG))
Expand All @@ -356,81 +355,58 @@ public static void injectBiomeTemperature(RegistryEntry<Biome> entry, World worl
((BiomeMixed) (Object) biome).setOriginalWeather(originalWeather);
}
Season season = FabricSeasons.getCurrentSeason(world);
boolean isJungle = entry.isIn(JUNGLE_LIKE_TAG);

Pair<Boolean, Float> modifiedWeather = getSeasonWeather(season, biomeId, isJungle, originalWeather.hasPrecipitation, originalWeather.temperature);
Pair<Boolean, Float> modifiedWeather = getSeasonWeather(season, biomeId, originalWeather.hasPrecipitation, originalWeather.temperature);
currentWeather.hasPrecipitation = modifiedWeather.getLeft();
currentWeather.temperature = modifiedWeather.getRight();
}

public static Pair<Boolean, Float> getSeasonWeather(Season season, Identifier biomeId, boolean jungle, Boolean hasPrecipitation, float temp) {
public static Pair<Boolean, Float> getSeasonWeather(Season season, Identifier biomeId, Boolean hasPrecipitation, float temp) {
if(!CONFIG.doTemperatureChanges(biomeId)) {
return new Pair<>(hasPrecipitation, temp);
}
if(jungle) {
//Jungle Biomes
if (season == Season.WINTER) {
return new Pair<>(hasPrecipitation, temp-0.1f);
} else {
return new Pair<>(hasPrecipitation, temp);
}
}else if(temp <= 0.1) {
//Frozen Biomes
switch (season) {
case SUMMER -> {
if (CONFIG.shouldSnowyBiomesMeltInSummer())
return new Pair<>(hasPrecipitation, temp + 0.3f);
else return new Pair<>(hasPrecipitation, temp);
}
case WINTER -> {
return new Pair<>(hasPrecipitation, temp - 0.2f);
}
default -> {
return new Pair<>(hasPrecipitation, temp);
}
}
}else if(temp <= 0.3) {
//Cold Biomes
switch (season) {
case SUMMER -> {
return new Pair<>(hasPrecipitation, temp + 0.2f);
}
case WINTER -> {
return new Pair<>(hasPrecipitation, temp - 0.2f);
}
default -> {
return new Pair<>(hasPrecipitation, temp);
}
}
}else if(temp <= 0.95) {
//Temperate Biomes
switch (season) {
case SUMMER -> {
return new Pair<>(hasPrecipitation, temp + 0.2f);
}
case FALL -> {
return new Pair<>(hasPrecipitation, temp - 0.1f);
}
case WINTER -> {
return new Pair<>(hasPrecipitation, temp - 0.7f);
}
default -> {
return new Pair<>(hasPrecipitation, temp);
}
}
if(CONFIG.isSnowForcedInBiome(biomeId) && season == Season.WINTER) {
return new Pair<>(hasPrecipitation, 0.14f);
}else if(temp <= -0.51) {
//Permanently Frozen Biomes
return switch (season) {
case SPRING -> new Pair<>(hasPrecipitation, temp - 0.3f);
case SUMMER -> new Pair<>(hasPrecipitation, temp + 0.84f);
case WINTER -> new Pair<>(hasPrecipitation, temp - 0.7f);
default -> new Pair<>(hasPrecipitation, temp);
};
}else if(temp <= 0.15) {
//Usually Frozen Biomes
return switch (season) {
case SPRING -> new Pair<>(hasPrecipitation, temp - 0.25f);
case SUMMER -> new Pair<>(hasPrecipitation, temp + (CONFIG.shouldSnowyBiomesMeltInSummer() ? 0.66f : 0f));
case WINTER -> new Pair<>(hasPrecipitation, temp - 0.75f);
default -> new Pair<>(hasPrecipitation, temp);
};
}else if(temp <= 0.49) {
//Temparate Biomes
return switch (season) {
case SPRING -> new Pair<>(hasPrecipitation, temp - 0.16f);
case SUMMER -> new Pair<>(hasPrecipitation, temp + 0.66f);
case WINTER -> new Pair<>(hasPrecipitation, temp - 0.8f);
default -> new Pair<>(hasPrecipitation, temp);
};
}else if(temp <= 0.79) {
//Usually Ice Free Biomes
return switch (season) {
case SPRING -> new Pair<>(hasPrecipitation, temp - 0.34f);
case SUMMER -> new Pair<>(hasPrecipitation, temp + 0.46f);
case WINTER -> new Pair<>(hasPrecipitation, temp - 0.56f);
default -> new Pair<>(hasPrecipitation, temp);
};
}else{
//Hot biomes
switch (season) {
case SUMMER -> {
return new Pair<>(hasPrecipitation, temp + 0.2f);
}
case WINTER -> {
return new Pair<>(true, temp - 0.2f);
}
default -> {
return new Pair<>(hasPrecipitation, temp);
}
}
// Ice Free Biomes
return switch (season) {
case SPRING -> new Pair<>(hasPrecipitation, temp - 0.34f);
case SUMMER -> new Pair<>(hasPrecipitation, temp + 0.4f);
case WINTER -> new Pair<>(true, temp - 0.64f);
default -> new Pair<>(hasPrecipitation, temp);
};
}
}

Expand Down
59 changes: 39 additions & 20 deletions src/main/java/io/github/lucaargolo/seasons/mixin/ItemMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.Registries;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
Expand All @@ -35,44 +34,64 @@ public void appendTooltipInject(ItemStack stack, @Nullable World world, List<Tex
Item item = stack.getItem();
Block block = FabricSeasons.SEEDS_MAP.getOrDefault(item, null);
if (block != null) {
Identifier cropIdentifier = Registries.BLOCK.getId(block);
float multiplier = CropConfigs.getSeasonCropMultiplier(cropIdentifier, season);
if (multiplier == 0f) {
tooltip.add(Text.translatable("tooltip.seasons.not_grow").formatted(Formatting.RED));
} else if (multiplier < 1.0f) {
tooltip.add(Text.translatable("tooltip.seasons.slowed_grow").formatted(Formatting.GOLD));
} else if (multiplier == 1.0f) {
tooltip.add(Text.translatable("tooltip.seasons.normal_grow").formatted(Formatting.GREEN));
} else {
tooltip.add(Text.translatable("tooltip.seasons.faster_grow").formatted(Formatting.LIGHT_PURPLE));
}


MinecraftClient client = MinecraftClient.getInstance();
long handle = client.getWindow().getHandle();
KeyBinding sneakKey = client.options.sneakKey;
InputUtil.Key boundKey = sneakKey.boundKey;
Identifier cropIdentifier = Registries.BLOCK.getId(block);
float multiplier = CropConfigs.getSeasonCropMultiplier(cropIdentifier, season);
boolean sneak = false;
if(boundKey.getCategory() == InputUtil.Type.MOUSE) {
sneak = GLFW.glfwGetMouseButton(handle, boundKey.getCode()) == 1;
}else if(boundKey.getCategory() == InputUtil.Type.KEYSYM) {
sneak = GLFW.glfwGetKey(handle, boundKey.getCode()) == 1;
}
if (multiplier == 0f) {
tooltip.add(Text.translatable("tooltip.seasons.not_grow").formatted(Formatting.RED));
} else if (multiplier == 1.0f) {
tooltip.add(Text.translatable("tooltip.seasons.normal_grow").formatted(Formatting.GREEN));
}
if (sneak) {
if (multiplier != 0f && multiplier < 1.0f) {
tooltip.add(Text.translatable("tooltip.seasons.slowed_grow").formatted(Formatting.GOLD));
} else if (multiplier > 1.0f) {
tooltip.add(Text.translatable("tooltip.seasons.faster_grow").formatted(Formatting.LIGHT_PURPLE));
}

for (Season s : Season.values()) {
if(season == s) {
MutableText text = Text.translatable(s.getTranslationKey()).formatted(s.getFormatting(), Formatting.UNDERLINE);
MutableText multiplierText = Text.literal(String.format("%.1f", (CropConfigs.getSeasonCropMultiplier(cropIdentifier, s) * 100)) + "% speed");
tooltip.add(text.append(Text.literal(": ").append(multiplierText.formatted(s.getFormatting()))));
}else{
MutableText text = Text.translatable(s.getTranslationKey()).formatted(s.getFormatting());
MutableText multiplierText = Text.literal(String.format("%.1f", (CropConfigs.getSeasonCropMultiplier(cropIdentifier, s) * 100)) + "% speed");
tooltip.add(text.append(Text.literal(": ").append(multiplierText.formatted(Formatting.WHITE))));
tooltip.add(Text.translatable("tooltip.seasons.season_speed",
Text.translatable(s.getTranslationKey()).formatted(s.getFormatting(), Formatting.UNDERLINE),
Text.translatable("tooltip.seasons.season_delimitator").formatted(s.getFormatting()),
Text.literal(String.format("%.1f", (CropConfigs.getSeasonCropMultiplier(cropIdentifier, s) * 100))).formatted(Formatting.WHITE)
));
} else{
tooltip.add(Text.translatable("tooltip.seasons.season_speed",
Text.translatable(s.getTranslationKey()).formatted(s.getFormatting()),
Text.translatable("tooltip.seasons.season_delimitator").formatted(s.getFormatting()),
Text.literal(String.format("%.1f", (CropConfigs.getSeasonCropMultiplier(cropIdentifier, s) * 100)))).formatted(Formatting.GRAY)
);
}
}
}else {
} else {
if (multiplier != 0f && multiplier < 1.0f) {
tooltip.add(Text.translatable("tooltip.seasons.combined_grow",
Text.translatable("tooltip.seasons.slowed_grow"),
String.format("%.1f", (CropConfigs.getSeasonCropMultiplier(cropIdentifier, season) * 100))).formatted(Formatting.GOLD)
);
} else if (multiplier > 1.0f) {
tooltip.add(Text.translatable("tooltip.seasons.combined_grow",
Text.translatable("tooltip.seasons.faster_grow"),
String.format("%.1f", (CropConfigs.getSeasonCropMultiplier(cropIdentifier, season) * 100))).formatted(Formatting.LIGHT_PURPLE)
);
}
tooltip.add(Text.translatable("tooltip.seasons.show_more", sneakKey.getBoundKeyLocalizedText().copy().formatted(Formatting.BLUE)).formatted(Formatting.GRAY));
}
}
}
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ public void setMeltableSnow(boolean raining, BlockPos pos, CallbackInfo ci, Bloc
FabricSeasons.setMeltable(blockPos);
}


@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;precipitationTick(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/biome/Biome$Precipitation;)V"), method = "tickIceAndSnow", locals = LocalCapture.CAPTURE_FAILSOFT)
public void setReplacedMeltable(boolean raining, BlockPos pos, CallbackInfo ci, BlockPos blockPos, BlockPos blockPos2, Biome biome, int k, Biome.Precipitation precipitation, BlockState blockState3) {
Meltable.replaceBlockOnSnow((ServerWorld) (Object) this, blockPos, biome);
if (FabricSeasons.CONFIG.shouldSnowReplaceVegetation())
Meltable.replaceBlockOnSnow((ServerWorld) (Object) this, blockPos, biome);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package io.github.lucaargolo.seasons.mixin;

import io.github.lucaargolo.seasons.FabricSeasons;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.SugarCaneBlock;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.WorldView;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

import java.util.Iterator;

@Mixin(SugarCaneBlock.class)
public class SugarCaneBlockMixin {

@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/WorldView;getFluidState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/fluid/FluidState;"), method = "canPlaceAt", locals = LocalCapture.CAPTURE_FAILSOFT, cancellable = true)
public void allowSugarCaneToGrowOnIce(BlockState state, WorldView world, BlockPos pos, CallbackInfoReturnable<Boolean> cir, BlockState blockState, BlockPos blockPos, Iterator var6, Direction direction, BlockState blockState2) {
if(!FabricSeasons.CONFIG.shouldIceBreakSugarCane() && blockState2.isOf(Blocks.ICE)) {
cir.setReturnValue(true);
}
}

}
33 changes: 32 additions & 1 deletion src/main/java/io/github/lucaargolo/seasons/utils/ModConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,31 @@ private static class SeasonLength {

private boolean doTemperatureChanges = true;

private boolean shouldSnowReplaceVegetation = true;

private boolean shouldSnowyBiomesMeltInSummer = true;

private boolean shouldIceNearWaterMelt = false;

private boolean shouldIceBreakSugarCane = false;

private List<String> biomeDenylist = List.of(
"terralith:glacial_chasm"
"terralith:glacial_chasm",
"minecraft:frozen_ocean",
"minecraft:deep_frozen_ocean",
"minecraft:cold_ocean",
"minecraft:deep_cold_ocean",
"minecraft:ocean",
"minecraft:deep_ocean",
"minecraft:lukewarm_ocean",
"minecraft:deep_lukewarm_ocean",
"minecraft:warm_ocean"
);

private List<String> biomeForceSnowInWinterList = List.of(
"minecraft:plains",
"minecraft:sunflower_plains",
"minecraft:stony_peaks"
);

private boolean isSeasonTiedWithSystemTime = false;
Expand Down Expand Up @@ -79,6 +98,14 @@ public boolean doTemperatureChanges(Identifier biomeId) {
return doTemperatureChanges && !biomeDenylist.contains(biomeId.toString());
}

public boolean isSnowForcedInBiome(Identifier biomeId) {
return biomeForceSnowInWinterList.contains(biomeId.toString());
}

public boolean shouldSnowReplaceVegetation() {
return shouldSnowReplaceVegetation;
}

public boolean shouldSnowyBiomesMeltInSummer() {
return shouldSnowyBiomesMeltInSummer;
}
Expand All @@ -87,6 +114,10 @@ public boolean shouldIceNearWaterMelt() {
return shouldIceNearWaterMelt;
}

public boolean shouldIceBreakSugarCane() {
return shouldIceBreakSugarCane;
}

public int getSpringLength() {
return seasonLength.springLength;
}
Expand Down
Loading

0 comments on commit 887ae39

Please sign in to comment.