Skip to content

Commit

Permalink
Add 1.20 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Matyrobbrt committed Jul 28, 2023
1 parent 708ab42 commit 4d8ba01
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 94 deletions.
2 changes: 1 addition & 1 deletion docs/blockentities/ber.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This method is called every frame in order to render the block entity.

#### Parameters
* `blockEntity`: This is the instance of the block entity being rendered.
* `partialTicks`: The amount of time, in fractions of a tick, that has passed since the last full tick.
* `partialTick`: The amount of time, in fractions of a tick, that has passed since the last full tick.
* `poseStack`: A stack holding four-dimensional matrix entries offset to the current position of the block entity.
* `bufferSource`: A rendering buffer able to access a vertex consumer.
* `combinedLight`: An integer of the current light value on the block entity.
Expand Down
4 changes: 2 additions & 2 deletions docs/blocks/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ For simple blocks, which need no special functionality (think cobblestone, woode
All these methods are *chainable* which means you can call them in series. See the `Blocks` class for examples of this.

:::note
Blocks have no setter for their `CreativeModeTab`. This is now handled by the [`CreativeModeTabEvent$BuildContents`][creativetabs] if the block has an associated item (e.g. `BlockItem`). Furthermore, there is no setter for translation key as it is now generated from the registry name.
Blocks have no setter for their `CreativeModeTab`. This is handled by the [`BuildCreativeModeTabContentsEvent`][creativetabs] if the block has an associated item (e.g. `BlockItem`). Furthermore, there is no setter for translation key of the block as it is generated from the registry name via `Block#getDescriptionId`.
:::

### Advanced Blocks
Expand All @@ -38,7 +38,7 @@ When a block is registered, *only* a block is registered. The block does not aut

#### Optionally Registering Blocks

In the past there have been several mods that have allowed users to disable blocks/items in a configuration file. However, you shouldn't do this. There is no limit on the amount of blocks that can be register, so register all blocks in your mod! If you want a block to be disabled through a configuration file, you should disable the crafting recipe. If you would like to disable the block in the creative tab, use a `FeatureFlag` when building the contents within [`CreativeModeTabEvent$BuildContents`][creativetabs].
In the past there have been several mods that have allowed users to disable blocks/items in a configuration file. However, you shouldn't do this. There is no limit on the amount of blocks that can be register, so register all blocks in your mod! If you want a block to be disabled through a configuration file, you should disable the crafting recipe. If you would like to disable the block in the creative tab, use a `FeatureFlag` when building the contents within [`BuildCreativeModeTabContentsEvent`][creativetabs].

Further Reading
---------------
Expand Down
4 changes: 3 additions & 1 deletion docs/concepts/lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ Mods *must* take care to be thread-safe, like when calling other mods' APIs or a
Registry Events
---------------

The registry events are fired after the mod instance construction. There are two: `NewRegistryEvent` and `RegisterEvent`. These events are fired synchronously during mod loading.
The registry events are fired after the mod instance construction. There are three: `NewRegistryEvent`, `DataPackRegistryEvent$NewRegistry` and `RegisterEvent`. These events are fired synchronously during mod loading.

`NewRegistryEvent` allows modders to register their own custom registries, using the `RegistryBuilder` class.

`DataPackRegistryEvent$NewRegistry` allows modders to register custom datapack registries by providing a `Codec` to encode and decode the object from JSON.

`RegisterEvent` is for [registering objects][registering] into the registries. The event is fired for each registry.

Data Generation
Expand Down
10 changes: 9 additions & 1 deletion docs/concepts/registries.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ An example of a mod registering a custom block:
```java
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);

public static final RegistryObject<Block> ROCK_BLOCK = BLOCKS.register("rock", () -> new Block(BlockBehaviour.Properties.of(Material.STONE)));
public static final RegistryObject<Block> ROCK_BLOCK = BLOCKS.register("rock", () -> new Block(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));

public ExampleMod() {
BLOCKS.register(FMLJavaModLoadingContext.get().getModEventBus());
Expand Down Expand Up @@ -158,6 +158,14 @@ Any newly created registry should use its associated [registration method][regis

When using `NewRegistryEvent`, calling `#create` with a `RegistryBuilder` will return a supplier-wrapped registry. The supplied registry can be accessed after `NewRegistryEvent` has finished posting to the mod event bus. Getting the custom registry from the supplier before `NewRegistryEvent` finishes firing will result in a `null` value.

#### New Datapack Registries

New datapack registries can be added using the `DataPackRegistryEvent$NewRegistry` event on the mod event bus. The registry is created via `#dataPackRegistry` by passing in the `ResourceKey` representing the registry name and the `Codec` used to encode and decode the data from JSON. An optional `Codec` can be provided to sync the datapack registry to the client.

:::note
Datapack Registries cannot be created with `DeferredRegister`. They can only be created through the event.
:::

### With DeferredRegister

The `DeferredRegister` method is once again another wrapper around the above event. Once a `DeferredRegister` is created in a constant field using the `#create` overload which takes in the registry name and the mod id, the registry can be constructed via `DeferredRegister#makeRegistry`. This takes in a supplied `RegistryBuilder` containing any additional configurations. The method already populates `#setName` by default. Since this method can be returned at any time, a supplied version of an `IForgeRegistry` is returned instead. Getting the custom registry from the supplier before `NewRegistryEvent` is fired will result in a `null` value.
Expand Down
18 changes: 0 additions & 18 deletions docs/datastorage/capabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,24 +172,6 @@ By default, the capability data does not persist on death. In order to change th

This can be done via `PlayerEvent$Clone` by reading the data from the original entity and assigning it to the new entity. In this event, the `#isWasDeath` method can be used to distinguish between respawning after death and returning from the End. This is important because the data will already exist when returning from the End, so care has to be taken to not duplicate values in this case.

Migrating from IExtendedEntityProperties
---------------------------

Although the Capability system can do everything IEEPs (IExtendedEntityProperties) did and more, the two concepts don't fully match 1:1. This section will explain how to convert existing IEEPs into Capabilities.
This is a quick list of IEEP concepts and their Capability equivalent:
* Property name/id (`String`): Capability key (`ResourceLocation`)
* Registration (`EntityConstructing`): Attaching (`AttachCapabilitiesEvent<Entity>`), the real registration of the `Capability` happens during `FMLCommonSetupEvent`.
* Tag read/write methods: Does not happen automatically. Attach an `ICapabilitySerializable` in the event and run the read/write methods from the `serializeNBT`/`deserializeNBT`.
Quick conversion guide:
1. Convert the IEEP key/id string into a `ResourceLocation` (which will use your MODID as a namespace).
2. In your handler class (not the class that implements your capability interface), create a field that will hold the Capability instance.
3. Change the `EntityConstructing` event to `AttachCapabilitiesEvent`, and instead of querying the IEEP, you will want to attach an `ICapabilityProvider` (probably `ICapabilitySerializable`, which allows saving/loading from a tag).
4. Create a registration method if you don't have one (you may have one where you registered your IEEP's event handlers) and in it, run the capability registration function.
[expose]: #exposing-a-capability
[handled]: ../concepts/events.md#creating-an-event-handler
[network]: ../networking/index.md
18 changes: 3 additions & 15 deletions docs/gettingstarted/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,6 @@ Replace all occurrences of `examplemod`, including [`mods.toml` and the main mod
base.archivesName = 'mymod'
```

:::info
The Forge MDK currently uses `archivesBaseName` to set the artifact name instead of `base.archivesName`. We recommend using `base.archivesName` instead as `archivesBaseName` is deprecated for removal in Gradle 9, which a future version of ForgeGradle will support.

You can still use `archivesBaseName` by setting the following:

```gradle
// In some build.gradle
base.archivesName = 'mymod'
```

:::

#### Group Id

The `group` property should be set to your [top-level package][packaging], which should either be a domain you own or your email address:
Expand Down Expand Up @@ -110,7 +98,7 @@ Set the `version` property to the current version of your mod. We recommend usin

```gradle
// In some build.gradle
version = '1.19.4-1.0.0.0'
version = '1.20-1.0.0.0'
```

### Additional Configurations
Expand All @@ -130,9 +118,9 @@ You should always test your mod in a dedicated server environment. This includes
:::

[jdk]: https://adoptium.net/temurin/releases?version=17 "Eclipse Temurin 17 Prebuilt Binaries"
[ForgeGradle]: https://docs.minecraftforge.net/en/fg-5.x
[ForgeGradle]: https://docs.neoforged.net/neogradle/docs/
[files]: https://files.minecraftforge.net "Forge Files distribution site"
[config]: https://docs.minecraftforge.net/en/fg-5.x/configuration/runs/
[config]: https://docs.neoforged.net/neogradle/docs/configuration/runs
[modfiles]: ./modfiles.md
[packaging]: ./structuring.md#packaging
[mvnver]: ./versioning.md
Expand Down
10 changes: 5 additions & 5 deletions docs/gettingstarted/modfiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The file uses the [Tom's Obvious Minimal Language, or TOML][toml], format. The f

```toml
modLoader="javafml"
loaderVersion="[45,)"
loaderVersion="[46,)"

license="All Rights Reserved"
issueTrackerURL="https://github.com/MinecraftForge/MinecraftForge/issues"
Expand All @@ -35,14 +35,14 @@ showAsResourcePack=false
[[dependencies.examplemod]]
modId="forge"
mandatory=true
versionRange="[45,)"
versionRange="[46,)"
ordering="NONE"
side="BOTH"

[[dependencies.examplemod]]
modId="minecraft"
mandatory=true
versionRange="[1.19.4]"
versionRange="[1.20]"
ordering="NONE"
side="BOTH"
```
Expand All @@ -56,7 +56,7 @@ Non-mod-specific properties are properties associated with the JAR itself, indic
Property | Type | Default | Description | Example
:--- | :---: | :---: | :---: | :---
`modLoader` | string | **mandatory** | The language loader used by the mod(s). Can be used to support alternative language structures, such as Kotlin objects for the main file, or different methods of determining the entrypoint, such as an interface or method. Forge provides the Java loader `"javafml"` and low/no code loader `"lowcodefml"`. | `"javafml"`
`loaderVersion` | string | **mandatory** | The acceptable version range of the language loader, expressed as a [Maven Version Range][mvr]. For `javafml` and `lowcodefml`, the version is the major version of the Forge version. | `"[45,)"`
`loaderVersion` | string | **mandatory** | The acceptable version range of the language loader, expressed as a [Maven Version Range][mvr]. For `javafml` and `lowcodefml`, the version is the major version of the Forge version. | `"[46,)"`
`license` | string | **mandatory** | The license the mod(s) in this JAR are provided under. It is suggested that this is set to the [SPDX identifier][spdx] you are using and/or a link to the license. You can visit https://choosealicense.com/ to help pick the license you want to use. | `"MIT"`
`showAsResourcePack` | boolean | `false` | When `true`, the mod(s)'s resources will be displayed as a separate resource pack on the 'Resource Packs' menu, rather than being combined with the 'Mod resources' pack. | `true`
`services` | array | `[]` | An array of services your mod **uses**. This is consumed as part of the created module for the mod from Forge's implementation of the Java Platform Module System. | `["net.minecraftforge.forgespi.language.IModLanguageProvider"]`
Expand Down Expand Up @@ -85,7 +85,7 @@ Property | Type | Default | Description | Example
:--- | :---: | :---: | :---: | :---
`modId` | string | **mandatory** | The unique identifier representing this mod. The id must match `^[a-z][a-z0-9_]{1,63}$` (a string 2-64 characters; starts with a lowercase letter; made up of lowercase letters, numbers, or underscores). | `"examplemod"`
`namespace` | string | value of `modId` | An override namespace for the mod. The namespace much match `^[a-z][a-z0-9_.-]{1,63}$` (a string 2-64 characters; starts with a lowercase letter; made up of lowercase letters, numbers, underscores, dots, or dashes). Currently unused. | `"example"`
`version` | string | `"1"` | The version of the mod, preferably in a [variation of Maven versioning][mvnver]. When set to `${file.jarVersion}`, it will be replaced with the value of the `Implementation-Version` property in the JAR's manifest (displays as `0.0NONE` in a development environment). | `"1.19.4-1.0.0.0"`
`version` | string | `"1"` | The version of the mod, preferably in a [variation of Maven versioning][mvnver]. When set to `${file.jarVersion}`, it will be replaced with the value of the `Implementation-Version` property in the JAR's manifest (displays as `0.0NONE` in a development environment). | `"1.20-1.0.0.0"`
`displayName` | string | value of `modId` | The pretty name of the mod. Used when representing the mod on a screen (e.g., mod list, mod mismatch). | `"Example Mod"`
`description` | string | `"MISSING DESCRIPTION"` | The description of the mod shown in the mod list screen. It is recommended to use a [multiline literal string][multiline]. | `"This is an example."`
`logoFile` | string | *nothing* | The name and extension of an image file used on the mods list screen. The logo must be in the root of the JAR or directly in the root of the source set (e.g., `src/main/resources` for the main source set). | `"example_logo.png"`
Expand Down
Loading

1 comment on commit 4d8ba01

@neoforged-pages-deployments
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploying with Cloudflare Pages

Name Result
Last commit: 4d8ba01681212887cd758b46c6c088f748904bde
Status: ✅ Deploy successful!
Preview URL: https://6e27556e.neoforged-docs-previews.pages.dev
PR Preview URL: https://pr-6.neoforged-docs-previews.pages.dev

Please sign in to comment.