Jump to content

[SOLVED BUT PARSING PROBLEM] [1.19.2] force client to toggle custom "post" shader when something happens on server


cocicocyn

Recommended Posts

disclaimer: i am new to java. however i will not ask for implementation nuances (at least not much. any help is appreciated).

suppose we have a custom block. when we rightclick on it we send a custom package (i assume that because we want specific things to happen on a server). server handles the package (applies effects or whatever) and sends back the answer. client part handles the answer. how do i toggle/load a custom shader when handling the answer from the server? can't seem to find suitable method. do i need to write a mixin? and if so what should i "mixin into"?

i believe it's possible because there is an in-game nausea effect and "wobble" shader (which btw has uniform float Time in it in .fsh file so it's animated)

thanks for help in advance 

Edited by cocicocyn
PostChain#parseUniformNode is sus + problem is finally solved
Link to comment
Share on other sites

  • cocicocyn changed the title to [1.19.2] force client to toggle custom "post" shader when something happens on server
10 hours ago, cocicocyn said:

how do i toggle/load a custom shader when handling the answer from the server?

So, if you want to use the postchain method, you can load a given effect via GameRenderer#loadEffect, the rest would be creating the json, vsh, and fsh as necessary.

10 hours ago, cocicocyn said:

i believe it's possible because there is an in-game nausea effect and "wobble" shader (which btw has uniform float Time in it in .fsh file so it's animated)

Nausea is rendered is highly hardcoded by manipulating the base posestack before everything else is rendered and the overlay is just a simple blit. As for the wobble shader, it's not really used anywhere afaik since it was probably part of the secret settings.

4 hours ago, cocicocyn said:

