Skip to content

Commit

Permalink
Lint fixes (FabricMC#117)
Browse files Browse the repository at this point in the history
* Lint fixes.

* Update markdownlint configuration

* Add push trigger for test in markdownlint workflow

* Update .vscode/settings.json and players/updating-fabric.md

* Update markdownlint workflow
  • Loading branch information
IMB11 authored Jun 15, 2024
1 parent fbf06f2 commit adfb349
Show file tree
Hide file tree
Showing 17 changed files with 191 additions and 56 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/markdownlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
- main
paths:
- '**/*.md'
- '!LICENSE.md'
- '!README.md'
- '!translated/**'
- '!versions/*/translated/**'
workflow_dispatch: # Manual run
Expand All @@ -28,15 +30,17 @@ jobs:
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

- id: titlecase
run: npm install [email protected]
- run: npm install

- id: lint
uses: DavidAnson/markdownlint-cli2-action@v16
with:
config: .markdownlint-cli2.yaml
globs: |
**/*.md
!LICENSE.md
!README.md
!**/node_modules
!**/.git
!translated/**
!versions/*/translated/**
13 changes: 2 additions & 11 deletions .markdownlint-cli2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,7 @@ config:
MD033: false
MD035:
style: ---
MD044:
names:
- CurseForge
- Fabric
- GitHub
- Java
- Minecraft
- Modrinth
- Mojang
code_blocks: false
MD044: false
MD046:
style: fenced
MD048:
Expand All @@ -49,4 +40,4 @@ config:
MD055:
style: leading_and_trailing
customRules:
- markdownlint-rule-titlecase
- ./node_modules/markdownlint-rule-titlecase/rule.js
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"davidanson.vscode-markdownlint"
]
}
15 changes: 14 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
{
"java.checkstyle.configuration": "${workspaceFolder}\\reference\\checkstyle.xml"
"markdownlint.lintWorkspaceGlobs": [
"**/*.{md,mkd,mdwn,mdown,markdown,markdn,mdtxt,mdtext,workbook}",
"!**/bower_components",
"!**/node_modules",
"!**/vendor",
"!**/.git",
"!versions/*/translated/**",
"!translated/**",
"!LICENSE.md",
"!README.md"
],
"markdownlint.customRules": [
"../node_modules/markdownlint-rule-titlecase/"
]
}
10 changes: 5 additions & 5 deletions develop/codecs.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,16 @@ Will output this json:
#### Either

`Codec.either` combines two codecs, `Codec<A>` and `Codec<B>`, into a `Codec<Either<A, B>>`. The resulting codec will,
during deserialization, attempt to use the first codec, and *only if that fails*, attempt to use the second one.
If the second one also fails, the error of the *second* codec will be returned.
during deserialization, attempt to use the first codec, and _only if that fails_, attempt to use the second one.
If the second one also fails, the error of the _second_ codec will be returned.

#### Maps

For processing maps with arbitrary keys, such as `HashMap`s, `Codec.unboundedMap` can be used. This returns a
`Codec<Map<K, V>>` for a given `Codec<K>` and `Codec<V>`. The resulting codec will serialize to a json object or
whatever equivalent is available for the current dynamic ops.

Due to limitations of json and nbt, the key codec used *must* serialize to a string. This includes codecs for types that
Due to limitations of json and nbt, the key codec used _must_ serialize to a string. This includes codecs for types that
aren't strings themselves, but do serialize to them, such as `Identifier.CODEC`. See the example below:
```java
Expand Down Expand Up @@ -294,7 +294,7 @@ convert them.

### Mutually Convertible Types and You

#### xmap
#### `xmap`

Say we have two classes that can be converted to each other, but don't have a parent-child relationship. For example,
a vanilla `BlockPos` and `Vec3d`. If we have a codec for one, we can use `Codec#xmap` to create a codec for the other by
Expand Down Expand Up @@ -411,7 +411,7 @@ Our new codec will serialize beans to json like this, grabbing only fields that

### Recursive Codecs

Sometimes it is useful to have a codec that uses *itself* to decode specific fields, for example when dealing with certain recursive data structures. In vanilla code, this is used for `Text` objects, which may store other `Text`s as children. Such a codec can be constructed using `Codecs#createRecursive`.
Sometimes it is useful to have a codec that uses _itself_ to decode specific fields, for example when dealing with certain recursive data structures. In vanilla code, this is used for `Text` objects, which may store other `Text`s as children. Such a codec can be constructed using `Codecs#createRecursive`.

For example, let's try to serialize a singly-linked list. This way of representing lists consists of a bunch of nodes that hold both a value and a reference to the next node in the list. The list is then represented by its first node, and traversing the list is done by following the next node until none remain. Here is a simple implementation of nodes that store integers.
Expand Down
22 changes: 11 additions & 11 deletions develop/commands/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ The integer can be considered the result of the command. Typically values less t
do nothing. Positive values mean the command was successful and did something. Brigadier provides a constant to indicate
success; `Command#SINGLE_SUCCESS`.

