Skip to content

Commit

Permalink
Fix reloading for CraftTweaker & Crafting Harmonics #537 #547
Browse files Browse the repository at this point in the history
  • Loading branch information
mezz committed Oct 28, 2016
1 parent 04db141 commit ef2f5b9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
20 changes: 8 additions & 12 deletions src/main/java/mezz/jei/JeiStarter.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,23 @@
import net.minecraftforge.fml.common.ProgressManager;

public class JeiStarter {
private final ModRegistry modRegistry;
private final StackHelper stackHelper;
private final IngredientRegistry ingredientRegistry;

private boolean started;
@Nullable
private GuiEventHandler guiEventHandler;

public JeiStarter(List<IModPlugin> plugins) {
public void start(List<IModPlugin> plugins) {
long jeiStartTime = System.currentTimeMillis();

Log.info("Starting JEI...");
SubtypeRegistry subtypeRegistry = new SubtypeRegistry();

registerItemSubtypes(plugins, subtypeRegistry);

stackHelper = new StackHelper(subtypeRegistry);
StackHelper stackHelper = new StackHelper(subtypeRegistry);
stackHelper.enableUidCache();
Internal.setStackHelper(stackHelper);

ingredientRegistry = registerIngredients(plugins);
IngredientRegistry ingredientRegistry = registerIngredients(plugins);
Internal.setIngredientRegistry(ingredientRegistry);

JeiHelpers jeiHelpers = new JeiHelpers(ingredientRegistry, stackHelper, subtypeRegistry);
Expand All @@ -44,13 +43,9 @@ public JeiStarter(List<IModPlugin> plugins) {
ModIdUtil modIdUtil = Internal.getModIdUtil();
ItemRegistry itemRegistry = new ItemRegistry(ingredientRegistry, modIdUtil);

modRegistry = new ModRegistry(jeiHelpers, itemRegistry, ingredientRegistry);
ModRegistry modRegistry = new ModRegistry(jeiHelpers, itemRegistry, ingredientRegistry);

registerPlugins(plugins, modRegistry);
}

public void start(List<IModPlugin> plugins) {
stackHelper.enableUidCache();

Log.info("Building recipe registry...");
long start_time = System.currentTimeMillis();
Expand Down Expand Up @@ -80,6 +75,7 @@ public void start(List<IModPlugin> plugins) {
MinecraftForge.EVENT_BUS.register(guiEventHandler);

started = true;
Log.info("Finished Starting JEI in {} ms", System.currentTimeMillis() - jeiStartTime);
}

public boolean hasStarted() {
Expand Down
12 changes: 3 additions & 9 deletions src/main/java/mezz/jei/ProxyCommonClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
@SuppressWarnings("unused")
public class ProxyCommonClient extends ProxyCommon {
private List<IModPlugin> plugins = new ArrayList<IModPlugin>();
@Nullable
private JeiStarter starter;
private final JeiStarter starter = new JeiStarter();

private static void initVersionChecker() {
final NBTTagCompound compound = new NBTTagCompound();
Expand Down Expand Up @@ -108,12 +107,7 @@ public void onResourceManagerReload(IResourceManager resourceManager) {
}
});

long jeiStartTime = System.currentTimeMillis();
Log.info("Starting JEI...");
this.starter = new JeiStarter(this.plugins);

this.starter.start(this.plugins);
Log.info("Finished Starting JEI in {} ms", System.currentTimeMillis() - jeiStartTime);
this.starter.start(plugins);
}

@SubscribeEvent
Expand All @@ -127,7 +121,7 @@ public void onEntityJoinedWorld(EntityJoinWorldEvent event) {
@Override
public void restartJEI() {
// check that JEI has been started before. if not, do nothing
if (this.starter != null && this.starter.hasStarted()) {
if (this.starter.hasStarted()) {
this.starter.start(this.plugins);
}
}
Expand Down

0 comments on commit ef2f5b9

Please sign in to comment.