mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 11:29:15 +00:00
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:
1 parent
270e778ac5
commit
4ed9117799
1485 files changed
+14960
-15446
No files matched your search
@@ -10,15 +10,12 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.collect.Sets.SetView;
|
||||
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
import net.minecraft.core.WritableRegistry;
|
||||
@@ -26,7 +23,7 @@ import net.minecraft.data.BuiltinRegistries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraftforge.fml.IModStateTransition;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
import net.minecraftforge.network.HandshakeMessages;
|
||||
import net.minecraftforge.registries.ForgeRegistry.Snapshot;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -41,8 +38,7 @@ public class RegistryManager
|
||||
public static final RegistryManager FROZEN = new RegistryManager("FROZEN");
|
||||
private static Set<ResourceLocation> vanillaRegistryKeys = Set.of();
|
||||
|
||||
BiMap<ResourceLocation, ForgeRegistry<? extends IForgeRegistryEntry<?>>> registries = HashBiMap.create();
|
||||
private BiMap<Class<? extends IForgeRegistryEntry<?>>, ResourceLocation> superTypes = HashBiMap.create();
|
||||
BiMap<ResourceLocation, ForgeRegistry<?>> registries = HashBiMap.create();
|
||||
private Set<ResourceLocation> persisted = Sets.newHashSet();
|
||||
private Set<ResourceLocation> synced = Sets.newHashSet();
|
||||
private Map<ResourceLocation, ResourceLocation> legacyNames = new HashMap<>();
|
||||
@@ -69,39 +65,22 @@ public class RegistryManager
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <V extends IForgeRegistryEntry<V>> Class<V> getSuperType(ResourceLocation key)
|
||||
{
|
||||
return (Class<V>)superTypes.inverse().get(key);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <V extends IForgeRegistryEntry<V>> ForgeRegistry<V> getRegistry(ResourceLocation key)
|
||||
public <V> ForgeRegistry<V> getRegistry(ResourceLocation key)
|
||||
{
|
||||
return (ForgeRegistry<V>)this.registries.get(key);
|
||||
}
|
||||
|
||||
public <V extends IForgeRegistryEntry<V>> ForgeRegistry<V> getRegistry(ResourceKey<? extends Registry<V>> key)
|
||||
public <V> ForgeRegistry<V> getRegistry(ResourceKey<? extends Registry<V>> key)
|
||||
{
|
||||
return getRegistry(key.location());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #getRegistry(ResourceLocation)
|
||||
* @see #getRegistry(ResourceKey)
|
||||
* @deprecated The uniqueness of registry super types will not be guaranteed starting in 1.19.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.18.2")
|
||||
public <V extends IForgeRegistryEntry<V>> IForgeRegistry<V> getRegistry(Class<? super V> cls)
|
||||
{
|
||||
return getRegistry(superTypes.get(cls));
|
||||
}
|
||||
|
||||
public <V extends IForgeRegistryEntry<V>> ResourceLocation getName(IForgeRegistry<V> reg)
|
||||
public <V> ResourceLocation getName(IForgeRegistry<V> reg)
|
||||
{
|
||||
return this.registries.inverse().get(reg);
|
||||
}
|
||||
|
||||
public <V extends IForgeRegistryEntry<V>> ResourceLocation updateLegacyName(ResourceLocation legacyName)
|
||||
public <V> ResourceLocation updateLegacyName(ResourceLocation legacyName)
|
||||
{
|
||||
ResourceLocation originalName = legacyName;
|
||||
while (getRegistry(legacyName) == null)
|
||||
@@ -115,7 +94,7 @@ public class RegistryManager
|
||||
return legacyName;
|
||||
}
|
||||
|
||||
public <V extends IForgeRegistryEntry<V>> ForgeRegistry<V> getRegistry(ResourceLocation key, RegistryManager other)
|
||||
public <V> ForgeRegistry<V> getRegistry(ResourceLocation key, RegistryManager other)
|
||||
{
|
||||
if (!this.registries.containsKey(key))
|
||||
{
|
||||
@@ -123,7 +102,6 @@ public class RegistryManager
|
||||
if (ot == null)
|
||||
return null;
|
||||
this.registries.put(key, ot.copy(this));
|
||||
this.superTypes.put(ot.getRegistrySuperType(), key);
|
||||
if (other.persisted.contains(key))
|
||||
this.persisted.add(key);
|
||||
if (other.synced.contains(key))
|
||||
@@ -135,24 +113,12 @@ public class RegistryManager
|
||||
return getRegistry(key);
|
||||
}
|
||||
|
||||
<V extends IForgeRegistryEntry<V>> ForgeRegistry<V> createRegistry(ResourceLocation name, RegistryBuilder<V> builder)
|
||||
<V> ForgeRegistry<V> createRegistry(ResourceLocation name, RegistryBuilder<V> builder)
|
||||
{
|
||||
Set<Class<?>> parents = Sets.newHashSet();
|
||||
findSuperTypes(builder.getType(), parents);
|
||||
SetView<Class<?>> overlappedTypes = Sets.intersection(parents, superTypes.keySet());
|
||||
if (!overlappedTypes.isEmpty())
|
||||
{
|
||||
Class<?> foundType = overlappedTypes.iterator().next();
|
||||
LOGGER.error("Found existing registry of type {} named {}, you cannot create a new registry ({}) with type {}, as {} has a parent of that type",
|
||||
foundType, superTypes.get(foundType), name, builder.getType(), builder.getType());
|
||||
throw new IllegalArgumentException("Duplicate registry parent type found - you can only have one registry for a particular super type");
|
||||
}
|
||||
if (registries.containsKey(name))
|
||||
throw new IllegalArgumentException("Attempted to register a registry for " + name + " with type "
|
||||
+ builder.getType().getName() + " but it already exists as " + registries.get(name).getRegistrySuperType().getName());
|
||||
throw new IllegalArgumentException("Attempted to register a registry for " + name + " but it already exists");
|
||||
ForgeRegistry<V> reg = new ForgeRegistry<V>(this, name, builder);
|
||||
registries.put(name, reg);
|
||||
superTypes.put(builder.getType(), name);
|
||||
if (builder.getSaveToDisc())
|
||||
this.persisted.add(name);
|
||||
if (builder.getSync())
|
||||
@@ -162,18 +128,18 @@ public class RegistryManager
|
||||
return getRegistry(name);
|
||||
}
|
||||
|
||||
static <V extends IForgeRegistryEntry<V>> void registerToRootRegistry(ForgeRegistry<V> forgeReg)
|
||||
static <V> void registerToRootRegistry(ForgeRegistry<V> forgeReg)
|
||||
{
|
||||
injectForgeRegistry(forgeReg, Registry.REGISTRY);
|
||||
}
|
||||
|
||||
static <V extends IForgeRegistryEntry<V>> void registerToBuiltinRegistry(ForgeRegistry<V> forgeReg)
|
||||
static <V> void registerToBuiltinRegistry(ForgeRegistry<V> forgeReg)
|
||||
{
|
||||
injectForgeRegistry(forgeReg, BuiltinRegistries.REGISTRY);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <V extends IForgeRegistryEntry<V>> void injectForgeRegistry(ForgeRegistry<V> forgeReg, Registry<? extends Registry<?>> rootRegistry)
|
||||
private static <V> void injectForgeRegistry(ForgeRegistry<V> forgeReg, Registry<? extends Registry<?>> rootRegistry)
|
||||
{
|
||||
WritableRegistry<Registry<V>> registry = (WritableRegistry<Registry<V>>) rootRegistry;
|
||||
Registry<V> wrapper = forgeReg.getWrapper();
|
||||
@@ -181,25 +147,14 @@ public class RegistryManager
|
||||
registry.register(forgeReg.getRegistryKey(), wrapper, Lifecycle.experimental());
|
||||
}
|
||||
|
||||
public static IModStateTransition.EventGenerator<NewRegistryEvent> newRegistryEventGenerator()
|
||||
public static void postNewRegistryEvent()
|
||||
{
|
||||
NewRegistryEvent event = new NewRegistryEvent();
|
||||
return mc -> event;
|
||||
}
|
||||
vanillaRegistryKeys = Set.copyOf(Registry.REGISTRY.keySet());
|
||||
|
||||
ModLoader.get().postEvent(event);
|
||||
|
||||
public static CompletableFuture<List<Throwable>> preNewRegistryEvent(final Executor executor,
|
||||
final IModStateTransition.EventGenerator<? extends NewRegistryEvent> eventGenerator)
|
||||
{
|
||||
return CompletableFuture.runAsync(() -> vanillaRegistryKeys = Set.copyOf(Registry.REGISTRY.keySet()), executor)
|
||||
.handle((v, t) -> t != null ? Collections.singletonList(t) : Collections.emptyList());
|
||||
}
|
||||
|
||||
public static CompletableFuture<List<Throwable>> postNewRegistryEvent(final Executor executor,
|
||||
final IModStateTransition.EventGenerator<? extends NewRegistryEvent> eventGenerator)
|
||||
{
|
||||
return CompletableFuture.runAsync(() -> eventGenerator.apply(null).fill(), executor)
|
||||
.handle((v, t) -> t != null ? Collections.singletonList(t) : Collections.emptyList());
|
||||
event.fill();
|
||||
}
|
||||
|
||||
private void addLegacyName(ResourceLocation legacyName, ResourceLocation name)
|
||||
@@ -239,7 +194,6 @@ public class RegistryManager
|
||||
this.persisted.clear();
|
||||
this.synced.clear();
|
||||
this.registries.clear();
|
||||
this.superTypes.clear();
|
||||
}
|
||||
|
||||
public static List<Pair<String, HandshakeMessages.S2CRegistry>> generateRegistryPackets(boolean isLocal)
|
||||
|
||||
Reference in new issue
Block a user