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

@@ -7,58 +7,43 @@ package net.minecraftforge.registries;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Collections;
import java.util.LinkedList;
import java.util.Locale;
import java.util.Queue;
import java.util.function.Consumer;
import java.util.function.Predicate;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.ResourceLocationException;
import javax.annotation.Nullable;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.Nullable;
@SuppressWarnings("rawtypes")
class ObjectHolderRef implements Consumer<Predicate<ResourceLocation>>
{
private static final Logger LOGGER = LogManager.getLogger();
private Field field;
private ResourceLocation injectedObject;
private boolean isValid;
private ForgeRegistry<?> registry;
private final Field field;
private final ResourceLocation injectedObject;
private final ForgeRegistry<?> registry;
public ObjectHolderRef(Field field, ResourceLocation injectedObject)
@SuppressWarnings("unchecked")
@Nullable
static ObjectHolderRef create(ResourceLocation registryName, Field field, String injectedObject, boolean extractFromExistingValues)
{
this(field, injectedObject.toString(), false);
}
ObjectHolderRef(Field field, String injectedObject, boolean extractFromExistingValues)
{
this.registry = getRegistryForType(field);
this.field = field;
this.isValid = registry != null;
ForgeRegistry<?> registry = RegistryManager.ACTIVE.getRegistry(registryName);
if (registry == null)
return null;
ResourceLocation injectedObjectName;
if (extractFromExistingValues)
{
try
{
Object existing = field.get(null);
// nothing is ever allowed to replace AIR
if (!isValid || (existing == null || existing == registry.getDefault()))
{
this.injectedObject = null;
this.field = null;
this.isValid = false;
return;
}
else
{
this.injectedObject = ((IForgeRegistryEntry)existing).getRegistryName();
}
// Nothing is ever allowed to replace AIR
if (existing == null || existing == registry.getDefault())
return null;
injectedObjectName = ((ForgeRegistry) registry).getKey(existing);
}
catch (IllegalAccessException e)
{
@@ -69,7 +54,7 @@ class ObjectHolderRef implements Consumer<Predicate<ResourceLocation>>
{
try
{
this.injectedObject = new ResourceLocation(injectedObject);
injectedObjectName = new ResourceLocation(injectedObject);
}
catch (ResourceLocationException e)
{
@@ -77,10 +62,8 @@ class ObjectHolderRef implements Consumer<Predicate<ResourceLocation>>
}
}
if (this.injectedObject == null || !isValid())
{
throw new IllegalStateException(String.format(Locale.ENGLISH, "The ObjectHolder annotation cannot apply to a field that does not map to a registry. Ensure the registry was created during the RegistryEvent.NewRegistry event. (found : %s at %s.%s)", field.getType().getName(), field.getDeclaringClass().getName(), field.getName()));
}
if (injectedObjectName == null)
throw new IllegalStateException(String.format(Locale.ENGLISH, "The ObjectHolder annotation cannot apply to a field that does not map to a registry. Ensure the registry was created during NewRegistryEvent. (found : %s at %s.%s)", field.getType().getName(), field.getDeclaringClass().getName(), field.getName()));
field.setAccessible(true);
@@ -88,36 +71,15 @@ class ObjectHolderRef implements Consumer<Predicate<ResourceLocation>>
{
throw new RuntimeException("@ObjectHolder on final field, our transformer did not run? " + field.getDeclaringClass().getName() + "/" + field.getName());
}
return new ObjectHolderRef(registry, field, injectedObjectName);
}
@SuppressWarnings("unchecked")
@Nullable
private ForgeRegistry<?> getRegistryForType(Field field)
private ObjectHolderRef(ForgeRegistry<?> registry, Field field, ResourceLocation injectedObject)
{
Queue<Class<?>> typesToExamine = new LinkedList<Class<?>>();
typesToExamine.add(field.getType());
ForgeRegistry<?> registry = null;
while (!typesToExamine.isEmpty() && registry == null)
{
Class<?> type = typesToExamine.remove();
Collections.addAll(typesToExamine, type.getInterfaces());
if (IForgeRegistryEntry.class.isAssignableFrom(type))
{
registry = (ForgeRegistry<?>)RegistryManager.ACTIVE.getRegistry((Class<IForgeRegistryEntry>)type);
final Class<?> parentType = type.getSuperclass();
if (parentType != null)
{
typesToExamine.add(parentType);
}
}
}
return registry;
}
public boolean isValid()
{
return isValid;
this.registry = registry;
this.field = field;
this.injectedObject = injectedObject;
}
@Override
@@ -127,7 +89,7 @@ class ObjectHolderRef implements Consumer<Predicate<ResourceLocation>>
return;
Object thing;
if (isValid && registry.containsKey(injectedObject) && !registry.isDummied(injectedObject))
if (registry.containsKey(injectedObject) && !registry.isDummied(injectedObject))
{
thing = registry.getValue(injectedObject);
}