Skip to content

Commit

Permalink
Merge branch 'refs/heads/1.20' into 1.19.4
Browse files Browse the repository at this point in the history
  • Loading branch information
UnlikePaladin committed Sep 20, 2024
2 parents 89e98ca + 434cb65 commit cc7b66a
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 41 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

![skullemoji](https://raw.githubusercontent.com/FiguraMC/Figura/HEAD/.github/assets/skull.png)

Meet us on the [FiguraMC Discord Server](https://discord.figuramc.org/) for more info and help!\
Meet us on the [FiguraMC Discord Server](https://discord.figuramc.org/) for more info and help!

Help translate Figura to your native language on [Weblate](https://translate.figuramc.org/projects/figuramc/figura/)!\
![translate]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void registerClass(Class<?> clazz) {
}

public void setGlobal(String name, Object obj) {
userGlobals.set(name, typeManager.javaToLua(obj).arg1());
userGlobals.rawset(name, typeManager.javaToLua(obj).arg1());
}

public void setUser(Entity user) {
Expand All @@ -114,8 +114,8 @@ public void setUser(Entity user) {
val = entityAPI = EntityAPI.wrap(user);
}

userGlobals.set("user", typeManager.javaToLua(val).arg1());
userGlobals.set("player", userGlobals.get("user"));
userGlobals.rawset("user", typeManager.javaToLua(val).arg1());
userGlobals.rawset("player", userGlobals.rawget("user"));
}

public Entity getUser() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public RendererAPI shadowRadius(Float shadowRadius) {
@LuaWhitelist
@LuaMethodDoc("renderer.get_shadow_radius")
public Float getShadowRadius() {
return this.shadowRadius;
return this.shadowRadius != null ? this.shadowRadius : 0.5f;
}

@LuaWhitelist
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ public static List<BlockStateAPI> getBlocks(Object x, Object y, Double z, Double
Math.min(min.getY() + 8, max.getY()),
Math.min(min.getZ() + 8, max.getZ())
);

if (min.compareTo(max) > 0) {
throw new LuaError("Your max value can't be smaller than your min!");
}
Level world = getCurrentWorld();
if (!world.hasChunksAt(min, max))
return list;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ private int drawWithColor(Font font, Component component, float x, float y, int
backgroundColor = figura$custom.background != null ? figura$custom.background : backgroundColor;
boolean deadmau = component.getString().equals("deadmau5");

// This renders the translucent part of the nametag you see when shifting, and the background
if (figura$isRenderingName()) {
int ret = 0;
// If the player's name is being rendered, render by lines otherwise just render whatever component is being passed. Applies for the rest of the loops below
Expand All @@ -130,7 +131,7 @@ private int drawWithColor(Font font, Component component, float x, float y, int
if (text1.getString().isEmpty())
continue;

int line = i - figura$textList.size() + (figura$hasScore() ? 0 : 1);
int line = i - figura$textList.size() + 1;
x = -font.width(text1) / 2f;
y = (deadmau ? -10f : 0f) + (font.lineHeight + 1) * line;
ret = original.call(font, text1, x, y, color, shadow, matrix4f, multiBufferSource, displayMode, backgroundColor, light);
Expand All @@ -151,6 +152,7 @@ private int drawWithOutline(Font font, Component component, float x, float y, in
boolean deadmau = component.getString().equals("deadmau5");

if (figura$enabled && figura$avatar != null && figura$hasCustomNameplate && figura$custom.outline) {
// This renders the opaque text with an outline if the player has that enabled.
int outlineColor = figura$custom.outlineColor != null ? figura$custom.outlineColor : 0x202020;
if (figura$isRenderingName()) {
for (int i = 0; i < figura$textList.size(); i++) {
Expand All @@ -159,7 +161,7 @@ private int drawWithOutline(Font font, Component component, float x, float y, in
if (text1.getString().isEmpty())
continue;

int line = i - figura$textList.size() + (figura$hasScore() ? 0 : 1);
int line = i - figura$textList.size() + 1;
x = -font.width(text1) / 2f;
y = (deadmau ? -10f : 0f) + (font.lineHeight + 1) * line;
font.drawInBatch8xOutline(text1.getVisualOrderText(), x, y, color, outlineColor, matrix4f, multiBufferSource, light);
Expand All @@ -169,16 +171,16 @@ private int drawWithOutline(Font font, Component component, float x, float y, in
}
return original.call(font, Component.empty(), x, y, color, shadow, textMatrix.get(), multiBufferSource, displayMode, backgroundColor, light);
} else {
if (figura$enabled && figura$isRenderingName()) {
if (figura$enabled && figura$avatar != null && figura$hasCustomNameplate && figura$isRenderingName()) {
int ret = 0;

// This renders the opaque part of the nametag, that is text
for (int i = 0; i < figura$textList.size(); i++) {
Component text1 = figura$textList.get(i);

if (text1.getString().isEmpty())
continue;

int line = i - figura$textList.size() + (figura$hasScore() ? 0 : 1);
int line = i - figura$textList.size() + 1;
x = -font.width(text1) / 2f;
y = (deadmau ? -10f : 0f) + (font.lineHeight + 1) * line;
ret = original.call(font, text1, x, y, color, shadow, textMatrix.get(), multiBufferSource, displayMode, backgroundColor, light);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private void setHasScore(AbstractClientPlayer player, Component text, PoseStack
return hasScore;
}

@ModifyArg(method = "renderNameTag(Lnet/minecraft/client/player/AbstractClientPlayer;Lnet/minecraft/network/chat/Component;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/LivingEntityRenderer;renderNameTag(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/network/chat/Component;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V"), index = 1)
@ModifyArg(method = "renderNameTag(Lnet/minecraft/client/player/AbstractClientPlayer;Lnet/minecraft/network/chat/Component;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/LivingEntityRenderer;renderNameTag(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/network/chat/Component;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", ordinal = 1))
private Component modifyPlayerNameText(Component text, @Local(argsOnly = true) AbstractClientPlayer player) {
int config = Configs.ENTITY_NAMEPLATE.value;
if (config == 0 || AvatarManager.panic)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.io.File;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -130,34 +131,34 @@ private void parseTextures(Path avatar, Path sourceFile, String folders, String
String path;
byte[] source;
try {
//check the file to load
// Check the file to load
Path p = sourceFile.getParent().resolve(texture.relative_path);
if (p.getFileSystem() == FileSystems.getDefault()) {
File f = p.toFile().getCanonicalFile();
p = f.toPath();
if (!f.exists()) {
// Compatibility with old Blockbench models. (BB 4.9-)
if (texture.relative_path.startsWith("../")) {
p = sourceFile.resolve(texture.relative_path);
if (p.getFileSystem() == FileSystems.getDefault()) {
f = p.toFile().getCanonicalFile();
p = f.toPath();
if (!f.exists()) throw new IllegalStateException("File do not exists!");
} else {
p = p.normalize();
if (p.getFileSystem() != avatar.getFileSystem())
throw new IllegalStateException("File from outside the avatar folder!");
}
} else {
throw new IllegalStateException("File do not exists!");
}
if (p.getFileSystem() == FileSystems.getDefault())
p = p.toFile().getCanonicalFile().toPath();

p = p.normalize();

if (!Files.exists(p) || (avatar.getNameCount() > 1 && !p.startsWith(avatar))) {
// Compatibility with old Blockbench models. (BB 4.9-)
if (texture.relative_path.startsWith("../")) {
p = sourceFile.resolve(texture.relative_path);
if (p.getFileSystem() == FileSystems.getDefault())
p = p.toFile().getCanonicalFile().toPath();

p = p.normalize();

if (!Files.exists(p))
throw new IllegalStateException("File does not exist!");
} else {
throw new IllegalStateException("File does not exist!");
}
} else {
p = p.normalize();
if (p.getFileSystem() != avatar.getFileSystem())
throw new IllegalStateException("File from outside the avatar folder!");
}
if (avatar.getNameCount() > 1) if (!p.startsWith(avatar)) throw new IllegalStateException("File from outside the avatar folder!");


// Make sure we are still looking in the avatar's folder
if ((avatar.getNameCount() > 1 && !p.startsWith(avatar)) || p.getFileSystem() != avatar.getFileSystem())
throw new IllegalStateException("File from outside the avatar folder!");

FiguraMod.debug("path is {}", p.toString());
//load texture
source = IOUtils.readFileBytes(p);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public void visit(Exp.BinopExp exp) {
public void visit(Exp.Constant exp) {
LuaValue value = exp.value;
if (value instanceof LuaString str) {
String input = new String(str.m_bytes, StandardCharsets.UTF_8);
String input = new String(str.m_bytes, str.m_offset, str.m_length, StandardCharsets.UTF_8);
int sdq = 0;
for (char c : input.toCharArray()) {
if (c == '\'') sdq--;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,13 @@ else if (hasCapeOrElytra)
Group leftElytra = model.addGroup(LeftElytra, FiguraVec3.of(-5, 24, 2), elytra);
Cube cube = model.addCube(FiguraVec3.of(-5, 4, 2), FiguraVec3.of(10, 20, 2), leftElytra);
cube.inflate = 1;
cube.generateBoxFaces(22, 0, capeTex, 1, hasPlayer ? 2 : 1);
cube.generateBoxFaces(22, 0, capeTex, 1, 1);

//right wing
Group rightElytra = model.addGroup(RightElytra, FiguraVec3.of(5, 24, 2), elytra);
cube = model.addCube(FiguraVec3.of(-5, 4, 2), FiguraVec3.of(10, 20, 2), rightElytra);
cube.inflate = 1;
cube.generateBoxFaces(22, 0, capeTex, -1, hasPlayer ? 2 : 1);
cube.generateBoxFaces(22, 0, capeTex, -1, 1);
}

//pivots
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mappings = 1
enabled_platforms = fabric,forge

# Mod Properties
mod_version = 0.1.5-rc.2
mod_version = 0.1.5-rc.3
maven_group = org.figuramc
archives_base_name = figura
assets_version = v2
Expand Down

0 comments on commit cc7b66a

Please sign in to comment.