Forge 1.19

* Bump pack.mcmeta formats
* 1.19 biome modifiers
* Mark ClientPlayerNetworkEvent.LoggedOutEvent's getters as nullable
* Add docs and package-info to client extension interfaces package
* Move RenderBlockOverlayEvent hooks to ForgeHooksClient
* Add package-infos to client events package
* Rename SoundLoadEvent to SoundEngineLoadEvent

This reduces confusion from consumers which may think the
name SoundLoadEvent refers to an individual sound being loaded rather
than the sound engine.
* Document and change SoundLoadEvent to fire on mod bus

Previously, it fired on both the mod bus and the Forge bus, which is
confusing for consumers.
* Delete SoundSetupEvent

Looking at its original implementation shows that there isn't an
appropriate place in the new sound code to reinsert the event, and the
place of 'sound engine/manager initialization event' is taken already by SoundLoadEvent.
* Perform some cleanup on client events

 - Removed nullable annotations from ClientPlayerNetworkEvent
 - Renamed #getPartialTicks methods to #getPartialTick, to be consistent
  with vanilla's naming of the partial tick
 - Cleanup documentation to remove line breaks, use the
  spelling 'cancelled' over
  'canceled', and improve docs on existing and
   new methods.
* Remove EntityEvent.CanUpdate

Closes MinecraftForge/MinecraftForge#6394
* Switch to Jetbrains nullability annotations
* New PlayLevelSoundEvent; replaces old PlaySoundAtEntityEvent
* Remove ForgeWorldPresetScreens
* Remove IForgeRegistryEntry
* Remove use of List<Throwable> in FML's CompletableFutures
* Add docs to mod loading stages, stages, and phases
* Gradle 7.4.2
* Use SLF4J in FMLLoader and other subprojects
* Switch dynamic versions in subprojects to pinned ones
* Switch ForgeRoot and MDK to FG plugin markers
* Configure Forge javadoc task

The task now uses a custom stylesheet with MCForge elements, and
configured to combine the generation from the four FML subprojects
(fmlloader, fmlcore, javafmllanguage, mclanguage) and the Forge project
into the javadoc output.
* Update docs/md files, for 1.19 update and the move away from IRC to Discord.
* Make "Potentially dangerous alternative prefix" a debug warning, not info.

Co-authored-by: Curle <[email protected]>
Co-authored-by: sciwhiz12 <[email protected]>
Signed-off-by: SizableShrimp <[email protected]>
This commit is contained in:
committed 2022-06-07 15:31:26 -05:00
1 parent 270e778ac5
commit 4ed9117799
1485 files changed
+14960 -15446

No files matched your search

