diff --git a/.idea/libraries/Gradle__io_papermc_paper_paper_api_1_21_10_R0_1_SNAPSHOT.xml b/.idea/libraries/Gradle__io_papermc_paper_paper_api_1_21_10_R0_1_SNAPSHOT.xml index 603dada4b..e421723b2 100644 --- a/.idea/libraries/Gradle__io_papermc_paper_paper_api_1_21_10_R0_1_SNAPSHOT.xml +++ b/.idea/libraries/Gradle__io_papermc_paper_paper_api_1_21_10_R0_1_SNAPSHOT.xml @@ -7,7 +7,6 @@ - \ No newline at end of file diff --git a/src/main/kotlin/org/xodium/vanillaplus/VanillaPlusBootstrap.kt b/src/main/kotlin/org/xodium/vanillaplus/VanillaPlusBootstrap.kt index fa704d08d..e880b8a55 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/VanillaPlusBootstrap.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/VanillaPlusBootstrap.kt @@ -17,6 +17,7 @@ import org.xodium.vanillaplus.enchantments.NightVisionEnchantment import org.xodium.vanillaplus.enchantments.NimbusEnchantment import org.xodium.vanillaplus.enchantments.PickupEnchantment import org.xodium.vanillaplus.enchantments.ReplantEnchantment +import java.util.Objects.requireNonNull /** Main bootstrap class of the plugin. */ @Suppress("UnstableApiUsage", "Unused") @@ -104,6 +105,16 @@ internal class VanillaPlusBootstrap : PluginBootstrap { addToTag(EnchantmentTagKeys.IN_ENCHANTING_TABLE, enchants) } } + registerEventHandler( + LifecycleEvents.DATAPACK_DISCOVERY.newHandler { event -> + try { + val uri = requireNonNull(javaClass.getResource("/nyctophobia")).toURI() + event.registrar().discoverPack(uri, "provided") + } catch (e: Exception) { + e.printStackTrace() + } + }, + ) } } } diff --git a/src/main/kotlin/org/xodium/vanillaplus/hooks/NyctophobiaHook.kt b/src/main/kotlin/org/xodium/vanillaplus/hooks/NyctophobiaHook.kt new file mode 100644 index 000000000..6dc1fb651 --- /dev/null +++ b/src/main/kotlin/org/xodium/vanillaplus/hooks/NyctophobiaHook.kt @@ -0,0 +1,34 @@ +package org.xodium.vanillaplus.hooks + +import net.kyori.adventure.audience.Audience +import net.kyori.adventure.resource.ResourcePackInfo +import net.kyori.adventure.resource.ResourcePackRequest +import org.xodium.vanillaplus.utils.ExtUtils.mm +import java.net.URI + +/** A utility object for checking datapack availability and handling related dependencies. */ +object NyctophobiaHook { + val PACK_INFO = + ResourcePackInfo + .resourcePackInfo() + .uri( + URI.create( + "https://cdn.modrinth.com/data/Q2HFmuJV/versions/xe548JsZ/Nyctophobia%20Resourcepack%20V1.5%20%5BOPTIFINE%5D.zip", + ), + ).build() + + /** + * Sends the Nyctophobia resource pack to the specified audience. + * @param target The audience to send the resource pack to. + */ + fun sendResourcePack(target: Audience) { + target.sendResourcePacks( + ResourcePackRequest + .resourcePackRequest() + .packs(PACK_INFO) + .prompt("This Resource Pack is required to play on this server.".mm()) + .required(true) + .build(), + ) + } +} diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/PlayerModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/PlayerModule.kt index 070fc8647..a24bac17d 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/PlayerModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/PlayerModule.kt @@ -29,6 +29,7 @@ import org.xodium.vanillaplus.data.CommandData import org.xodium.vanillaplus.enchantments.NightVisionEnchantment import org.xodium.vanillaplus.enchantments.PickupEnchantment import org.xodium.vanillaplus.enchantments.ReplantEnchantment +import org.xodium.vanillaplus.hooks.NyctophobiaHook import org.xodium.vanillaplus.interfaces.ModuleInterface import org.xodium.vanillaplus.pdcs.PlayerPDC.nickname import org.xodium.vanillaplus.utils.ExtUtils.mm @@ -85,6 +86,8 @@ internal class PlayerModule( val player = event.player + NyctophobiaHook.sendResourcePack(player) + player.displayName(player.nickname?.mm()) if (config.i18n.playerJoinMsg.isEmpty()) return diff --git a/src/main/resources/nyctophobia/data/minecraft/tags/function/load.json b/src/main/resources/nyctophobia/data/minecraft/tags/function/load.json new file mode 100644 index 000000000..1b15e9006 --- /dev/null +++ b/src/main/resources/nyctophobia/data/minecraft/tags/function/load.json @@ -0,0 +1,5 @@ +{ + "values": [ + "nycto:load" + ] +} \ No newline at end of file diff --git a/src/main/resources/nyctophobia/data/minecraft/tags/function/tick.json b/src/main/resources/nyctophobia/data/minecraft/tags/function/tick.json new file mode 100644 index 000000000..f379be8b9 --- /dev/null +++ b/src/main/resources/nyctophobia/data/minecraft/tags/function/tick.json @@ -0,0 +1,5 @@ +{ + "values": [ + "nycto:tick" + ] +} \ No newline at end of file diff --git a/src/main/resources/nyctophobia/data/nycto/function/difficulty/easy.mcfunction b/src/main/resources/nyctophobia/data/nycto/function/difficulty/easy.mcfunction new file mode 100644 index 000000000..8689550fb --- /dev/null +++ b/src/main/resources/nyctophobia/data/nycto/function/difficulty/easy.mcfunction @@ -0,0 +1 @@ +scoreboard players set .diff grue.diff 1 \ No newline at end of file diff --git a/src/main/resources/nyctophobia/data/nycto/function/difficulty/hard.mcfunction b/src/main/resources/nyctophobia/data/nycto/function/difficulty/hard.mcfunction new file mode 100644 index 000000000..30a7bbf83 --- /dev/null +++ b/src/main/resources/nyctophobia/data/nycto/function/difficulty/hard.mcfunction @@ -0,0 +1 @@ +scoreboard players set .diff grue.diff 3 \ No newline at end of file diff --git a/src/main/resources/nyctophobia/data/nycto/function/difficulty/normal.mcfunction b/src/main/resources/nyctophobia/data/nycto/function/difficulty/normal.mcfunction new file mode 100644 index 000000000..73ea2d3b0 --- /dev/null +++ b/src/main/resources/nyctophobia/data/nycto/function/difficulty/normal.mcfunction @@ -0,0 +1 @@ +scoreboard players set .diff grue.diff 2 \ No newline at end of file diff --git a/src/main/resources/nyctophobia/data/nycto/function/grue/despawn.mcfunction b/src/main/resources/nyctophobia/data/nycto/function/grue/despawn.mcfunction new file mode 100644 index 000000000..20001b858 --- /dev/null +++ b/src/main/resources/nyctophobia/data/nycto/function/grue/despawn.mcfunction @@ -0,0 +1,7 @@ +particle smoke ~ ~ ~ 0.5 0.5 0.5 0 600 normal +execute store result score @s grue.rng run loot spawn ~ ~ ~ loot nycto:rng/1-3 +execute if score @s grue.rng matches 1 run playsound minecraft:grue.snarl1 hostile @a ~ ~ ~ 1 +execute if score @s grue.rng matches 2 run playsound minecraft:grue.snarl2 hostile @a ~ ~ ~ 1 +execute if score @s grue.rng matches 3 run playsound minecraft:grue.snarl3 hostile @a ~ ~ ~ 1 +tp @s ~ ~-256 ~ +kill @s \ No newline at end of file diff --git a/src/main/resources/nyctophobia/data/nycto/function/grue/give.mcfunction b/src/main/resources/nyctophobia/data/nycto/function/grue/give.mcfunction new file mode 100644 index 000000000..b22bb98d3 --- /dev/null +++ b/src/main/resources/nyctophobia/data/nycto/function/grue/give.mcfunction @@ -0,0 +1 @@ +give @p husk_spawn_egg{EntityTag:{CanBreakDoors:1,DeathLootTable:"minecraft:entities/allay",CustomName:'[{"text":"Unknown"}]',Health:800,Silent:1b,Tags:["grue.gruemob"],active_effects:[{id:"minecraft:invisibility",duration:1000000,amplifier:1,show_particles:0b}],ArmorItems:[{},{},{},{id:"string",tag:{CustomModelData:557001},Count:1}],ArmorDropChances:[0f,0f,0f,0.00f],Attributes:[{Name:"generic.movement_speed",Base:0.5d},{Name:"generic.attack_damage",Base:500d},{Name:"generic.max_health",Base:800d}]},display:{Name:'[{"text":"Grue Spawn Egg","italic":false}]'}} 1 \ No newline at end of file diff --git a/src/main/resources/nyctophobia/data/nycto/function/grue/hurt.mcfunction b/src/main/resources/nyctophobia/data/nycto/function/grue/hurt.mcfunction new file mode 100644 index 000000000..7c7142c2a --- /dev/null +++ b/src/main/resources/nyctophobia/data/nycto/function/grue/hurt.mcfunction @@ -0,0 +1,4 @@ +execute store result score @s grue.rng run loot spawn ~ ~ ~ loot nycto:rng/1-2 + +execute if score @s grue.rng matches 1 run playsound minecraft:grue.hurt1 hostile @a ~ ~ ~ 1 +execute if score @s grue.rng matches 2 run playsound minecraft:grue.hurt2 hostile @a ~ ~ ~ 1 \ No newline at end of file diff --git a/src/main/resources/nyctophobia/data/nycto/function/grue/main.mcfunction b/src/main/resources/nyctophobia/data/nycto/function/grue/main.mcfunction new file mode 100644 index 000000000..431f88697 --- /dev/null +++ b/src/main/resources/nyctophobia/data/nycto/function/grue/main.mcfunction @@ -0,0 +1,7 @@ +execute unless predicate nycto:in_darkness run function nycto:grue/despawn + +execute unless entity @a[distance=..30] run function nycto:grue/despawn +execute if entity @a[distance=..30,gamemode=!creative,gamemode=!spectator,nbt={active_effects:[{id:"minecraft:night_vision"}]}] run function nycto:grue/despawn + +execute as @s[nbt={HurtTime:10s}] at @s run function nycto:grue/hurt + diff --git a/src/main/resources/nyctophobia/data/nycto/function/grue/sound.mcfunction b/src/main/resources/nyctophobia/data/nycto/function/grue/sound.mcfunction new file mode 100644 index 000000000..7d0392eef --- /dev/null +++ b/src/main/resources/nyctophobia/data/nycto/function/grue/sound.mcfunction @@ -0,0 +1,4 @@ +execute store result score @s grue.rng run loot spawn ~ ~ ~ loot nycto:rng/1-3 +execute if score @s grue.rng matches 1 run playsound minecraft:grue.growl1 hostile @a ~ ~ ~ 1 +execute if score @s grue.rng matches 2 run playsound minecraft:grue.growl2 hostile @a ~ ~ ~ 1 +execute if score @s grue.rng matches 3 run playsound minecraft:grue.growl3 hostile @a ~ ~ ~ 1 \ No newline at end of file diff --git a/src/main/resources/nyctophobia/data/nycto/function/grue/spawn.mcfunction b/src/main/resources/nyctophobia/data/nycto/function/grue/spawn.mcfunction new file mode 100644 index 000000000..71d27f608 --- /dev/null +++ b/src/main/resources/nyctophobia/data/nycto/function/grue/spawn.mcfunction @@ -0,0 +1,4 @@ +summon husk ~ ~ ~ {Silent:1b,Health:800f,CanBreakDoors:1b,Tags:["grue.gruemob"],CustomName:'{"text":"Unknown"}',ArmorItems:[{},{},{},{id:"string",components:{custom_model_data:557001},count:1}],ArmorDropChances:[0.000F,0.000F,0.000F,0.000F],active_effects:[{id:"minecraft:invisibility",amplifier:1,duration:1000000,show_particles:0b}],attributes:[{id:"minecraft:generic.attack_damage",base:500},{id:"minecraft:generic.max_health",base:800},{id:"minecraft:generic.movement_speed",base:0.5}]} +playsound minecraft:grue.growl1 hostile @a ~ ~ ~ 1 +execute as @a[distance=..8] at @s run playsound minecraft:grue.spawn hostile @s ~ ~ ~ 0.8 +execute as @a[distance=9..30] at @s run playsound minecraft:grue.mistake hostile @s ~ ~ ~ 0.8 \ No newline at end of file diff --git a/src/main/resources/nyctophobia/data/nycto/function/load.mcfunction b/src/main/resources/nyctophobia/data/nycto/function/load.mcfunction new file mode 100644 index 000000000..18c66d833 --- /dev/null +++ b/src/main/resources/nyctophobia/data/nycto/function/load.mcfunction @@ -0,0 +1,18 @@ +# - Schedules + +schedule clear nycto:tick_20t +schedule function nycto:tick_20t 20t + +function nycto:difficulty/normal + +# - Scoreboards + +scoreboard objectives add grue.darknesstimer dummy +scoreboard objectives add grue.rng dummy +scoreboard objectives add grue.diff dummy + +# - Settings + + + +# - General \ No newline at end of file diff --git a/src/main/resources/nyctophobia/data/nycto/function/player/darkness/inside.mcfunction b/src/main/resources/nyctophobia/data/nycto/function/player/darkness/inside.mcfunction new file mode 100644 index 000000000..8ebddeff1 --- /dev/null +++ b/src/main/resources/nyctophobia/data/nycto/function/player/darkness/inside.mcfunction @@ -0,0 +1,16 @@ +# Runs every tick the player is in light level 0 as the player inside + +execute if score @s grue.darknesstimer matches 1.. run scoreboard players remove @s grue.darknesstimer 1 + +execute if score @s grue.darknesstimer matches 375 run playsound minecraft:grue.warning hostile @s ~ ~ ~ 0.8 + +execute if score @s grue.darknesstimer matches 238 run function nycto:player/warn + +execute if score @s grue.darknesstimer matches 238 run effect give @s darkness 2 4 true +execute if score @s grue.darknesstimer matches 100 run effect give @s darkness 2 8 true +execute if score @s grue.darknesstimer matches 1 run effect give @s darkness 8 15 true +execute if score @s grue.darknesstimer matches 1 run effect give @s blindness 8 1 true +execute if score .diff grue.diff matches 3 if score @s grue.darknesstimer matches 1 run effect give @s slowness 8 2 true + +execute if score @s grue.darknesstimer matches 1 run function nycto:grue/spawn +tag @s[tag=!nycto.indarkness] add nycto.indarkness \ No newline at end of file diff --git a/src/main/resources/nyctophobia/data/nycto/function/player/darkness/outside.mcfunction b/src/main/resources/nyctophobia/data/nycto/function/player/darkness/outside.mcfunction new file mode 100644 index 000000000..0c9c15559 --- /dev/null +++ b/src/main/resources/nyctophobia/data/nycto/function/player/darkness/outside.mcfunction @@ -0,0 +1,13 @@ +playsound minecraft:grue.escape hostile @s[tag=nycto.indarkness,scores={grue.darknesstimer=1..330}] + +title @s[tag=nycto.indarkness,scores={grue.darknesstimer=1..150}] actionbar [{"text": "You escaped... This time","color": "dark_red"}] + + +execute if score .diff grue.diff matches 1 run scoreboard players set @s grue.darknesstimer 580 +execute if score .diff grue.diff matches 2 run scoreboard players set @s grue.darknesstimer 455 +execute if score .diff grue.diff matches 3 run scoreboard players set @s grue.darknesstimer 378 + + +stopsound @s hostile minecraft:grue.warning + +tag @s[tag=nycto.indarkness] remove nycto.indarkness \ No newline at end of file diff --git a/src/main/resources/nyctophobia/data/nycto/function/player/register.mcfunction b/src/main/resources/nyctophobia/data/nycto/function/player/register.mcfunction new file mode 100644 index 000000000..3a237521b --- /dev/null +++ b/src/main/resources/nyctophobia/data/nycto/function/player/register.mcfunction @@ -0,0 +1,3 @@ +scoreboard players set @s grue.darknesstimer 455 + +tag @s add nycto.registered \ No newline at end of file diff --git a/src/main/resources/nyctophobia/data/nycto/function/player/warn.mcfunction b/src/main/resources/nyctophobia/data/nycto/function/player/warn.mcfunction new file mode 100644 index 000000000..d31661822 --- /dev/null +++ b/src/main/resources/nyctophobia/data/nycto/function/player/warn.mcfunction @@ -0,0 +1,7 @@ +execute store result score @s grue.rng run loot spawn ~ ~ ~ loot nycto:rng/1-6 +execute if score @s grue.rng matches 1 run title @s actionbar [{"text": "Breathing is heard in the darkness","color": "dark_gray"}] +execute if score @s grue.rng matches 2 run title @s actionbar [{"text": "You feel as though you are being watched","color": "dark_gray"}] +execute if score @s grue.rng matches 3 run title @s actionbar [{"text": "A horrible chill creeps down your spine","color": "dark_gray"}] +execute if score @s grue.rng matches 4 run title @s actionbar [{"text": "You feel an unshakable sense of unease","color": "dark_gray"}] +execute if score @s grue.rng matches 5 run title @s actionbar [{"text": "You sense danger in the cloak of darkness","color": "dark_gray"}] +execute if score @s grue.rng matches 6 run title @s actionbar [{"text": "Heavy breathing approaches slowly","color": "dark_gray"}] \ No newline at end of file diff --git a/src/main/resources/nyctophobia/data/nycto/function/tick.mcfunction b/src/main/resources/nyctophobia/data/nycto/function/tick.mcfunction new file mode 100644 index 000000000..4fba8ea3f --- /dev/null +++ b/src/main/resources/nyctophobia/data/nycto/function/tick.mcfunction @@ -0,0 +1,20 @@ +## --------------------------- +## +## Nyctophobia - Tick Function +## Do not redistribute without permission +## +## --------------------------- + +# - New Player + +execute as @a[tag=!nycto.registered] at @s run function nycto:player/register + +# - Darkness - # + +execute as @a[predicate=nycto:in_darkness,gamemode=!spectator,gamemode=!creative,nbt=!{active_effects:[{id:"minecraft:night_vision"}]}] at @s if block ~ ~ ~ #nycto:nonsolid run function nycto:player/darkness/inside +execute as @a[predicate=!nycto:in_darkness] at @s run function nycto:player/darkness/outside +execute as @a[nbt={active_effects:[{id:"minecraft:night_vision"}]}] at @s run function nycto:player/darkness/outside + +# - Grue + +execute as @e[type=husk,tag=grue.gruemob] at @s run function nycto:grue/main \ No newline at end of file diff --git a/src/main/resources/nyctophobia/data/nycto/function/tick_20t.mcfunction b/src/main/resources/nyctophobia/data/nycto/function/tick_20t.mcfunction new file mode 100644 index 000000000..3158d7a7f --- /dev/null +++ b/src/main/resources/nyctophobia/data/nycto/function/tick_20t.mcfunction @@ -0,0 +1,8 @@ +# - Grue + +execute as @e[type=husk,tag=grue.gruemob] at @s if predicate nycto:soundchance run function nycto:grue/sound + + +# Rerun + +schedule function nycto:tick_20t 20t \ No newline at end of file diff --git a/src/main/resources/nyctophobia/data/nycto/loot_table/rng/1-2.json b/src/main/resources/nyctophobia/data/nycto/loot_table/rng/1-2.json new file mode 100644 index 000000000..1c5478d38 --- /dev/null +++ b/src/main/resources/nyctophobia/data/nycto/loot_table/rng/1-2.json @@ -0,0 +1,23 @@ +{ + "pools": [ + { + "rolls": { + "min": 1, + "max": 2 + }, + "entries": [ + { + "type": "item", + "weight": 1, + "name": "minecraft:stone_button", + "functions": [ + { + "function": "set_count", + "count": 0 + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/nyctophobia/data/nycto/loot_table/rng/1-3.json b/src/main/resources/nyctophobia/data/nycto/loot_table/rng/1-3.json new file mode 100644 index 000000000..778395296 --- /dev/null +++ b/src/main/resources/nyctophobia/data/nycto/loot_table/rng/1-3.json @@ -0,0 +1,23 @@ +{ + "pools": [ + { + "rolls": { + "min": 1, + "max": 3 + }, + "entries": [ + { + "type": "item", + "weight": 1, + "name": "minecraft:stone_button", + "functions": [ + { + "function": "set_count", + "count": 0 + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/nyctophobia/data/nycto/loot_table/rng/1-6.json b/src/main/resources/nyctophobia/data/nycto/loot_table/rng/1-6.json new file mode 100644 index 000000000..5d6a5300a --- /dev/null +++ b/src/main/resources/nyctophobia/data/nycto/loot_table/rng/1-6.json @@ -0,0 +1,23 @@ +{ + "pools": [ + { + "rolls": { + "min": 1, + "max": 6 + }, + "entries": [ + { + "type": "item", + "weight": 1, + "name": "minecraft:stone_button", + "functions": [ + { + "function": "set_count", + "count": 0 + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/nyctophobia/data/nycto/predicate/in_darkness.json b/src/main/resources/nyctophobia/data/nycto/predicate/in_darkness.json new file mode 100644 index 000000000..1a68c29be --- /dev/null +++ b/src/main/resources/nyctophobia/data/nycto/predicate/in_darkness.json @@ -0,0 +1,11 @@ +{ + "condition": "minecraft:location_check", + "predicate": { + "light": { + "light": { + "min": 0, + "max": 1 + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/nyctophobia/data/nycto/predicate/soundchance.json b/src/main/resources/nyctophobia/data/nycto/predicate/soundchance.json new file mode 100644 index 000000000..eea971be5 --- /dev/null +++ b/src/main/resources/nyctophobia/data/nycto/predicate/soundchance.json @@ -0,0 +1,4 @@ +{ + "condition": "minecraft:random_chance", + "chance": 0.35 +} \ No newline at end of file diff --git a/src/main/resources/nyctophobia/data/nycto/tags/block/nonsolid.json b/src/main/resources/nyctophobia/data/nycto/tags/block/nonsolid.json new file mode 100644 index 000000000..f6f381b8d --- /dev/null +++ b/src/main/resources/nyctophobia/data/nycto/tags/block/nonsolid.json @@ -0,0 +1,49 @@ +{ + "values": [ + "air", + "cave_air", + "void_air", + "water", + "lava", + "#wool_carpets", + "#banners", + "#buttons", + "#candles", + "#cave_vines", + "#climbable", + "#signs", + "#fire", + "#crops", + "#pressure_plates", + "#saplings", + "#minecraft:small_flowers", + "#minecraft:tall_flowers", + "#rails", + "sculk_vein", + "snow", + "short_grass", + "tall_grass", + "kelp", + "bubble_column", + "torch", + "wall_torch", + "soul_torch", + "soul_wall_torch", + "redstone_wire", + "redstone_torch", + "redstone_wall_torch", + "dead_bush", + "red_mushroom", + "brown_mushroom", + "warped_fungus", + "crimson_fungus", + "sugar_cane", + "lever", + "fern", + "large_fern", + "warped_roots", + "crimson_roots", + "hanging_roots", + "nether_sprouts" + ] +} \ No newline at end of file diff --git a/src/main/resources/nyctophobia/pack.mcmeta b/src/main/resources/nyctophobia/pack.mcmeta new file mode 100644 index 000000000..92374d9c0 --- /dev/null +++ b/src/main/resources/nyctophobia/pack.mcmeta @@ -0,0 +1,6 @@ +{ + "pack": { + "pack_format": 48, + "description": "Nyctophobia Datapack" + } +} \ No newline at end of file diff --git a/src/main/resources/nyctophobia/pack.png b/src/main/resources/nyctophobia/pack.png new file mode 100644 index 000000000..cb1aa92b0 Binary files /dev/null and b/src/main/resources/nyctophobia/pack.png differ