Posted December 30, 201410 yr Hello everyone, I'd like to activate a certain Minecraft shader from "super secret settings" when an item is used, specifically the one named "wobble". Now, I have an item set up and everything, and I overrid the "onItemUse" method (is this the way to do it, BTW?) but I have no idea how to start the shader. I've been looking around the minecraft Shader classes (ShaderManager, ShaderLoader, ...) for a long time but can't seem to figure out how to do this. Thanks! PS: I don't expect a full code or anything similar, just general pointers on how to work with Minecraft shaders, because I'm not at all new to programming, however I am new to modding Minecraft
December 31, 201410 yr Take a look at EntityRenderer#activateNextShader BEFORE ASKING FOR HELP READ THE EAQ! I'll help if I can. Apologies if I do something obviously stupid. If you don't know basic Java yet, go and follow these tutorials.
December 31, 201410 yr Author Thanks shieldbug, that is indeed changing the shaders. Sorry for the late reply. I now have this code in the item use method: Minecraft.getMinecraft().entityRenderer.activateNextShader(); However I am getting an exception, "No OpenGL context found in the current thread.". Which is kind of expected because OpenGL contexts are thread-specific and when one thread uses the context another one cannot. I am assuming for that reason that the GUI thread owns the OpenGL context and that item use method is in a different thread which does not have it. Is there a way to activate the shader from this thread, or is there some other way around this?
January 1, 201510 yr Author Where did you call that method? In my item class which is the subclass of Item, I overrid the "onItemRightClick" method: @Override public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { Minecraft.getMinecraft().entityRenderer.activateNextShader(); return p_77659_1_; }
January 1, 201510 yr Author onItemRightClick is called on both server & client, you cannot interact with client-code directly in there. Check that the world is a client world (world.isRemote is true) and then call a method in your proxy (@SidedProxy) that then activates the shader. Thanks, that fixed it! It's working now, and this is how I currently get wobble: while(Minecraft.getMinecraft().entityRenderer.isShaderActive() ? !(Minecraft.getMinecraft().entityRenderer.getShaderGroup().getShaderGroupName().equals("minecraft:shaders/post/wobble.json")) : true) Minecraft.getMinecraft().entityRenderer.activateNextShader(); Basicly it cycles through all the shaders until it finds "wobble", is there maybe a certain method for getting a specific one or is this the way to go?
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.