-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a0deed
commit 44472b5
Showing
14 changed files
with
168 additions
and
43 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
common/src/main/resources/assets/minecraft/shaders/core/ping_rendertype_ping.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,17 @@ | ||
#version 150 | ||
|
||
uniform sampler2D Sampler0; | ||
uniform vec4 ColorModulator; | ||
|
||
in vec2 texCoord0; | ||
in vec4 vertexColor; | ||
|
||
out vec4 fragColor; | ||
|
||
void main() { | ||
vec4 color = texture(Sampler0, texCoord0) * vertexColor; | ||
if (color.a < 0.1) { | ||
discard; | ||
} | ||
fragColor = color * ColorModulator; | ||
} |
24 changes: 24 additions & 0 deletions
24
common/src/main/resources/assets/minecraft/shaders/core/ping_rendertype_ping.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,24 @@ | ||
{ | ||
"blend": { | ||
"func": "add", | ||
"srcrgb": "srcalpha", | ||
"dstrgb": "1-srcalpha" | ||
}, | ||
"vertex": "ping_rendertype_ping", | ||
"fragment": "ping_rendertype_ping", | ||
"attributes": [ | ||
"Position", | ||
"UV0", | ||
"Color", | ||
"Normal" | ||
], | ||
"samplers": [ | ||
{ "name": "Sampler0" } | ||
], | ||
"uniforms": [ | ||
{ "name": "ModelViewMat", "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": "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": "ScreenSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, | ||
{ "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } | ||
] | ||
} |
39 changes: 39 additions & 0 deletions
39
common/src/main/resources/assets/minecraft/shaders/core/ping_rendertype_ping.vsh
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,39 @@ | ||
#version 150 | ||
|
||
uniform mat4 ModelViewMat; | ||
uniform mat4 ProjMat; | ||
uniform vec2 ScreenSize; | ||
|
||
in vec3 Position; | ||
in vec2 UV0; | ||
in vec4 Color; | ||
|
||
out vec2 texCoord0; | ||
out vec4 vertexColor; | ||
|
||
const float VIEW_SHRINK = 1.0 - (1.0 / 256.0); | ||
const mat4 VIEW_SCALE = mat4( | ||
VIEW_SHRINK, 0.0, 0.0, 0.0, | ||
0.0, VIEW_SHRINK, 0.0, 0.0, | ||
0.0, 0.0, VIEW_SHRINK, 0.0, | ||
0.0, 0.0, 0.0, 1.0 | ||
); | ||
|
||
void main() { | ||
vec4 linePosStart = ProjMat * VIEW_SCALE * ModelViewMat * vec4(Position, 1.0); | ||
vec4 linePosEnd = ProjMat * VIEW_SCALE * ModelViewMat * vec4(Position, 1.0); | ||
|
||
vec3 ndc1 = linePosStart.xyz / linePosStart.w; | ||
vec3 ndc2 = linePosEnd.xyz / linePosEnd.w; | ||
|
||
vec2 lineScreenDirection = normalize((ndc2.xy - ndc1.xy) * ScreenSize); | ||
vec2 lineOffset = vec2(-lineScreenDirection.y, lineScreenDirection.x) / ScreenSize; | ||
|
||
if (lineOffset.x < 0.0) { | ||
lineOffset *= -1.0; | ||
} | ||
|
||
gl_Position = vec4((ndc1 - vec3(lineOffset, 0.0)) * linePosStart.w, linePosStart.w); | ||
texCoord0 = UV0; | ||
vertexColor = Color; | ||
} |
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 |
---|---|---|
@@ -1,11 +1,40 @@ | ||
package com.girafi.ping; | ||
|
||
import com.girafi.ping.client.KeyHelper; | ||
import com.girafi.ping.client.PingHandlerHelper; | ||
import com.girafi.ping.client.PingKeybinds; | ||
import com.girafi.ping.client.gui.PingSelectGui; | ||
import commonnetwork.CommonNetworkMod; | ||
import commonnetwork.networking.FabricNetworkHandler; | ||
import commonnetwork.networking.data.Side; | ||
import net.fabricmc.api.ClientModInitializer; | ||
import net.fabricmc.api.ModInitializer; | ||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; | ||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; | ||
import net.fabricmc.loader.api.FabricLoader; | ||
|
||
public class Ping implements ModInitializer { | ||
|
||
@Override | ||
public void onInitialize() { | ||
//ForgeConfigRegistry.INSTANCE.register(Constants.MOD_ID, ModConfig.Type.COMMON, ConfigurationHandler.spec); | ||
PingCommon.loadCommon(FabricLoader.getInstance().getConfigDir()); | ||
|
||
//Register keybinds | ||
KeyBindingHelper.registerKeyBinding(PingKeybinds.KEY_BINDING); | ||
KeyBindingHelper.registerKeyBinding(PingKeybinds.PING_ALERT); | ||
KeyBindingHelper.registerKeyBinding(PingKeybinds.PING_MINE); | ||
KeyBindingHelper.registerKeyBinding(PingKeybinds.PING_LOOK); | ||
KeyBindingHelper.registerKeyBinding(PingKeybinds.PING_GOTO); | ||
|
||
//TODO Register Shader Instance (Probably not here, but somehow somewhere) | ||
|
||
ClientTickEvents.END_CLIENT_TICK.register((mc) -> { | ||
PingHandlerHelper.pingTimer(); | ||
KeyHelper.onTick(); | ||
|
||
if ((mc.level == null || mc.isPaused()) && PingSelectGui.active) { | ||
PingSelectGui.deactivate(); | ||
} | ||
}); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
fabric/src/main/java/com/girafi/ping/mixin/MixinLevelRenderer.java
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,22 @@ | ||
package com.girafi.ping.mixin; | ||
|
||
import com.girafi.ping.client.PingHandlerHelper; | ||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import net.minecraft.client.Camera; | ||
import net.minecraft.client.renderer.GameRenderer; | ||
import net.minecraft.client.renderer.LevelRenderer; | ||
import net.minecraft.client.renderer.LightTexture; | ||
import org.joml.Matrix4f; | ||
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.CallbackInfo; | ||
|
||
@Mixin(LevelRenderer.class) | ||
public class MixinLevelRenderer { | ||
|
||
@Inject(at = @At("TAIL"), method = "renderLevel(Lcom/mojang/blaze3d/vertex/PoseStack;FJZLnet/minecraft/client/Camera;Lnet/minecraft/client/renderer/GameRenderer;Lnet/minecraft/client/renderer/LightTexture;Lorg/joml/Matrix4f;)V") | ||
private void renderLevel(PoseStack poseStack, float f, long l, boolean b, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f projectionMatrix, CallbackInfo info) { | ||
PingHandlerHelper.translateWorldPing(poseStack, projectionMatrix); | ||
} | ||
} |
23 changes: 0 additions & 23 deletions
23
fabric/src/main/java/com/girafi/ping/mixin/MixinServerPlayerGamemode.java
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
fabric/src/main/java/com/girafi/ping/mixin/MixinShaderInstance.java
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,27 @@ | ||
package com.girafi.ping.mixin; | ||
|
||
import com.girafi.ping.Constants; | ||
import com.girafi.ping.client.ClientHandlerBase; | ||
import com.google.common.collect.Lists; | ||
import com.mojang.blaze3d.vertex.DefaultVertexFormat; | ||
import com.mojang.datafixers.util.Pair; | ||
import net.minecraft.client.renderer.GameRenderer; | ||
import net.minecraft.client.renderer.ShaderInstance; | ||
import net.minecraft.server.packs.resources.ResourceProvider; | ||
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.CallbackInfo; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.function.Consumer; | ||
|
||
@Mixin(GameRenderer.class) | ||
public class MixinShaderInstance { | ||
|
||
@Inject(at = @At("HEAD"), method = "reloadShaders(Lnet/minecraft/server/packs/resources/ResourceProvider;)V") | ||
private void renderLevel(ResourceProvider resourceProvider, CallbackInfo info) { | ||
|
||
} | ||
} |
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,2 @@ | ||
accessWidener v2 named | ||
accessible field net/minecraft/client/renderer/GameRenderer shaders Ljava/util/Map; |
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
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