Skip to content

Commit

Permalink
all the format
Browse files Browse the repository at this point in the history
  • Loading branch information
LLytho committed Jul 6, 2024
1 parent eb32461 commit cf893e1
Show file tree
Hide file tree
Showing 16 changed files with 81 additions and 75 deletions.
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"singleQuote": false,
"semi": false,
"trailingComma": "all",
"trailingComma": "es5",
"quoteProps": "as-needed",
"bracketSpacing": true,
"bracketSameLine": true,
Expand Down
16 changes: 9 additions & 7 deletions main/WikiConfig.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { z } from "zod";
import fs from "fs";
import path from "path";
import { z } from "zod"
import fs from "fs"
import path from "path"

const schema = z.object({
wikis: z.array(z.object({
name: z.string(),
})),
wikis: z.array(
z.object({
name: z.string(),
})
),
})

const jsonString = fs.readFileSync(path.resolve(__dirname, "../", "wikis.json"), "utf-8");
const jsonString = fs.readFileSync(path.resolve(__dirname, "../", "wikis.json"), "utf-8")
const json = schema.parse(JSON.parse(jsonString))
const wikis: Map<string, WikiEntry> = new Map()

Expand Down
2 changes: 1 addition & 1 deletion main/defineAlmostWiki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DefaultTheme, UserConfig } from "vitepress"
function getBaseThemeConfig(title: string): DefaultTheme.Config {
return {
editLink: {
pattern: `https://github.com/AlmostReliable/almostreliable.github.io/edit/main/wikis/${title}/docs/:path`
pattern: `https://github.com/AlmostReliable/almostreliable.github.io/edit/main/wikis/${title}/docs/:path`,
},
socialLinks: [
{
Expand Down
2 changes: 1 addition & 1 deletion main/start_dev_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import path from "path"
import WikiConfig, { WikiEntry } from "./WikiConfig"

const DIST_DIR = path.join(__dirname, "../dist")
if(!fs.existsSync(DIST_DIR)) throw new Error("Wiki dist directory not found")
if (!fs.existsSync(DIST_DIR)) throw new Error("Wiki dist directory not found")

const app = express()
app.use(express.static(DIST_DIR))
Expand Down
3 changes: 1 addition & 2 deletions main/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ export default {
// https://vitepress.dev/guide/extending-default-theme#layout-slots
})
},
enhanceApp({ app, router, siteData }) {
},
enhanceApp({ app, router, siteData }) {},
} satisfies Theme
6 changes: 2 additions & 4 deletions wikis/lootjs/.vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig } from "../../../main/defineAlmostWiki";
import { defineConfig } from "../../../main/defineAlmostWiki"