### What can the `ServerCommandSource` do?
### What Can the `ServerCommandSource` Do?

A `ServerCommandSource` provides some additional implementation-specific context when a command is run. This includes
the
Expand Down Expand Up @@ -80,11 +80,11 @@ The event should be registered in your mod's initializer.

The callback has three parameters:

* `CommandDispatcher<ServerCommandSource> dispatcher` - Used to register, parse and execute commands. `S` is the type
- `CommandDispatcher<ServerCommandSource> dispatcher` - Used to register, parse and execute commands. `S` is the type
of command source the command dispatcher supports.
* `CommandRegistryAccess registryAccess` - Provides an abstraction to registries that may be passed to certain command
- `CommandRegistryAccess registryAccess` - Provides an abstraction to registries that may be passed to certain command
argument methods
* `CommandManager.RegistrationEnvironment environment` - Identifies the type of server the commands are being registered
- `CommandManager.RegistrationEnvironment environment` - Identifies the type of server the commands are being registered
on.

In the mod initializer, we just register a simple command:
Expand Down Expand Up @@ -155,23 +155,23 @@ Command redirects - also known as aliases - are a way to redirect the functional

<br>

### Why does my code not compile?
### Why Does My Code Not Compile?

* Catch or throw a `CommandSyntaxException` - `CommandSyntaxException` is not a `RuntimeException`. If you throw it,
- Catch or throw a `CommandSyntaxException` - `CommandSyntaxException` is not a `RuntimeException`. If you throw it,
that should be in methods that throw `CommandSyntaxException` in method signatures, or it should be caught.
Brigadier will handle the checked exceptions and forward the proper error message in the game for you.

* Issues with generics - You may have an issue with generics once in a while. If you are registering server
- Issues with generics - You may have an issue with generics once in a while. If you are registering server
commands (which are most of the case), make sure you are using `CommandManager.literal`
or `CommandManager.argument` instead of `LiteralArgumentBuilder.literal` or `RequiredArgumentBuilder.argument`.

* Check `sendFeedback()` method - You may have forgotten to provide a boolean as the second argument. Also remember
- Check `sendFeedback()` method - You may have forgotten to provide a boolean as the second argument. Also remember
that, since Minecraft 1.20, the first parameter is `Supplier<Text>` instead of `Text`.

* A Command should return an integer - When registering commands, the `executes()` method accepts a `Command` object,
- A Command should return an integer - When registering commands, the `executes()` method accepts a `Command` object,
which is usually a lambda. The lambda should return an integer, instead of other types.

### Can I register commands in runtime?
### Can I Register Commands at Runtime?

::: warning
You can do this, but it is not recommended. You would get the `CommandManager` from the server and add anything commands
Expand All @@ -184,7 +184,7 @@ This is required because the client locally caches the command tree it receives
are sent) for local completions-rich error messages.
:::

### Can I unregister commands in runtime?
### Can I Unregister Commands at Runtime?

::: warning
You can also do this, however, it is much less stable than registering commands at runtime and could cause unwanted side
Expand Down
14 changes: 7 additions & 7 deletions develop/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ authors:

# Events

Fabric API provides a system that allows mods to react to actions or occurrences, also defined as *events* that occur in the game.
Fabric API provides a system that allows mods to react to actions or occurrences, also defined as _events_ that occur in the game.

Events are hooks that satisfy common use cases and/or provide enhanced compatibility and performance between mods that hook into the same areas of the code. The use of events often substitutes the use of mixins.

Fabric API provides events for important areas in the Minecraft codebase that multiple modders may be interested in hooking into.

Events are represented by instances of `net.fabricmc.fabric.api.event.Event` which stores and calls *callbacks*. Often there is a single event instance for a callback, which is stored in a static field `EVENT` of the callback interface, but there are other patterns as well. For example, `ClientTickEvents` groups several related events together.
Events are represented by instances of `net.fabricmc.fabric.api.event.Event` which stores and calls _callbacks_. Often there is a single event instance for a callback, which is stored in a static field `EVENT` of the callback interface, but there are other patterns as well. For example, `ClientTickEvents` groups several related events together.

## Callbacks

Expand Down Expand Up @@ -61,7 +61,7 @@ Fabric API has an event that is fired when loot tables are loaded, `LootTableEve

#### Adding Items to the Loot Table

In loot tables, items are stored in *loot pool entries*, and entries are stored in *loot pools*. To add an item, we'll need to add a pool with an item entry to the loot table.
In loot tables, items are stored in _loot pool entries_, and entries are stored in _loot pools_. To add an item, we'll need to add a pool with an item entry to the loot table.

We can make a pool with `LootPool#builder`, and add it to the loot table.