@@ -33,29 +33,6 @@ public final class RegistryObject<T> implements Supplier<T>
@Nullable
private Holder<T> holder;
/**
* @deprecated The uniqueness of registry super types will not be guaranteed starting in 1.19.
* Use {@link #create(ResourceLocation, ResourceLocation, String)}.
*/
@Deprecated(forRemoval = true, since = "1.18.2")
public static <T extends IForgeRegistryEntry<T>, U extends T> RegistryObject<U> of(final ResourceLocation name, Supplier<Class<? super T>> registryType) {
return new RegistryObject<>(name, registryType);
}
/**
* Factory for a {@link RegistryObject} that stores the value of an object from the provided forge registry once it is ready.
*
* @param name the name of the object to look up in the forge registry
* @param registry the forge registry
* @return a {@link RegistryObject} that stores the value of an object from the provided forge registry once it is ready
* @deprecated Use {@link #create(ResourceLocation, IForgeRegistry)} instead.
*/
@Deprecated(forRemoval = true, since = "1.18.2")
public static <T extends IForgeRegistryEntry<T>, U extends T> RegistryObject<U> of(final ResourceLocation name, IForgeRegistry<T> registry)
{
return new RegistryObject<>(name, registry);
}
/**
* Factory for a {@link RegistryObject} that stores the value of an object from the provided forge registry once it is ready.
*
@@ -63,39 +40,9 @@ public final class RegistryObject<T> implements Supplier<T>
* @param registry the forge registry
* @return a {@link RegistryObject} that stores the value of an object from the provided forge registry once it is ready
*/
public static <T extends IForgeRegistryEntry<T>, U extends T> RegistryObject<U> create(final ResourceLocation name, IForgeRegistry<T> registry)
public static <T, U extends T> RegistryObject<U> create(final ResourceLocation name, IForgeRegistry<T> registry)
{
return new RegistryObject<>(name, registry);
}
/**
* @deprecated The uniqueness of registry super types will not be guaranteed starting in 1.19.
* Use {@link #create(ResourceLocation, ResourceLocation, String)}.
*/
@Deprecated(forRemoval = true, since = "1.18.2")
public static <T extends IForgeRegistryEntry<T>, U extends T> RegistryObject<U> of(final ResourceLocation name, final Class<T> baseType, String modid) {
return new RegistryObject<>(name, baseType, modid);
}
/**
* Factory for a {@link RegistryObject} that stores the value of an object from a registry once it is ready based on a lookup of the provided registry key.
* <p>
* If a registry with the given key cannot be found, an exception will be thrown when trying to fill this RegistryObject.
* Use {@link #createOptional(ResourceLocation, ResourceKey, String)} for RegistryObjects of optional registries.
*
* @param name the name of the object to look up in a registry
* @param registryKey the key of the registry. Supports lookups on {@link BuiltinRegistries}, {@link Registry}, and {@link RegistryManager#ACTIVE}.
* @param modid the mod id calling context
* @return a {@link RegistryObject} that stores the value of an object from a registry once it is ready
* @see #createOptional(ResourceLocation, ResourceKey, String)
* @see #create(ResourceLocation, IForgeRegistry)
* @see #create(ResourceLocation, ResourceLocation, String)
* @deprecated Use {@link #create(ResourceLocation, ResourceKey, String)} instead.
*/
@Deprecated(forRemoval = true, since = "1.18.2")
public static <T, U extends T> RegistryObject<U> of(final ResourceLocation name, final ResourceKey<? extends Registry<T>> registryKey, String modid)
{
return new RegistryObject<>(name, registryKey.location(), modid, false);
return new RegistryObject<U>(name, registry);
}
/**
@@ -138,27 +85,6 @@ public final class RegistryObject<T> implements Supplier<T>
return new RegistryObject<>(name, registryKey.location(), modid, true);
}
/**
* Factory for a {@link RegistryObject} that stores the value of an object from a registry once it is ready based on a lookup of the provided registry name.
* <p>
* If a registry with the given name cannot be found, an exception will be thrown when trying to fill this RegistryObject.
* Use {@link #createOptional(ResourceLocation, ResourceLocation, String)} for RegistryObjects of optional registries.
*
* @param name the name of the object to look up in a registry
* @param registryName the name of the registry. Supports lookups on {@link BuiltinRegistries}, {@link Registry}, and {@link RegistryManager#ACTIVE}.
* @param modid the mod id calling context
* @return a {@link RegistryObject} that stores the value of an object from a registry once it is ready
* @see #createOptional(ResourceLocation, ResourceLocation, String)
* @see #create(ResourceLocation, IForgeRegistry)
* @see #create(ResourceLocation, ResourceKey, String)
* @deprecated Use {@link #create(ResourceLocation, ResourceLocation, String)} instead.
*/
@Deprecated(forRemoval = true, since = "1.18.2")
public static <T, U extends T> RegistryObject<U> of(final ResourceLocation name, final ResourceLocation registryName, String modid)
{
return new RegistryObject<>(name, registryName, modid, false);
}
/**
* Factory for a {@link RegistryObject} that stores the value of an object from a registry once it is ready based on a lookup of the provided registry name.
* <p>
@@ -208,66 +134,24 @@ public final class RegistryObject<T> implements Supplier<T>
private RegistryObject() {
this.name = null;
this.key = null;
this.optionalRegistry = false;
}
@Deprecated(forRemoval = true, since = "1.18.2")
private <V extends IForgeRegistryEntry<V>> RegistryObject(ResourceLocation name, Supplier<Class<? super V>> registryType)
{
this(name, RegistryManager.ACTIVE.<V>getRegistry(registryType.get()));
}
@SuppressWarnings("unchecked")
private <V extends IForgeRegistryEntry<V>> RegistryObject(ResourceLocation name, IForgeRegistry<V> registry)
private RegistryObject(ResourceLocation name, IForgeRegistry<?> registry)
{
if (registry == null)
throw new IllegalArgumentException("Invalid registry argument, must not be null");
this.name = name;
this.key = (ResourceKey<T>) ResourceKey.create(registry.getRegistryKey(), name);
this.optionalRegistry = false;
ObjectHolderRegistry.addHandler(pred ->
{
if (pred.test(registry.getRegistryName()))
this.updateReference((IForgeRegistry<? extends T>) registry);
});
this.updateReference(((IForgeRegistry<? extends T>) registry));
}
@SuppressWarnings("unchecked")
@Deprecated(forRemoval = true, since = "1.18.2")
private <V extends IForgeRegistryEntry<V>> RegistryObject(final ResourceLocation name, final Class<V> baseType, final String modid)
{
this.name = name;
this.optionalRegistry = false;
final Throwable callerStack = new Throwable("Calling Site from mod: " + modid);
ObjectHolderRegistry.addHandler(new Consumer<Predicate<ResourceLocation>>()
{
private IForgeRegistry<V> registry;
private boolean invalidRegistry = false;
@Override
public void accept(Predicate<ResourceLocation> pred)
{
if (invalidRegistry)
return;
if (registry == null)
{
this.registry = RegistryManager.ACTIVE.getRegistry(baseType);
if (registry == null)
{
invalidRegistry = true;
throw new IllegalStateException("Unable to find registry for type " + baseType.getName() + " for mod \"" + modid + "\". Check the 'caused by' to see further stack.", callerStack);
}
}
if (pred.test(registry.getRegistryName()))
RegistryObject.this.updateReference((IForgeRegistry<? extends T>) registry);
}
});
IForgeRegistry<V> registry = RegistryManager.ACTIVE.getRegistry(baseType);
// allow registry to be null, this might be for a custom registry that does not exist yet
if (registry != null)
{
this.updateReference(((IForgeRegistry<? extends T>) registry));
}
this.updateReference((IForgeRegistry<? extends T>) registry);
}
private RegistryObject(final ResourceLocation name, final ResourceLocation registryName, final String modid, boolean optionalRegistry)
@@ -322,16 +206,13 @@ public final class RegistryObject<T> implements Supplier<T>
}
@SuppressWarnings("unchecked")
@Deprecated(since = "1.18.1") // TODO: make package-private
public void updateReference(IForgeRegistry<? extends T> registry)
void updateReference(IForgeRegistry<? extends T> registry)
{
if (this.name == null)
if (this.name == null || this.key == null)
return;
if (registry.containsKey(this.name))
{
this.value = registry.getValue(this.name);
if (this.key == null)
this.key = (ResourceKey<T>) ResourceKey.create(registry.getRegistryKey(), this.name);
this.holder = (Holder<T>) registry.getHolder(this.name).orElse(null);
}
else
@@ -344,13 +225,11 @@ public final class RegistryObject<T> implements Supplier<T>
@SuppressWarnings("unchecked")
void updateReference(Registry<? extends T> registry)
{
if (this.name == null)
if (this.name == null || this.key == null)
return;
if (registry.containsKey(this.name))
{
this.value = registry.get(this.name);
if (this.key == null)
this.key = (ResourceKey<T>) ResourceKey.create(registry.key(), this.name);
this.holder = ((Registry<T>) registry).getHolder(this.key).orElse(null);
}
else
@@ -390,6 +269,22 @@ public final class RegistryObject<T> implements Supplier<T>
this.holder = null;
}
void updateReference(RegisterEvent event)
{
IForgeRegistry<? extends T> forgeRegistry = event.getForgeRegistry();
if (forgeRegistry != null)
{
updateReference(forgeRegistry);
return;
}
Registry<? extends T> vanillaRegistry = event.getVanillaRegistry();
if (vanillaRegistry != null)
updateReference(vanillaRegistry);
else
this.value = null;
}
private static boolean registryExists(ResourceLocation registryName)
{
return RegistryManager.ACTIVE.getRegistry(registryName) != null
@@ -404,7 +299,7 @@ public final class RegistryObject<T> implements Supplier<T>
/**
* Returns the resource key that points to the registry and name of this registry object.
* Nullable only when the deprecated factories {@link #of(ResourceLocation, Class, String)} or {@link #of(ResourceLocation, Supplier)} are used.
* Nullable only if this RegistryObject is empty and has no name.
*
* @return the resource key that points to the registry and name of this registry object
*/
@@ -584,9 +479,7 @@ public final class RegistryObject<T> implements Supplier<T>
* This should <b>only</b> be used in cases where vanilla code requires passing in a Holder.
* Mod-written code should rely on RegistryObjects or Suppliers instead.
* <p>
* The returned optional will be empty if the registry does not exist
* or if the deprecated factories {@link #of(ResourceLocation, Class, String)}
* or {@link #of(ResourceLocation, Supplier)} are used.
* The returned optional will be empty if the registry does not exist.
* Otherwise, the optional Holder will be present even if {@link #isPresent()} returns false.
*
* @return an optional {@link Holder} instance pointing to this RegistryObject's name and value
@@ -603,7 +496,7 @@ public final class RegistryObject<T> implements Supplier<T>
registry = (Registry<T>) BuiltinRegistries.REGISTRY.get(registryName);
if (registry != null)
this.holder = registry.getOrCreateHolder(this.key);
this.holder = registry.getOrCreateHolder(this.key).result().get();
}
return Optional.ofNullable(this.holder);