Skip to content

Commit

Permalink
Update readme and add parchment
Browse files Browse the repository at this point in the history
  • Loading branch information
LLytho committed Jul 26, 2024
1 parent b50d6b9 commit 7a9980a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 101 deletions.
128 changes: 27 additions & 101 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div align="center">
<h1>LootJS</h1>

A [Minecraft] mod for packdevs to easily modify the loot system with [KubeJS].
A [Minecraft] mod for packdevs to easily modify loot tables with [KubeJS].

[![Workflow Status][workflow_status_badge]][workflow_status_link]
[![License][license_badge]][license]
Expand All @@ -16,132 +16,58 @@ A [Minecraft] mod for packdevs to easily modify the loot system with [KubeJS].
</div>

## **📑 Overview**
This is a mod for [Minecraft]-[Forge] and [Fabric] and needs [KubeJS].<br>

This is a mod for [Minecraft]-[NeoForge] and needs [KubeJS].<br>

## **🔧 Installation**

1. Download the latest **mod jar** from the [releases], from [CurseForge] or from [Modrinth].
2. Download the latest **mod jar** of [KubeJS].
3. Install Minecraft [Forge] or [Fabric].
3. Install Minecraft [NeoForge].
4. Drop both **jar files** into your mods folder.

## **✏️ Your first loot modification**
Loot modifications are handled server side. So all your scripts will go into your `your_minecraft_instance/kubejs/server_scripts` directory. Just create a `.js` file and let's get started.

Here's simple example which adds a gunpowder for creepers:
```js
LootJS.modifiers((event) => {
event
.addEntityLootModifier("minecraft:creeper")
.randomChance(0.3) // 30% chance
.thenAdd("minecraft:gunpowder");
});
```

Instead of using a loot table for reference, you can also apply the modification to all entities:
```js
LootJS.modifiers((event) => {
event
.addLootTypeModifier(LootType.ENTITY) // you also can use multiple types
.logName("It's raining loot") // you can set a custom name for logging
.weatherCheck({
raining: true,
})
.thenModify(Ingredient.getAll(), (itemStack) => {
// you have to return an item!
return itemStack.withCount(itemStack.getCount() * 2);
});
});
```

Next, let's check if the player holds a specific item:
```js
LootJS.modifiers((event) => {
event
.addBlockLootModifier("#forge:ores") // keep in mind this is a block tag not an item tag
.matchEquip(EquipmentSlot.MAINHAND, Item.of("minecraft:netherite_pickaxe").ignoreNBT())
.thenAdd("minecraft:gravel");

// for MainHand and OffHand you can also use:
// matchMainHand(Item.of("minecraft:netherite_pickaxe").ignoreNBT())
// matchOffHand(Item.of("minecraft:netherite_pickaxe").ignoreNBT())
});
```

## **⚙️ More Information**
For more information about the usage and the functionality of the mod, please
visit our [wiki] or explore the [examples].

## **❌ Disable loot tables for loot modifications** (**[Forge] only**)
Some blocks like leaves are getting randomly destroyed. If you don't want them to trigger your loot modifications, you can disable their loot tables. The default loot tables will still be triggered.
```js
LootJS.modifiers((event) => {
// all leaves disabled via regex
event.disableLootModification(/.*:blocks\/.*_leaves/);

// disable bats
event.disableLootModification("minecraft:entities/bat");
});

```

## **📜 Enable logging for loot modifications**
With a lot of modifications, it can be hard to track which modification triggers on specific conditions. With `enableLogging`, LootJS will log every modification trigger into `your_minecraft_instance/logs/kubejs/server.txt`.
```js
LootJS.modifiers((event) => {
event.enableLogging();
});
```

Here's the output for the `additional gunpowder` and `raining loot` examples:
```lua
[ Loot information ]
LootTable : "minecraft:entities/creeper"
Loot Type : ENTITY
Current loot :
Position : (151.86, 80.00, -264.23)
Entity : Type="minecraft:creeper", Id=378, Dim="minecraft:overworld", x=151.86, y=80.00, z=-264.23
Killer Entity: Type="minecraft:player", Id=122, Dim="minecraft:overworld", x=152.52, y=80.00, z=-262.85
Direct Killer: Type="minecraft:player", Id=122, Dim="minecraft:overworld", x=152.52, y=80.00, z=-262.85
Player : Type="minecraft:player", Id=122, Dim="minecraft:overworld", x=152.52, y=80.00, z=-262.85
Player Pos : (152.52, 80.00, -262.85)
Distance : 1.53
MainHand : 1 netherite_sword {Damage:0}
[ Modifications ]
🔧 LootTables["minecraft:entities/creeper"] {
RandomChance
conditions are false. Stopping at AddLootAction
}
🔧 "It's raining loot" {
✔️ WeatherCheck
invoke ModifyLootAction
}
```

## **🎓 License**

This project is licensed under the [GNU Lesser General Public License v3.0][license].

<!-- Badges -->

[workflow_status_badge]: https://img.shields.io/github/actions/workflow/status/AlmostReliable/lootjs/build.yml?branch=1.20.1&style=for-the-badge

[workflow_status_link]: https://github.com/AlmostReliable/lootjs/actions

[total_downloads_cf_badge]: https://img.shields.io/badge/dynamic/json?color=e04e14&label=CurseForge&style=for-the-badge&query=downloads.total&url=https://api.cfwidget.com/570630&logo=curseforge

[total_downloads_mr_badge]: https://img.shields.io/modrinth/dt/fJFETWDN?color=5da545&label=Modrinth&style=for-the-badge&logo=modrinth

[version_badge]: https://img.shields.io/github/v/release/AlmostReliable/lootjs?include_prereleases&style=for-the-badge

[version_link]: https://github.com/AlmostReliable/lootjs/releases/latest

[license_badge]: https://img.shields.io/github/license/AlmostReliable/lootjs?style=for-the-badge

[discord_badge]: https://img.shields.io/discord/917251858974789693?color=5865f2&label=Discord&logo=discord&style=for-the-badge

[wiki_badge]: https://img.shields.io/badge/Read%20the-Wiki-ba00ff?style=for-the-badge

<!-- Links -->
[forgeloot]: https://mcforge.readthedocs.io/en/latest/items/globallootmodifiers/

[minecraft]: https://www.minecraft.net/

[kubejs]: https://www.curseforge.com/minecraft/mc-mods/kubejs

[discord]: https://discord.com/invite/ThFnwZCyYY

[releases]: https://github.com/AlmostReliable/lootjs/releases

[curseforge]: https://www.curseforge.com/minecraft/mc-mods/lootjs

[modrinth]: https://modrinth.com/mod/lootjs
[forge]: http://files.minecraftforge.net/
[fabric]: https://fabricmc.net/
[wiki]: https://github.com/AlmostReliable/lootjs/wiki

[neoforge]: https://neoforged.net/

[wiki]: https://docs.almostreliable.com/lootjs/

[changelog]: CHANGELOG.md

[license]: LICENSE
[examples]: examples/server_scripts
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ kubejsVersion = 2100.7.0-build.103
githubUser = AlmostReliable
githubRepo = lootjs

# Parchment
neoForge.parchment.minecraftVersion = 1.21
neoForge.parchment.mappingsVersion = 2024.07.07

# Gradle
org.gradle.jvmargs = -Xmx3G
org.gradle.daemon = false
Expand Down

0 comments on commit 7a9980a

Please sign in to comment.