Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add arrow hiding function #291

Open
wants to merge 2 commits into
base: 1.20
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions common/src/main/java/org/figuramc/figura/lua/api/RendererAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class RendererAPI {
public FiguraVec4 blockOutlineColor;
public Boolean upsideDown;
public Boolean rootRotation;
public Boolean renderArrows;

public RendererAPI(Avatar owner) {
this.owner = owner.owner;
Expand Down Expand Up @@ -439,6 +440,22 @@ public RendererAPI postEffect(String effect) {
return setPostEffect(effect);
}

@LuaWhitelist
@LuaMethodDoc(
overloads = @LuaMethodOverload(
argumentTypes = Boolean.class,
argumentNames = "bool"
),
aliases = "renderArrows",
value = "renderer.set_render_arrows"
)
public RendererAPI setRenderArrows(Boolean bool) {
this.renderArrows = bool;
return this;
}
@LuaWhitelist
public RendererAPI renderArrows(Boolean bool) { return setRenderArrows(bool); }

@LuaWhitelist
@LuaMethodDoc("renderer.get_fov")
public Float getFOV() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.figuramc.figura.mixin.render.renderers;

import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.layers.ArrowLayer;
import net.minecraft.world.entity.Entity;
import org.figuramc.figura.FiguraMod;
import org.figuramc.figura.avatar.Avatar;
import org.figuramc.figura.avatar.AvatarManager;
import org.figuramc.figura.permissions.Permissions;
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(ArrowLayer.class)
public abstract class StuckArrowsFeatureRendererMixin {
private static boolean bool = true;

@Inject(method = "renderStuckItem", at = @At("HEAD"), cancellable = true)
private void disableStuckArrowsRendering(PoseStack matrices, MultiBufferSource vertexConsumers, int light, Entity entity, float directionX, float directionY, float directionZ, float tickDelta, CallbackInfo ci) {
Avatar avatar = AvatarManager.getAvatarForPlayer(FiguraMod.getLocalPlayerUUID());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad implementation, now the arrows' visibility for all players depends on the the setting of the avatar of the local player, not of their respective avatars

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i fucked up and forgot to test mp, ill draft and work on fix

if (avatar != null && avatar.luaRuntime != null && avatar.luaRuntime.renderer.renderArrows != null && !avatar.luaRuntime.renderer.renderArrows && avatar.permissions.get(Permissions.VANILLA_MODEL_EDIT) == 1) {
ci.cancel();
}
}
}
1 change: 1 addition & 0 deletions common/src/main/resources/assets/figura/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -1468,6 +1468,7 @@
"figura.docs.renderer.get_camera_normal": "Returns the modified camera normal matrix",
"figura.docs.renderer.set_camera_normal": "Sets the camera normal matrix with the given matrix",
"figura.docs.renderer.set_post_effect": "Sets the current rendering effect\nSame as the discontinued Super Secret Settings",
"figura.docs.renderer.set_render_arrows": "Sets whether or not arrows should be rendered",
"figura.docs.renderer.get_fov": "Gets the multiplier of your fov",
"figura.docs.renderer.set_fov": "Sets the multiplier of your fov\nThe default value is nil, which means no changes will be applied to your fov",
"figura.docs.renderer.get_crosshair_offset": "Gets the offset of your crosshair",
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/figura-common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"render.renderers.ScreenEffectRendererMixin",
"render.renderers.SignRendererMixin",
"render.renderers.SkullBlockRendererMixin",
"render.renderers.StuckArrowsFeatureRendererMixin",
"render.renderers.TridentRendererMixin",
"render.PoseStackAccessor",
"sound.ChannelHandleMixin",
Expand Down