Skip to content

Commit

Permalink
feat(docs): Entity constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
ChampionAsh5357 committed Jun 6, 2024
1 parent ad5bf52 commit 3fd3c5b
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions docs/entities/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The `String` in the `build` method represents the registry name of the `EntityTy

```java
// For some entity
public static class ExampleEntity extends Entity {
public class ExampleEntity extends Entity {

// This is the constructor definition for use in 'EntityType.EntityFactory'
public ExampleEntity(EntityType<? extends ExampleEntity> type, Level level) {
Expand All @@ -60,19 +60,43 @@ public static final DeferredHolder<EntityType<?>, EntityType<ExampleEntity>> EXA
The builder contains many methods that will be further discussed in other sections to help with understanding. An example for applying each to an `EntityType` will be provided there.
:::

### Entity Dimensions
## Everything Revolves Around `Entity`

TODO
The `Entity` class is the base containing the logic that the entity executes when ticked or interacted with. The `Entity` constructor takes in two parameters: the `EntityType` of the entity, and the `Level` the entity is spawned in. This constructor is passed into the `EntityType` builder to spawn entities on both the server and the client.

### Entity Attachments
```java
public class ExampleEntity extends Entity {

// This is the constructor definition for use in 'EntityType.EntityFactory'
public ExampleEntity(EntityType<? extends ExampleEntity> type, Level level) {
super(type, level);
// ...
}
}
```

If the entity will be spawned manually rather than by the game, then additional constructors can be added to spawn the entity. These constructors usually hardcode the entity type to whatever is attempting to be spawned.

```java
public class ExampleEntity extends Entity {

public ExampleEntity(Level level, double x, double y, double z) {
// Delegates to the factory constructor
this(EXAMPLE_ENITTY.value(), level);
this.setPos(x, y, z);
}
}
```

### To Pick or Not to Pick

TODO

## Everything Revolves Around `Entity`
### Entity Dimensions

TODO

### To Pick or Not to Pick
### Entity Attachments

TODO

Expand Down

1 comment on commit 3fd3c5b

@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: 3fd3c5b2856227f6bd8f512526e78c9726b2ed8a
Status: ✅ Deploy successful!
Preview URL: https://b263107e.neoforged-docs-previews.pages.dev
PR Preview URL: https://pr-95.neoforged-docs-previews.pages.dev

Please sign in to comment.