Skip to content

Commit

Permalink
feat: serene seasons compat, closes #70
Browse files Browse the repository at this point in the history
  • Loading branch information
bruberu committed Apr 19, 2024
1 parent f1fadfc commit 0b04003
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 2 deletions.
1 change: 1 addition & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ dependencies {
compileOnly files("libs/NuclearCraft-2o.6.0-1.12.2.jar")
implementation("com.cleanroommc:modularui:2.4.1") { transitive = false }

implementation rfg.deobf("curse.maven:serene-seasons-291874:2799213")
implementation rfg.deobf("curse.maven:nutrition-gtceu-964594:5047422")
implementation rfg.deobf("curse.maven:nutrition-unofficial-extended-life-964516:5049991")
testImplementation 'junit:junit:4.13.2'
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/gregtechfoodoption/GTFOValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public class GTFOValues {
MODID_AC = "agricraft",
MODID_AP = "applecore",
MODID_NU = "nutrition",
MODID_NUGT = "nutrition_gtceu";
MODID_NUGT = "nutrition_gtceu",
MODID_SS = "sereneseasons";

public static final String craftingToolRollingPin = "craftingToolRollingPin";

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/gregtechfoodoption/GregTechFoodOption.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import gregtech.api.GTValues;
import gregtech.api.GregTechAPI;
import gregtech.api.util.Mods;
import gregtechfoodoption.block.GTFOMetaBlocks;
import gregtechfoodoption.client.GTFOClientHandler;
import gregtechfoodoption.covers.GTFOCoverBehaviors;
Expand Down Expand Up @@ -69,7 +70,7 @@ public void init(FMLInitializationEvent event) {
proxy.onLoad();
} catch (Exception e) {
}
if (Loader.isModLoaded(GTValues.MODID_TOP)) {
if (Loader.isModLoaded(Mods.Names.THE_ONE_PROBE)) {
GTFOTOPCompatibility.registerCompatibility();
}
if (Loader.isModLoaded(GTFOValues.MODID_GF) && Loader.isModLoaded(GTFOValues.MODID_TFC)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package gregtechfoodoption.integration.sereneseasons;

import gregtechfoodoption.block.GTFOCrop;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import sereneseasons.config.FertilityConfig;
import sereneseasons.core.SereneSeasons;
import sereneseasons.init.ModFertility;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.List;

public class GTFOSSTooltipHandler {
@SideOnly(Side.CLIENT)
public static void addTooltip(GTFOCrop crop, List<String> tooltip) {
try {
Field seedSeasons = ModFertility.class.getDeclaredField("seedSeasons");
seedSeasons.setAccessible(true);
HashMap<String, Integer> map = (HashMap<String, Integer>) seedSeasons.get(FertilityConfig.seasonal_fertility);
String name = crop.getRegistryName().toString();
if (map.containsKey(name)) {
int mask = map.get(name);
tooltip.add("Fertile Seasons:");
if ((mask & 1) != 0 && (mask & 2) != 0 && (mask & 4) != 0 && (mask & 8) != 0) {
tooltip.add(TextFormatting.LIGHT_PURPLE + " Year-Round");
} else {
if ((mask & 1) != 0) {
tooltip.add(TextFormatting.GREEN + " Spring");
}

if ((mask & 2) != 0) {
tooltip.add(TextFormatting.YELLOW + " Summer");
}

if ((mask & 4) != 0) {
tooltip.add(TextFormatting.GOLD + " Autumn");
}

if ((mask & 8) != 0) {
tooltip.add(TextFormatting.AQUA + " Winter");
}
}
}

} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
}
11 changes: 11 additions & 0 deletions src/main/java/gregtechfoodoption/item/GTFOCropSeedBehaviour.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package gregtechfoodoption.item;

import gregtech.api.items.metaitem.stats.IItemBehaviour;
import gregtechfoodoption.GTFOValues;
import gregtechfoodoption.block.GTFOCrop;
import gregtechfoodoption.block.GTFORootCrop;
import gregtechfoodoption.integration.sereneseasons.GTFOSSTooltipHandler;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.resources.I18n;
Expand All @@ -14,6 +16,11 @@
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.FMLContainer;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.relauncher.Side;
import sereneseasons.core.SereneSeasons;

import java.util.List;

Expand Down Expand Up @@ -43,5 +50,9 @@ public void addInformation(ItemStack itemStack, List<String> lines) {
lines.add(I18n.format("gregtechfoodoption.seed.0"));
if (crop instanceof GTFORootCrop)
lines.add(I18n.format("gregtechfoodoption.seed.root_crop"));

if (Loader.isModLoaded(GTFOValues.MODID_SS)) {
GTFOSSTooltipHandler.addTooltip(crop, lines);
}
}
}

0 comments on commit 0b04003

Please sign in to comment.