Skip to content

Commit

Permalink
damn forge
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke100000 committed Feb 13, 2024
1 parent e031063 commit 44eda0b
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 25 deletions.
2 changes: 1 addition & 1 deletion common/src/main/java/net/mca/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ public static Config getInstance() {
public String villagerChatAIEndpoint = "https://api.conczin.net/v1/mca/chat";
public String villagerChatAIToken = "";
public String villagerChatAIModel = "mistral-small";
public String villagerTTSServer = "http://api.rk.conczin.net/";

// TTS
public boolean enableOnlineTTS = false;
public String villagerTTSServer = "http://api.rk.conczin.net/";
public String onlineTTSLanguage = "en";

//village behavior
Expand Down

This file was deleted.

35 changes: 35 additions & 0 deletions common/src/main/java/net/mca/mixin/client/MixinSoundLoader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package net.mca.mixin.client;

import net.minecraft.client.sound.AudioStream;
import net.minecraft.client.sound.OggAudioStream;
import net.minecraft.client.sound.RepeatingAudioStream;
import net.minecraft.client.sound.SoundLoader;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
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.CallbackInfoReturnable;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;

@Mixin(SoundLoader.class)
public class MixinSoundLoader {
@Inject(method = "loadStreamed(Lnet/minecraft/util/Identifier;Z)Ljava/util/concurrent/CompletableFuture;", at = @At("HEAD"), cancellable = true)
void mca$injectLoadStreamed(Identifier id, boolean repeatInstantly, CallbackInfoReturnable<CompletableFuture<AudioStream>> cir) {
if (id.getPath().startsWith("sounds/tts_cache/")) {
cir.setReturnValue(CompletableFuture.supplyAsync(() -> {
try {
InputStream inputStream = new FileInputStream(id.getPath().replace("sounds/", ""));
return repeatInstantly ? new RepeatingAudioStream(OggAudioStream::new, inputStream) : new OggAudioStream(inputStream);
} catch (IOException iOException) {
throw new CompletionException(iOException);
}
}, Util.getMainWorkerExecutor()));
}
}
}
1 change: 1 addition & 0 deletions common/src/main/java/net/mca/server/command/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ private static int chatAIHelp(CommandContext<ServerCommandSource> context) {
}

private static int chatAI(String model, String endpoint, String token) {
Config.getInstance().enableVillagerChatAI = true;
Config.getInstance().villagerChatAIModel = model;
Config.getInstance().villagerChatAIEndpoint = endpoint;
Config.getInstance().villagerChatAIToken = token;
Expand Down
4 changes: 2 additions & 2 deletions common/src/main/resources/mca.mixin.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"MixinGoatEntity", "MixinHorseBaseEntity", "MixinMemoryModuleType", "MixinMilkBucketItem", "MixinPlayerEntity",
"MixinPlayerInventory", "MixinProtoChunk", "MixinSensorType", "MixinServerPlayNetworkHandler", "MixinServerWorld",
"MixinTranslatableText", "MixinVillagerEntity", "MixinVillagerEntityInvoker", "MixinVillagerProfession",
"MixinZombieEntity", "MixinZombieVillagerEntity", "client.MixinResourceFactory"
"MixinZombieEntity", "MixinZombieVillagerEntity"
],
"client": [
"client.MixinArmorFeatureRenderer", "client.MixinGameRenderer", "client.MixinHeldItemFeatureRenderer",
"client.MixinLivingEntityRenderer", "client.MixinMessageHandler", "client.MixinPlayerEntityClient",
"client.MixinPlayerEntityRenderer", "client.MixinTranslationStorage"
"client.MixinPlayerEntityRenderer", "client.MixinSoundLoader", "client.MixinTranslationStorage"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 44eda0b

Please sign in to comment.