**vred's Data-Pack Library** (vred's DP Lib for short) is the first Data-Pack library I've ever made.
The main scope of this project is to add useful tools for creating custom items faster and more easily.
This tools is split into different sections:
- **Data Components**
- **Behaviour Components**
- **Function Tags**
- **Misc**

> **Data Components**
These define information about the item. Which will be quite important!
### As general rule, every vred's DP lib component goes in the "..." part
### <code>custom_data={vred_lib:{...}}</code>


## Component: <code>id</code>

  **string**

This one doesn't really do anything important, just defines the <code>id</code> of an item.

  **Example:**

### <code>give @s stick[custom_data={vred_lib:{id:"example:cool_stick"}}]</code>



## Component: <code>weapon_id</code>

  **string**


This one very important, as it's required for upcoming components. <code>id</code> contains 2 parts, one of these is the <code>weapon_id</code>, which is the part after the ":".
It requires a folder named from <code>weapon_id</code> in the current datapack. As for the namespace, it will be taken from the next component, <code>namespace</code>.

  **Example:**

### <code>give @s stick[custom_data={vred_lib:{id:"example:cooler_stick",weapon_id:cooler_stick}}]</code>
This item won't do anything yet.



## Component: <code>namespace</code>

  **string**


This one is also very important, as it's required for upcoming components too. <code>id</code> contains 2 parts, one of these is the <code>namespace</code>, which is the part before the ":".
It requires a folder named from <code>namespace</code> in the current datapack. 

  **Example:**

### <code>give @s stick[custom_data={vred_lib:{id:"example:very_cool_stick",weapon_id:very_cool_stick,namespace:example}}]</code>
This item won't do anything yet.


> **Behaviour Components**
These will run functions in a specific condition.
These require a certain slot to work with:

<code>mainhand:{...}</code> in mainhand.

<code>offhand:{...}</code> in offhand.

<code>head:{...}</code> head slot.

<code>chest:{...}</code> chest slot.

<code>legs:{...}</code> chest slot.

<code>feet:{...}</code> chest slot.

<code>all:{...}</code> all the previous slots.

<code>hand:{...}</code> either hand.

<code>armor:{...}</code> any armor slot.


## Component: <code>on_hit_effect</code>

**boolean**

This will run a command on hit.
The function that will be run is this:

```
data/<namespace>/function/<weapon_id>/on_hit.mcfunction
```

  **Example:**

#### <code>give @s bow[custom_data={vred_lib:{id:"example:fast_bow",weapon_id:fast_bow,namespace:example,hand:{on_hit_effect:true}}}]</code>

<code> 
## data/example/function/fast_bow/on_hit.mcfunction

give @s arrow
say I hit an entity!
</code>

When hitting an entity (either arrow or hand) it will give an arrow to the player.




## Component: <code>entity_hit_effect</code>

**boolean**

This will run a command when recieving a hit.
The function that will be run is this:

```
data/<namespace>/function/<weapon_id>/entity_hit.mcfunction
```


  **Example:**

#### <code>give @s stick[custom_data={vred_lib:{id:"example:strong_shield",weapon_id:strong_shield,namespace:example,offhand:{entity_hit_effect:true}}}]</code>

```
## data/example/function/strong_shield/entity_hit.mcfunction
effect give @s resistance 4 1 true
execute rotated as @s on attacker run tp @s ^ ^ ^2
```

While holding the shield in offhand, recieving a hit from an entity will push it away by 2 blocks.




## Component: <code>on_kill</code>

**boolean**

This will run a command when kiling an entity.
The function that will be run is this:

```
data/<namespace>/function/<weapon_id>/on_kill.mcfunction
```

  **Example:**

#### <code>give @s iron_sword[custom_data={vred_lib:{id:"example:bloodlust",weapon_id:bloodlust,namespace:example,mainhand:{on_kill_effect:true}}}]</code>

``` 
## data/example/function/bloodlust/on_kill.mcfunction

effect give @s strength 10 1 true
```

After killing an entity, the user will get strength 2 for a few seconds.





## Component: <code>double_sneak_effect</code>

  **boolean**


This will run a command when pressing the sneak button twice in a small amount of time. 
The command will be run as such:

```
data/<namespace>/function/<weapon_id>/double_sneak.mcfunction
```

  **Example:**

#### <code>give @s stick[custom_data={vred_lib:{id:"example:very_cool_stick",weapon_id:very_cool_stick,namespace:example,hand:{double_sneak:true}}}]</code>

<code> 
## data/example/function/very_cool_stick/double_sneak.mcfunction

effect give @s speed 2 2
</code>

This will make the stick give speed 3 when tapping the sneak button twice in quick succession(while holding the item in either hand).




## Component: <code>tap_sneak_effect</code>

  **boolean**


This will run a command when sneaking once (tapping). 
The command will be run as such:

```
data/<namespace>/function/<weapon_id>/tap_sneak.mcfunction
```

  **Example:**

#### <code>give @s diamond_boots[custom_data={vred_lib:{id:"example:jumping_boots",weapon_id:jumping_boots,namespace:example,feet:{tap_sneak:true}}}]</code>

```
## data/example/function/jumping_boots/tap_sneak.mcfunction
effect give @s jump_boost 3 1
particle cloud ^ ^ ^ 0 0 0 0.2 30
```

This will make the boots give jump boost and emit particles when tapping sneak.




## Component: <code>interaction</code>

  **string**


This component will spawn an interaction entity in front of the player while the player is holding the item in the main hand. The interaction entity can be used for both right and left click and the functions will be ran like this: 
```
data/<namespace>/function/<weapon_id>/left_click.mcfunction
data/<namespace>/function/<weapon_id>/right_click.mcfunction
```

