diff --git a/src/main/java/net/minecraftforge/registries/RegistryBuilder.java b/src/main/java/net/minecraftforge/registries/RegistryBuilder.java index 5f49b914d..f43968ac4 100644 --- a/src/main/java/net/minecraftforge/registries/RegistryBuilder.java +++ b/src/main/java/net/minecraftforge/registries/RegistryBuilder.java @@ -43,6 +43,7 @@ public class RegistryBuilder> private List> validateCallback = Lists.newArrayList(); private List> bakeCallback = Lists.newArrayList(); private boolean saveToDisc = true; + private boolean sync = true; private boolean allowOverrides = true; private boolean allowModifications = false; private DummyFactory dummyFactory; @@ -145,6 +146,12 @@ public class RegistryBuilder> this.saveToDisc = false; return this; } + + public RegistryBuilder disableSync() + { + this.sync = false; + return this; + } public RegistryBuilder disableOverrides() { @@ -285,4 +292,9 @@ public class RegistryBuilder> { return saveToDisc; } + + public boolean getSync() + { + return sync; + } } diff --git a/src/main/java/net/minecraftforge/registries/RegistryManager.java b/src/main/java/net/minecraftforge/registries/RegistryManager.java index 3c573aa48..2e6eb1bf5 100644 --- a/src/main/java/net/minecraftforge/registries/RegistryManager.java +++ b/src/main/java/net/minecraftforge/registries/RegistryManager.java @@ -49,6 +49,7 @@ public class RegistryManager BiMap>> registries = HashBiMap.create(); private BiMap>, ResourceLocation> superTypes = HashBiMap.create(); private Set persisted = Sets.newHashSet(); + private Set synced = Sets.newHashSet(); private final String name; public RegistryManager(String name) @@ -94,6 +95,8 @@ public class RegistryManager this.superTypes.put(ot.getRegistrySuperType(), key); if (other.persisted.contains(key)) this.persisted.add(key); + if (other.synced.contains(key)) + this.synced.add(key); } return getRegistry(key); } @@ -115,6 +118,8 @@ public class RegistryManager superTypes.put(builder.getType(), name); if (builder.getSaveToDisc()) this.persisted.add(name); + if (builder.getSync()) + this.synced.add(name); return getRegistry(name); } @@ -135,7 +140,7 @@ public class RegistryManager public Map takeSnapshot(boolean savingToDisc) { Map ret = Maps.newHashMap(); - Set keys = savingToDisc ? this.persisted : this.registries.keySet(); + Set keys = savingToDisc ? this.persisted : this.synced; keys.forEach(name -> ret.put(name, getRegistry(name).makeSnapshot())); return ret; } @@ -144,6 +149,7 @@ public class RegistryManager public void clean() { this.persisted.clear(); + this.synced.clear(); this.registries.clear(); this.superTypes.clear(); }