Skip to content

Commit

Permalink
new version, using consumable component
Browse files Browse the repository at this point in the history
  • Loading branch information
lullaby6 committed Feb 12, 2025
1 parent f505b5c commit a938383
Show file tree
Hide file tree
Showing 32 changed files with 292 additions and 173 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ Version: `1.21.4`
Give Empty Experience Bottle:

```mcfunction
/loot give @s loot experience_bottle:empty_experience_bottle
/loot give @s loot experience_bottle:empty
```

Give Filled Experience Bottle:

```mcfunction
/loot give @s loot experience_bottle:filled_experience_bottle
/loot give @s loot experience_bottle:filled
```

Disable:
Expand Down
19 changes: 19 additions & 0 deletions data/experience_bottle/advancement/consume/empty.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"criteria": {
"requirement": {
"trigger": "minecraft:consume_item",
"conditions": {
"item": {
"components": {
"minecraft:custom_data": {
"experience_bottle.empty": true
}
}
}
}
}
},
"rewards": {
"function": "experience_bottle:empty/consume"
}
}
19 changes: 19 additions & 0 deletions data/experience_bottle/advancement/consume/filled.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"criteria": {
"requirement": {
"trigger": "minecraft:consume_item",
"conditions": {
"item": {
"components": {
"minecraft:custom_data": {
"experience_bottle.filled": true
}
}
}
}
}
},
"rewards": {
"function": "experience_bottle:filled/consume"
}
}
3 changes: 0 additions & 3 deletions data/experience_bottle/function/empty/check_hand.mcfunction

This file was deleted.

4 changes: 0 additions & 4 deletions data/experience_bottle/function/empty/check_xp.mcfunction

This file was deleted.

6 changes: 6 additions & 0 deletions data/experience_bottle/function/empty/consume.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
advancement revoke @s only experience_bottle:consume/empty

xp add @s -1395 points

execute if predicate experience_bottle:empty/mainhand run return run loot replace entity @s weapon.mainhand loot experience_bottle:filled
execute if predicate experience_bottle:empty/offhand run return run loot replace entity @s weapon.offhand loot experience_bottle:filled
5 changes: 5 additions & 0 deletions data/experience_bottle/function/empty/holding.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
execute store result score @s experience_bottle.player.xp run xp query @s levels

$execute if score @s experience_bottle.player.xp matches ..29 run return run item modify entity @s weapon.$(hand)hand experience_bottle:non_consumable

$item modify entity @s weapon.$(hand)hand experience_bottle:consumable/empty

This file was deleted.

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions data/experience_bottle/function/empty/left.mcfunction

This file was deleted.

3 changes: 0 additions & 3 deletions data/experience_bottle/function/empty/right.mcfunction

This file was deleted.

3 changes: 0 additions & 3 deletions data/experience_bottle/function/filled/check_hand.mcfunction

This file was deleted.

9 changes: 9 additions & 0 deletions data/experience_bottle/function/filled/consume.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
advancement revoke @s only experience_bottle:consume/filled

xp add @s 1395 points

execute if predicate experience_bottle:filled/mainhand run return run loot replace entity @s weapon.mainhand loot experience_bottle:empty
execute if predicate experience_bottle:filled/offhand run return run loot replace entity @s weapon.offhand loot experience_bottle:empty

# execute if items entity @s weapon.mainhand minecraft:glass_bottle run return run loot replace entity @s weapon.mainhand loot experience_bottle:empty
# execute if items entity @s weapon.offhand minecraft:glass_bottle run return run loot replace entity @s weapon.offhand loot experience_bottle:empty
5 changes: 0 additions & 5 deletions data/experience_bottle/function/filled/left.mcfunction

This file was deleted.

5 changes: 0 additions & 5 deletions data/experience_bottle/function/filled/right.mcfunction

This file was deleted.

6 changes: 4 additions & 2 deletions data/experience_bottle/function/load.mcfunction
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
scoreboard objectives add experience_bottle.potion_use minecraft.used:minecraft.potion
scoreboard objectives add experience_bottle.player_xp dummy
scoreboard objectives add experience_bottle.player.xp dummy

