-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
305 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# MoreUtils | ||
|
||
## Methods | ||
|
||
- `findStructure(pos: BlockPos, level: Level, structure: string | string[] | RegEx, chunkRadius: number)` | ||
- `findBiome(pos: BlockPos, level: Level, biome: string | string[] | RegEx, chunkRadius: number)` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Potion Brewing | ||
|
||
## Methods | ||
|
||
- `addPotionBrewing(ingredient: Ingredient, input: Potion, output: Potion)` | ||
- `removePotionBrewing(filter: PotionBrewingFilter)` | ||
- `addContainerRecipe(ingredient: Ingredient, input: Item, output: Item)` | ||
- `removeContainer(ingredient: Ingredient)` | ||
- `addCustomBrewing(ingredient: Ingredient, input: Ingredient, output: Item)` | ||
- `removeCustomBrewing(filter: CustomBrewingFilter)` | ||
- `getCustomBrewingRecipes()` | ||
- Returns a mutable list of all custom brewing recipes. Some mods register their own implementation of a custom brewing recipe. This method can be used to remove them or modify them. | ||
|
||
## Usage | ||
|
||
### Add brewing | ||
|
||
::: info | ||
Remember that the arguments for input and output are `Potion` ids and not items! | ||
::: | ||
|
||
This will add a brewing recipe which creates a strong regeneration potion when using apples. | ||
|
||
```js | ||
MoreJS.registerPotionBrewing((event) => { | ||
event.addPotionBrewing("minecraft:apple", "minecraft:water", "minecraft:strong_regeneration") | ||
}) | ||
``` | ||
|
||
### Add custom brewing | ||
|
||
Custom brewing allows to not rely on any potion. We can just use any item to convert. | ||
|
||
```js | ||
MoreJS.registerPotionBrewing((event) => { | ||
event.addCustomBrewing("minecraft:emerald", "minecraft:nether_star", "minecraft:diamond") | ||
}) | ||
``` | ||
|
||
### Remove brewing | ||
|
||
For removing simple potion brewings we can use a `PotionBrewingFilter` which looks like follow: | ||
|
||
```ts | ||
interface PotionBrewingFilter { | ||
ingredient: Ingredient | ||
input: Potion | Potion[] | RegEx | ||
output: Potion | Potion[] | RegEx | ||
} | ||
``` | ||
|
||
Using the filter does not require to use all the arguments. Arguments which are not given automatically act as wildcards. | ||
|
||
```js | ||
MoreJS.registerPotionBrewing((event) => { | ||
event.removePotionBrewing({ | ||
ingredient: "minecraft:apple", | ||
input: "minecraft:harming", | ||
output: "minecraft:strong_harming", | ||
}) | ||
}) | ||
``` | ||
|
||
### Remove custom brewing | ||
|
||
For removing custom potion brewings we can use a `CustomBrewingFilter` which looks like follow: | ||
|
||
```ts | ||
interface CustomBrewingFilter { | ||
ingredient: Ingredient | ||
input: Ingredient | ||
output: Ingredient | ||
} | ||
``` | ||
|
||
```js | ||
MoreJS.registerPotionBrewing((event) => { | ||
event.removeCustomBrewing({ | ||
ingredient: "minecraft:emerald", | ||
input: "minecraft:nether_star", | ||
output: "minecraft:diamond", | ||
}) | ||
}) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,163 @@ | ||
# Villager Utils | ||
# VillagerUtils | ||
|
||
## Methods | ||
|
||
- `isVanillaTypedTrade(trade: Trade)` | ||
- Checks if given `trade` is using a vanilla trade class internally. Keep in mind that mods can do this too. | ||
- `isModdedTypedTrade(trade: Trade)` | ||
- `isCustomTypedTrade(trade: Trade)` | ||
- Returns `true` for trade classes provided by `MoreJS` | ||
- `createSimpleTrade(input: Item | Item[], output: Item)` | ||
- `createCustomTrade((offer, entity, random) => {})` | ||
- `createStructureMapTrade(input: Item | Item[], structure: string | RegEx | string[])` | ||
- `createBiomeMapTrade(input: Item | Item[], biome: string | RegEx | string[])` | ||
- `createCustomMapTrade(input: Item | Item[], (level, entity) => {})` | ||
- `createEnchantedItemTrade(input: Item | Item[], output: Item)` | ||
- `createEnchantedItemTrade(input: Item | Item[], output: Item, enchantments: string | string[] | RegEx)` | ||
- `createStewTrade(input: Item | Item[])` | ||
- `createPotionTrade(input: Item | Item[])` | ||
- `getVillagerTrades(profession: string)` | ||
- Returns a list of all trades for given profession | ||
- `getVillagerTrades(profession: string, level: number)` | ||
- Returns a list of all trades for given profession and level | ||
- `getRandomVillagerTrade(profession: string)` | ||
- Returns a random trade for given profession | ||
- `getRandomVillagerTrade(profession: string, level: number)` | ||
- Returns a random trade for given profession and level | ||
- `getWandererTrades(level: number)` | ||
- Returns a list of all trades for given level | ||
- `getRandomWandererTrade(level: number)` | ||
- Returns a random trade for given level | ||
|
||
## Usage | ||
|
||
### Treasure map trades | ||
|
||
```js | ||
MoreJS.villagerTrades((event) => { | ||
const trade = VillagerUtils.createStructureMapTrade("minecraft:diamond", "minecraft:stronghold") | ||
event.addTrade("minecraft:cartographer", 1, trade) | ||
}) | ||
``` | ||
|
||
```js | ||
MoreJS.villagerTrades((event) => { | ||
const trade = VillagerUtils.createStructureMapTrade( | ||
["minecraft:diamond", "minecraft:paper"], | ||
"minecraft:stronghold" | ||
) | ||
event.addTrade("minecraft:cartographer", 1, trade) | ||
}) | ||
``` | ||
|
||
We can also use `#` to search for a tag. This works for structures and biomes. | ||
|
||
```js | ||
MoreJS.villagerTrades((event) => { | ||
const trade = VillagerUtils.createBiomeMapTrade("5x minecraft:emerald", "#minecraft:is_forest") | ||
event.addTrade("minecraft:cartographer", 1, trade) | ||
}) | ||
``` | ||
|
||
It's also possible to create a custom map trade by providing your own block pos. This example will get a random overworld biome and search for the position of the biome. | ||
|
||
```js | ||
MoreJS.villagerTrades((event) => { | ||
const trade = VillagerUtils.createCustomMapTrade( | ||
["10x minecraft:diamond", "minecraft:paper"], | ||
(level, entity) => { | ||
const rndBiome = Registry.of("worldgen/biome") | ||
.getValues("#minecraft:is_overworld") | ||
.getRandom() | ||
return MoreUtils.findBiome(entity.blockPosition(), level, rndBiome, 250) | ||
} | ||
) | ||
|
||
event.addTrade("minecraft:cartographer", 1, trade) | ||
}) | ||
``` | ||
|
||
#### Further modify map trades | ||
|
||
When creating a map trade we can further modify it. You can find possible map markers [here](https://minecraft.wiki/w/Map#Map_icons) | ||
|
||
```js | ||
MoreJS.villagerTrades((event) => { | ||
const trade = VillagerUtils.createBiomeMapTrade("5x minecraft:emerald", "#minecraft:is_forest") | ||
.displayName("Nearest forest") | ||
.marker("banner_orange") | ||
.noPreview() | ||
.scale(4) | ||
|
||
event.addTrade("minecraft:cartographer", 1, trade) | ||
}) | ||
``` | ||
|
||
### Enchanted trades | ||
|
||
If no enchantments are provided the trade will use `#minecraft:on_traded_equipment` for the enchantments. | ||
|
||
```js | ||
MoreJS.villagerTrades((event) => { | ||
const trade = VillagerUtils.createEnchantedItemTrade( | ||
"5x minecraft:emerald", | ||
"minecraft:diamond_pickaxe" | ||
) | ||
|
||
event.addTrade("minecraft:weaponsmith", 1, trade) | ||
}) | ||
``` | ||
|
||
We can also provide which enchantments we want. | ||
|
||
```js | ||
MoreJS.villagerTrades((event) => { | ||
const trade = VillagerUtils.createEnchantedItemTrade( | ||
"5x minecraft:emerald", | ||
"minecraft:diamond_pickaxe", | ||
"#morejs:our_cool_enchantments" | ||
) | ||
|
||
event.addTrade("minecraft:weaponsmith", 1, trade) | ||
}) | ||
``` | ||
|
||
```js | ||
MoreJS.villagerTrades((event) => { | ||
const trade = VillagerUtils.createEnchantedItemTrade( | ||
"5x minecraft:emerald", | ||
"minecraft:diamond_pickaxe", | ||
["minecraft:unbreaking", "minecraft:mending", "minecraft:fortune"] | ||
) | ||
|
||
event.addTrade("minecraft:weaponsmith", 1, trade) | ||
}) | ||
``` | ||
|
||
#### Define the enchantment levels | ||
|
||
The enchantment trade will enchant the given item by a given level or levels. We can set them by `.levels()`. The default value is `[5, 20]` which is the same as vanilla uses. | ||
|
||
```js | ||
MoreJS.villagerTrades((event) => { | ||
const trade = VillagerUtils.createEnchantedItemTrade( | ||
"5x minecraft:emerald", | ||
"minecraft:diamond_pickaxe" | ||
).levels(10) | ||
|
||
event.addTrade("minecraft:weaponsmith", 1, trade) | ||
}) | ||
``` | ||
|
||
Or we can set them by `.levels([10, 30])` if we want a random range between the two values. | ||
|
||
```js | ||
MoreJS.villagerTrades((event) => { | ||
const trade = VillagerUtils.createEnchantedItemTrade( | ||
"5x minecraft:emerald", | ||
"minecraft:diamond_pickaxe" | ||
).levels([10, 30]) | ||
|
||
event.addTrade("minecraft:weaponsmith", 1, trade) | ||
}) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters