This repository was archived by the owner on Jul 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
Add Paper Doll HUD Mod #138
Open
DarkKronicle
wants to merge
2
commits into
Sol-Client:develop
Choose a base branch
from
DarkKronicle:feature/kronhud-elements
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
121 changes: 121 additions & 0 deletions
121
src/main/java/io/github/solclient/client/mod/impl/hud/PaperDollMod.java
This file contains hidden or 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,121 @@ | ||
| package io.github.solclient.client.mod.impl.hud; | ||
|
|
||
| import com.google.gson.annotations.Expose; | ||
| import com.mojang.blaze3d.platform.GLX; | ||
| import com.mojang.blaze3d.platform.GlStateManager; | ||
| import io.github.solclient.client.event.EventHandler; | ||
| import io.github.solclient.client.event.impl.PlayerHeadRotateEvent; | ||
| import io.github.solclient.client.event.impl.PreTickEvent; | ||
| import io.github.solclient.client.mod.impl.SolClientHudMod; | ||
| import io.github.solclient.client.mod.option.ModOption; | ||
| import io.github.solclient.client.mod.option.ModOptionStorage; | ||
| import io.github.solclient.client.mod.option.annotation.AbstractTranslationKey; | ||
| import io.github.solclient.client.mod.option.annotation.Option; | ||
| import io.github.solclient.client.mod.option.impl.SliderOption; | ||
| import io.github.solclient.client.util.MinecraftUtils; | ||
| import io.github.solclient.client.util.data.Position; | ||
| import io.github.solclient.client.util.data.Rectangle; | ||
| import net.minecraft.client.MinecraftClient; | ||
| import net.minecraft.client.render.DiffuseLighting; | ||
| import net.minecraft.client.render.entity.EntityRenderDispatcher; | ||
| import net.minecraft.client.resource.language.I18n; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
| // Originally from KronHUD | ||
| // Added here by DarkKronicle :) | ||
| // https://github.com/DarkKronicle/KronHUD/blob/master/src/main/java/io/github/darkkronicle/kronhud/gui/hud/PlayerHud.java | ||
| @AbstractTranslationKey("sol_client.mod.paperdoll") | ||
| public class PaperDollMod extends SolClientHudMod { | ||
|
|
||
| @Expose | ||
| @Option | ||
| private boolean dynamicRotation = true; | ||
|
|
||
| @Expose | ||
| private float rotation = 0; | ||
|
|
||
| private float lastYawOffset = 0; | ||
| private float yawOffset = 0; | ||
|
|
||
| @Override | ||
| public Rectangle getBounds(Position position) { | ||
| return new Rectangle(position.getX(), position.getY(), 62, 94); | ||
| } | ||
|
|
||
| @Override | ||
| public String getDetail() { | ||
| return I18n.translate("sol_client.mod.screen.by", "DarkKronicle"); // maybe also add original creator | ||
| } | ||
|
|
||
| @Override | ||
| protected List<ModOption<?>> createOptions() { | ||
| List<ModOption<?>> options = super.createOptions(); | ||
| Optional<String> format = Optional.empty(); | ||
| options.add( | ||
| new SliderOption( | ||
| "sol_client.mod.paperdoll.option.rotation", | ||
| ModOptionStorage.of(Number.class, () -> rotation, (value) -> rotation = value.floatValue()), | ||
| format, 0, 360, 1 | ||
| ) | ||
| ); | ||
| return options; | ||
| } | ||
|
Comment on lines
+53
to
+64
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can already use the |
||
|
|
||
| public void renderPlayer(double x, double y, float delta) { | ||
| if (mc.player == null) { | ||
| return; | ||
| } | ||
|
|
||
| float deltaYaw = mc.player.prevYaw + (mc.player.yaw - mc.player.prevYaw) * delta; | ||
| if (dynamicRotation) { | ||
| deltaYaw -= (lastYawOffset + ((yawOffset - lastYawOffset) * delta)); | ||
| } | ||
|
|
||
| GlStateManager.enableColorMaterial(); | ||
| GlStateManager.pushMatrix(); | ||
| GlStateManager.translate((float) x, (float) y, 500.0F); | ||
| GlStateManager.scale((float) (-40), (float) 40, (float) 40); | ||
| GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F); | ||
|
|
||
| GlStateManager.rotate(135.0F, 0.0F, 1.0F, 0.0F); | ||
| DiffuseLighting.enableNormally(); | ||
| GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F); | ||
| GlStateManager.rotate(deltaYaw + rotation, 0.0F, 1.0F, 0.0F); | ||
|
|
||
| EntityRenderDispatcher entityRenderDispatcher = MinecraftClient.getInstance().getEntityRenderManager(); | ||
| entityRenderDispatcher.setYaw(0); | ||
| entityRenderDispatcher.setRenderShadows(false); | ||
| entityRenderDispatcher.render(mc.player, 0.0, 0.0, 0.0, 0.0F, MinecraftUtils.getTickDelta()); | ||
| entityRenderDispatcher.setRenderShadows(true); | ||
|
|
||
| GlStateManager.popMatrix(); | ||
| DiffuseLighting.disable(); | ||
| GlStateManager.disableRescaleNormal(); | ||
| GlStateManager.activeTexture(GLX.lightmapTextureUnit); | ||
| GlStateManager.disableTexture(); | ||
| GlStateManager.activeTexture(GLX.textureUnit); | ||
|
|
||
| } | ||
|
|
||
| @EventHandler | ||
| public void onPlayerRotate(PlayerHeadRotateEvent event) { | ||
| if (event.yaw == 0 && event.pitch == 0) { | ||
| return; | ||
| } | ||
| yawOffset += (event.yaw * .15) / 2; | ||
| } | ||
|
|
||
| @Override | ||
| public void render(Position position, boolean editMode) { | ||
| renderPlayer(position.getX() + 31, position.getY() + 86, MinecraftUtils.getTickDelta()); | ||
| } | ||
|
|
||
| @EventHandler | ||
| public void onTick(PreTickEvent event) { | ||
| lastYawOffset = yawOffset; | ||
| yawOffset *= .93f; | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only meant for abstract classes