Skip to content

Commit

Permalink
fix using lotr code without proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
mist475 committed Aug 20, 2023
1 parent 8ed1836 commit 88654e3
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 20 deletions.
25 changes: 20 additions & 5 deletions src/main/java/org/blockartistry/mod/DynSurround/Module.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@

package org.blockartistry.mod.DynSurround;

import java.io.File;

import org.apache.logging.log4j.LogManager;
import org.blockartistry.mod.DynSurround.proxy.Proxy;

import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
Expand All @@ -39,6 +34,12 @@
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.common.config.Configuration;
import org.apache.logging.log4j.LogManager;
import org.blockartistry.mod.DynSurround.compat.ILOTRProxy;
import org.blockartistry.mod.DynSurround.compat.NoLotrProxy;
import org.blockartistry.mod.DynSurround.proxy.Proxy;

import java.io.File;

@Mod(modid = Module.MOD_ID, useMetadata = true, dependencies = Module.DEPENDENCIES, version = Module.VERSION, guiFactory = Module.GUI_FACTORY)
public class Module {
Expand All @@ -48,6 +49,10 @@ public class Module {
public static final String DEPENDENCIES = "required-after:Forge@[10.13.4.1614,);required-after:gtnhmixins@[2.0.0,)";
public static final String GUI_FACTORY = "org.blockartistry.mod.DynSurround.client.gui.ConfigGuiFactory";

public static final String LOTR_PROXY_LOCATION = "org.blockartistry.mod.DynSurround.compat.ILotrProxy";

public static ILOTRProxy LOTR_PROXY;

@Instance(MOD_ID)
protected static Module instance;

Expand Down Expand Up @@ -105,6 +110,16 @@ public void init(final FMLInitializationEvent event) {
@EventHandler
public void postInit(final FMLPostInitializationEvent event) {
proxy.postInit(event);
if (Proxy.LOTR) {
try {
LOTR_PROXY = Class.forName(LOTR_PROXY_LOCATION).asSubclass(ILOTRProxy.class).newInstance();
}
catch (ClassNotFoundException | InstantiationException | IllegalAccessException ignored) {
LOTR_PROXY = new NoLotrProxy();
}
} else {
LOTR_PROXY = new NoLotrProxy();
}
config.save();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.blockartistry.mod.DynSurround.compat;

public interface ILOTRProxy {
String getSeason();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.blockartistry.mod.DynSurround.compat;

import lotr.common.LOTRDate;

public class LotrProxy implements ILOTRProxy {
@Override
public String getSeason() {
return LOTRDate.ShireReckoning.getSeason().name();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.blockartistry.mod.DynSurround.compat;

public class NoLotrProxy implements ILOTRProxy{
@Override
public String getSeason() {
return "noseason";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,6 @@

package org.blockartistry.mod.DynSurround.data;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import lotr.common.LOTRDate;
import org.blockartistry.mod.DynSurround.ModLog;
import org.blockartistry.mod.DynSurround.ModOptions;
import org.blockartistry.mod.DynSurround.Module;
import org.blockartistry.mod.DynSurround.data.config.DimensionConfig;
import org.blockartistry.mod.DynSurround.util.DiurnalUtils;

import cpw.mods.fml.common.Loader;
import foxie.calendar.api.CalendarAPI;
import foxie.calendar.api.ICalendarProvider;
Expand All @@ -43,13 +32,21 @@
import net.minecraft.world.WorldProvider;
import net.minecraft.world.WorldType;
import net.minecraftforge.common.DimensionManager;
import org.blockartistry.mod.DynSurround.ModLog;
import org.blockartistry.mod.DynSurround.ModOptions;
import org.blockartistry.mod.DynSurround.Module;
import org.blockartistry.mod.DynSurround.data.config.DimensionConfig;
import org.blockartistry.mod.DynSurround.proxy.Proxy;
import org.blockartistry.mod.DynSurround.util.DiurnalUtils;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public final class DimensionRegistry implements Comparable<DimensionRegistry> {

private static final int SPACE_HEIGHT_OFFSET = 32;
private static final boolean CALENDAR_API = Loader.isModLoaded("CalendarAPI");
//Lotr has its own date system
private static final boolean LOTR = Loader.isModLoaded("lotr");
private static final String SEASON_NOT_AVAILABLE = "noseason";

private static final List<DimensionConfig.Entry> cache = new ArrayList<>();
Expand Down Expand Up @@ -220,8 +217,8 @@ public boolean getHasWeather() {

public String getSeason() {
//TODO: lotr shire reckoning -> CalenderAPI bridge in MistLotrTweaks
if (LOTR && this.name.equals("MiddleEarth")) {
return LOTRDate.ShireReckoning.getSeason().name();
if (Proxy.LOTR && this.name.equals("MiddleEarth")) {
return Module.LOTR_PROXY.getSeason();
}
if (!CALENDAR_API) {
return SEASON_NOT_AVAILABLE;
Expand Down

0 comments on commit 88654e3

Please sign in to comment.