Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions src/main/kotlin/org/xodium/vanillaplus/VanillaPlusBootstrap.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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()
}
},
)
}
}
}
34 changes: 34 additions & 0 deletions src/main/kotlin/org/xodium/vanillaplus/hooks/NyctophobiaHook.kt
Original file line number Diff line number Diff line change
@@ -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(),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"nycto:load"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"nycto:tick"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scoreboard players set .diff grue.diff 1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scoreboard players set .diff grue.diff 3
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scoreboard players set .diff grue.diff 2
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions src/main/resources/nyctophobia/data/nycto/function/load.mcfunction
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
scoreboard players set @s grue.darknesstimer 455

tag @s add nycto.registered
Original file line number Diff line number Diff line change
@@ -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"}]
20 changes: 20 additions & 0 deletions src/main/resources/nyctophobia/data/nycto/function/tick.mcfunction
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions src/main/resources/nyctophobia/data/nycto/loot_table/rng/1-2.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
]
}
]
}
23 changes: 23 additions & 0 deletions src/main/resources/nyctophobia/data/nycto/loot_table/rng/1-3.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
]
}
]
}
23 changes: 23 additions & 0 deletions src/main/resources/nyctophobia/data/nycto/loot_table/rng/1-6.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"condition": "minecraft:location_check",
"predicate": {
"light": {
"light": {
"min": 0,
"max": 1
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"condition": "minecraft:random_chance",
"chance": 0.35
}
49 changes: 49 additions & 0 deletions src/main/resources/nyctophobia/data/nycto/tags/block/nonsolid.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
6 changes: 6 additions & 0 deletions src/main/resources/nyctophobia/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"pack": {
"pack_format": 48,
"description": "Nyctophobia Datapack"
}
}
Binary file added src/main/resources/nyctophobia/pack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading