1919
2020import micdoodle8 .mods .galacticraft .annotations .ReplaceWith ;
2121import micdoodle8 .mods .galacticraft .api .event .celestial .RegisterEvent ;
22- import micdoodle8 .mods .galacticraft .api .util .stream .Accumulators ;
22+ import micdoodle8 .mods .galacticraft .api .util .stream .CelestialCollector ;
2323import micdoodle8 .mods .galacticraft .core .util .list .CelestialList ;
2424import micdoodle8 .mods .galacticraft .core .util .list .ImmutableCelestialList ;
2525
@@ -173,39 +173,39 @@ public static CelestialBody getPlanetOrMoonFromTranslationkey(String translation
173173 return null ;
174174 }
175175
176- public static <T > boolean register (T object )
176+ public static <T > void register (T object )
177177 {
178178 if (object instanceof SolarSystem )
179179 {
180180 SolarSystem solarSystem = (SolarSystem ) object ;
181181 RegisterEvent registerEvent = new RegisterEvent (solarSystem , Loader .instance ().activeModContainer ());
182182 solarSystems .add (solarSystem );
183183 objects .add (solarSystem );
184- return MinecraftForge .EVENT_BUS .post (registerEvent );
184+ MinecraftForge .EVENT_BUS .post (registerEvent );
185185 }
186186 if (object instanceof Planet )
187187 {
188188 Planet planet = (Planet ) object ;
189189 RegisterEvent registerEvent = new RegisterEvent (planet , Loader .instance ().activeModContainer ());
190190 planets .add (planet );
191191 objects .add (planet );
192- return MinecraftForge .EVENT_BUS .post (registerEvent );
192+ MinecraftForge .EVENT_BUS .post (registerEvent );
193193 }
194194 if (object instanceof Moon )
195195 {
196196 Moon moon = (Moon ) object ;
197197 RegisterEvent registerEvent = new RegisterEvent (moon , Loader .instance ().activeModContainer ());
198198 moons .add (moon );
199199 objects .add (moon );
200- return MinecraftForge .EVENT_BUS .post (registerEvent );
200+ MinecraftForge .EVENT_BUS .post (registerEvent );
201201 }
202202 if (object instanceof Satellite )
203203 {
204204 Satellite satellite = (Satellite ) object ;
205205 RegisterEvent registerEvent = new RegisterEvent (satellite , Loader .instance ().activeModContainer ());
206206 satellites .add (satellite );
207207 objects .add (satellite );
208- return MinecraftForge .EVENT_BUS .post (registerEvent );
208+ MinecraftForge .EVENT_BUS .post (registerEvent );
209209 }
210210 if (object instanceof CelestialBody )
211211 {
@@ -217,7 +217,7 @@ public static <T> boolean register(T object)
217217 }
218218 RegisterEvent registerEvent = new RegisterEvent (celestialType , Loader .instance ().activeModContainer ());
219219 objects .add (celestialType );
220- return MinecraftForge .EVENT_BUS .post (registerEvent );
220+ MinecraftForge .EVENT_BUS .post (registerEvent );
221221 }
222222 throw new GalacticraftRegistryException ("Unable to register " + object );
223223 }
@@ -233,6 +233,9 @@ public GalacticraftRegistryException(String message)
233233 }
234234 }
235235
236+ /**
237+ * Returns a read-only list containing all registered CelestialObjects
238+ */
236239 public static ImmutableCelestialList <CelestialObject > getAllRegisteredObjects ()
237240 {
238241 return ImmutableCelestialList .of (objects );
@@ -263,18 +266,21 @@ public static ImmutableCelestialList<Moon> getMoons()
263266 }
264267
265268 /**
266- * Returns a read-only list containing all registered Solar Systems
269+ * Returns a read-only list containing all registered Satellites
267270 */
268271 public static ImmutableCelestialList <Satellite > getSatellites ()
269272 {
270273 return ImmutableCelestialList .of (satellites );
271274 }
272275
276+ /**
277+ * Returns a read-only list containing all CelestialObjects that are reachable
278+ */
273279 public static ImmutableCelestialList <CelestialBody > getAllReachableBodies ()
274280 {//@noformat
275281 return ImmutableCelestialList .from (
276- planets .stream ().filter (CelestialBody .filterReachable ()).collect (Accumulators . celestialList ()),
277- moons .stream ().filter (CelestialBody .filterReachable ()).collect (Accumulators . celestialList ())
282+ planets .stream ().filter (CelestialBody .filterReachable ()).collect (CelestialCollector . toList ()),
283+ moons .stream ().filter (CelestialBody .filterReachable ()).collect (CelestialCollector . toList ())
278284 );
279285 }
280286
@@ -291,7 +297,7 @@ public static ImmutableCelestialList<CelestialObject> getCelestialObjectsFromMod
291297 */
292298 public static ImmutableCelestialList <CelestialObject > getCelestialObjectsFromMod (String modId )
293299 {
294- return objects .stream ().filter (CelestialObject .filter (modId )).collect (Accumulators . toImmutableCelestialList () );
300+ return objects .stream ().filter (CelestialObject .filter (modId )).collect (CelestialCollector . toList ()). toUnmodifiableList ( );
295301 }
296302
297303 public static String [] getAllTransltionKeys ()
@@ -318,7 +324,8 @@ public static CelestialBody getCelestialBodyFromUnlocalizedName(String unlocaliz
318324 @ ReplaceWith ("GalaxyRegistry.register(T object)" )
319325 public static boolean registerSolarSystem (SolarSystem solarSystem )
320326 {
321- return GalaxyRegistry .register (solarSystem );
327+ GalaxyRegistry .register (solarSystem );
328+ return solarSystems .contains (solarSystem );
322329 }
323330
324331 /**
@@ -328,7 +335,8 @@ public static boolean registerSolarSystem(SolarSystem solarSystem)
328335 @ ReplaceWith ("GalaxyRegistry.register(T object)" )
329336 public static boolean registerPlanet (Planet planet )
330337 {
331- return GalaxyRegistry .register (planet );
338+ GalaxyRegistry .register (planet );
339+ return planets .contains (planet );
332340 }
333341
334342 /**
@@ -338,7 +346,8 @@ public static boolean registerPlanet(Planet planet)
338346 @ ReplaceWith ("GalaxyRegistry.register(T object)" )
339347 public static boolean registerMoon (Moon moon )
340348 {
341- return GalaxyRegistry .register (moon );
349+ GalaxyRegistry .register (moon );
350+ return moons .contains (moon );
342351 }
343352
344353 /**
@@ -348,7 +357,8 @@ public static boolean registerMoon(Moon moon)
348357 @ ReplaceWith ("GalaxyRegistry.register(T object)" )
349358 public static boolean registerSatellite (Satellite satellite )
350359 {
351- return GalaxyRegistry .register (satellite );
360+ GalaxyRegistry .register (satellite );
361+ return satellites .contains (satellite );
352362 }
353363
354364 /**
0 commit comments