Skip to content

Commit

Permalink
update: dependence
Browse files Browse the repository at this point in the history
  • Loading branch information
WDRshadow committed Mar 23, 2024
1 parent d411a2a commit 359bea7
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 4 deletions.
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# NPC Basic Functions

> The mod is still under development, and the current version is not stable. If you encounter any problems, please submit an issue.
## 1. Introduction

NPC basic functions are a feature of the OpenAI API that allows ChatGPT to call functions that may affect game balance as an NPC at the appropriate time. The functions are defined by the server administrator, and the effects that can be achieved are determined by you. For a detailed introduction to this feature, please refer to the [OpenAI API documentation](https://beta.openai.com/docs/api-reference/function-calls/create-function-call).

In this mod, we provide some implementation examples of basic functions that can be called by NPCs. These functions are simple and can be used as a reference for you to create more complex functions.

## 2. Dependencies

- [ChatWithNPC](https://npchat.jackdaw.wdr.im/) >= 0.0.3
- [Fabric API](https://www.curseforge.com/minecraft/mc-mods/fabric-api) *
- Minecraft Server 1.19.4 or higher
- Fabric Loader 0.12.0 or higher

## 3. Basic Functions Provided

### 3.1. Give Diamond Function

The `give_diamond` function is used to give the player a certain number of diamonds. This function accepts a parameter `number`, which represents how many diamonds to give to the player. The function is implemented by creating a diamond item stack and giving it to the player.

### 3.2. Basic Action Function

The `basic_action` function is a generic function that can be used to perform NPC's basic actions in the game. It accepts a parameter `action`, which represents the action to be performed. The function is implemented by executing the specified action.

The basic actions that can be performed include:

- `walk to player`: The NPC walks towards the player.
- `escape`: The NPC escapes from the player.

### 3.3. Basic Feeling Function

The `basic_feeling` function is a generic function that can be used to express NPC's basic feelings in the game. It accepts a parameter `feeling`, which represents the feeling to be expressed. The function is implemented by displaying the actions below:

- `happy`: The NPC expresses happiness by displaying love particles.
- `shake head`: The NPC shakes its head to express disagreement.

## 4. Usage

To use these basic functions, you can add or remove them from the NPC closest to you using the following commands:

- `/npchat npc addFunction <function>` - Add a function to the NPC closest to you
- `/npchat npc deleteFunction <function>` - Remove a function from the NPC closest to you

and don't forget to save this setting by using the `/npchat saveAll` command.

## 5. Developer Notes

Developers can create their own custom functions by extending the `CustomFunction` class provided by the `ChatWithNPC` API. For more information on creating custom functions, please refer to the [Advanced Function Calling](https://npchat.jackdaw.wdr.im/docs/Advanced.html) documentation.

You can start with fork the source code of this mod and write your own custom functions base on this structure to enhance the interaction between NPCs and players in your game.

2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ base {
}

repositories {
mavenLocal()
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
Expand All @@ -19,6 +20,7 @@ repositories {
}

dependencies {
modImplementation "com.jackdaw:chat-with-NPC:${project.chat_with_npc_version}"
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ org.gradle.jvmargs=-Xmx1G
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.87.2+1.19.4
chat_with_npc_version = 0.0.3+build.2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.jackdaw.npcbasicfunction;

import com.jackdaw.chatwithnpc.openaiapi.functioncalling.FunctionManager;
import com.jackdaw.chatwithnpc.openaiapi.function.FunctionManager;
import com.jackdaw.npcbasicfunction.function.BasicActionFunction;
import com.jackdaw.npcbasicfunction.function.BasicFeelingFunction;
import com.jackdaw.npcbasicfunction.function.GiveDiamondFunction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.jackdaw.chatwithnpc.ChatWithNPCMod;
import com.jackdaw.chatwithnpc.conversation.ConversationHandler;
import com.jackdaw.chatwithnpc.npc.NPCEntity;
import com.jackdaw.chatwithnpc.openaiapi.functioncalling.CustomFunction;
import com.jackdaw.chatwithnpc.openaiapi.function.CustomFunction;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.mob.PathAwareEntity;
import net.minecraft.entity.player.PlayerEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.jackdaw.chatwithnpc.ChatWithNPCMod;
import com.jackdaw.chatwithnpc.conversation.ConversationHandler;
import com.jackdaw.chatwithnpc.npc.NPCEntity;
import com.jackdaw.chatwithnpc.openaiapi.functioncalling.CustomFunction;
import com.jackdaw.chatwithnpc.openaiapi.function.CustomFunction;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.passive.VillagerEntity;
import net.minecraft.particle.ParticleTypes;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.jackdaw.npcbasicfunction.function;

import com.jackdaw.chatwithnpc.conversation.ConversationHandler;
import com.jackdaw.chatwithnpc.openaiapi.functioncalling.CustomFunction;
import com.jackdaw.chatwithnpc.openaiapi.function.CustomFunction;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import org.jetbrains.annotations.NotNull;
Expand Down

0 comments on commit 359bea7

Please sign in to comment.