export default defineConfig({
srcDir: "./docs",
Expand All @@ -22,9 +22,7 @@ export default defineConfig({
},
{
text: "Loot Modifiers",
items: [
{ text: "Event Overview", link: "/loot-modifiers/event" },
],
items: [{ text: "Event Overview", link: "/loot-modifiers/event" }],
},
{
text: "API",
Expand Down
4 changes: 2 additions & 2 deletions wikis/lootjs/docs/api/item-filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ Combines multiple item filters into one. Matches if all filters match.
```js
ItemFilter.allOf(
ItemFilter.hasEnchantment("minecraft:fortune"),
ItemFilter.equipmentSlotGroup("hand"),
ItemFilter.equipmentSlotGroup("hand")
)
```

Expand All @@ -229,7 +229,7 @@ Combines multiple item filters into one. Matches if any filter matches.
```js
ItemFilter.anyOf(
ItemFilter.hasEnchantment("minecraft:silk_touch"),
ItemFilter.equipmentSlotGroup("armor"),
ItemFilter.equipmentSlotGroup("armor")
)
```

Expand Down
6 changes: 3 additions & 3 deletions wikis/lootjs/docs/api/loot-entry.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ LootEntry.reference("minecraft:chests/abandoned_mineshaft")
LootEntry.alternative(
LootEntry.of("minecraft:diamond").when((c) => c.randomChance(0.5)),
LootEntry.of("minecraft:emerald").when((c) => c.randomChance(0.5)),
LootEntry.of("minecraft:iron_ingot"),
LootEntry.of("minecraft:iron_ingot")
)
```

Expand All @@ -146,7 +146,7 @@ LootEntry.alternative(
LootEntry.sequence(
LootEntry.of("minecraft:diamond").when((c) => c.randomChance(0.5)),
LootEntry.of("minecraft:emerald").when((c) => c.randomChance(0.2)),
LootEntry.of("minecraft:iron_ingot"),
LootEntry.of("minecraft:iron_ingot")
)
```

Expand All @@ -158,7 +158,7 @@ LootEntry.sequence(
LootEntry.group(
LootEntry.of("minecraft:diamond").when((c) => c.randomChance(0.5)),
LootEntry.of("minecraft:emerald").when((c) => c.randomChance(0.2)),
LootEntry.of("minecraft:iron_ingot"),
LootEntry.of("minecraft:iron_ingot")
)
```

Expand Down
9 changes: 6 additions & 3 deletions wikis/lootjs/docs/api/loot-function.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Applies a bonus based on the binomial distribution, where `n = enchantmentLevel
LootEntry.of("minecraft:emerald_ore").applyBinomialDistributionBonus(
"minecraft:fortune",
0.2,
3,
3
)
```

Expand All @@ -94,7 +94,10 @@ LootEntry.of("minecraft:emerald_ore").applyEnchantmentBonus([2, 5])
```

```js
LootEntry.of("minecraft:emerald_ore").applyEnchantmentBonus("minecraft:fortune", [2, 5])
LootEntry.of("minecraft:emerald_ore").applyEnchantmentBonus(
"minecraft:fortune",
[2, 5]
)
```

## `setCount`
Expand Down Expand Up @@ -153,7 +156,7 @@ LootEntry.of("minecraft:emerald_ore").setCustomData({ someCustomStuff: true })

```js
LootEntry.of("minecraft:emerald_ore").setName(
Component.translatable("item.minecraft.emerald_ore"),
Component.translatable("item.minecraft.emerald_ore")
)
```

Expand Down
12 changes: 6 additions & 6 deletions wikis/lootjs/docs/api/loot-modifier.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ LootJS.modifiers((event) => {
const stickWhenFortune = LootEntry.of("minecraft:stick")
.applyOreBonus("minecraft:fortune")
.when((c) =>
c.matchMainHand(ItemFilter.hasEnchantment("minecraft:fortune")),
c.matchMainHand(ItemFilter.hasEnchantment("minecraft:fortune"))
)

/**
* Second loot entry with a condition. Will drop if the player has silk touch and the first entry doesn't match.
*/
const appleWhenSilkTouch = LootEntry.of("minecraft:apple").when((c) =>
c.matchMainHand(ItemFilter.hasEnchantment("minecraft:silk_touch")),
c.matchMainHand(ItemFilter.hasEnchantment("minecraft:silk_touch"))
)

/**
Expand Down Expand Up @@ -86,14 +86,14 @@ LootJS.modifiers((event) => {
* First loot entry with a condition. Will drop if the player has fortune.
*/
const stickWhenFortune = LootEntry.of("minecraft:stick").when((c) =>
c.matchMainHand(ItemFilter.hasEnchantment("minecraft:fortune")),
c.matchMainHand(ItemFilter.hasEnchantment("minecraft:fortune"))
)

/**
* Second loot entry with a condition. Will drop if the player has silk touch.
*/
const appleWhenEfficiency = LootEntry.of("minecraft:apple").when((c) =>
c.matchMainHand(ItemFilter.hasEnchantment("minecraft:efficiency")),
c.matchMainHand(ItemFilter.hasEnchantment("minecraft:efficiency"))
)

/**
Expand All @@ -105,7 +105,7 @@ LootJS.modifiers((event) => {
* Random chance is 0 so no diamond will ever drop. Just to show, that it will skip all other entries.
*/
const diamondNoDrop = LootEntry.of("minecraft:diamond").when((c) =>
c.randomChance(0.0),
c.randomChance(0.0)
)

/**
Expand All @@ -121,7 +121,7 @@ LootJS.modifiers((event) => {
appleWhenEfficiency,
flint,
diamondNoDrop,
ironIngot,
ironIngot
)
})
```
Expand Down
3 changes: 2 additions & 1 deletion wikis/lootjs/docs/api/loot-table.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# LootTable

Loot tables are used dictate what items should be dropped through specific actions.
Loot tables are used dictate what items should be dropped through specific actions.

`LootTables` in LootJS extends from `LootEntriesTransformer`. See [`LootEntriesTransformer`](/api/loot-entries-transformer) for more information.

## `firstPool`

Returns the first pool inside a loot table. If no pool exist, it will create one and return it.

- Syntax:
Expand Down
2 changes: 1 addition & 1 deletion wikis/lootjs/docs/api/number-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

`NumberProvider`s are used in loot tables to create a random number depending on the loot context. Minecraft itself offers three number providers, but mods can add their own.

To simplify the usage of number providers LootJS does register a type wrapper in KubeJS.
To simplify the usage of number providers LootJS does register a type wrapper in KubeJS.

## Constant Number

Expand Down
69 changes: 37 additions & 32 deletions wikis/lootjs/docs/event.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ The loot tables event contains multiple functions to modify or create new loot t

```js
LootJS.lootTables((event) => {
let ids = event.getLootTableIds();
let ids = event.getLootTableIds()

// or

let filteredIds = event.getLootTableIds(/.*chests\/.*/);
});
let filteredIds = event.getLootTableIds(/.*chests\/.*/)
})
```

## `hasLootTable`
Expand All @@ -25,9 +25,10 @@ Returns `true` if the loot table with the given id exists.

```js
LootJS.lootTables((event) => {
let exists = event.hasLootTable("minecraft:chests/simple_dungeon");
});
let exists = event.hasLootTable("minecraft:chests/simple_dungeon")
})
```

## `getLootTable`

Returns a mutable loot table by the given id which can be modified. Will return `null` if no loot table with the given id exists.
Expand All @@ -38,8 +39,8 @@ Returns a mutable loot table by the given id which can be modified. Will return

```js
LootJS.lootTables((event) => {
let table = event.getLootTable("minecraft:chests/simple_dungeon");
});
let table = event.getLootTable("minecraft:chests/simple_dungeon")
})
```

## `modifyLootTables`
Expand All @@ -54,8 +55,8 @@ Modify all matching loot tables by given filter.
LootJS.lootTables((event) => {
event.modifyLootTables(/.*chests\/.*/).createPool((pool) => {
// editing the pool
});
});
})
})
```

