Introduce RegisterShadersEvent to register shaders with the proper timing (runs every client resource reload).

Fix ShaderInstance to allow resourcelocations with namespaces as input.
Fix shader parsing to respect resource domains.
Fix ForgeRenderTypes to use the right shader in each situation.
Add custom forge shader for unlit translucent entity rendering, equivalent to the vanilla entity translucent shader.
This commit is contained in:
gigaherz committed 2021-07-30 01:48:20 +02:00
1 parent 7d4c238165
commit 80d08dbf3a
9 files changed
+273 -37

No files matched your search

@@ -0,0 +1,51 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2021.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.client.event;
import com.mojang.datafixers.util.Pair;
import net.minecraft.client.renderer.ShaderInstance;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.fml.event.IModBusEvent;
import java.util.List;
import java.util.function.Consumer;
public class RegisterShadersEvent extends Event implements IModBusEvent
{
private final ResourceManager resourceManager;
private final List<Pair<ShaderInstance, Consumer<ShaderInstance>>> shaderList;
public RegisterShadersEvent(ResourceManager resourceManager, List<Pair<ShaderInstance, Consumer<ShaderInstance>>> shaderList)
{
this.resourceManager = resourceManager;
this.shaderList = shaderList;
}
public ResourceManager getResourceManager()
{
return resourceManager;
}
public void registerShader(ShaderInstance shaderInstance, Consumer<ShaderInstance> onLoaded)
{
shaderList.add(Pair.of(shaderInstance, onLoaded));
}
}