generated from NeoForgeMDKs/MDK-1.21-ModDevGradle
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a layer of jukeboxes and raised the end by two chunks . also se…
…t up for custom render types (currently useless)
- Loading branch information
Showing
7 changed files
with
305 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.thebeyond.client; | ||
|
||
import com.mojang.blaze3d.vertex.DefaultVertexFormat; | ||
import com.mojang.blaze3d.vertex.VertexFormat; | ||
import com.mojang.serialization.MapCodec; | ||
import com.thebeyond.TheBeyond; | ||
import net.minecraft.client.renderer.RenderStateShard; | ||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.core.registries.BuiltInRegistries; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.server.packs.resources.ResourceProvider; | ||
import net.minecraft.world.level.chunk.ChunkGenerator; | ||
import net.neoforged.bus.api.SubscribeEvent; | ||
import net.neoforged.fml.common.EventBusSubscriber; | ||
import net.neoforged.neoforge.client.event.RegisterNamedRenderTypesEvent; | ||
import net.neoforged.neoforge.registries.DeferredRegister; | ||
|
||
import static net.minecraft.client.renderer.RenderStateShard.*; | ||
|
||
@EventBusSubscriber(modid = TheBeyond.MODID, bus = EventBusSubscriber.Bus.MOD) | ||
public class BeyondRenderTypes { | ||
public static final RenderStateShard.ShaderStateShard TRANSLUCENT_PROXIMITY_SHADER = new RenderStateShard.ShaderStateShard(() -> BeyondShaders.translucentProximityShader); | ||
|
||
@SubscribeEvent | ||
public static void onRegisterNamedRenderTypes(RegisterNamedRenderTypesEvent event) { | ||
|
||
RenderType TRANSLUCENT_PROXIMITY = RenderType.create(TheBeyond.MODID + ":" +"translucent_proximity", DefaultVertexFormat.NEW_ENTITY, | ||
VertexFormat.Mode.QUADS, 256, true, true, RenderType.CompositeState.builder() | ||
.setShaderState(RENDERTYPE_SOLID_SHADER) | ||
.setTextureState(BLOCK_SHEET) | ||
.setTransparencyState(ADDITIVE_TRANSPARENCY) | ||
.setCullState(NO_CULL) | ||
.setLightmapState(LIGHTMAP) | ||
.setOverlayState(OVERLAY) | ||
.createCompositeState(true)); | ||
|
||
event.register(ResourceLocation.fromNamespaceAndPath(TheBeyond.MODID, "translucent_proximity"), RenderType.translucent(), TRANSLUCENT_PROXIMITY); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.thebeyond.client; | ||
|
||
import com.mojang.blaze3d.vertex.DefaultVertexFormat; | ||
import com.thebeyond.TheBeyond; | ||
import net.minecraft.client.renderer.ShaderInstance; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.server.packs.resources.ResourceProvider; | ||
import net.neoforged.api.distmarker.Dist; | ||
import net.neoforged.bus.api.SubscribeEvent; | ||
import net.neoforged.fml.common.EventBusSubscriber; | ||
import net.neoforged.neoforge.client.event.RegisterShadersEvent; | ||
|
||
import java.io.IOException; | ||
|
||
@EventBusSubscriber(value = Dist.CLIENT, bus = EventBusSubscriber.Bus.MOD) | ||
public class BeyondShaders { | ||
public static ShaderInstance translucentProximityShader; | ||
@SubscribeEvent | ||
public static void onRegisterShaders(RegisterShadersEvent event) throws IOException { | ||
ResourceProvider resourceProvider = event.getResourceProvider(); | ||
event.registerShader(new ShaderInstance(resourceProvider, ResourceLocation.fromNamespaceAndPath(TheBeyond.MODID,"translucent_proximity_shader"), DefaultVertexFormat.NEW_ENTITY), shader -> translucentProximityShader = shader); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/main/resources/assets/the_beyond/shaders/core/translucent_proximity_shader.fsh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#version 150 | ||
|
||
uniform vec2 iResolution; // Resolution of the screen | ||
uniform sampler2D Sampler0; // The texture to which the highlight mask will be applied | ||
|
||
in vec2 texCoord0; // Texture coordinates input | ||
out vec4 fragColor; // Final fragment color output | ||
|
||
// Hash function to create a pseudo-random value | ||
float Hash(vec2 p) { | ||
vec3 p2 = vec3(p.xy, 1.0); | ||
return fract(sin(dot(p2, vec3(37.1, 61.7, 12.4))) * 758.5453123); | ||
} | ||
|
||
// 2D noise function using the hash function | ||
float noise(in vec2 p) { | ||
vec2 i = floor(p); | ||
vec2 f = fract(p); | ||
f *= f * (3.0 - 2.0 * f); | ||
|
||
return mix(mix(Hash(i + vec2(0., 0.)), Hash(i + vec2(1., 0.)), f.x), | ||
mix(Hash(i + vec2(0., 1.)), Hash(i + vec2(1., 1.)), f.x), | ||
f.y); | ||
} | ||
|
||
// Fractal Brownian Motion function for more complexity in noise | ||
float fbm(vec2 p) { | ||
float v = 0.0; | ||
v += noise(p * 1.0) * 0.1; // Frequency 1 | ||
v += noise(p * 2.0) * 0.025; // Frequency 2 | ||
v += noise(p * 4.0) * 0.125; // Frequency 3 | ||
v += noise(p * 8.0) * 0.0625; // Frequency 4 | ||
return v; | ||
} | ||
|
||
void main() { | ||
// Normalize pixel coordinates | ||
vec2 uv = texCoord0; // Use the incoming texture coordinates | ||
|
||
// Calculate the distance from the center (0.5, 0.5) | ||
float dist = distance(uv, vec2(0.5)); // Center of the texture | ||
|
||
// Scale the distance for noise input (adjusted for a smaller highlight effect) | ||
float scaledDist = dist * 15.0; // Increase the multiplier for a smaller effect | ||
|
||
// Calculate the noise value based on the scaled distance | ||
float k = clamp(fbm(vec2(scaledDist)), 0.1, 1.0) - 0.1; // Calculate noise value and clamp | ||
k = k * 2.0; // Scale the noise down | ||
|
||
// Generate a color based on the noise value | ||
vec3 col = vec3(k, k, k); // Grayscale color for highlight | ||
|
||
// Sample the original texture (optional) | ||
vec4 textureColor = texture(Sampler0, uv); | ||
|
||
// Output the highlight mask (you can blend this with the original texture if needed) | ||
fragColor = vec4(textureColor.rgb + col * 0.5, 1.0); // Add highlight to the original texture color | ||
} |
116 changes: 116 additions & 0 deletions
116
src/main/resources/assets/the_beyond/shaders/core/translucent_proximity_shader.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
{ | ||
"vertex": "rendertype_cutout", | ||
"fragment": "rendertype_cutout", | ||
"samplers": [ | ||
{ | ||
"name": "Sampler0" | ||
}, | ||
{ | ||
"name": "Sampler2" | ||
} | ||
], | ||
"uniforms": [ | ||
{ | ||
"name": "ModelViewMat", | ||
"type": "matrix4x4", | ||
"count": 16, | ||
"values": [ | ||
1, | ||
0, | ||
0, | ||
0, | ||
0, | ||
1, | ||
0, | ||
0, | ||
0, | ||
0, | ||
1, | ||
0, | ||
0, | ||
0, | ||
0, | ||
1 | ||
] | ||
}, | ||
{ | ||
"name": "ProjMat", | ||
"type": "matrix4x4", | ||
"count": 16, | ||
"values": [ | ||
1, | ||
0, | ||
0, | ||
0, | ||
0, | ||
1, | ||
0, | ||
0, | ||
0, | ||
0, | ||
1, | ||
0, | ||
0, | ||
0, | ||
0, | ||
1 | ||
] | ||
}, | ||
{ | ||
"name": "ChunkOffset", | ||
"type": "float", | ||
"count": 3, | ||
"values": [ | ||
0, | ||
0, | ||
0 | ||
] | ||
}, | ||
{ | ||
"name": "ColorModulator", | ||
"type": "float", | ||
"count": 4, | ||
"values": [ | ||
1, | ||
1, | ||
1, | ||
1 | ||
] | ||
}, | ||
{ | ||
"name": "FogStart", | ||
"type": "float", | ||
"count": 1, | ||
"values": [ | ||
0 | ||
] | ||
}, | ||
{ | ||
"name": "FogEnd", | ||
"type": "float", | ||
"count": 1, | ||
"values": [ | ||
1 | ||
] | ||
}, | ||
{ | ||
"name": "FogColor", | ||
"type": "float", | ||
"count": 4, | ||
"values": [ | ||
0, | ||
0, | ||
0, | ||
0 | ||
] | ||
}, | ||
{ | ||
"name": "FogShape", | ||
"type": "int", | ||
"count": 1, | ||
"values": [ | ||
0 | ||
] | ||
} | ||
] | ||
} |
Oops, something went wrong.