Skip to content

Commit

Permalink
address most feedback by ChampionAsh
Browse files Browse the repository at this point in the history
  • Loading branch information
IchHabeHunger54 committed Feb 22, 2024
1 parent 965be16 commit 2e65131
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions docs/blocks/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static final DeferredRegister.Blocks BLOCKS = DeferredRegister.createBloc
public static final DeferredBlock<Block> EXAMPLE_BLOCK = BLOCKS.registerBlock(
"example_block",
Block::new, // The factory that the properties will be passed into.
new BlockBehaviour.Properties() // The properties to use.
BlockBehaviour.Properties.of() // The properties to use.
);
```

Expand All @@ -113,7 +113,7 @@ If you want to use `Block::new`, you can leave out the factory entirely:
```java
public static final DeferredBlock<Block> EXAMPLE_BLOCK = BLOCKS.registerSimpleBlock(
"example_block",
new BlockBehaviour.Properties() // The properties to use.
BlockBehaviour.Properties.of() // The properties to use.
);
```

Expand Down
12 changes: 6 additions & 6 deletions docs/concepts/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

One of NeoForge's main features is the event system. Events are fired for various things that happen in the game. For example, there are events for when the player right clicks, when a player or another entity jumps, when blocks are rendered, when the game is loaded, etc. A modder can subscribe event handlers to each of these events, and then perform their desired behavior inside these event handlers.

Events are fired on their respective event bus. The most important bus is `NeoForge.EVENT_BUS`. Besides that, during startup, a mod bus is spawned for each loaded mod and passed into the mod's constructor; mod bus event handlers can run in parallel, dramatically increasing startup speed. See [below][modbus] for more information.
Events are fired on their respective event bus. The most important bus is `NeoForge.EVENT_BUS`. Besides that, during startup, a mod bus is spawned for each loaded mod and passed into the mod's constructor. Many mod bus events are fired in parallel (as opposed to main bus events that always run on the same thread), dramatically increasing startup speed. See [below][modbus] for more information.

## Registering an Event Handler

Expand Down Expand Up @@ -36,7 +36,7 @@ Alternatively, event handlers can be annotation-driven by creating an event hand

```java
public class EventHandler {
@SubscribeEvent
@SubscribeEvent
public void onLivingJump(LivingJumpEvent event) {
Entity entity = event.getEntity();
if (!entity.level().isClientSide()) {
Expand Down Expand Up @@ -97,14 +97,14 @@ public class EventHandler {

### Fields and Methods

Probably the most obvious part. Most events contain context for the event handler to use, such as an entity causing the event or a level the event occurs in.
Fields and methods are probably the most obvious part of an event. Most events contain context for the event handler to use, such as an entity causing the event or a level the event occurs in.

### Hierarchy

In order to use the advantages of inheritance, some events do not directly extend `Event`, but one of its subclasses, for example `BlockEvent` (which contains block context for block-related events) or `EntityEvent` (which similarly contains entity context) and its subclasses `LivingEvent` (for `LivingEntity`-specific context) and `PlayerEvent` (for `Player`-specific context). These context-providing super events are `abstract` and cannot be listened to.

:::danger
If you listen to an `abstract` event, your game will crash, as this is not what you want. Listen to one of its sub events instead.
If you listen to an `abstract` event, your game will crash, as this is never what you want. You always want to listen to one of the subevents instead.
:::

### Cancellable Events
Expand All @@ -125,7 +125,7 @@ Results are deprecated and will be replaced by more specific per-event results s

Event handlers can optionally get assigned a priority. The `EventPriority` enum contains five values: `HIGHEST`, `HIGH`, `NORMAL` (default), `LOW` and `LOWEST`. Events are executed from highest to lowest priority, with undefined order for two events of the same priority.

Priorities can be defined by setting the `priority` parameter in `IEventBus#addListener` or `@SubscribeEvent`, depending on how you attach event handlers.
Priorities can be defined by setting the `priority` parameter in `IEventBus#addListener` or `@SubscribeEvent`, depending on how you attach event handlers. Note that priorities are ignored for events that are fired in parallel.

### Sided Events

Expand Down Expand Up @@ -173,7 +173,7 @@ Next to the lifecycle events, there are a few miscellaneous events that are fire
- `TextureStitchEvent`

:::warning
Most of these events will be moved to `NeoForge.EVENT_BUS` eventually.
Most of these events are planned to be moved to the main event bus in a future version.
:::

[modbus]: #event-buses
Expand Down
6 changes: 5 additions & 1 deletion docs/items/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ If you want to use `Item::new`, you can leave out the factory entirely:
```java
public static final Supplier<Item> EXAMPLE_ITEM = ITEMS.registerItem(
"example_item",
new ItemBehaviour.Properties() // The properties to use.
new Item.Properties() // The properties to use.
);
```

Expand All @@ -101,6 +101,10 @@ public static final Supplier<BlockItem> EXAMPLE_BLOCK_ITEM = ITEMS.registerSimpl
public static final Supplier<BlockItem> EXAMPLE_BLOCK_ITEM = ITEMS.registerSimpleBlockItem(ExampleBlocksClass.EXAMPLE_BLOCK);
```

:::note
If you keep your blocks in a separate class, you should classload your blocks class before your items class.
:::

### Resources

If you register your item and get your item (via `/give` or through a [creative tab][creativetabs]), you will find it to be missing a proper model and texture. This is because textures and models are handled by Minecraft's resource system.
Expand Down

1 comment on commit 2e65131

@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: 2e65131562c8f9bf76cbcab96e38e50d4092ca02
Status: ✅ Deploy successful!
Preview URL: https://a1857238.neoforged-docs-previews.pages.dev
PR Preview URL: https://pr-48.neoforged-docs-previews.pages.dev

Please sign in to comment.