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
# Conflicts:
#	common/src/main/java/org/figuramc/figura/avatar/Avatar.java
#	gradle.properties
  • Loading branch information
UnlikePaladin committed Jul 6, 2024
2 parents fae40c9 + 8ff2a3a commit 2f6d4a9
Show file tree
Hide file tree
Showing 42 changed files with 565 additions and 118 deletions.
58 changes: 58 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Bug Report
description: "For reporting bugs and other defects"
labels:
- bug
body:
- type: markdown
attributes:
value: >-
**Note: This issue tracker is not intended for support requests!** If you need help with crashes or other issues, then
you should [ask on our Discord server](https://discord.figuramc.org/) instead.
<br><br>
Additionally, please make sure you have done the following:
- **Have you ensured that all of your mods are up-to-date?** The latest version of Figura
can always be found [on Modrinth](https://modrinth.com/mod/figura) or [on CurseForge](https://curseforge.com/minecraft/mc-mods/figura).
- **Have you used the [search tool](https://github.com/FiguraMC/Figura/issues) to check whether your issue
has already been reported?** If it has been, then consider adding more information to the existing issue instead.
- **Have you determined the minimum set of instructions to reproduce the issue?** If your problem only occurs
with other mods installed, then you should narrow down exactly which mods are causing the issue. Please do not
provide your entire list of mods to us and expect that we will be able to figure out the problem.
<br>
This issue template was based [off of Sodium's](https://github.com/CaffeineMC/sodium-fabric/blob/dev/.github/ISSUE_TEMPLATE/bug_report.yml)
- type: textarea
id: description
attributes:
label: Bug Description
description: >-
Use this section to describe the issue you are experiencing in as much depth as possible. The description should
explain what behavior you were expecting, and why you believe the issue to be a bug. If the issue you are reporting
only occurs with specific mods installed, then provide the name and version of each mod.
**Hint:** If you have any screenshots, videos, or other information that you feel is necessary to
explain the issue, you can attach them here.
- type: textarea
id: description-reproduction-steps
attributes:
label: Reproduction Steps
description: >-
Provide as much information as possible on how to reproduce this bug. Make sure your instructions are as clear and
concise as possible, because other people will need to be able to follow your guide in order to re-create the issue.
**Hint:** A common way to fill this section out is to write a step-by-step guide.
validations:
required: true
- type: textarea
id: log-file
attributes:
label: Log File
description: >-
**Hint:** You can usually find the log files within the folder `.minecraft/logs`. Most often, you will want the `latest.log`
file, since that file belongs to the last played session of the game.
placeholder: >-
Drag-and-drop the log file here.
validations:
required: true
7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
blank_issues_enabled: true
contact_links:
- name: For help with other issues, join the Discord community
url: https://discord.figuramc.org/
about: This is the best option for getting help with mod installation, performance issues, and any other support inquiries
# Copied from https://github.com/CaffeineMC/sodium-fabric#community
# Copied from https://github.com/CaffeineMC/sodium-fabric/blob/dev/.github/ISSUE_TEMPLATE/config.yml
26 changes: 26 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Feature Request
description: "For requesting new features or improvements"
labels:
- enhancement
body:
- type: markdown
attributes:
value: >-
This form is for requesting new features or improvements, and should not be used for bug reports or other issues.
- type: markdown
attributes:
value: >-
Make sure you have used the [search tool](https://github.com/FiguraMC/Figura/issues) to see if a similar
request already exists. If we have previously closed a feature request, then please do not create another request.
- type: markdown
attributes:
value: >-
This template was based [off of Sodium's](https://github.com/CaffeineMC/sodium-fabric/blob/dev/.github/ISSUE_TEMPLATE/feature_request.yml)
- type: textarea
id: description
attributes:
label: Request Description
description: >-
Use this section to describe the feature or improvement that you are looking for. The description should explain
what you would like to see added, and a clear and concise description
of what you would like changed.
4 changes: 1 addition & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.2-SNAPSHOT" apply false
id "io.github.juuxel.loom-vineflower" version "1.+" apply false
id "dev.architectury.loom" version "1.5-SNAPSHOT" apply false
}

architectury {
Expand All @@ -10,7 +9,6 @@ architectury {

subprojects {
apply plugin: "dev.architectury.loom"
apply plugin: "io.github.juuxel.loom-vineflower"

loom {
silentMojangMappingsLicense()
Expand Down
2 changes: 2 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ dependencies {
exclude group: "net.fabricmc"
}

implementation(annotationProcessor("io.github.llamalad7:mixinextras-common:0.3.6"))

// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
// Do NOT use other classes from fabric loader
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
Expand Down
6 changes: 4 additions & 2 deletions common/src/main/java/org/figuramc/figura/FiguraMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ public static void tick() {
popPushProfiler("files");
LocalAvatarLoader.tick();
LocalAvatarFetcher.tick();
popPushProfiler("avatars");
AvatarManager.tickLoadedAvatars();
if (Minecraft.getInstance().player != null) {
popPushProfiler("avatars");
AvatarManager.tickLoadedAvatars();
}
popPushProfiler("chatPrint");
FiguraLuaPrinter.printChatFromQueue();
popPushProfiler("emojiAnim");
Expand Down
15 changes: 13 additions & 2 deletions common/src/main/java/org/figuramc/figura/animation/Animation.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ public void tick() {
else if (inverted && time < offset - loopDelay)
time += length + loopDelay - offset;
}
case HOLD -> time = inverted ? Math.max(time, offset) : Math.min(time, length);
case HOLD -> {
time = inverted ? Math.max(time, offset) : Math.min(time, length);
if (time == length)
playState = PlayState.HOLDING;
}
}

this.lastTime = this.frameTime;
Expand Down Expand Up @@ -158,6 +162,12 @@ public boolean isStopped() {
return this.playState == PlayState.STOPPED;
}

@LuaWhitelist
@LuaMethodDoc("animation.is_holding")
public boolean isHolding() {
return this.playState == PlayState.HOLDING;
}

@LuaWhitelist
@LuaMethodDoc("animation.play")
public Animation play() {
Expand Down Expand Up @@ -598,7 +608,8 @@ public String toString() {
public enum PlayState {
STOPPED,
PAUSED,
PLAYING
PLAYING,
HOLDING
}

public enum LoopMode {
Expand Down
32 changes: 23 additions & 9 deletions common/src/main/java/org/figuramc/figura/avatar/Avatar.java
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public void punish(int amount) {
luaRuntime.takeInstructions(amount);
}

// -- script events -- //
// -- script events -- //

private boolean isCancelled(Varargs args) {
if (args == null)
Expand Down Expand Up @@ -429,6 +429,10 @@ public void resourceReloadEvent() {
if (loaded) run("RESOURCE_RELOAD", tick);
}

public void damageEvent(String sourceType, EntityAPI<?> sourceCause, EntityAPI<?> sourceDirect, FiguraVec3 sourcePosition) {
if (loaded) run("DAMAGE", tick, sourceType, sourceCause, sourceDirect, sourcePosition);
}

// -- host only events -- //

public String chatSendMessageEvent(String message) { // piped event
Expand Down Expand Up @@ -476,6 +480,10 @@ public void charTypedEvent(String chars, int modifiers, int codePoint) {
if (loaded) run("CHAR_TYPED", tick, chars, modifiers, codePoint);
}

public boolean totemEvent() {
return isCancelled(loaded ? run("TOTEM",tick) : null);
}

// -- rendering events -- //

private void render() {
Expand Down Expand Up @@ -888,7 +896,7 @@ public void updateMatrices(LivingEntityRenderer<?, ?> entityRenderer, PoseStack
}


// -- animations -- //
// -- animations -- //


public void applyAnimations() {
Expand Down Expand Up @@ -918,7 +926,7 @@ public void clearAnimations() {
AnimationPlayer.clear(animation);
}

// -- functions -- //
// -- functions -- //

/**
* We should call this whenever an avatar is no longer reachable!
Expand All @@ -939,8 +947,10 @@ public void clean() {

public void clearSounds() {
SoundAPI.getSoundEngine().figura$stopSound(owner, null);
for (SoundBuffer value : customSounds.values())
value.releaseAlBuffer();
if (SoundAPI.getSoundEngine().figura$isEngineActive()) {
for (SoundBuffer value : customSounds.values())
value.releaseAlBuffer();
}
}

public void closeBuffers() {
Expand Down Expand Up @@ -977,7 +987,7 @@ private int getVersionStatus() {
return version.compareTo(FiguraMod.VERSION);
}

// -- loading -- //
// -- loading -- //

private void createLuaRuntime() {
if (!nbt.contains("scripts"))
Expand Down Expand Up @@ -1077,9 +1087,13 @@ private void loadCustomSounds() {
}

public void loadSound(String name, byte[] data) throws Exception {
try (ByteArrayInputStream inputStream = new ByteArrayInputStream(data); OggAudioStream oggAudioStream = new OggAudioStream(inputStream)) {
SoundBuffer sound = new SoundBuffer(oggAudioStream.readAll(), oggAudioStream.getFormat());
this.customSounds.put(name, sound);
if (SoundAPI.getSoundEngine().figura$isEngineActive()) {
try (ByteArrayInputStream inputStream = new ByteArrayInputStream(data); OggAudioStream oggAudioStream = new OggAudioStream(inputStream)) {
SoundBuffer sound = new SoundBuffer(oggAudioStream.readAll(), oggAudioStream.getFormat());
this.customSounds.put(name, sound);
}
} else {
FiguraMod.LOGGER.error("Sound is not supported or enabled on this system but a custom sound tried to load anyway, scripts may break.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static void init() {

public static boolean checkAndLoad(String hash, UserData target) {
Path p = getAvatarCacheDirectory();
p = p.resolve(hash + ".moon");
p = p.resolve(hash + ".nbt");

if (Files.exists(p)) {
load(hash, target);
Expand All @@ -57,7 +57,7 @@ public static boolean checkAndLoad(String hash, UserData target) {

public static void load(String hash, UserData target) {
LocalAvatarLoader.async(() -> {
Path path = getAvatarCacheDirectory().resolve(hash + ".moon");
Path path = getAvatarCacheDirectory().resolve(hash + ".nbt");
try {
target.loadAvatar(NbtIo.readCompressed(Files.newInputStream(path)));
FiguraMod.debug("Loaded avatar \"{}\" from cache to \"{}\"", hash, target.id);
Expand All @@ -69,7 +69,7 @@ public static void load(String hash, UserData target) {

public static void save(String hash, CompoundTag nbt) {
LocalAvatarLoader.async(() -> {
Path file = getAvatarCacheDirectory().resolve(hash + ".moon");
Path file = getAvatarCacheDirectory().resolve(hash + ".nbt");
try {
NbtIo.writeCompressed(nbt, Files.newOutputStream(file));
FiguraMod.debug("Saved avatar \"{}\" on cache", hash);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
import org.figuramc.figura.utils.FiguraText;
import org.figuramc.figura.utils.IOUtils;

import java.io.*;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.*;
import java.util.*;
import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -44,7 +47,7 @@ public class LocalAvatarLoader {
CEM_AVATARS.clear();
AvatarManager.clearCEMAvatars();

for (Map.Entry<ResourceLocation, Resource> cem : manager.listResources("cem", location -> location.getNamespace().equals(FiguraMod.MOD_ID) && location.getPath().endsWith(".moon")).entrySet()) {
for (Map.Entry<ResourceLocation, Resource> cem : manager.listResources("cem", location -> location.getNamespace().equals(FiguraMod.MOD_ID) && location.getPath().endsWith(".nbt")).entrySet()) {
// id
ResourceLocation key = cem.getKey();
String[] split = key.getPath().split("/");
Expand Down Expand Up @@ -131,10 +134,15 @@ public static void loadAvatar(Path path, UserData target) {

// metadata
loadState = LoadState.METADATA;
String metadata = IOUtils.readFile(finalPath.resolve("avatar.json"));
nbt.put("metadata", AvatarMetadataParser.parse(metadata, IOUtils.getFileNameOrEmpty(finalPath)));
AvatarMetadataParser.injectToModels(metadata, models);
AvatarMetadataParser.injectToTextures(metadata, textures);
String _meta = IOUtils.readFile(finalPath.resolve("avatar.json"));
var metadata = AvatarMetadataParser.read(_meta);

CompoundTag metaNBT = AvatarMetadataParser.parse(metadata,_meta, IOUtils.getFileNameOrEmpty(finalPath));
nbt.put("metadata", metaNBT);
metaNBT.putString("uuid",target.id.toString());

AvatarMetadataParser.injectToModels(metadata, models);
AvatarMetadataParser.injectToTextures(metadata, textures);

// return :3
if (!models.isEmpty())
Expand Down Expand Up @@ -310,7 +318,7 @@ public static void tick() {
Path path = entry.getKey().resolve((Path) event.context());
String name = IOUtils.getFileNameOrEmpty(path);

if (IOUtils.isHidden(path) || !(Files.isDirectory(path) || name.matches("(.*(\\.lua|\\.bbmodel|\\.ogg|\\.png)$|avatar\\.json)")))
if (IOUtils.isHiddenAvatarResource(path) || !(Files.isDirectory(path) || name.matches("(.*(\\.lua|\\.bbmodel|\\.ogg|\\.png)$|avatar\\.json)")))
continue;

if (kind == StandardWatchEventKinds.ENTRY_CREATE && !IS_WINDOWS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private static int runAvatarExport(CommandContext<FiguraClientCommandSource> con
if (avatar.nbt == null)
throw new Exception();

NbtIo.writeCompressed(avatar.nbt, FiguraMod.getFiguraDirectory().resolve(filename + ".moon").toFile());
NbtIo.writeCompressed(avatar.nbt, FiguraMod.getFiguraDirectory().resolve(filename + ".nbt").toFile());

context.getSource().figura$sendFeedback(FiguraText.of("command.export_avatar.success"));
return 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ public interface SoundEngineAccessor {
float figura$getVolume(SoundSource category);
SoundBufferLibrary figura$getSoundBuffers();
boolean figura$isPlaying(UUID owner);
boolean figura$isEngineActive();
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public String tojstring() {
private static final Function<FiguraLuaRuntime, LuaValue> TO_JSON_FUNCTION = runtime -> new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
if (args.narg() == 0) return LuaValue.NIL;
return LuaValue.valueOf(tableToJsonString(args.arg(1)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ public static void sendLuaError(LuaError error, Avatar owner) {
.replace("\n\t[Java]: in ?", "")
.replace("'<eos>' expected", "Expected end of script");

if (Configs.EASTER_EGGS.value && Math.random() < 0.0001) {
message = message
.replaceFirst("attempt to index ? (a nil value) with key", "attempt to key (a ? value) with index nil")
.replaceFirst("attempt to call a nil value", "attempt to nil a call value");
}

// get script line
line: {
Expand Down
Loading

0 comments on commit 2f6d4a9

Please sign in to comment.