Expand All @@ -75,17 +75,17 @@ Some areas of the game do not have hooks provided by the Fabric API, so you can

We'll look at creating an event that is triggered when sheep are sheared. The process of creating an event is:

* Creating the event callback interface
* Triggering the event from a mixin
* Creating a test implementation
- Creating the event callback interface
- Triggering the event from a mixin
- Creating a test implementation

### Creating the Event Callback Interface

The callback interface describes what must be implemented by event listeners that will listen to your event. The callback interface also describes how the event will be called from our mixin. It is conventional to place an `Event` object as a field in the callback interface, which will identify our actual event.

For our `Event` implementation, we will choose to use an array-backed event. The array will contain all event listeners that are listening to the event.

Our implementation will call the event listeners in order until one of them does not return `ActionResult.PASS`. This means that a listener can say "*cancel this*", "*approve this*" or "*don't care, leave it to the next event listener*" using its return value.
Our implementation will call the event listeners in order until one of them does not return `ActionResult.PASS`. This means that a listener can say "_cancel this_", "_approve this_" or "_don't care, leave it to the next event listener_" using its return value.

Using `ActionResult` as a return value is a conventional way to make event handlers cooperate in this fashion.

Expand Down
4 changes: 2 additions & 2 deletions develop/getting-started/introduction-to-fabric-and-modding.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ You should be aware of the four main components of Fabric:
- **Fabric API**: A set of APIs and tools for mod developers to use when creating mods.
- **Yarn**: A set of open Minecraft mappings, free for everyone to use under the Creative Commons Zero license.

## Why is Fabric necessary to mod Minecraft?
## Why Is Fabric Necessary to Mod Minecraft?

> Modding is the process of modifying a game in order to change its behavior or add new features - in the case of Minecraft, this can be anything from adding new items, blocks, or entities, to changing the game's mechanics or adding new game modes.
Expand All @@ -56,7 +56,7 @@ Loom remaps the obfuscated code to a human-readable format using these mappings,

Loom allows you to easily develop and compile mods against remapped code, and Fabric Loader allows you to load these mods into the game.

## What does Fabric API provide, and why is it needed?
## What Does Fabric API Provide, and Why Is It Needed?

> Fabric API is a set of APIs and tools for mod developers to use when creating mods.
Expand Down
12 changes: 6 additions & 6 deletions develop/items/potions.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ hold this.

We pass an instance of `StatusEffectInstance`, which takes 3 parameters:

* `StatusEffect type` - An effect. We use our custom effect here. Alternatively you can access vanilla effects
- `StatusEffect type` - An effect. We use our custom effect here. Alternatively you can access vanilla effects
through `net.minecraft.entity.effect.StatusEffects`.
* `int duration` - Duration of the effect in game ticks.
* `int amplifier` - An amplifier for the effect. For example, Haste II would have an amplifier of 1.
- `int duration` - Duration of the effect in game ticks.
- `int amplifier` - An amplifier for the effect. For example, Haste II would have an amplifier of 1.

::: info
To create your own effect, please see the [Effects](../entities/effects.md) guide.
Expand All @@ -47,9 +47,9 @@ In our initializer, we call `BrewingRecipeRegistry.registerPotionRecipe`.

`registerPotionRecipe` takes 3 parameters:

* `Potion input` - The starting potion. Usually this can be a Water Bottle or an Awkward Potion.
* `Item item` - The item which is the main ingredient of the potion.
* `Potion output` - The resultant potion.
- `Potion input` - The starting potion. Usually this can be a Water Bottle or an Awkward Potion.
- `Item item` - The item which is the main ingredient of the potion.
- `Potion output` - The resultant potion.

If you use Fabric API, the mixin invoker is not necessary and a direct call
to `BrewingRecipeRegistry.registerPotionRecipe` can be done.
Expand Down
2 changes: 1 addition & 1 deletion develop/rendering/basic-concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ This method returns a vertex builder, which we can use to specify additional inf

It's also worth understanding the concept of culling. Culling is the process of removing faces of a 3D shape that aren't visible from the viewer's perspective. If the vertices for a face are specified in the wrong order, the face might not render correctly due to culling.

#### What is a Transformation Matrix?
#### What Is a Transformation Matrix?

A transformation matrix is a 4x4 matrix that is used to transform a vector. In Minecraft, the transformation matrix is just transforming the coordinates we give into the vertex call. The transformations can scale our model, move it around and rotate it.

Expand Down
2 changes: 1 addition & 1 deletion develop/rendering/particles/creating-particles.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Once you have completed the JSON file and saved your work, you are good to load

You can see if everything has worked by typing the following command:

```
```command
/particle <mod id here>:sparkle_particle ~ ~1 ~
```

Expand Down
Loading

0 comments on commit adfb349

Please sign in to comment.