-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding logic to render info over the world
- Loading branch information
Showing
8 changed files
with
97 additions
and
2 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
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
22 changes: 22 additions & 0 deletions
22
src/main/java/com/sekwah/narutomod/client/renderer/NarutoRenderTypes.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.sekwah.narutomod.client.renderer; | ||
|
||
import com.mojang.blaze3d.vertex.DefaultVertexFormat; | ||
import com.mojang.blaze3d.vertex.VertexFormat; | ||
import net.minecraft.client.renderer.RenderType; | ||
import org.lwjgl.opengl.GL11; | ||
|
||
public class NarutoRenderTypes extends RenderType { | ||
|
||
public static final RenderType JUTSU_INFO = create("narutomod_jutsu_overlay", | ||
DefaultVertexFormat.POSITION_COLOR_TEX, VertexFormat.Mode.QUADS, 256/*bufferSize*/, | ||
false/*affectsCrumbling*/, false/*sortOnUpload*/, RenderType.CompositeState.builder() | ||
.setTransparencyState(TRANSLUCENT_TRANSPARENCY) | ||
.setWriteMaskState(COLOR_WRITE) | ||
.setCullState(CULL) | ||
.createCompositeState(false) | ||
); | ||
|
||
public NarutoRenderTypes(String p_173178_, VertexFormat p_173179_, VertexFormat.Mode p_173180_, int p_173181_, boolean p_173182_, boolean p_173183_, Runnable p_173184_, Runnable p_173185_) { | ||
super(p_173178_, p_173179_, p_173180_, p_173181_, p_173182_, p_173183_, p_173184_, p_173185_); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/com/sekwah/narutomod/client/renderer/NarutoWorldRenderEvents.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,36 @@ | ||
package com.sekwah.narutomod.client.renderer; | ||
|
||
import com.mojang.blaze3d.systems.RenderSystem; | ||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.mojang.math.Matrix4f; | ||
import com.sekwah.narutomod.client.gui.SubstitutionGUI; | ||
import com.sekwah.narutomod.client.renderer.worldinfo.SubstitutionWorldMarkerRenderer; | ||
import net.minecraft.client.Camera; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.GuiComponent; | ||
import net.minecraft.client.renderer.GameRenderer; | ||
import net.minecraft.client.renderer.MultiBufferSource; | ||
import net.minecraftforge.client.event.RenderLevelLastEvent; | ||
import net.minecraftforge.common.MinecraftForge; | ||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
|
||
public class NarutoWorldRenderEvents { | ||
|
||
public static void registerEvents() { | ||
MinecraftForge.EVENT_BUS.register(NarutoWorldRenderEvents.class); | ||
} | ||
|
||
@SubscribeEvent | ||
public static void renderLevelLast(RenderLevelLastEvent event) { | ||
Minecraft mc = Minecraft.getInstance(); | ||
if(mc.options.hideGui || mc.level == null || mc.player == null) { | ||
return; | ||
} | ||
Camera camera = mc.getEntityRenderDispatcher().camera; | ||
PoseStack poseStack = event.getPoseStack(); | ||
Matrix4f matrix = event.getProjectionMatrix(); | ||
float partialTicks = event.getPartialTick(); | ||
MultiBufferSource multiBufferSource = mc.renderBuffers().bufferSource(); | ||
SubstitutionWorldMarkerRenderer.render(poseStack, camera, matrix, multiBufferSource, partialTicks); | ||
} | ||
} |
23 changes: 22 additions & 1 deletion
23
.../java/com/sekwah/narutomod/client/renderer/worldinfo/SubstitutionWorldMarkerRenderer.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 |
---|---|---|
@@ -1,7 +1,28 @@ | ||
package com.sekwah.narutomod.client.renderer.worldinfo; | ||
|
||
import com.mojang.blaze3d.systems.RenderSystem; | ||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.mojang.blaze3d.vertex.VertexConsumer; | ||
import com.mojang.math.Matrix4f; | ||
import com.sekwah.narutomod.NarutoMod; | ||
import com.sekwah.narutomod.client.gui.SubstitutionGUI; | ||
import com.sekwah.narutomod.client.renderer.NarutoRenderTypes; | ||
import net.minecraft.client.Camera; | ||
import net.minecraft.client.renderer.GameRenderer; | ||
import net.minecraft.client.renderer.MultiBufferSource; | ||
|
||
public class SubstitutionWorldMarkerRenderer { | ||
public static void render() { | ||
|
||
public static void render(PoseStack poseStack, Camera camera, Matrix4f matrix, MultiBufferSource multiBufferSource, float partialTicks) { | ||
int textureWidth = 19; | ||
int textureHeight = 18; | ||
RenderSystem.setShader(GameRenderer::getPositionTexShader); | ||
RenderSystem.setShaderTexture(0, SubstitutionGUI.LOG_TEXTURE); | ||
poseStack.pushPose(); | ||
poseStack.translate(camera.getPosition().x, camera.getPosition().y, camera.getPosition().z); | ||
|
||
VertexConsumer vertexConsumer = multiBufferSource.getBuffer(NarutoRenderTypes.JUTSU_INFO); | ||
|
||
poseStack.popPose(); | ||
} | ||
} |