note for myself: research PostPass and PostChain classes in net.minecraft.client.renderer package (i guess the wiki provider is some third party warn me if this isn't supported) https://nekoyue.github.io/ForgeJavaDocs-NG/javadoc/1.19.3/net/minecraft/client/renderer/package-summary.html

It's illegal for this to be hosted.

  • Thanks 1
Link to comment
Share on other sites

am i the problem here? im not even reading anything from an array. 

net.minecraft.server.ChainedJsonException: Invalid shaders/post/tripeffect.json (Mod Resources) passes[0]->uniforms[0]->values[4]: Index 4 out of bounds for length 4
	at net.minecraft.server.ChainedJsonException.forException(ChainedJsonException.java:47) ~[forge-1.19.2-43.2.3_mapped_official_1.19.2-recomp.jar%23183!/:?] {re:classloading}
	at net.minecraft.client.renderer.PostChain.parseUniformNode(PostChain.java:245) ~[forge-1.19.2-43.2.3_mapped_official_1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.PostChain.parsePassNode(PostChain.java:217) ~[forge-1.19.2-43.2.3_mapped_official_1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.PostChain.load(PostChain.java:88) ~[forge-1.19.2-43.2.3_mapped_official_1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.PostChain.<init>(PostChain.java:54) ~[forge-1.19.2-43.2.3_mapped_official_1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.GameRenderer.loadEffect(GameRenderer.java:321) ~[forge-1.19.2-43.2.3_mapped_official_1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.guryavkin.drugsmodguryavkin.event.ClientEvents$ClientKeyEvents.onKeyInput(ClientEvents.java:38) ~[%23188!/:?] {re:classloading}
	at net.guryavkin.drugsmodguryavkin.event.__ClientKeyEvents_onKeyInput_Key.invoke(.dynamic) ~[%23188!/:?] {re:classloading,pl:eventbus:B}
	at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73) ~[eventbus-6.0.3.jar%23107!/:?] {}
	at net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) ~[eventbus-6.0.3.jar%23107!/:?] {}
	at net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) ~[eventbus-6.0.3.jar%23107!/:?] {}
	at net.minecraftforge.client.ForgeHooksClient.onKeyInput(ForgeHooksClient.java:753) ~[forge-1.19.2-43.2.3_mapped_official_1.19.2-recomp.jar%23182%23189!/:?] {re:classloading}
	at net.minecraft.client.KeyboardHandler.keyPress(KeyboardHandler.java:407) ~[forge-1.19.2-43.2.3_mapped_official_1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.KeyboardHandler.lambda$setup$7(KeyboardHandler.java:442) ~[forge-1.19.2-43.2.3_mapped_official_1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.util.thread.BlockableEventLoop.execute(BlockableEventLoop.java:90) ~[forge-1.19.2-43.2.3_mapped_official_1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.client.KeyboardHandler.lambda$setup$8(KeyboardHandler.java:441) ~[forge-1.19.2-43.2.3_mapped_official_1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:runtimedistcleaner:A}
	at org.lwjgl.glfw.GLFWKeyCallbackI.callback(GLFWKeyCallbackI.java:44) ~[lwjgl-glfw-3.3.1.jar%23162!/:build 7] {}
	at org.lwjgl.system.JNI.invokeV(Native Method) ~[lwjgl-3.3.1.jar%23168!/:build 7] {}
	at org.lwjgl.glfw.GLFW.glfwPollEvents(GLFW.java:3403) ~[lwjgl-glfw-3.3.1.jar%23162!/:build 7] {}
	at com.mojang.blaze3d.systems.RenderSystem.flipFrame(RenderSystem.java:164) ~[forge-1.19.2-43.2.3_mapped_official_1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:runtimedistcleaner:A}
	at com.mojang.blaze3d.platform.Window.updateDisplay(Window.java:337) ~[forge-1.19.2-43.2.3_mapped_official_1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.runTick(Minecraft.java:1143) ~[forge-1.19.2-43.2.3_mapped_official_1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.run(Minecraft.java:700) ~[forge-1.19.2-43.2.3_mapped_official_1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.main.Main.run(Main.java:212) ~[forge-1.19.2-43.2.3_mapped_official_1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.main.Main.main(Main.java:51) ~[forge-1.19.2-43.2.3_mapped_official_1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:runtimedistcleaner:A}
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] {}
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}
	at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] {}
	at net.minecraftforge.fml.loading.targets.ForgeClientUserdevLaunchHandler.lambda$launchService$0(ForgeClientUserdevLaunchHandler.java:25) ~[fmlloader-1.19.2-43.2.3.jar%2395!/:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:30) [modlauncher-10.0.8.jar%23108!/:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) [modlauncher-10.0.8.jar%23108!/:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) [modlauncher-10.0.8.jar%23108!/:?] {}
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) [modlauncher-10.0.8.jar%23108!/:?] {}
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) [modlauncher-10.0.8.jar%23108!/:?] {}
	at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) [modlauncher-10.0.8.jar%23108!/:?] {}
	at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) [modlauncher-10.0.8.jar%23108!/:?] {}
	at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:141) [bootstraplauncher-1.1.2.jar:?] {}
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 4 out of bounds for length 4
	at net.minecraft.client.renderer.PostChain.parseUniformNode(PostChain.java:243) ~[forge-1.19.2-43.2.3_mapped_official_1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:runtimedistcleaner:A}
	... 36 more
fuckety resource location bad, drugsmodguryavkin shaders/post/tripeffect.json
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 4 out of bounds for length 4

i can't make further progress anymore. managed to load a shader without shader compilation issues. this is what i get.
my "post" json:

Spoiler
{
    "targets": [
        "swap"
    ],
    "passes": [
        {
            "name": "tripeffect",
            "intarget": "minecraft:main",
            "outtarget": "swap",
            "uniforms": [
                { "name": "ProjMat", "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", "values": [ 1.0, 1.0 ] },
                { "name": "Time",  "values": [ 0.0 ] }
            ]
        },
        {
            "name": "blit",
            "intarget": "swap",
            "outtarget": "minecraft:main"
        }
    ]
}

 

 my "program" json:

Spoiler
{
    "blend": {
        "func": "add",
        "srcrgb": "one",
        "dstrgb": "zero"
    },
    "vertex": "tripeffect",
    "fragment": "tripeffect",
    "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 ] },
        { "name": "Time",         "type": "float",     "count": 1,  "values": [ 0.0 ] }
    ]
}

 

my event handler where shader is loaded:

Spoiler
        @SubscribeEvent
        public static void onKeyInput(InputEvent.Key event)
        {
            try
            {
                if(KeyBinding.FUCK_KEY.consumeClick())
                {
                    GameRenderer renderer = Minecraft.getInstance().gameRenderer;
                    ResourceLocation loc = new ResourceLocation(DrugsModGuryavkin.MOD_ID, "shaders/post/tripeffect.json");
                    if (ResourceLocation.isValidResourceLocation(loc.getPath()))
                    {
                        renderer.loadEffect(loc);
                        ModMessages.sendToServer(new HighC2SPacket());
                    }
                    System.out.println(String.format("fuckety resource location bad, %1$s %2$s", loc.getNamespace(), loc.getPath()));
                }
            }
            catch (Exception e)
            {
                System.out.println(e.getMessage());
            }

all sorts of output because im losing my mind rn trying to make it work

my .fsh (if im using built-in uniforms wrong i will fix them later myself dont mind me):

Spoiler
#version 150

#ifdef GL_ES
precision mediump float;
#endif

uniform float Time;
uniform sampler2D DiffuseSampler;

in vec2 texCoord;
in vec2 oneTexel;

out vec4 fragColor;

vec3 pal( in float t, in vec3 a, in vec3 b, in vec3 c, in vec3 d )
{
    return a + b*cos( 6.28318*(c*t+d) );
}

void main() {
    vec4 origColor = texture(DiffuseSampler, texCoord);

    float catx = texCoord.x;

    float caty = texCoord.y;

    float hyp = sqrt(pow(catx, 2.0) + pow(caty, 2.0));

    float rotAmp = degrees(Time/hyp);

    mat2 rotate = mat2(sin(rotAmp), cos(rotAmp), -cos(rotAmp), sin(rotAmp));

    vec2 p = texCoord.xy / oneTexel.xy * rotate;

    p.x *= oneTexel.x/oneTexel.y;

    vec3 col = pal( p.x+p.y, vec3(abs(0.5*sin(Time)),0.3,0.3),vec3(0.4,abs(0.5*sin(Time-0.7587)),0.2),vec3(abs(0.5*sin(2.0*Time-0.7587)),0.3,abs(0.8*sin(0.1*Time-0.7587))),vec3(0.0,abs(0.5*cos(1.5*Time-0.7587)),0.1) );

    col *= 0.2*abs(sin(degrees(Time/(360.0*4.0))));

    fragColor.r = mix(col.r, origColor.r, 0.1);
    fragColor.g = mix(col.g, origColor.g, 0.1);
    fragColor.b = mix(col.b, origColor.b, 0.1);
    fragColor.a = 1.0;
  
  	//all credit to gleurop on shaderstoy.com btw
}

 

my .vsh (copied blit.vsh)

Spoiler
#version 150

in vec4 Position;

uniform mat4 ProjMat;
uniform vec2 OutSize;
uniform float Time;

out vec2 texCoord;
out vec2 oneTexel;

void main(){
    vec4 outPos = ProjMat * vec4(Position.xy, 0.0, 1.0);
    gl_Position = vec4(outPos.xy, 0.2, 1.0);

    texCoord = Position.xy / OutSize;
    oneTexel = 1.0 / OutSize;
}

 

what am i doing wrong

progress#1 branch in github https://github.com/lveeeeeeeeeee/guryavkin_drugs_mod_for_minecraft

Edited by cocicocyn
added github
Link to comment
Share on other sites

  • cocicocyn changed the title to [SOLVED BUT PARSING PROBLEM] [1.19.2] force client to toggle custom "post" shader when something happens on server

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Baba  Serege [[+27-73 590 8989]] has experience of 27 years in helping and guiding many people from all over the world. His psychic abilities may help you answer and resolve many unanswered questions. He specialize in helping women and men from all walks of life.. 1) – Bring back lost lover. even if lost for a long time. 2) – My lover is abusing alcohol, partying and cheating on me I urgently need help” 3) – Divorce or court issues. 4) – Is your love falling apart? 5) – Do you want your love to grow stronger? 6) – Is your partner losing interest in you? 7) – Do you want to catch your partner cheating on you? – We help to keep your partner faithful and loyal to you. 9) – We recover love and happiness when relationship breaks down. 10) – Making your partner loves you alone. 11) – We create loyalty and everlasting love between couples. 12) – Get a divorce settlement quickly from your ex-partner. 13) – We create everlasting love between couples. 14) – We help you look for the best suitable partner. 15) – We bring back lost lover even if lost for a long time. 16) – We strengthen bonds in all love relationship and marriages 17) – Are you an herbalist who wants to get more powers? 18) – Buy a house or car of your dream. 19) – Unfinished jobs by other doctors come to me. 20) – I help those seeking employment. 21) – Pensioners free treatment. 22) – Win business tenders and contracts. 23) – Do you need to recover your lost property? 24) – Promotion at work and better pay. 25) – Do you want to be protected from bad spirits and nightmares? 26) – Financial problems. 27) – Why you can’t keep money or lovers? 28) – Why you have a lot of enemies? 29) – Why you are fired regularly on jobs? 30) – Speed up money claim spell, delayed payments, pension and accident funds 31) – I help students pass their exams/interviews. 33) – Removal of bad luck and debts. 34) – Are struggling to sleep because of a spiritual wife or husband. 35- ) Recover stolen property
    • OLXTOTO adalah situs bandar togel online resmi terbesar dan terpercaya di Indonesia. Bergabunglah dengan OLXTOTO dan nikmati pengalaman bermain togel yang aman dan terjamin. Koleksi toto 4D dan togel toto terlengkap di OLXTOTO membuat para member memiliki pilihan taruhan yang lebih banyak. Sebagai situs togel terpercaya, OLXTOTO menjaga keamanan dan kenyamanan para membernya dengan sistem keamanan terbaik dan enkripsi data. Transaksi yang cepat, aman, dan terpercaya merupakan jaminan dari OLXTOTO. Nikmati layanan situs toto terbaik dari OLXTOTO dengan tampilan yang user-friendly dan mudah digunakan. Layanan pelanggan tersedia 24/7 untuk membantu para member. Bergabunglah dengan OLXTOTO sekarang untuk merasakan pengalaman bermain togel yang menyenangkan dan menguntungkan.
    • Baba  Serege [[+27-73 590 8989]] has experience of 27 years in helping and guiding many people from all over the world. His psychic abilities may help you answer and resolve many unanswered questions. He specialize in helping women and men from all walks of life.. 1) – Bring back lost lover. even if lost for a long time. 2) – My lover is abusing alcohol, partying and cheating on me I urgently need help” 3) – Divorce or court issues. 4) – Is your love falling apart? 5) – Do you want your love to grow stronger? 6) – Is your partner losing interest in you? 7) – Do you want to catch your partner cheating on you? – We help to keep your partner faithful and loyal to you. 9) – We recover love and happiness when relationship breaks down. 10) – Making your partner loves you alone. 11) – We create loyalty and everlasting love between couples. 12) – Get a divorce settlement quickly from your ex-partner. 13) – We create everlasting love between couples. 14) – We help you look for the best suitable partner. 15) – We bring back lost lover even if lost for a long time. 16) – We strengthen bonds in all love relationship and marriages 17) – Are you an herbalist who wants to get more powers? 18) – Buy a house or car of your dream. 19) – Unfinished jobs by other doctors come to me. 20) – I help those seeking employment. 21) – Pensioners free treatment. 22) – Win business tenders and contracts. 23) – Do you need to recover your lost property? 24) – Promotion at work and better pay. 25) – Do you want to be protected from bad spirits and nightmares? 26) – Financial problems. 27) – Why you can’t keep money or lovers? 28) – Why you have a lot of enemies? 29) – Why you are fired regularly on jobs? 30) – Speed up money claim spell, delayed payments, pension and accident funds 31) – I help students pass their exams/interviews. 33) – Removal of bad luck and debts. 34) – Are struggling to sleep because of a spiritual wife or husband. 35- ) Recover stolen property
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.