advancement revoke @a only experience_bottle:consume/empty
advancement revoke @a only experience_bottle:consume/filled
6 changes: 2 additions & 4 deletions data/experience_bottle/function/tick.mcfunction
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
execute as @a[nbt={active_effects:[{id:"minecraft:mining_fatigue",amplifier:19b}]}] if score @s experience_bottle.potion_use matches 1.. run function experience_bottle:empty/check_xp
execute as @a[nbt={active_effects:[{id:"minecraft:mining_fatigue",amplifier:20b}]}] if score @s experience_bottle.potion_use matches 1.. at @s run function experience_bottle:filled/check_hand

execute as @a if score @s experience_bottle.potion_use matches 1.. run scoreboard players reset @s experience_bottle.potion_use
execute as @a if predicate experience_bottle:empty/mainhand run function experience_bottle:empty/holding {"hand":"main"}
execute as @a if predicate experience_bottle:empty/offhand run function experience_bottle:empty/holding {"hand":"off"}
11 changes: 11 additions & 0 deletions data/experience_bottle/item_modifier/consumable/empty.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"function": "minecraft:set_components",
"components": {
"minecraft:consumable": {
"consume_seconds": 0.05,
"animation": "none",
"sound": "minecraft:block.trial_spawner.spawn_mob",
"has_consume_particles": false
}
}
}
17 changes: 17 additions & 0 deletions data/experience_bottle/item_modifier/consumable/filled.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"function": "minecraft:set_components",
"components": {
"minecraft:consumable": {
"consume_seconds": 2,
"animation": "drink",
"sound": "minecraft:entity.generic.drink",
"has_consume_particles": false,
"on_consume_effects": [
{
"type": "minecraft:play_sound",
"sound": "entity.player.levelup"
}
]
}
}
}
6 changes: 6 additions & 0 deletions data/experience_bottle/item_modifier/non_consumable.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"function": "minecraft:set_components",
"components": {
"!minecraft:consumable": {}
}
}
43 changes: 43 additions & 0 deletions data/experience_bottle/loot_table/empty.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "item",
"weight": 1,
"name": "minecraft:command_block",
"functions": [
{
"function": "set_count",
"count": 1
},
{
"function": "set_components",
"components": {
"minecraft:rarity": "epic",
"minecraft:enchantment_glint_override": true,
"minecraft:max_stack_size": 1,
"minecraft:custom_data": {
"experience_bottle.empty": true
},
"minecraft:consumable": {
"consume_seconds": 0.05,
"animation": "none",
"sound": "minecraft:block.trial_spawner.spawn_mob",
"has_consume_particles": false
},
"minecraft:use_cooldown": {
"seconds": 2,
"cooldown_group": "experience_bottle:cooldown"
},
"minecraft:item_model": "minecraft:glass_bottle",
"minecraft:custom_name": "{\"text\":\"Experience Bottle\",\"italic\": false}"
}
}
]
}
]
}
]
}
49 changes: 0 additions & 49 deletions data/experience_bottle/loot_table/empty_experience_bottle.json

This file was deleted.

52 changes: 52 additions & 0 deletions data/experience_bottle/loot_table/filled.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "item",
"weight": 1,
"name": "minecraft:potion",
"functions": [
{
"function": "set_count",
"count": 1
},
{
"function": "set_components",
"components": {
"minecraft:rarity": "epic",
"minecraft:enchantment_glint_override": true,
"minecraft:custom_data": {
"experience_bottle.filled": true
},
"minecraft:potion_contents": {
"custom_color": 2276636
},
"minecraft:hide_additional_tooltip": {},
"minecraft:consumable": {
"consume_seconds": 2,
"animation": "drink",
"sound": "minecraft:entity.generic.drink",
"has_consume_particles": false,
"on_consume_effects": [
{
"type": "minecraft:play_sound",
"sound": "entity.player.levelup"
}
]
},
"minecraft:use_cooldown": {
"seconds": 2,
"cooldown_group": "experience_bottle:cooldown"
},
"minecraft:custom_name": "{\"text\":\"Experience Bottle\",\"italic\": false}",
"!minecraft:use_remainder": {}
}
}
]
}
]
}
]
}
49 changes: 0 additions & 49 deletions data/experience_bottle/loot_table/filled_experience_bottle.json

This file was deleted.

Loading

0 comments on commit a938383

Please sign in to comment.