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

@@ -22,31 +22,31 @@ import net.minecraft.world.item.Items;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.InteractionHand;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.extensions.IForgeMenuType;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.network.NetworkHooks;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.ObjectHolder;
import net.minecraftforge.registries.RegisterEvent;
@Mod("containertypetest")
public class ContainerTypeTest
{
@ObjectHolder("containertypetest:container")
@ObjectHolder(registryName = "menu", value = "containertypetest:container")
public static final MenuType<TestContainer> TYPE = null;
public class TestContainer extends AbstractContainerMenu
{
private final String text;
protected TestContainer(int windowId, Inventory playerInv, FriendlyByteBuf extraData)
{
this(windowId, new SimpleContainer(9), extraData.readUtf(128));
}
public TestContainer(int windowId, SimpleContainer inv, String text)
{
super(TYPE, windowId);
@@ -57,13 +57,19 @@ public class ContainerTypeTest
}
}
@Override
public ItemStack quickMoveStack(Player p_38941_, int p_38942_)
{
return ItemStack.EMPTY;
}
@Override
public boolean stillValid(Player playerIn)
{
return true;
}
}
public class TestGui extends AbstractContainerScreen<TestContainer>
{
public TestGui(TestContainer container, Inventory inv, Component name)
@@ -80,21 +86,21 @@ public class ContainerTypeTest
public ContainerTypeTest()
{
FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(MenuType.class, this::registerContainers);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::registerContainers);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
MinecraftForge.EVENT_BUS.addListener(this::onRightClick);
}
private void registerContainers(final RegistryEvent.Register<MenuType<?>> event)
private void registerContainers(final RegisterEvent event)
{
event.getRegistry().register(IForgeMenuType.create(TestContainer::new).setRegistryName("container"));
event.register(ForgeRegistries.Keys.CONTAINER_TYPES, helper -> helper.register("container", IForgeMenuType.create(TestContainer::new)));
}
private void setup(FMLClientSetupEvent event)
{
MenuScreens.register(TYPE, TestGui::new);
}
private void onRightClick(PlayerInteractEvent.RightClickBlock event)
{
if (!event.getWorld().isClientSide && event.getHand() == InteractionHand.MAIN_HAND)
@@ -114,11 +120,11 @@ public class ContainerTypeTest
}
return new TestContainer(p_createMenu_1_, inv, text);
}
@Override
public Component getDisplayName()
{
return new TextComponent("Test");
return Component.literal("Test");
}
}, extraData -> {
extraData.writeUtf(text);
@@ -9,6 +9,7 @@ import java.io.IOException;
import java.nio.file.Path;
import java.util.Locale;
import net.minecraft.data.CachedOutput;
import org.slf4j.Logger;
import com.google.gson.Gson;
@@ -42,7 +43,6 @@ import net.minecraftforge.fml.loading.FMLEnvironment;
import net.minecraftforge.fml.util.thread.EffectiveSide;
import net.minecraftforge.forge.event.lifecycle.GatherDataEvent;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistryEntry;
import net.minecraftforge.registries.RegistryBuilder;
import net.minecraftforge.registries.RegistryObject;
@@ -65,7 +65,7 @@ public class DataPackRegistriesTest
public static final String MODID = "data_pack_registries_test";
private static final Logger LOGGER = LogUtils.getLogger();
private static final ResourceLocation TEST_RL = new ResourceLocation(MODID, "test");
private final RegistryObject<Unsyncable> datagenTestObject;
public DataPackRegistriesTest()
@@ -75,40 +75,36 @@ public class DataPackRegistriesTest
final IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus();
final IEventBus forgeBus = MinecraftForge.EVENT_BUS;
// Deferred Registers can be created for datapack registries in static init or mod constructor.
// (We'll do it in mod constructor, as when doing the ENABLED check it's less verbose than static init.)
// As with static registries, any mod can make a Deferred Register for a given datapack registry,
// but only one mod can register the internal registry with makeRegistry.
final DeferredRegister<Unsyncable> unsyncables = DeferredRegister.create(Unsyncable.REGISTRY_KEY, MODID);
final DeferredRegister<Syncable> syncables = DeferredRegister.create(Syncable.REGISTRY_KEY, MODID);
// RegistryBuilder#dataPackRegistry marks the registry as a datapack registry rather than a static registry.
unsyncables.makeRegistry(Unsyncable.class,
() -> new RegistryBuilder<Unsyncable>().disableSaving().dataPackRegistry(Unsyncable.DIRECT_CODEC));
unsyncables.makeRegistry(() -> new RegistryBuilder<Unsyncable>().disableSaving().dataPackRegistry(Unsyncable.DIRECT_CODEC));
// The overload of #dataPackRegistry that takes a second codec marks the datapack registry as syncable.
syncables.makeRegistry(Syncable.class,
() -> new RegistryBuilder<Syncable>().disableSaving().dataPackRegistry(Syncable.DIRECT_CODEC, Syncable.DIRECT_CODEC));
syncables.makeRegistry(() -> new RegistryBuilder<Syncable>().disableSaving().dataPackRegistry(Syncable.DIRECT_CODEC, Syncable.DIRECT_CODEC));
// Datapack registry elements can be datagenerated, but they must be registered as builtin objects first.
this.datagenTestObject = unsyncables.register("datagen_test", () -> new Unsyncable("Datagen Success"));
unsyncables.register(modBus);
syncables.register(modBus);
modBus.addListener(this::onGatherData);
forgeBus.addListener(this::onServerStarting);
if (FMLEnvironment.dist == Dist.CLIENT)
{
ClientEvents.subscribeClientEvents();
}
}
private void onGatherData(final GatherDataEvent event)
{
if (!event.includeServer())
return;
// Example of how to datagen datapack registry objects.
// Objects to be datagenerated must be registered (e.g. via DeferredRegister above).
// This outputs to data/data_pack_registries_test/data_pack_registries_test/unsyncable/datagen_test.json
@@ -121,10 +117,11 @@ public class DataPackRegistriesTest
final Unsyncable element = this.datagenTestObject.get();
final String pathString = String.join("/", PackType.SERVER_DATA.getDirectory(), id.getNamespace(), registryId.getNamespace(), registryId.getPath(), id.getPath()+".json");
final Path path = outputFolder.resolve(pathString);
generator.addProvider(new DataProvider()
generator.addProvider(event.includeServer(), new DataProvider()
{
@Override
public void run(final HashCache cache) throws IOException
public void run(final CachedOutput cache) throws IOException
{
Unsyncable.DIRECT_CODEC.encodeStart(ops, element)
.resultOrPartial(msg -> LOGGER.error("Failed to encode {}: {}", path, msg)) // Log error on encode failure.
@@ -132,7 +129,7 @@ public class DataPackRegistriesTest
{
try
{
DataProvider.save(gson, cache, json, path);
DataProvider.saveStable(cache, json, path);
}
catch (IOException e) // The throws can't deal with this exception, because we're inside the ifPresent.
{
@@ -148,7 +145,7 @@ public class DataPackRegistriesTest
}
});
}
private void onServerStarting(final ServerStartingEvent event)
{
// Assert existence of json objects and tags.
@@ -162,17 +159,17 @@ public class DataPackRegistriesTest
final TagKey<Unsyncable> tag = TagKey.create(Unsyncable.REGISTRY_KEY, TEST_RL);
if (!registry.getTag(tag).get().contains(holder))
throw new IllegalStateException(String.format(Locale.ENGLISH, "Tag %s does not contain %s", tag, TEST_RL));
LOGGER.info("DataPackRegistriesTest server data loaded successfully!");
}
public static class ClientEvents
{
private static void subscribeClientEvents()
{
MinecraftForge.EVENT_BUS.addListener(ClientEvents::onClientTagsUpdated);
}
private static void onClientTagsUpdated(final TagsUpdatedEvent event)
{
// We want to check whether tags have been synced after the player logs in.
@@ -196,12 +193,12 @@ public class DataPackRegistriesTest
final TagKey<Syncable> tag = TagKey.create(Syncable.REGISTRY_KEY, TEST_RL);
if (!registry.getTag(tag).get().contains(holder))
throw new IllegalStateException(String.format(Locale.ENGLISH, "Tag %s does not contain %s", tag, TEST_RL));
LOGGER.info("DataPackRegistriesTest client data synced successfully!");
}
}
public static class Unsyncable extends ForgeRegistryEntry<Unsyncable>
public static class Unsyncable
{
public static final ResourceKey<Registry<Unsyncable>> REGISTRY_KEY = ResourceKey.createRegistryKey(new ResourceLocation(MODID, "unsyncable"));
public static final Codec<Unsyncable> DIRECT_CODEC = Codec.STRING.fieldOf("value").codec().xmap(Unsyncable::new, Unsyncable::value);
@@ -218,19 +215,19 @@ public class DataPackRegistriesTest
return this.value;
}
}
public static class Syncable extends ForgeRegistryEntry<Syncable>
public static class Syncable
{
public static final ResourceKey<Registry<Syncable>> REGISTRY_KEY = ResourceKey.createRegistryKey(new ResourceLocation(MODID, "syncable"));
public static final Codec<Syncable> DIRECT_CODEC = Codec.STRING.fieldOf("value").codec().xmap(Syncable::new, Syncable::value);
private final String value;
public Syncable(final String value)
{
this.value = value;
}
public String value()
{
return this.value;
@@ -25,12 +25,11 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.ForgeRegistry;
import net.minecraftforge.registries.IForgeRegistry;
import net.minecraftforge.registries.IForgeRegistryEntry;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
* This test mod show a few example usages of {@link IForgeRegistry#getCodec()} to serialize and deserialize {@link IForgeRegistryEntry} to json or nbt.
* This test mod show a few example usages of {@link IForgeRegistry#getCodec()} to serialize and deserialize registry entries to JSON or NBT.
* There are 4 tested cases :
* 1. json -> Pair
* 2. Pair -> nbt