## `getBlockTable`
Expand All @@ -68,8 +69,8 @@ Returns a mutable loot table for the given block which can be modified. Will ret

```js
LootJS.lootTables((event) => {
let table = event.getBlockTable("minecraft:diamond_ore");
});
let table = event.getBlockTable("minecraft:diamond_ore")
})
```

## `modifyBlockTables`
Expand All @@ -84,24 +85,26 @@ Modify all matching block loot by given filter.
LootJS.lootTables((event) => {
event.modifyBlockTables("minecraft:diamond_ore").createPool((pool) => {
// editing the pool
});
});
})
})
```

```js
LootJS.lootTables((event) => {
event.modifyBlockTables(["minecraft:diamond_ore", "minecraft:emerald_ore"]).createPool((pool) => {
// editing the pool
});
});
event
.modifyBlockTables(["minecraft:diamond_ore", "minecraft:emerald_ore"])
.createPool((pool) => {
// editing the pool
})
})
```

```js
LootJS.lootTables((event) => {
event.modifyBlockTables("#minecraft:logs").createPool((pool) => {
// editing the pool
});
});
})
})
```

## `getEntityTable`
Expand All @@ -114,8 +117,8 @@ Returns a mutable loot table for the given entity which can be modified. Will re

```js
LootJS.lootTables((event) => {
let table = event.getEntityTable("minecraft:sheep");
});
let table = event.getEntityTable("minecraft:sheep")
})
```

## `modifyEntityTables`
Expand All @@ -130,8 +133,8 @@ Modify all matching entity loot by given filter.
LootJS.lootTables((event) => {
event.modifyEntityTables("minecraft:sheep").createPool((pool) => {
// editing the pool
});
});
})
})
```

## `modifyLootTypeTables`
Expand All @@ -158,18 +161,20 @@ Modify all matching loot tables by given type. Loot tables mostly have a type e.
LootJS.lootTables((event) => {
event.modifyLootTypeTables(LootType.CHEST).createPool((pool) => {
// editing the pool
});
})

// As kubejs automatically type wraps Enums, we can just use the name of the enum
event.modifyLootTypeTables("chest").createPool((pool) => {
// editing the pool
});
})

// If we want to match multiple types, we can use an array
event.modifyLootTypeTables([LootType.CHEST, LootType.ENTITY]).createPool((pool) => {
// editing the pool
});
});
event
.modifyLootTypeTables([LootType.CHEST, LootType.ENTITY])
.createPool((pool) => {
// editing the pool
})
})
```

## `clearLootTables`
Expand Down Expand Up @@ -200,13 +205,13 @@ Create a new loot table.
LootJS.lootTables((event) => {
event.create("lootjs:table1", LootType.CHEST).createPool((pool) => {
// editing the pool
});
})

// We can skip the type argument if we want to use the default
event.create("lootjs:table2").createPool((pool) => {
// editing the pool
});
});
})
})
```

[ResourceLocationFilter]: ./test.md
Expand Down
Loading

0 comments on commit cf893e1

Please sign in to comment.