-
Notifications
You must be signed in to change notification settings - Fork 2
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
6142cfb
commit e54f25c
Showing
6 changed files
with
130 additions
and
36 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
30 changes: 30 additions & 0 deletions
30
src/main/java/kasuga/lib/core/util/projectile/CameraTracker.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,30 @@ | ||
package kasuga.lib.core.util.projectile; | ||
|
||
import com.mojang.math.Vector3f; | ||
import lombok.Getter; | ||
import net.minecraft.client.Camera; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.Gui; | ||
import net.minecraft.world.phys.Vec3; | ||
|
||
import static kasuga.lib.core.util.projectile.PanelRenderer.BASE_OFFSET_2; | ||
|
||
@Getter | ||
public class CameraTracker { | ||
|
||
private final Camera camera; | ||
private final Gui gui; | ||
|
||
public CameraTracker(Gui gui, Camera camera) { | ||
this.camera = camera; | ||
this.gui = gui; | ||
} | ||
|
||
public Ray test(float mouseX, float mouseY) { | ||
Vec3 vec = camera.getPosition(); | ||
Vec3 forward = new Vec3(camera.getLookVector()).add(BASE_OFFSET_2); | ||
return new Ray(vec, forward); | ||
} | ||
|
||
|
||
} |
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
40 changes: 40 additions & 0 deletions
40
src/main/java/kasuga/lib/core/util/projectile/RayRenderer.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,40 @@ | ||
package kasuga.lib.core.util.projectile; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.mojang.math.Quaternion; | ||
import com.mojang.math.Vector3f; | ||
import kasuga.lib.KasugaLib; | ||
import kasuga.lib.core.client.model.AnimModelLoader; | ||
import kasuga.lib.core.client.model.anim_model.AnimModel; | ||
import kasuga.lib.core.util.LazyRecomputable; | ||
import net.minecraft.client.renderer.MultiBufferSource; | ||
import net.minecraft.resources.ResourceLocation; | ||
|
||
import static kasuga.lib.core.util.projectile.PanelRenderer.BASE_OFFSET; | ||
|
||
public class RayRenderer { | ||
|
||
private static final LazyRecomputable<AnimModel> arrowModel = LazyRecomputable.of( | ||
() -> { | ||
AnimModel model = AnimModelLoader.INSTANCE.getModel(new ResourceLocation(KasugaLib.MOD_ID, "arrow")); | ||
model.init(); | ||
return model; | ||
} | ||
); | ||
|
||
private final Ray ray; | ||
public RayRenderer(Ray ray) { | ||
this.ray = ray; | ||
} | ||
|
||
public void render(PoseStack pose, MultiBufferSource buffer, int light, int overlay) { | ||
pose.pushPose(); | ||
Vector3f source = ray.getSource(); | ||
pose.translate(source.x(), source.y(), source.z()); | ||
Quaternion quaternion = Panel.getQuaternion(ray.getForward()); | ||
pose.mulPose(quaternion); | ||
pose.translate(-BASE_OFFSET.x(), BASE_OFFSET.y(), -BASE_OFFSET.z()); | ||
arrowModel.get().render(pose, buffer, light, overlay); | ||
pose.popPose(); | ||
} | ||
} |