Skip to content

Commit

Permalink
Small additions
Browse files Browse the repository at this point in the history
  • Loading branch information
miyucomics committed Jul 6, 2024
1 parent de9c0ab commit 15f4f86
Show file tree
Hide file tree
Showing 16 changed files with 185 additions and 60 deletions.
57 changes: 15 additions & 42 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,20 @@ loom {
}

repositories {
maven { url 'https://jitpack.io' }
maven { url "https://squiddev.cc/maven/" }
maven { url "https://maven.terraformersmc.com/" }
maven { url "https://maven.terraformersmc.com/releases" }
maven { url "https://maven.shedaniel.me/" }

maven {
name "KosmX's maven"
url 'https://maven.kosmx.dev/'
}

// Hex Casting Dependencies
maven { url "https://maven.blamejared.com/" }
maven {
name "entity reach"
url "https://maven.jamieswhiteshirt.com/libs-release/"
}
maven { url "https://maven.jamieswhiteshirt.com/libs-release/" }
maven { url "https://mvn.devos.one/snapshots/" }
maven {
name = 'Ladysnake Mods'
url = 'https://maven.ladysnake.org/releases'
}
maven {
url = "https://maven.theillusivec4.top/"
}
maven {
name = 'GeckoLib'
url 'https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/'
}
maven { url = "https://maven.ladysnake.org/releases" }
maven { url = "https://api.modrinth.com/maven" }
maven { url "https://maven.kosmx.dev/" }
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
url = "https://ladysnake.jfrog.io/artifactory/mods"
content {
includeGroup "io.github.ladysnake"
includeGroupByRegex "io\\.github\\.onyxstudios.*"
}
}
}