If it's "interaction:no_shift", the interaction entity will always be there.
If it's "interaction:shift", the interaction entity will only appear while the player is shifting.

  **Example:**

#### <code>give @s netherite_shovel[custom_data={vred_lib:{id:"example:offbrand_spear",weapon_id:offbrand_spear,interaction:no_shift}}]</code>

<code> 
## data/example/function/offbrand_spear/left_click.mcfunction

say left click
</code>

<code> 
## data/example/function/offbrand_spear/right_click.mcfunction

say right click
</code>




## Component: <code>no_interaction_right_click</code>

  **boolean**


This will run a command while holding right click. It requires the food component:  <code>minecraft:food={nutrition:0,saturation:0,can_always_eat:1b,eat_seconds:1000000}</code>
The function will be ran constantly while holding right click.

```
data/<namespace>/function/<weapon_id>/right_click.mcfunction
```

  **Example: (needs to be changed)**

#### <code>give @s blaze_rod[custom_data={vred_lib:{id:"example:hot_rod",weapon_id:hot_rod,namespace:example,no_interaction_right_click:1b}},food={nutrition:0,saturation:0,can_always_eat:1b,eat_seconds:1000000}]</code>


```
## data/example/function/hot_rod/right_click.mcfunction
execute anchored eyes run particle flame ^ ^ ^1
execute anchored eyes run particle flame ^ ^ ^2
execute anchored eyes run particle flame ^ ^ ^3
```






## Component: <code>scrollable</code>

  **boolean**

When dropping the item from the main hand, it reference an item modifier based on the <code>map_id</code> component.
This is a brand new system I made for displaying item descriptions, as each item modifier can reference a different lore page and change the <code>map_id</code> to go on the next page.


```
data/<namespace>/item_modifier/page/<weapon_id>/<n>.json
```

  **Example:**

#### <code>give @s diamond_sword[custom_data={vred_lib:{id:"example:multitool",weapon_id:multitool,namespace:example,scrollable:1b}},map_id=1,unbreakable={}]</code>


```
## data/example/item_modifier/page/multitool/1.json (you can't have comments in json)
[{function:"set_item",item:"minecraft:netherite_axe"},{function:"set_components",components:{map_id:2}}]

## data/example/item_modifier/page/multitool/2.json 
[{function:"set_item",item:"minecraft:diamond_pickaxe"},{function:"set_components",components:{map_id:3}}]

## data/example/item_modifier/page/multitool/2.json 
[{function:"set_item",item:"minecraft:diamond_pickaxe"},{function:"set_components",components:{map_id:3}}]

## data/example/item_modifier/page/multitool/3.json 
[{function:"set_item",item:"minecraft:diamond_shovel"},{function:"set_components",components:{map_id:4}}]

## data/example/item_modifier/page/multitool/4.json 
[{function:"set_item",item:"minecraft:diamond_hoe"},{function:"set_components",components:{map_id:1}}]
```

The example is a pretty simple multitool, where each "page" switches the multitool to a different item. An important thing to mention is that each item modifier changes the <code>map_id</code> for next item modifier to use.



> **Function Tags**
Various function tags I use. Why not use the vanilla ones? I don't know.


## #vred_lib:load

Works identically to normal <code>#minecraft:load</code> function. No idea why I made it.




## <code>#vred_lib:entity</code>

Tick function only for entity, excluding the player.



## <code>#vred_lib:entity</code>

Tick function only for player.


> **Misc**
Contains various miscellaneous, but useful stuff.


## Predicate: <code>vred_lib:stuff</code>
This predicate includes entities that shouldn't be targeted.
It includes:

- Display entities;
- Entities being ridden;
- Dropped items;
- Arrows.





## Predicate: <code>vred_lib:id_check</code>
Simple <code>id</code> system. Each player gets a <code>vred_lib.id</code> score.  

You can use a predicate to check if the player has the same ID as the specified ID (stored in a fake player on a scoreboard). 
In this case, this predicate will only trigger if the player’s <code>vred_lib.id</code> score is equal to the <code>vred_lib.id</code> score of the fake player (#temp). 




## score: <code>vred_lib.config</code>

This score will be used for different mod compats. The mod name is stored with acronym. The main and only example at the moment is **Iron's Spells and Spellbooks**.

To check if the mod is present, check the <code>vred_lib.config</code> score of the fake player <code>#iss_compat</code>. 
If the score is 1, that means the mod is present. **The detection works by using a command from the mod.**
There's also the <code>vred_lib.iss.mana</code> score, which can be used to check the amount of mana of the player.

The compatibilies will be expanded in the future with more mods, be sure to send some suggestions!


## Tag: <code>1slot_tag</code>
This tag checks if the player has at least 1 free inventory and hotbar slot. If it has one, the player will have the tag.


## Custom Projectiles

You can add custom projectiles. These projectiles are very barebones and don't even have gravity (will changed in the future).

To add a custom projectile, 
```
scoreboard players operation #test vred_lib.id = @s vred_lib.id
execute rotated as @s anchored eyes positioned ~ ~-1 ~ run function vred_lib:projectile/summon {id:"<projectile_id>"}
function vred_lib:projectile/throw {id:"<projectile_id>"}
```
This will spawn the projectile with the <code><projectile_id></code>. 
To change the behaviour and data of said projectile, target it back in the tick function. It has a built-in timer, called <code>rayAge</code>.

The <code>throw</code> function will save a copy of the item and reduce the amount of the item in the main hand.

Later then use <code>function vred_lib:projectile/return {id:"<projectile_id>"}</code> as the projectile to make the item return to the owner.

