Skip to content

Commit

Permalink
Chore/update doc 0.4.3 (LotsOfPixelsStudios#99)
Browse files Browse the repository at this point in the history
* Update addon config doc

Signed-off-by: Matthias <56599453+12rcu@users.noreply.github.com>

* added projectile/item/attachable doc

* spelling

* added rideable doc

---------

Signed-off-by: Matthias <56599453+12rcu@users.noreply.github.com>
  • Loading branch information
12rcu authored Jun 29, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 92f1344 commit 4a9aa26
Showing 5 changed files with 194 additions and 30 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ repositories {
}
dependencies {
implementation("com.lotsofpixelsstudios:monstera:0.3.2")
implementation("com.lotsofpixelsstudios:monstera:0.4.3")
}
````

41 changes: 14 additions & 27 deletions docs/pages/Addon.md
Original file line number Diff line number Diff line change
@@ -4,30 +4,22 @@

Within the `Main.kt` is already an addon structure given and hints on what is possible.

### Addon Config

To create an addon, Monstera needs some basic information in the form of a config, if no config exists as in the
template, one will be created for you when you run the program once. In the console or std in/out Monstera will ask for
the project name and short, other information can be edited directly in the config.

````kotlin
addon(config(projectName = "Template") {
//config
"npm.cmd run build".runCommand(File(System.getProperty("user.dir"), "scripting"))
projectShort = "te"
description = "sample description"
packIcon = getResource("general/pack.png")
world = getResource("world/template-world")
version = arrayListOf(0, 1, 0)
targetMcVersion = arrayListOf(1, 20, 0)
scriptEntryFile = File("scripting", "dist", "src", "index.js")
scriptingVersion = "1.6.0-beta"
val conf = addon(loadConfig().getOrElse {
it.printStackTrace()
return //something went wrong loading the config, for example an I/O error
}) {
//addon body
}
````

Within the header of the addon function we can define some basics of the addon we want to have. The projectShort is
thereby also used as the namespace of entities etc.

Within the Body or the Addon Context we can define entities, items, etc. that will automatically be associated with the
addon.

## :fa-solid fa-screwdriver-wrench: Modifications
### :fa-solid fa-screwdriver-wrench: Modifications of the Config

This section may be interesting for publishing the addon, as for example overwriting the end users version may be
a bit different as on the machine of the developer:
@@ -46,14 +38,8 @@ Note: You may not use components of a newer Version then.

### My mc folder can't be found

This can happen if minecraft wasn't installed with the default parameters, change the direcotry like:

```kotlin
addon(/*...*/) {
properties.comMojangPath =
System.getenv("LOCALAPPDATA") + "\\Packages\\Microsoft.MinecraftUWP_8wekyb3d8bbwe\\LocalState\\games\\com.mojang"
}
```
If an error like this happens, have a look at the monstera-local.json, there is the minecraft path that Monstera
assumed, you can change this path so that it points to the correct directory.

## :fa-solid fa-hammer: Build the addon

@@ -94,4 +80,5 @@ To correctly package the addon, see the Package page.

## :fa-solid fa-flask: Experimental Features

Currently, the JSON UI is experimental and may be discontinued as it will be deprecated in future mc versions.
The JSON UI is not currently in the latest builds and is not currently being worked on, if you are interested open a
discussion.
164 changes: 162 additions & 2 deletions docs/pages/Entities.md
Original file line number Diff line number Diff line change
@@ -197,7 +197,9 @@ components {

## :fa-solid fa-horse: Resource

### Blockbench Files
### Blockbench Files (Experimental)

Note: some complex stuff with UV scaling/mirroring is not supported!

Monstera has also the option to load blockbench files, note: this is a std lib feature:

@@ -430,4 +432,162 @@ craftingRecipe {
context()
}
}
```
```

## Examples

### Projectile Entity

Projectiles require only a few basic components

````kotlin
behaviour {
components {
projectile {
power = 4
gravity = 0.1f
anchor = 1
shouldBounce = true
offset(0f, -0.1f, 0f)

onHit {
impactDamage {
damage(4, 6)
knockback = true
destroyOnHit = false
semiRandomDiffDamage = false
}
stickInGround {
shakeTime = 0
}
}
}
collisionBox {
width = 0.25
height = 0.35
}
physics { }
pushable {
isPushable = false
}
balloonable {
mass = 0.1f
}
conditionalBandwidthOptimization {
defaultValues {
maxOptimizedDistance = 80
maxDroppedTicks = 7
useMotionPredictionHints = true
}
}
}
}
````

It may be beneficial to add a runtime identifier, otherwise the projectile may look strange.

````kotlin
behaviour {
runtimeIdentifier = RuntimeIdentifier.SNOWBLL
}
````

### Throw the projectile with a custom item

When you create an item, you have the option to add a component so that you can throw or shoot your custom projectile.

````kotlin
val spear = entity("spear") {
behaviour {
components {
projectile {
//...
}
}
}
}

item("fishing_spear", "Fishing Spear") {
texture(getResource("spear/spear_ico.png"))
components {
maxStackSize(1)
throwable {
scalePowerByDrawDuration = true
maxDrawDuration = 1
minDrawDuration = 0.2
launchPowerScale = 1.2
maxLaunchPower = 2
}
projectile {
projectileEntity = spear.getIdentifier()
}
}
}
````

Instead of the throwable component, consider using the shooter component

````kotlin
components {
shooter { }
}
````

### Adding an attachable for your item

To add an attachable you need a geo with texture and at least 2 animations, one for the first person and one for the
third person. For custom armor you can omit the first person or set the scale to 0.

````kotlin
item("fishing_spear", "Fishing Spear") {
texture(getResource("spear/spear_ico.png"))
components {
//...
}
attachable {
material("parrot", "parrot")
geometry(getResource("spear/spear.geo.json"))
texture(getResource("spear/spear/spear.png"))

//contains the "hold_first_person" and "hold_third_person" anim
animation(getResource("spear/spear.animation.json"))
renderController("controller.render.item_default")
scripts {
animate("hold_first_person", Query("context.is_first_person == 1.0"))
animate("hold_third_person", Query("context.is_first_person == 0.0"))
}
}
}
````


### Rideable Entities

You can add the Rideable component to an entity to allow players or mobs to ride on the entity. The player will need a
form of input if they want to be able to move with the entity.

````kotlin
rideable {
pullInEntities = true //pulls in the parrots like the player does for parrots
familyTypes("parrot")
seat {
position(0.2, 1.8, 0)
}
seatCountFromSeats()
}
````

For the player you can use:

````kotlin
rideable {
familyTypes("player")
seat {
position(0, 0, 2)
}
seatCountFromSeats()
}
inputGroundControlled { }
//or
itemControllable { }
````
Original file line number Diff line number Diff line change
@@ -13,6 +13,13 @@ class Rideable : MonsteraRawFile() {
@SerializedName("seat_count")
@Expose
var seatCount: Number? = null

/**
* needs to be called after the seats where created
*/
fun seatCountFromSeats() {
seatCount = seatsData?.size
}

@SerializedName("passenger_max_width")
@Expose
Original file line number Diff line number Diff line change
@@ -52,6 +52,16 @@ class BasicEntityTest {
avoidWater = true
}
additionalKeys = mapOf("my_component" to "my_value")

rideable {
familyTypes("player")
seat {
position(0, 0, 2)
}
seatCountFromSeats()
}
inputGroundControlled { }
itemControllable { }
}
}
}

0 comments on commit 4a9aa26

Please sign in to comment.