Forge 1.19.3

Created a CreativeModeTabEvent to register creative mode tabs and populate entries per tab
Moved datapack registries to DataPackRegistryEvent.NewRegistry event instead of tying them to ForgeRegistry
Made it easier for mods to datagen datapack builtin entries with DatapackBuiltinEntriesProvider
Provided access to lookupProvider for datagen
Updated dependencies to match versions used by vanilla and update JarJar to 0.3.18
Added a test mod for the new CreativeModeTabEvent
Throws better error message for Forge registries in tag datagen
Deleted ForgeRegistryTagsProvider
Updated ClientChatReceivedEvent and ServerChatEvent for Mojang changes
Added patches for both sign related methods in ModelLayers
Changed RegisterShadersEvent to use ResourceProvider
Migrated old Mojang math types to JOML

Co-authored-by: Marc Hermans <[email protected]>
Co-authored-by: LexManos <[email protected]>
Co-authored-by: sciwhiz12 <[email protected]>
Co-authored-by: coehlrich <[email protected]>
This commit is contained in:
committed 2022-12-08 01:45:22 -06:00
1 parent 617ecb7ad3
commit 8255d7aed3
726 files changed
+7615 -6653

No files matched your search

@@ -5,24 +5,21 @@
package net.minecraftforge.registries;
import com.google.common.collect.Lists;
import net.minecraft.core.Holder;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.registries.IForgeRegistry.AddCallback;
import net.minecraftforge.registries.IForgeRegistry.BakeCallback;
import net.minecraftforge.registries.IForgeRegistry.ClearCallback;
import net.minecraftforge.registries.IForgeRegistry.CreateCallback;
import net.minecraftforge.registries.IForgeRegistry.DummyFactory;
import net.minecraftforge.registries.IForgeRegistry.MissingFactory;
import net.minecraftforge.registries.IForgeRegistry.ValidateCallback;
import org.jetbrains.annotations.Nullable;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
import java.util.function.Supplier;
import com.google.common.base.Suppliers;
import com.google.common.collect.Lists;
import com.mojang.serialization.Codec;
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.registries.IForgeRegistry.*;
import org.jetbrains.annotations.Nullable;
public class RegistryBuilder<T>
{
@@ -37,16 +34,16 @@ public class RegistryBuilder<T>
private List<CreateCallback<T>> createCallback = Lists.newArrayList();
private List<ValidateCallback<T>> validateCallback = Lists.newArrayList();
private List<BakeCallback<T>> bakeCallback = Lists.newArrayList();
private Function<T, Holder.Reference<T>> vanillaHolder;
private boolean saveToDisc = true;
private boolean sync = true;
private boolean allowOverrides = true;
private boolean allowModifications = false;
private boolean hasWrapper = false;
private Supplier<RegistryAccess.RegistryData<T>> dataPackRegistryData = () -> null; // If present, implies this is a datapack registry.
private DummyFactory<T> dummyFactory;
private MissingFactory<T> missingFactory;
private Set<ResourceLocation> legacyNames = new HashSet<>();
@Nullable
private Function<T, Holder.Reference<T>> intrusiveHolderCallback = null;
public RegistryBuilder<T> setName(ResourceLocation name)
{
@@ -176,8 +173,8 @@ public class RegistryBuilder<T>
}
/**
* Prevents the registry from being synced to clients. Does *not* affect datapack registries, datapack registries are unsynced by default
* unless a non-null network codec is registered via {@link #dataPackRegistry(Codec, Codec)}
* Prevents the registry from being synced to clients.
*
* @return this
*/
public RegistryBuilder<T> disableSync()
@@ -215,9 +212,9 @@ public class RegistryBuilder<T>
return this;
}
RegistryBuilder<T> vanillaHolder(Function<T, Holder.Reference<T>> func)
RegistryBuilder<T> intrusiveHolderCallback(Function<T, Holder.Reference<T>> intrusiveHolderCallback)
{
this.vanillaHolder = func;
this.intrusiveHolderCallback = intrusiveHolderCallback;
return this;
}
@@ -235,66 +232,6 @@ public class RegistryBuilder<T>
return this;
}
/**
* <p>Register this registry as an unsynced datapack registry, which will cause data to be loaded from
* a datapack folder based on the registry's name. The mod that registers this registry does not need to exist
* on the client to connect to servers with the mod/registry.</p>
* <p>Data JSONs will be loaded from {@code data/<datapack_namespace>/modid/registryname/}, where modid is the mod that registered this registry.</p>
*
* @param codec the codec to be used for loading data from datapacks on servers
* @return this builder
*
* @see #dataPackRegistry(Codec, Codec)
*/
public RegistryBuilder<T> dataPackRegistry(Codec<T> codec)
{
return this.dataPackRegistry(codec, null);
}
/**
* <p>Register this registry as a datapack registry, which will cause data to be loaded from
* a datapack folder based on the registry's name.</p>
* <p>Data JSONs will be loaded from {@code data/<datapack_namespace>/modid/registryname/}, where modid is the mod that registered this registry.</p>
*
* @param codec the codec to be used for loading data from datapacks on servers
* @param networkCodec the codec to be used for syncing loaded data to clients.<br>
* If networkCodec is null, data will not be synced, and clients without the mod that registered this registry can
* connect to servers with the mod.<br>
* If networkCodec is not null, then data will be synced (accessible via {@link ClientPacketListener#registryAccess()}),
* and the mod must be present on a client to connect to servers with the mod.
* @return this builder
*
* @see #dataPackRegistry(Codec)
*/
public RegistryBuilder<T> dataPackRegistry(Codec<T> codec, @Nullable Codec<T> networkCodec)
{
this.hasWrapper(); // A wrapper is required for data pack registries.
this.disableSync(); // Datapack registries are synced using a different system than static registries.
// Supplier averts having to set the registry name before calling this.
this.dataPackRegistryData = Suppliers.memoize(() -> {
// Validate registry key.
if (this.registryName == null)
throw new IllegalStateException("Registry builder cannot build a datapack registry: registry name not set");
ResourceKey<Registry<T>> registryKey = ResourceKey.createRegistryKey(this.registryName);
return new RegistryAccess.RegistryData<>(registryKey, codec, networkCodec);
});
return this;
}
/**
* Retrieves datapack registry information, if any.
*
* @return RegistryData containing the registry's key and codec(s). If returned data is null, this has not been marked as a datapack registry.
*
* @throws IllegalStateException if this has been marked as a datapack registry, but registry name has not been set.
*/
@Nullable
RegistryAccess.RegistryData<T> getDataPackRegistryData()
{
return this.dataPackRegistryData.get();
}
/**
* Modders: Use {@link NewRegistryEvent#create(RegistryBuilder)} instead
*/
@@ -438,9 +375,9 @@ public class RegistryBuilder<T>
return legacyNames;
}
Function<T, Holder.Reference<T>> getVanillaHolder()
Function<T, Holder.Reference<T>> getIntrusiveHolderCallback()
{
return this.vanillaHolder;
return this.intrusiveHolderCallback;
}
boolean getHasWrapper()