Expand All @@ -60,16 +42,16 @@ dependencies {
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "net.fabricmc:fabric-language-kotlin:${project.fabric_kotlin_version}"

modImplementation "at.petra-k.paucal:paucal-common-$minecraft_version:$paucalVersion"
modImplementation "vazkii.patchouli:Patchouli:$minecraft_version-$patchouliVersion-FABRIC"
modImplementation("at.petra-k.hexcasting:hexcasting-fabric-$minecraft_version:$hexcastingVersion") {
modImplementation "at.petra-k.paucal:paucal-common-$minecraft_version:$paucal_version"
modImplementation "vazkii.patchouli:Patchouli:$minecraft_version-$patchouli_version-FABRIC"
modImplementation("at.petra-k.hexcasting:hexcasting-fabric-$minecraft_version:$hexcasting_version") {
exclude module: "phosphor"
exclude module: "lithium"
exclude module: "emi"
}
compileOnly(annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-common:${mixinExtrasVersion}"))
include modImplementation("dev.kosmx.player-anim:player-animation-lib-fabric:${project.player_anim}")
include implementation("de.articdive:jnoise-pipeline:${project.jnoiseVersion}")
include implementation(annotationProcessor("io.github.llamalad7:mixinextras-fabric:${mixin_extras_version}"))
include modImplementation("dev.kosmx.player-anim:player-animation-lib-fabric:${player_animator_version}")
include modImplementation("io.github.ladysnake:satin:${satin_version}")
}

processResources {
Expand Down Expand Up @@ -99,13 +81,4 @@ jar {
from("LICENSE") {
rename { "${it}_${project.base.archivesName.get()}"}
}
}

publishing {
repositories {}
publications {
create("mavenJava", MavenPublication) {
from components.java
}
}
}
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ yarn_mappings = 1.19.2+build.28
loader_version = 0.15.11
fabric_kotlin_version = 1.11.0+kotlin.2.0.0

hexcastingVersion = 0.10.3
paucalVersion = 0.5.0
patchouliVersion = 77
mixinExtrasVersion = 0.2.0-beta.9
player_anim = 1.0.2
jnoiseVersion = 4.1.0
hexcasting_version = 0.10.3
paucal_version = 0.5.0
patchouli_version = 77
mixin_extras_version = 0.3.6
player_animator_version = 1.0.2
satin_version = 1.9.0

mod_version = 1.3.0
maven_group = miyucomics.hexical
Expand Down
1 change: 1 addition & 0 deletions src/main/java/miyucomics/hexical/HexicalClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class HexicalClient implements ClientModInitializer {
public void onInitializeClient() {
HexicalBlocks.clientInit();
HexicalEntities.clientInit();
HexicalEvents.clientInit();
HexicalItems.clientInit();
HexicalKeybinds.init();
HexicalNetworking.clientInit();
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/miyucomics/hexical/HexicalMain.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package miyucomics.hexical;

import de.articdive.jnoise.core.api.functions.Interpolation;
import de.articdive.jnoise.generators.noisegen.perlin.PerlinNoiseGenerator;
import miyucomics.hexical.data.PrestidigitationData;
import miyucomics.hexical.registry.*;
import net.fabricmc.api.ModInitializer;
Expand All @@ -12,7 +10,6 @@
public class HexicalMain implements ModInitializer {
public static final String MOD_ID = "hexical";
public static final Random RANDOM = new Random();
public static final PerlinNoiseGenerator PERLIN_NOISE = PerlinNoiseGenerator.newBuilder().setInterpolation(Interpolation.LINEAR).build();
public static final Integer EVOKE_DURATION = 30;

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/miyucomics/hexical/blocks/MediaJarBlock.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class MediaJarBlock : TransparentBlock(Settings.of(Material.GLASS).emissiveLight
if (world.isClient)
return ActionResult.SUCCESS
player.swingHand(hand)
world.playSoundFromEntity(null, player, SoundEvents.ENTITY_GENERIC_DRINK, SoundCategory.PLAYERS, 1f, 1f)
player.addStatusEffect(StatusEffectInstance(HexicalStatusEffects.MEDIA_SICKNESS_STATUS_EFFECT, 10, 0, false, false, true))
world.playSoundFromEntity(null, player, SoundEvents.ITEM_HONEY_BOTTLE_DRINK, SoundCategory.PLAYERS, 1f, 1f)
player.addStatusEffect(StatusEffectInstance(HexicalStatusEffects.MEDIA_VISION_STATUS_EFFECT, 2000, 0, false, false, true))
return ActionResult.SUCCESS
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getDouble
import at.petrak.hexcasting.api.spell.getVec3
import at.petrak.hexcasting.api.spell.iota.Iota
import miyucomics.hexical.HexicalMain
import miyucomics.hexical.utils.PerlinNoise

class OpPerlin : ConstMediaAction {
override val argc = 2
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val location = args.getVec3(0, argc).multiply(0.25) // reduce it so the change isn't so dramatic
return (HexicalMain.PERLIN_NOISE.evaluateNoise(location.x, location.y, location.z, args.getDouble(1, argc) * 0.25, ctx.world.seed) / 2 + 0.5).asActionResult
val location = args.getVec3(0, argc).multiply(0.25)
return (PerlinNoise(ctx.world.seed.toInt()).noise(location.x, location.y, location.z, args.getDouble(1, argc) * 0.25) / 2 + 0.5).asActionResult
}
}
15 changes: 15 additions & 0 deletions src/main/java/miyucomics/hexical/registry/HexicalEvents.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package miyucomics.hexical.registry

import ladysnake.satin.api.event.ShaderEffectRenderCallback
import ladysnake.satin.api.managed.ShaderEffectManager
import miyucomics.hexical.HexicalMain
import miyucomics.hexical.state.EvokeState
import miyucomics.hexical.state.KeybindData
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking
import net.minecraft.client.MinecraftClient

object HexicalEvents {
private val MEDIA_SICKNESS_SHADER = ShaderEffectManager.getInstance().manage(HexicalMain.id("shaders/post/media_vision.json"))

@JvmStatic
fun init() {
ServerPlayConnectionEvents.JOIN.register { handler, _, server ->
Expand Down Expand Up @@ -43,4 +49,13 @@ object HexicalEvents {
}
}
}

@JvmStatic
fun clientInit() {
ShaderEffectRenderCallback.EVENT.register(ShaderEffectRenderCallback { tickDelta: Float ->
val player = MinecraftClient.getInstance().player?: return@ShaderEffectRenderCallback
if (player.hasStatusEffect(HexicalStatusEffects.MEDIA_VISION_STATUS_EFFECT))
MEDIA_SICKNESS_SHADER.render(tickDelta)
})
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package miyucomics.hexical.registry

import miyucomics.hexical.HexicalMain
import miyucomics.hexical.status_effects.MediaSicknessStatusEffect
import miyucomics.hexical.status_effects.MediaVisionStatusEffect
import net.minecraft.util.registry.Registry

object HexicalStatusEffects {
val MEDIA_SICKNESS_STATUS_EFFECT = MediaSicknessStatusEffect()
val MEDIA_VISION_STATUS_EFFECT = MediaVisionStatusEffect()

@JvmStatic
fun init() {
Registry.register(Registry.STATUS_EFFECT, HexicalMain.id("media_sickness"), MEDIA_SICKNESS_STATUS_EFFECT)
Registry.register(Registry.STATUS_EFFECT, HexicalMain.id("media_vision"), MEDIA_VISION_STATUS_EFFECT)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ package miyucomics.hexical.status_effects
import net.minecraft.entity.effect.StatusEffect
import net.minecraft.entity.effect.StatusEffectCategory

class MediaSicknessStatusEffect : StatusEffect(StatusEffectCategory.NEUTRAL, 0x98D982) {
class MediaVisionStatusEffect : StatusEffect(StatusEffectCategory.NEUTRAL, 0x98D982) {
override fun canApplyUpdateEffect(duration: Int, amplifier: Int) = true
}
84 changes: 84 additions & 0 deletions src/main/java/miyucomics/hexical/utils/PerlinNoise.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package miyucomics.hexical.utils

import kotlin.math.floor

class PerlinNoise(seed: Int) {
private val permutations: IntArray

init {
val random = kotlin.random.Random(seed)
permutations = IntArray(512) { random.nextInt(256) }
}

private fun fade(t: Double): Double {
return t * t * t * (t * (t * 6 - 15) + 10)
}

private fun lerp(t: Double, a: Double, b: Double): Double {
return a + t * (b - a)
}

private fun grad(hash: Int, x: Double, y: Double, z: Double, w: Double): Double {
val h = hash and 31
val a = if (h and 1 == 0) x else -x
val b = if (h and 2 == 0) y else -y
val c = if (h and 4 == 0) z else -z
val d = if (h and 8 == 0) w else -w
return a + b + c + d
}

fun noise(x: Double, y: Double, z: Double, w: Double): Double {
val X = floor(x).toInt() and 255
val Y = floor(y).toInt() and 255
val Z = floor(z).toInt() and 255
val W = floor(w).toInt() and 255

val x = x - floor(x)
val y = y - floor(y)
val z = z - floor(z)
val w = w - floor(w)

val u = fade(x)
val v = fade(y)
val t = fade(z)
val s = fade(w)

val A = permutations[X] + Y
val AA = permutations[A] + Z
val AAA = permutations[AA] + W
val AAB = permutations[AA + 1] + W
val AB = permutations[A + 1] + Z
val ABA = permutations[AB] + W
val ABB = permutations[AB + 1] + W
val B = permutations[X + 1] + Y
val BA = permutations[B] + Z
val BAA = permutations[BA] + W
val BAB = permutations[BA + 1] + W
val BB = permutations[B + 1] + Z
val BBA = permutations[BB] + W
val BBB = permutations[BB + 1] + W

return lerp(s,
lerp(t,
lerp(v,
lerp(u, grad(permutations[AAA], x, y, z, w), grad(permutations[BAA], x - 1, y, z, w)),
lerp(u, grad(permutations[ABA], x, y - 1, z, w), grad(permutations[BBA], x - 1, y - 1, z, w))
),
lerp(v,
lerp(u, grad(permutations[AAB], x, y, z - 1, w), grad(permutations[BAB], x - 1, y, z - 1, w)),
lerp(u, grad(permutations[ABB], x, y - 1, z - 1, w), grad(permutations[BBB], x - 1, y - 1, z - 1, w))
)
),
lerp(t,
lerp(v,
lerp(u, grad(permutations[AAA + 1], x, y, z, w - 1), grad(permutations[BAA + 1], x - 1, y, z, w - 1)),
lerp(u, grad(permutations[ABA + 1], x, y - 1, z, w - 1), grad(permutations[BBA + 1], x - 1, y - 1, z, w - 1))
),
lerp(v,
lerp(u, grad(permutations[AAB + 1], x, y, z - 1, w - 1), grad(permutations[BAB + 1], x - 1, y, z - 1, w - 1)),
lerp(u, grad(permutations[ABB + 1], x, y - 1, z - 1, w - 1), grad(permutations[BBB + 1], x - 1, y - 1, z - 1, w - 1))
)
)
)
}
}
4 changes: 4 additions & 0 deletions src/main/resources/assets/hexical/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"block.hexical.hex_candle": "Hex Candle",
"block.hexical.mage_block": "Mage Block",
"block.hexical.media_jar": "Media Jar",
"effect.hexical.media_vision": "Media Vision",
"entity.hexical.living_scroll": "Living Scroll",
"entity.hexical.magic_missile": "Magic Missile",
"entity.hexical.speck": "Speck",
Expand Down Expand Up @@ -136,6 +137,9 @@
"hexical.page.themis.0": "Takes a list and a pattern or pattern list which is used to sort the list by casting over every iota similar to $(l:patterns/meta#hexcasting:for_each)Thoth's Gambit$().",
"hexical.page.themis.1": "After each iteration, it demands a number at the top of the stack which will correspond to that iota. At the end of the gambit, a list is pushed with the iota sorted by that number in increasing order. The order of identically numbered iota are kept. If it encounters $(l:patterns/meta#hexcasting:halt)Charon's Gambit$(), it will create a sorted list with only the iota it has come across.$(br2)$(o)Shuffling is the only thing which Nature cannot undo.$()",

"hexical.page.media_jar.title": "Media Jar",
"hexical.page.media_jar.0": "",:

"hexical.page.living_scroll.title": "Living Scrolls",
"hexical.page.living_scroll.0": "Living scrolls are mixed with a pinch of amethyst, enchanting the ink to move and wiggle like the patterns I draw with my $(l:items/staff)staff$(). Not only that, living scrolls can display lists of patterns.$(br2)$(o)You can't be a proper writer without a touch of madness, can you?$()",
"hexical.page.living_scroll.1": "I can freely write and rewrite the scroll's patterns at any time, along with reading it back out. The scroll accepts only a list of pattern iotas, or a pattern iota which is automatically wrapped in a list. When displaying a list of patterns, a living scroll shows one pattern at a time. It changes once per second. Even when I write the same pattern list to two of them at two different moments of their cycle, they end up in sync.",
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/hexical/models/block/media_jar.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"parent": "block/block",
"ambientocclusion": false,
"textures": {
"0": "hexical:block/media_jar",
"particle": "hexical:block/media_jar"
Expand Down
17 changes: 17 additions & 0 deletions src/main/resources/assets/hexical/shaders/post/media_vision.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"targets": [
"swap"
],
"passes": [
{
"name": "sobel",
"intarget": "minecraft:main",
"outtarget": "swap"
},
{
"name": "hexical:media_vision",
"intarget": "swap",
"outtarget": "minecraft:main"
}
]
}
15 changes: 15 additions & 0 deletions src/main/resources/assets/hexical/shaders/program/media_vision.fsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#version 150

uniform sampler2D DiffuseSampler;

in vec2 texCoord;

out vec4 fragColor;

void main() {
if (distance(texture(DiffuseSampler, texCoord).rgb, vec3(0.0)) > 0.5) {
fragColor = vec4(0.78, 0.56, 0.94, 1.0);
} else {
fragColor = vec4(0.0);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"blend": {
"func": "add",
"srcrgb": "srcalpha",
"dstrgb": "1-srcalpha"
},
"vertex": "sobel",
"fragment": "hexical:media_vision",
"attributes": [ "Position" ],
"samplers": [
{ "name": "DiffuseSampler" }
],
"uniforms": [
{ "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
{ "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 15f4f86

Please sign in to comment.