Add registry flag for syncing
This commit is contained in:
parent
35cd89c00c
commit
40f2276e88
2 changed files with 19 additions and 1 deletions
|
@ -43,6 +43,7 @@ public class RegistryBuilder<T extends IForgeRegistryEntry<T>>
|
|||
private List<ValidateCallback<T>> validateCallback = Lists.newArrayList();
|
||||
private List<BakeCallback<T>> bakeCallback = Lists.newArrayList();
|
||||
private boolean saveToDisc = true;
|
||||
private boolean sync = true;
|
||||
private boolean allowOverrides = true;
|
||||
private boolean allowModifications = false;
|
||||
private DummyFactory<T> dummyFactory;
|
||||
|
@ -146,6 +147,12 @@ public class RegistryBuilder<T extends IForgeRegistryEntry<T>>
|
|||
return this;
|
||||
}
|
||||
|
||||
public RegistryBuilder<T> disableSync()
|
||||
{
|
||||
this.sync = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RegistryBuilder<T> disableOverrides()
|
||||
{
|
||||
this.allowOverrides = false;
|
||||
|
@ -285,4 +292,9 @@ public class RegistryBuilder<T extends IForgeRegistryEntry<T>>
|
|||
{
|
||||
return saveToDisc;
|
||||
}
|
||||
|
||||
public boolean getSync()
|
||||
{
|
||||
return sync;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ public class RegistryManager
|
|||
BiMap<ResourceLocation, ForgeRegistry<? extends IForgeRegistryEntry<?>>> registries = HashBiMap.create();
|
||||
private BiMap<Class<? extends IForgeRegistryEntry<?>>, ResourceLocation> superTypes = HashBiMap.create();
|
||||
private Set<ResourceLocation> persisted = Sets.newHashSet();
|
||||
private Set<ResourceLocation> 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<ResourceLocation, Snapshot> takeSnapshot(boolean savingToDisc)
|
||||
{
|
||||
Map<ResourceLocation, Snapshot> ret = Maps.newHashMap();
|
||||
Set<ResourceLocation> keys = savingToDisc ? this.persisted : this.registries.keySet();
|
||||
Set<ResourceLocation> 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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue