From 0e57bed5c8a1dbe48bb8f0481ddae62255fca9f1 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 15 Jan 2026 21:52:39 +0900 Subject: [PATCH 01/10] Add client tick rate synchronization message to event registrar --- src/main/java/com/github/alexthe666/citadel/Citadel.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/github/alexthe666/citadel/Citadel.java b/src/main/java/com/github/alexthe666/citadel/Citadel.java index 6b626f6..581dd82 100644 --- a/src/main/java/com/github/alexthe666/citadel/Citadel.java +++ b/src/main/java/com/github/alexthe666/citadel/Citadel.java @@ -151,6 +151,7 @@ public static void registerPayloads(RegisterPayloadHandlersEvent event) { registrar.playToClient(SyncePathMessage.TYPE, SyncePathMessage.CODEC, SyncePathMessage::handle); // SyncPathReachedMessage is sent from server to specific player via sendToPlayer registrar.playToClient(SyncPathReachedMessage.TYPE, SyncPathReachedMessage.CODEC, SyncPathReachedMessage::handle); + registrar.playToClient(SyncClientTickRateMessage.TYPE, SyncClientTickRateMessage.CODEC, SyncClientTickRateMessage::handle); } // Registered manually to NeoForge.EVENT_BUS in constructor (not a mod bus event) From a2f0b0d2bfa9bc5a33dee9e08b7f3ef2931d1619 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 16 Jan 2026 18:12:20 +0900 Subject: [PATCH 02/10] Enhance logging in PostEffectRegistry for effect registration and initialization --- .../alexthe666/citadel/client/shader/PostEffectRegistry.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/github/alexthe666/citadel/client/shader/PostEffectRegistry.java b/src/main/java/com/github/alexthe666/citadel/client/shader/PostEffectRegistry.java index 04916f2..91db65b 100644 --- a/src/main/java/com/github/alexthe666/citadel/client/shader/PostEffectRegistry.java +++ b/src/main/java/com/github/alexthe666/citadel/client/shader/PostEffectRegistry.java @@ -29,12 +29,14 @@ public static void clear(){ } public static void registerEffect(ResourceLocation resourceLocation) { + Citadel.LOGGER.debug("PostEffectRegistry: registering effect {}", resourceLocation); registry.add(resourceLocation); } public static void onInitializeOutline() { clear(); Minecraft minecraft = Minecraft.getInstance(); + Citadel.LOGGER.debug("PostEffectRegistry: initializing {} effects", registry.size()); for (ResourceLocation resourceLocation : registry) { PostChain postChain; RenderTarget renderTarget; @@ -42,6 +44,7 @@ public static void onInitializeOutline() { postChain = new PostChain(minecraft.getTextureManager(), minecraft.getResourceManager(), minecraft.getMainRenderTarget(), resourceLocation); postChain.resize(minecraft.getWindow().getWidth(), minecraft.getWindow().getHeight()); renderTarget = postChain.getTempTarget("final"); + Citadel.LOGGER.debug("PostEffectRegistry: loaded shader {} successfully, renderTarget={}", resourceLocation, renderTarget); } catch (IOException ioexception) { Citadel.LOGGER.warn("Failed to load shader: {}", resourceLocation, ioexception); postChain = null; From 8f870785fd92f196b040e9c8d2b0b9d9dd131909 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 17 Jan 2026 11:30:27 +0900 Subject: [PATCH 03/10] Remove obsolete blit shader files and update blur and bumpy shaders for improved functionality --- .../assets/citadel/shaders/program/blit.fsh | 14 ------ .../assets/citadel/shaders/program/blit.json | 30 ------------- .../assets/citadel/shaders/program/blit.vsh | 15 ------- .../assets/citadel/shaders/program/blur.fsh | 25 +++++------ .../assets/citadel/shaders/program/blur.vsh | 6 ++- .../assets/citadel/shaders/program/bumpy.fsh | 44 +++++++++++-------- .../assets/citadel/shaders/program/bumpy.json | 3 +- .../assets/citadel/shaders/program/bumpy.vsh | 4 +- 8 files changed, 44 insertions(+), 97 deletions(-) delete mode 100644 src/main/resources/assets/citadel/shaders/program/blit.fsh delete mode 100644 src/main/resources/assets/citadel/shaders/program/blit.json delete mode 100644 src/main/resources/assets/citadel/shaders/program/blit.vsh diff --git a/src/main/resources/assets/citadel/shaders/program/blit.fsh b/src/main/resources/assets/citadel/shaders/program/blit.fsh deleted file mode 100644 index 54b0e6d..0000000 --- a/src/main/resources/assets/citadel/shaders/program/blit.fsh +++ /dev/null @@ -1,14 +0,0 @@ -#version 150 - -uniform sampler2D DiffuseSampler; - -in vec2 texCoord; - -uniform vec4 ColorModulate; - -out vec4 fragColor; - -void main() { - vec4 color = texture(DiffuseSampler, texCoord); - fragColor = color * ColorModulate; -} diff --git a/src/main/resources/assets/citadel/shaders/program/blit.json b/src/main/resources/assets/citadel/shaders/program/blit.json deleted file mode 100644 index f0a366d..0000000 --- a/src/main/resources/assets/citadel/shaders/program/blit.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "blend": { - "func": "add", - "srcrgb": "one", - "dstrgb": "zero" - }, - "vertex": "citadel:blit", - "fragment": "citadel:blit", - "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": "InSize", "type": "float", "count": 2, "values": [1.0, 1.0] }, - { "name": "OutSize", "type": "float", "count": 2, "values": [1.0, 1.0] }, - { - "name": "ColorModulate", - "type": "float", - "count": 4, - "values": [1.0, 1.0, 1.0, 1.0] - } - ] -} diff --git a/src/main/resources/assets/citadel/shaders/program/blit.vsh b/src/main/resources/assets/citadel/shaders/program/blit.vsh deleted file mode 100644 index 960a50f..0000000 --- a/src/main/resources/assets/citadel/shaders/program/blit.vsh +++ /dev/null @@ -1,15 +0,0 @@ -#version 150 - -in vec4 Position; - -uniform mat4 ProjMat; -uniform vec2 InSize; - -out vec2 texCoord; - -void main() { - vec4 outPos = ProjMat * vec4(Position.xy, 0.0, 1.0); - gl_Position = vec4(outPos.xy, 0.2, 1.0); - - texCoord = Position.xy / InSize; -} diff --git a/src/main/resources/assets/citadel/shaders/program/blur.fsh b/src/main/resources/assets/citadel/shaders/program/blur.fsh index 1b09fda..9b2f5ad 100644 --- a/src/main/resources/assets/citadel/shaders/program/blur.fsh +++ b/src/main/resources/assets/citadel/shaders/program/blur.fsh @@ -5,8 +5,6 @@ uniform sampler2D DiffuseSampler; in vec2 texCoord; in vec2 oneTexel; -uniform vec2 InSize; -uniform vec2 OutSize; uniform vec2 BlurDir; uniform float Radius; @@ -17,18 +15,17 @@ void main() { float totalStrength = 0.0; float totalAlpha = 0.0; float totalSamples = 0.0; - float rad = Radius; - - for(float r = -rad; r <= rad; r += 1.0) { - vec4 sampleValue = texture(DiffuseSampler, texCoord + oneTexel * r * BlurDir); - - // Gaussian weighting - float strength = 1.0 - abs(r / rad); - totalStrength += strength; - blurred.rgb += sampleValue.rgb * strength; - totalAlpha += sampleValue.a; - totalSamples += 1.0; - } + for(float r = -Radius; r <= Radius; r += 1.0) { + vec4 sample = texture(DiffuseSampler, texCoord + oneTexel * r * BlurDir); + + // Accumulate average alpha + totalAlpha = totalAlpha + sample.a; + totalSamples = totalSamples + 1.0; + // Accumulate smoothed blur + float strength = 1.0 - abs(r / Radius); + totalStrength = totalStrength + strength; + blurred = blurred + sample * strength; + } fragColor = vec4(blurred.rgb / totalStrength, totalAlpha / totalSamples); } diff --git a/src/main/resources/assets/citadel/shaders/program/blur.vsh b/src/main/resources/assets/citadel/shaders/program/blur.vsh index 352dcec..99e97e0 100644 --- a/src/main/resources/assets/citadel/shaders/program/blur.vsh +++ b/src/main/resources/assets/citadel/shaders/program/blur.vsh @@ -4,14 +4,16 @@ in vec4 Position; uniform mat4 ProjMat; uniform vec2 InSize; +uniform vec2 OutSize; out vec2 texCoord; out vec2 oneTexel; -void main() { +void main(){ vec4 outPos = ProjMat * vec4(Position.xy, 0.0, 1.0); gl_Position = vec4(outPos.xy, 0.2, 1.0); oneTexel = 1.0 / InSize; - texCoord = Position.xy / InSize; + + texCoord = Position.xy / OutSize; } diff --git a/src/main/resources/assets/citadel/shaders/program/bumpy.fsh b/src/main/resources/assets/citadel/shaders/program/bumpy.fsh index 90d01bb..26004c3 100644 --- a/src/main/resources/assets/citadel/shaders/program/bumpy.fsh +++ b/src/main/resources/assets/citadel/shaders/program/bumpy.fsh @@ -5,24 +5,32 @@ uniform sampler2D DiffuseSampler; in vec2 texCoord; in vec2 oneTexel; -uniform vec2 InSize; -uniform vec2 OutSize; -uniform float Time; - out vec4 fragColor; -void main() { - // Create a wavy/distortion effect - vec2 offset = vec2(0.0); - - // Add sine-based distortion for the "bumpy" shimmer effect - float frequency = 10.0; - float amplitude = 2.0; - - offset.x = sin(texCoord.y * frequency + Time * 0.5) * oneTexel.x * amplitude; - offset.y = cos(texCoord.x * frequency + Time * 0.7) * oneTexel.y * amplitude; - - vec4 color = texture(DiffuseSampler, texCoord + offset); - - fragColor = color; +void main(){ + vec4 c = texture(DiffuseSampler, texCoord); + vec4 u = texture(DiffuseSampler, texCoord + vec2( 0.0, -oneTexel.y)); + vec4 d = texture(DiffuseSampler, texCoord + vec2( 0.0, oneTexel.y)); + vec4 l = texture(DiffuseSampler, texCoord + vec2(-oneTexel.x, 0.0)); + vec4 r = texture(DiffuseSampler, texCoord + vec2( oneTexel.x, 0.0)); + + vec4 nc = normalize(c); + vec4 nu = normalize(u); + vec4 nd = normalize(d); + vec4 nl = normalize(l); + vec4 nr = normalize(r); + + float du = dot(nc, nu); + float dd = dot(nc, nd); + float dl = dot(nc, nl); + float dr = dot(nc, nr); + + float i = 64.0; + + float f = 1.0; + f += (du * i) - (dd * i); + f += (dr * i) - (dl * i); + + vec4 color = c * clamp(f, 0.5, 2.0); + fragColor = vec4(color.rgb, 1.0); } diff --git a/src/main/resources/assets/citadel/shaders/program/bumpy.json b/src/main/resources/assets/citadel/shaders/program/bumpy.json index 544427d..63db23f 100644 --- a/src/main/resources/assets/citadel/shaders/program/bumpy.json +++ b/src/main/resources/assets/citadel/shaders/program/bumpy.json @@ -19,7 +19,6 @@ ] }, { "name": "InSize", "type": "float", "count": 2, "values": [1.0, 1.0] }, - { "name": "OutSize", "type": "float", "count": 2, "values": [1.0, 1.0] }, - { "name": "Time", "type": "float", "count": 1, "values": [0.0] } + { "name": "OutSize", "type": "float", "count": 2, "values": [1.0, 1.0] } ] } diff --git a/src/main/resources/assets/citadel/shaders/program/bumpy.vsh b/src/main/resources/assets/citadel/shaders/program/bumpy.vsh index 352dcec..1136b29 100644 --- a/src/main/resources/assets/citadel/shaders/program/bumpy.vsh +++ b/src/main/resources/assets/citadel/shaders/program/bumpy.vsh @@ -8,10 +8,10 @@ uniform vec2 InSize; out vec2 texCoord; out vec2 oneTexel; -void main() { +void main(){ vec4 outPos = ProjMat * vec4(Position.xy, 0.0, 1.0); gl_Position = vec4(outPos.xy, 0.2, 1.0); oneTexel = 1.0 / InSize; - texCoord = Position.xy / InSize; + texCoord = outPos.xy * 0.5 + 0.5; } From bd54ca856c2c93f405fae0e9f03928319af0dde2 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 17 Jan 2026 17:42:45 +0900 Subject: [PATCH 04/10] Refactor blur shader to improve performance and remove obsolete vertex shader; add new sobel vertex shader --- .../assets/citadel/shaders/program/blur.fsh | 14 ++++--- .../assets/citadel/shaders/program/blur.json | 40 ++++++++----------- .../assets/citadel/shaders/program/bumpy.json | 36 +++++++---------- .../shaders/program/{blur.vsh => sobel.vsh} | 0 4 files changed, 40 insertions(+), 50 deletions(-) rename src/main/resources/assets/citadel/shaders/program/{blur.vsh => sobel.vsh} (100%) diff --git a/src/main/resources/assets/citadel/shaders/program/blur.fsh b/src/main/resources/assets/citadel/shaders/program/blur.fsh index 9b2f5ad..ce57673 100644 --- a/src/main/resources/assets/citadel/shaders/program/blur.fsh +++ b/src/main/resources/assets/citadel/shaders/program/blur.fsh @@ -5,6 +5,8 @@ uniform sampler2D DiffuseSampler; in vec2 texCoord; in vec2 oneTexel; +uniform vec2 InSize; + uniform vec2 BlurDir; uniform float Radius; @@ -16,16 +18,16 @@ void main() { float totalAlpha = 0.0; float totalSamples = 0.0; for(float r = -Radius; r <= Radius; r += 1.0) { - vec4 sample = texture(DiffuseSampler, texCoord + oneTexel * r * BlurDir); + vec4 sampleValue = texture(DiffuseSampler, texCoord + oneTexel * r * BlurDir); - // Accumulate average alpha - totalAlpha = totalAlpha + sample.a; + // Accumulate average alpha + totalAlpha = totalAlpha + sampleValue.a; totalSamples = totalSamples + 1.0; - // Accumulate smoothed blur + // Accumulate smoothed blur float strength = 1.0 - abs(r / Radius); totalStrength = totalStrength + strength; - blurred = blurred + sample * strength; + blurred = blurred + sampleValue; } - fragColor = vec4(blurred.rgb / totalStrength, totalAlpha / totalSamples); + fragColor = vec4(blurred.rgb / (Radius * 2.0 + 1.0), totalAlpha); } diff --git a/src/main/resources/assets/citadel/shaders/program/blur.json b/src/main/resources/assets/citadel/shaders/program/blur.json index af2b49d..9af9f94 100644 --- a/src/main/resources/assets/citadel/shaders/program/blur.json +++ b/src/main/resources/assets/citadel/shaders/program/blur.json @@ -1,26 +1,20 @@ { - "blend": { - "func": "add", - "srcrgb": "one", - "dstrgb": "zero" - }, - "vertex": "citadel:blur", - "fragment": "citadel:blur", - "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 - ] + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" }, - { "name": "InSize", "type": "float", "count": 2, "values": [1.0, 1.0] }, - { "name": "OutSize", "type": "float", "count": 2, "values": [1.0, 1.0] }, - { "name": "BlurDir", "type": "float", "count": 2, "values": [1.0, 1.0] }, - { "name": "Radius", "type": "float", "count": 1, "values": [5.0] } - ] + "vertex": "citadel:sobel", + "fragment": "citadel:blur", + "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": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "BlurDir", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "Radius", "type": "float", "count": 1, "values": [ 5.0 ] } + ] } diff --git a/src/main/resources/assets/citadel/shaders/program/bumpy.json b/src/main/resources/assets/citadel/shaders/program/bumpy.json index 63db23f..3179c62 100644 --- a/src/main/resources/assets/citadel/shaders/program/bumpy.json +++ b/src/main/resources/assets/citadel/shaders/program/bumpy.json @@ -1,24 +1,18 @@ { - "blend": { - "func": "add", - "srcrgb": "one", - "dstrgb": "zero" - }, - "vertex": "citadel:bumpy", - "fragment": "citadel:bumpy", - "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 - ] + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" }, - { "name": "InSize", "type": "float", "count": 2, "values": [1.0, 1.0] }, - { "name": "OutSize", "type": "float", "count": 2, "values": [1.0, 1.0] } - ] + "vertex": "citadel:bumpy", + "fragment": "citadel:bumpy", + "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": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] } + ] } diff --git a/src/main/resources/assets/citadel/shaders/program/blur.vsh b/src/main/resources/assets/citadel/shaders/program/sobel.vsh similarity index 100% rename from src/main/resources/assets/citadel/shaders/program/blur.vsh rename to src/main/resources/assets/citadel/shaders/program/sobel.vsh From c9fe2ea393b9dad2a2fe78a413fa6d97e7adcd58 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 17 Jan 2026 18:31:20 +0900 Subject: [PATCH 05/10] Update BookBlit and GuiBasicBook for improved rendering; set shader color and adjust entity rotation handling --- .../citadel/client/gui/BookBlit.java | 1 + .../citadel/client/gui/GuiBasicBook.java | 22 ++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/github/alexthe666/citadel/client/gui/BookBlit.java b/src/main/java/com/github/alexthe666/citadel/client/gui/BookBlit.java index b6fa3c3..6f7aefe 100644 --- a/src/main/java/com/github/alexthe666/citadel/client/gui/BookBlit.java +++ b/src/main/java/com/github/alexthe666/citadel/client/gui/BookBlit.java @@ -33,6 +33,7 @@ private static void blitWithColor(GuiGraphics guiGraphics, ResourceLocation p_28 private static void blitWithColor(GuiGraphics guiGraphics, ResourceLocation texture, int startX, int endX, int startY, int endY, int zLevel, float u0, float u1, float v0, float v1, int r, int g, int b, int a) { RenderSystem.setShaderTexture(0, texture); RenderSystem.setShader(GameRenderer::getPositionTexColorShader); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.enableBlend(); Matrix4f matrix4f = guiGraphics.pose().last().pose(); BufferBuilder bufferbuilder = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); diff --git a/src/main/java/com/github/alexthe666/citadel/client/gui/GuiBasicBook.java b/src/main/java/com/github/alexthe666/citadel/client/gui/GuiBasicBook.java index b8ccb44..e5a5ead 100644 --- a/src/main/java/com/github/alexthe666/citadel/client/gui/GuiBasicBook.java +++ b/src/main/java/com/github/alexthe666/citadel/client/gui/GuiBasicBook.java @@ -167,17 +167,14 @@ public void drawEntityOnScreen(GuiGraphics guiGraphics, MultiBufferSource buffer quaternion1.conjugate(); entityrenderdispatcher.overrideCameraOrientation(quaternion1); entityrenderdispatcher.setRenderShadow(false); - RenderSystem.runAsFancy(() -> entityrenderdispatcher.render(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, guiGraphics.pose(), bufferSource, 15728880)); + RenderSystem.runAsFancy(() -> entityrenderdispatcher.render(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, guiGraphics.pose(), bufferSource, 240)); entityrenderdispatcher.setRenderShadow(true); entity.setYRot(0); entity.setXRot(0); - entity.xRotO = 0; - entity.yRotO = 0; - if (entity instanceof LivingEntity livingEntity) { - livingEntity.yBodyRot = 0; - livingEntity.yBodyRotO = 0; - livingEntity.yHeadRot = 0; - livingEntity.yHeadRotO = 0; + if (entity instanceof LivingEntity) { + ((LivingEntity) entity).yBodyRot = 0; + ((LivingEntity) entity).yHeadRotO = 0; + ((LivingEntity) entity).yHeadRot = 0; } guiGraphics.flush(); @@ -270,6 +267,15 @@ protected void renderBlurredBackground(float partialTick) { // Do nothing - this prevents the blur effect from being applied } + /** + * Override to disable the menu background that was added in Minecraft 1.21 + * Without this override, the book appears darker due to the overlay + */ + @Override + protected void renderMenuBackground(GuiGraphics guiGraphics) { + // Do nothing - this prevents the dark menu background from being rendered + } + @Override public void render(GuiGraphics guiGraphics, int x, int y, float partialTicks) { this.mouseX = x; From 8c23c461bb8f9aaa82f52744bee879dbdd85303a Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 17 Jan 2026 19:53:17 +0900 Subject: [PATCH 06/10] Implement synchronous pathfinding methods in AdvancedPathNavigate for improved AI navigation --- .../raycoms/AdvancedPathNavigate.java | 83 ++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/github/alexthe666/citadel/server/entity/pathfinding/raycoms/AdvancedPathNavigate.java b/src/main/java/com/github/alexthe666/citadel/server/entity/pathfinding/raycoms/AdvancedPathNavigate.java index 85a11b1..7ee5cba 100644 --- a/src/main/java/com/github/alexthe666/citadel/server/entity/pathfinding/raycoms/AdvancedPathNavigate.java +++ b/src/main/java/com/github/alexthe666/citadel/server/entity/pathfinding/raycoms/AdvancedPathNavigate.java @@ -422,9 +422,90 @@ protected boolean canUpdatePath() { return this.ourEntity.position(); } + /** + * Creates a path to the given BlockPos synchronously. + * This method is called by vanilla AI goals like MeleeAttackGoal. + * It uses the same pathfinding algorithm as the async system but runs synchronously. + * + * @param pos The target position + * @param accuracy The accuracy/distance tolerance for reaching the target + * @return A Path to the target, or null if no path could be found + */ @Override public Path createPath(final @NotNull BlockPos pos, final int accuracy) { - return null; + return createPathInternal(pos, accuracy); + } + + /** + * Creates a path to the given Entity synchronously. + * This method is called by vanilla AI goals like MeleeAttackGoal. + * + * @param entity The target entity + * @param accuracy The accuracy/distance tolerance for reaching the target + * @return A Path to the entity, or null if no path could be found + */ + @Override + @Nullable + public Path createPath(final @NotNull Entity entity, final int accuracy) { + return createPathInternal(entity.blockPosition(), accuracy); + } + + /** + * Internal method that performs synchronous pathfinding. + * Uses the Citadel advanced pathfinding algorithm for consistent behavior + * with the async pathfinding system. + * + * @param targetPos The target position to path to + * @param accuracy The accuracy/distance tolerance + * @return A Path to the target, or null if no path could be found + */ + @Nullable + private Path createPathInternal(final BlockPos targetPos, final int accuracy) { + // Quick validation checks + if (targetPos == null) { + return null; + } + + // Check if entity is in a valid state for pathfinding + if (this.ourEntity.getY() < (double) level.getMinBuildHeight()) { + return null; + } + + if (!this.canUpdatePath()) { + return null; + } + + // Check if chunks are loaded + if (!level.isLoaded(targetPos)) { + return null; + } + + // Prepare the start position + final BlockPos start = AbstractPathJob.prepareStart(ourEntity); + + // Calculate the search range based on follow range and accuracy + final int followRange = (int) ourEntity.getAttributeValue(Attributes.FOLLOW_RANGE); + final int searchRange = Math.max(followRange, (int) Math.sqrt(start.distSqr(targetPos)) + 16); + + try { + // Create a synchronous path job using Citadel's advanced pathfinding + final PathJobMoveToLocation pathJob = new PathJobMoveToLocation( + level, + start, + targetPos, + searchRange, + ourEntity + ); + + // Apply the same pathing options as async pathfinding + pathJob.setPathingOptions(getPathingOptions()); + + // Execute the pathfinding synchronously by calling the job directly + return pathJob.call(); + } catch (final Exception e) { + Citadel.LOGGER.debug("Synchronous pathfinding failed for entity {}: {}", ourEntity, e.getMessage()); + return null; + } } @Override From 1720b754966b68b3a0963c614a35380c11ba6023 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 18 Jan 2026 01:31:22 +0900 Subject: [PATCH 07/10] Enhance collision handling by implementing custom pathfinding and movement logic; add EntityMixin for collision adjustments --- .../alexthe666/citadel/mixin/EntityMixin.java | 21 +++++++++++++++++++ .../collision/CustomCollisionsNavigator.java | 13 +++++------- .../CustomCollisionsNodeProcessor.java | 8 +++---- .../MovementControllerCustomCollisions.java | 7 +++++-- src/main/resources/citadel.mixins.json | 1 + 5 files changed, 36 insertions(+), 14 deletions(-) create mode 100644 src/main/java/com/github/alexthe666/citadel/mixin/EntityMixin.java diff --git a/src/main/java/com/github/alexthe666/citadel/mixin/EntityMixin.java b/src/main/java/com/github/alexthe666/citadel/mixin/EntityMixin.java new file mode 100644 index 0000000..b0cc157 --- /dev/null +++ b/src/main/java/com/github/alexthe666/citadel/mixin/EntityMixin.java @@ -0,0 +1,21 @@ +package com.github.alexthe666.citadel.mixin; + +import com.github.alexthe666.citadel.server.entity.collision.ICustomCollisions; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.phys.Vec3; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(Entity.class) +public class EntityMixin { + + @Inject(method = "collide", at = @At("HEAD"), cancellable = true) + private void citadel_collide(Vec3 vec, CallbackInfoReturnable cir) { + Entity self = (Entity) (Object) this; + if (self instanceof ICustomCollisions) { + cir.setReturnValue(ICustomCollisions.getAllowedMovementForEntity(self, vec)); + } + } +} diff --git a/src/main/java/com/github/alexthe666/citadel/server/entity/collision/CustomCollisionsNavigator.java b/src/main/java/com/github/alexthe666/citadel/server/entity/collision/CustomCollisionsNavigator.java index 76c3768..1070d72 100644 --- a/src/main/java/com/github/alexthe666/citadel/server/entity/collision/CustomCollisionsNavigator.java +++ b/src/main/java/com/github/alexthe666/citadel/server/entity/collision/CustomCollisionsNavigator.java @@ -10,6 +10,7 @@ import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.NotNull; public class CustomCollisionsNavigator extends GroundPathNavigation { @@ -17,15 +18,17 @@ public CustomCollisionsNavigator(Mob mob, Level world) { super(mob, world); } + @Override protected PathFinder createPathFinder(int i) { this.nodeEvaluator = new CustomCollisionsNodeProcessor(); return new PathFinder(this.nodeEvaluator, i); } - public static boolean isClearForMovementBetweenRespectCustomCollisions(Mob mob, Vec3 pos1, Vec3 pos2, boolean allowSwimming) { + @Override + protected boolean canMoveDirectly(@NotNull Vec3 pos1, @NotNull Vec3 pos2) { Vec3 vec3 = new Vec3(pos2.x, pos2.y + (double)mob.getBbHeight() * 0.5, pos2.z); BlockHitResult hitResult = mob.level() - .clip(new ClipContext(pos1, vec3, ClipContext.Block.COLLIDER, allowSwimming ? ClipContext.Fluid.ANY : ClipContext.Fluid.NONE, mob)); + .clip(new ClipContext(pos1, vec3, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, mob)); if(hitResult.getType() == HitResult.Type.MISS){ return true; }else{ @@ -34,10 +37,4 @@ public static boolean isClearForMovementBetweenRespectCustomCollisions(Mob mob, return mob instanceof ICustomCollisions customCollisions && customCollisions.canPassThrough(hitPos, state, state.getCollisionShape(mob.level(), hitPos)); } } - - @Override - protected boolean canMoveDirectly(Vec3 pos1, Vec3 pos2) { - return isClearForMovementBetweenRespectCustomCollisions(this.mob, pos1, pos2, false); - } - } diff --git a/src/main/java/com/github/alexthe666/citadel/server/entity/collision/CustomCollisionsNodeProcessor.java b/src/main/java/com/github/alexthe666/citadel/server/entity/collision/CustomCollisionsNodeProcessor.java index a8e5078..479813a 100644 --- a/src/main/java/com/github/alexthe666/citadel/server/entity/collision/CustomCollisionsNodeProcessor.java +++ b/src/main/java/com/github/alexthe666/citadel/server/entity/collision/CustomCollisionsNodeProcessor.java @@ -5,17 +5,17 @@ import net.minecraft.world.level.pathfinder.PathType; import net.minecraft.world.level.pathfinder.PathfindingContext; import net.minecraft.world.level.pathfinder.WalkNodeEvaluator; +import org.jetbrains.annotations.NotNull; public class CustomCollisionsNodeProcessor extends WalkNodeEvaluator { public CustomCollisionsNodeProcessor() { } - @Override - public PathType getPathType(PathfindingContext context, int x, int y, int z) { - BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); - BlockState state = context.getBlockState(blockpos$mutableblockpos.set(x, y, z)); + public @NotNull PathType getPathType(@NotNull PathfindingContext context, int x, int y, int z) { + BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(x, y, z); + BlockState state = context.getBlockState(blockpos$mutableblockpos); if (((ICustomCollisions) this.mob).canPassThrough(blockpos$mutableblockpos, state, state.getBlockSupportShape(context.level(), blockpos$mutableblockpos))) { return PathType.OPEN; } diff --git a/src/main/java/com/github/alexthe666/citadel/server/entity/collision/MovementControllerCustomCollisions.java b/src/main/java/com/github/alexthe666/citadel/server/entity/collision/MovementControllerCustomCollisions.java index 684a9df..76e5a07 100644 --- a/src/main/java/com/github/alexthe666/citadel/server/entity/collision/MovementControllerCustomCollisions.java +++ b/src/main/java/com/github/alexthe666/citadel/server/entity/collision/MovementControllerCustomCollisions.java @@ -82,8 +82,11 @@ public void tick() { private boolean isWalkable(float p_234024_1_, float p_234024_2_) { PathNavigation pathnavigator = this.mob.getNavigation(); - NodeEvaluator nodeprocessor = pathnavigator.getNodeEvaluator(); - return nodeprocessor.getPathType(this.mob, BlockPos.containing(this.mob.getX() + (double) p_234024_1_, this.mob.getY(), this.mob.getZ() + (double) p_234024_2_)) == PathType.WALKABLE; + if (pathnavigator != null) { + NodeEvaluator nodeprocessor = pathnavigator.getNodeEvaluator(); + return nodeprocessor == null || nodeprocessor.getPathType(this.mob, BlockPos.containing(this.mob.getX() + (double) p_234024_1_, this.mob.getY(), this.mob.getZ() + (double) p_234024_2_)) == PathType.WALKABLE; + } + return true; } } diff --git a/src/main/resources/citadel.mixins.json b/src/main/resources/citadel.mixins.json index 204468e..89babcd 100644 --- a/src/main/resources/citadel.mixins.json +++ b/src/main/resources/citadel.mixins.json @@ -7,6 +7,7 @@ "mixins": [ "BlockBehaviourAccessor", "ChunkGeneratorMixin", + "EntityMixin", "LevelMixin", "LivingEntityMixin", "MinecraftServerMixin", From 5fe4634b84d97c5d368d043ff69aea3f9c09a3ae Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 18 Jan 2026 15:59:47 +0900 Subject: [PATCH 08/10] Remove EntityMixin and update access transformer to allow public collision method for custom collision handling --- .../alexthe666/citadel/mixin/EntityMixin.java | 21 ------------------- .../resources/META-INF/accesstransformer.cfg | 4 +++- src/main/resources/citadel.mixins.json | 1 - 3 files changed, 3 insertions(+), 23 deletions(-) delete mode 100644 src/main/java/com/github/alexthe666/citadel/mixin/EntityMixin.java diff --git a/src/main/java/com/github/alexthe666/citadel/mixin/EntityMixin.java b/src/main/java/com/github/alexthe666/citadel/mixin/EntityMixin.java deleted file mode 100644 index b0cc157..0000000 --- a/src/main/java/com/github/alexthe666/citadel/mixin/EntityMixin.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.github.alexthe666.citadel.mixin; - -import com.github.alexthe666.citadel.server.entity.collision.ICustomCollisions; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(Entity.class) -public class EntityMixin { - - @Inject(method = "collide", at = @At("HEAD"), cancellable = true) - private void citadel_collide(Vec3 vec, CallbackInfoReturnable cir) { - Entity self = (Entity) (Object) this; - if (self instanceof ICustomCollisions) { - cir.setReturnValue(ICustomCollisions.getAllowedMovementForEntity(self, vec)); - } - } -} diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 8da4b99..5bf56ae 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -8,4 +8,6 @@ public net.minecraft.server.level.ChunkMap getVisibleChunkIfPresent(J)Lnet/minec public-f net.minecraft.client.renderer.RenderStateShard setupState #setupState public-f net.minecraft.client.DeltaTracker$Timer msPerTick #msPerTick public net.minecraft.client.gui.screens.ConfirmScreen callback #callback -public net.minecraft.client.gui.screens.BackupConfirmScreen onProceed #onProceed \ No newline at end of file +public net.minecraft.client.gui.screens.BackupConfirmScreen onProceed #onProceed +# Make Entity.collide() public so ICustomCollisions entities can override it +public net.minecraft.world.entity.Entity collide(Lnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3; # collide \ No newline at end of file diff --git a/src/main/resources/citadel.mixins.json b/src/main/resources/citadel.mixins.json index 89babcd..204468e 100644 --- a/src/main/resources/citadel.mixins.json +++ b/src/main/resources/citadel.mixins.json @@ -7,7 +7,6 @@ "mixins": [ "BlockBehaviourAccessor", "ChunkGeneratorMixin", - "EntityMixin", "LevelMixin", "LivingEntityMixin", "MinecraftServerMixin", From f770f3a685a5624b0a69fd0e2d3b42ecb92e29eb Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 18 Jan 2026 18:51:03 +0900 Subject: [PATCH 09/10] Fix indentation in blur shader for improved readability --- src/main/resources/assets/citadel/shaders/program/blur.fsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/assets/citadel/shaders/program/blur.fsh b/src/main/resources/assets/citadel/shaders/program/blur.fsh index ce57673..d0c8d02 100644 --- a/src/main/resources/assets/citadel/shaders/program/blur.fsh +++ b/src/main/resources/assets/citadel/shaders/program/blur.fsh @@ -20,11 +20,11 @@ void main() { for(float r = -Radius; r <= Radius; r += 1.0) { vec4 sampleValue = texture(DiffuseSampler, texCoord + oneTexel * r * BlurDir); - // Accumulate average alpha + // Accumulate average alpha totalAlpha = totalAlpha + sampleValue.a; totalSamples = totalSamples + 1.0; - // Accumulate smoothed blur + // Accumulate smoothed blur float strength = 1.0 - abs(r / Radius); totalStrength = totalStrength + strength; blurred = blurred + sampleValue; From acf644288e9299a90c15523b5640ba0f1bdb5a40 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 18 Jan 2026 18:59:21 +0900 Subject: [PATCH 10/10] Reset body rotation for LivingEntity in GuiBasicBook to ensure consistent entity orientation --- .../com/github/alexthe666/citadel/client/gui/GuiBasicBook.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/github/alexthe666/citadel/client/gui/GuiBasicBook.java b/src/main/java/com/github/alexthe666/citadel/client/gui/GuiBasicBook.java index e5a5ead..fb47ea2 100644 --- a/src/main/java/com/github/alexthe666/citadel/client/gui/GuiBasicBook.java +++ b/src/main/java/com/github/alexthe666/citadel/client/gui/GuiBasicBook.java @@ -173,6 +173,7 @@ public void drawEntityOnScreen(GuiGraphics guiGraphics, MultiBufferSource buffer entity.setXRot(0); if (entity instanceof LivingEntity) { ((LivingEntity) entity).yBodyRot = 0; + ((LivingEntity) entity).yBodyRotO = 0; ((LivingEntity) entity).yHeadRotO = 0; ((LivingEntity) entity).yHeadRot = 0; }