diff --git a/wiki/addons/research-tree/en.yml b/wiki/addons/research-tree/en.yml new file mode 100644 index 00000000..40676f55 --- /dev/null +++ b/wiki/addons/research-tree/en.yml @@ -0,0 +1 @@ +title: "Research Tree" \ No newline at end of file diff --git a/wiki/addons/research-tree/events/en.yml b/wiki/addons/research-tree/events/en.yml new file mode 100644 index 00000000..9673a0e4 --- /dev/null +++ b/wiki/addons/research-tree/events/en.yml @@ -0,0 +1,2 @@ +title: "ResearchTree Events" +description: "Events you can hook onto and do things with" \ No newline at end of file diff --git a/wiki/addons/research-tree/events/meta.yml b/wiki/addons/research-tree/events/meta.yml new file mode 100644 index 00000000..a3c243a7 --- /dev/null +++ b/wiki/addons/research-tree/events/meta.yml @@ -0,0 +1 @@ +script: server diff --git a/wiki/addons/research-tree/events/page.kubedoc b/wiki/addons/research-tree/events/page.kubedoc new file mode 100644 index 00000000..81ff6211 --- /dev/null +++ b/wiki/addons/research-tree/events/page.kubedoc @@ -0,0 +1,32 @@ +# Research Events +## Research Started +```js +// The first argument (where 'namespace:node_id' is) is required. +// This will get run when that research node has started +ResearchTree.researchStarted('namespace:node_id', event => { + // This gets the player who has started this research + event.getPlayer() + + // This gets the level where the player is located + event.getLevel() + + // Gets the research node that has been started + event.node() +}) +``` + +## Research Started +```js +// The first argument (where 'namespace:node_id' is) is required. +// This will get run when that research node has completed +ResearchTree.researchCompleted('namespace:node_id', event => { + // This gets the player who has completed this research + event.getPlayer() + + // This gets the level where the player is located + event.getLevel() + + // Gets the research node that has been completed + event.node() +}) +``` diff --git a/wiki/addons/research-tree/helpers/en.yml b/wiki/addons/research-tree/helpers/en.yml new file mode 100644 index 00000000..ebc2f502 --- /dev/null +++ b/wiki/addons/research-tree/helpers/en.yml @@ -0,0 +1,2 @@ +title: "Requirements, Rewards, and more" +description: "Documentation describing stuff for research nodes and more" \ No newline at end of file diff --git a/wiki/addons/research-tree/helpers/page.kubedoc b/wiki/addons/research-tree/helpers/page.kubedoc new file mode 100644 index 00000000..a8f4efd7 --- /dev/null +++ b/wiki/addons/research-tree/helpers/page.kubedoc @@ -0,0 +1,129 @@ +>>> info +For a more detailed list of everything listed, visit the [Research Tree General Knowledge](https://github.com/wolfieboy09/ResearchTree/wiki/General-Knowledge) page. +<<< + +# Requirements +Requirements are used for research nodes where certain things need to be met before researching can actually begin. + +>>> info +These listed methods will all be under `Requirements`. +`ItemRequirement`s are also **not** bound to the limit of 99 item count (as what an `ItemStack` would have. You could have 500 and it'll still work.) +<<< + +## Items +`[java].item(item: Item, amount: int)` +Creates an `ItemRequirement` requiring an item with the required amount. + +`[java].item(item: TagKey, amount: int)` +Creates an `ItemRequirement` allowing any item tag (eg. `#c:ingots/lead`), with the required amount + +## Fluids +`[java].fluid(fluid: Fluid, amount: int)` +Creates a `FluidRequirement` allowing any fluid (eg. `minecraft:water`), with the required amount (in mB) + +`[java].fluid(fluid: TagKey, amount: int)` +Creates a `FluidRequirement` allowing any fluid tag (eg. `kubejs:deadly_liquid`), with the required amount (in mB) + +## Energy +`[java].energy(amount: int)` +Creates an `EnergyRequirement` with the required amount of energy (FE) + +## Advancement +`[java].advancement(advancement: ResourceLocation)` +Creates an `AdvancementRequirement` requiring the player to have the advancement before proceeding + +`[java].advancement(advancements: ResourceLocation[])` +Creates an `AdvancementRequirement` requiring the player to have the given advancements before proceeding + +## Dimension +>>> info +When research has begun, the player must visit the dimension for it to be counted as fulfilled +<<< + +`[java].dimension(dimension: RegistryKey)` +Creates a `DimensionRequirement` requiring the player to visit the dimension (eg. `minecraft:the_end`) + +`[java].dimensions(dimensions: RegistryKey[])` +Creates a `DimensionRequirement` requiring the player to visit the dimension (eg. `minecraft:the_end` and `minecraft:the_nether`) + +## Timed Dimension +This is the same thing as `Dimension`, but with the number of ticks the player has been in each dimension. + +`[java].dimension(dimension: RegistryKey, int duration)` +Now, with a second parameter, the amount of time the player has to be in each dimension. Creates a `TimedDimensionRequirement`. + +`[java].dimensions(dimensions: RegistryKey[], int duration). ` +Creates a `TimedDimensionRequirement` with a list of dimensions. + + +## Time +`[java].time(ticks: int)` +Creates a `TimeRequirement` requiring the player to wait a certain amount of time + +## Stage Requirement +`[java].requireStage(stage: String)` +Creates `PlayerStageRequirement` requiring the player to have a stage unlocked/added. (Note: This only works with KubeJS stages). + +## Custom Requirements +`[java].custom(kubeRequirement: ResourceLocation)` +Allows you to use a requirement created with KubeJS + +# Rewards +>>> info +These listed methods will all be under `Rewards`. +<<< + +## Items +`[java].item(item: Item, amount: int)` +Creates an `ItemReward` granting the player the item(s) + +`[java].item(stack: ItemStack)` +Creates an `ItemReward` from a given `ItemStack` + +## Command Execution +>>> info +This will execute a command with permission level `2`, and it will be like the player ran it ignoring player permission level. +To target the player, you can do `@s` or `@p` for the player who has been rewarded. +Commands are not required to have a `/` at the start (eg. `/kill @p` will do the same as `kill @p`) +<<< + +`[java].command(command: String)` +Executes a command as the player (eg `title @p title {'text':'Research Complete!','color':'gold'}`) + +`[java].command(command: String, diplayName: Text)` +Executes a command as the player. Display name will show up instead of the command (eg: you can do `kill @s` and have the display name as `Text.of('200 diamond blocks!!')`) + +## Experience Points +`[java].xp(amount: int)` +Grants the player an amount of xp points (**NOT** levels) + +`[java].xpLevels(amount: int)` +Grants the player an amount of xp levels + +## Attribute Modification +>>> warn +Any attributes changed to the player (eg max health) are **permanent** changes. +The modifier id must also be unique. +<<< +`[java].attribute(attribute: ResourceLocation, modifierId: ResourceLocation, amount: double, operation: AttributeModifierOperation?)` +Modifies the player's attributes to one via the reward. If the `operation` argument is not present, it will default to `AttributeModifier.Operation.ADD_VALUE`. + +## Loot Tables +`[java].lootTable(lootTableId: ResourceLocation)` +Grants the player a loot table that is rolled. + +## Mob Effects +`[java].effect(effectInstance: MobEffectInstance)` +Gives the player an effect. To make `MobEffectInstance`, see `MobEffectUtil` + +## Recipe Unlocking +`[java].unlockRecipes(recipes: ResourceLocation[])` +Unlocks the given recipes to the player + +## Stage Unlocking +`[java].grantStage(stage: String)` +Creates a `PlayerUnlockStageReward` which grants the player a stage. (Note: This only works with KubeJS stages). + +## Custom Rewards +`[java].custom(kubeReward: ResourceLocation)` +Allows you to use a reward created with KubeJS diff --git a/wiki/addons/research-tree/meta.yml b/wiki/addons/research-tree/meta.yml new file mode 100644 index 00000000..a6de62e7 --- /dev/null +++ b/wiki/addons/research-tree/meta.yml @@ -0,0 +1,4 @@ +author: "F07631B3" +addon: "third-party" +download-curseforge: "research-tree" +download-modrinth: "research-tree" diff --git a/wiki/addons/research-tree/page.kubedoc b/wiki/addons/research-tree/page.kubedoc new file mode 100644 index 00000000..d26c41a9 --- /dev/null +++ b/wiki/addons/research-tree/page.kubedoc @@ -0,0 +1 @@ +Research Tree adds an entire system for a data-driven researching system. \ No newline at end of file diff --git a/wiki/addons/research-tree/rar-registration/en.yml b/wiki/addons/research-tree/rar-registration/en.yml new file mode 100644 index 00000000..d72b6c73 --- /dev/null +++ b/wiki/addons/research-tree/rar-registration/en.yml @@ -0,0 +1,2 @@ +title: "Registering Custom Requirements and Rewards" +description: "How to create custom research requirements and rewards" \ No newline at end of file diff --git a/wiki/addons/research-tree/rar-registration/meta.yml b/wiki/addons/research-tree/rar-registration/meta.yml new file mode 100644 index 00000000..e1ff8534 --- /dev/null +++ b/wiki/addons/research-tree/rar-registration/meta.yml @@ -0,0 +1 @@ +script: startup diff --git a/wiki/addons/research-tree/rar-registration/page.kubedoc b/wiki/addons/research-tree/rar-registration/page.kubedoc new file mode 100644 index 00000000..577aa816 --- /dev/null +++ b/wiki/addons/research-tree/rar-registration/page.kubedoc @@ -0,0 +1,56 @@ +# Custom Requirements +```js +StartupEvents.registry('researchtree:requirement_types', event => { + // This is the requirement type. This will be kubejs:my_requirement + // This is important for defining requirements on research nodes. + event.create('my_requirement') + + // This determines if the requirement is currently met + // Should return true or false + .isMet(player => { + // Example: check if player has a specific item in inventory + return player.inventory.contains('minecraft:diamond') + }) + + // Returns a progress value between 0.0 and 1.0 + // Used to show partial completion in the UI + .progress(player => { + // Example: check diamond count (max 64) + let count = 0 + player.inventory.allItems.forEach(stack => { + if (stack.id == 'minecraft:diamond') { + count += stack.count + } + }) + return count / 64.0 + }) + + // Display text is OPTIONAL + // By default, the lang key would be 'requirement.kubejs.' + // So this example would be 'requirement.kubejs.my_requirement' + // You can define a lang key, or use this method + .displayText(Text.of('Must have diamonds')) +}) +``` + + +# Custom Rewards +```js +StartupEvents.registry('researchtree:reward_types', event => { + // This is the reward type. This will be kubejs:my_reward + // This is important for defining rewards on research nodes (and category dependencies) + event.create('my_reward') + + // This is OPTIONAL. You should have this because you're making a custom reward... + // This gives you both the player and the level + .grant((player, level) => { + // Here you can do anything that involves the player and level + }) + + // Display text is OPTIONAL + // By default, the lang key would be 'reward.kubejs.' + // So this example would be 'reward.kubejs.my_reward' + // You can define a lang key, or this method + .displayText(Text.of('My epic reward')) +}) +``` diff --git a/wiki/addons/research-tree/research-categories/en.yml b/wiki/addons/research-tree/research-categories/en.yml new file mode 100644 index 00000000..bc4f5183 --- /dev/null +++ b/wiki/addons/research-tree/research-categories/en.yml @@ -0,0 +1,2 @@ +title: "Research Categories" +description: "Guide on how to add and modify existing Categories." \ No newline at end of file diff --git a/wiki/addons/research-tree/research-categories/meta.yml b/wiki/addons/research-tree/research-categories/meta.yml new file mode 100644 index 00000000..a3c243a7 --- /dev/null +++ b/wiki/addons/research-tree/research-categories/meta.yml @@ -0,0 +1 @@ +script: server diff --git a/wiki/addons/research-tree/research-categories/page.kubedoc b/wiki/addons/research-tree/research-categories/page.kubedoc new file mode 100644 index 00000000..2abe8daf --- /dev/null +++ b/wiki/addons/research-tree/research-categories/page.kubedoc @@ -0,0 +1,52 @@ +# Creating Research Categories +Everything will go under the `ResearchTree.category` event + +`[java]exists(id: ResourceLocation)` +Return `true` or `false` depending if a research category exists or not. + +`[java]modify(id: ResourceLocation)` +Modifies a research category. For methods, see below. **There are extra methods for modifications!** + +`[java]create(id: ResourceLocation)` +>>> info +Internally, this constructs a `ResourceLocation` that gets set to `kubejs:[the id you chose]`. +For example, `create('super_cool_category')` will get constructed as `kubejs:super_cool_category`. +<<< + +## Methods +`[java].name(name: Text)` +Overrides the default name (the id of the category formatted) to a custom one. + +`[java].description(description: Text)` +Creates a description for the category + +`[java].icon(icon: Item)` +Sets the categories icon as an item + +`[java].unlockRequirement(unlockRequirement: ResourceLocation)` +Unlocks the category after a research node has been completed + +`[java].addPrerequisite(prerequisite: ResourceLocation)` +Requires another category to be unlocked before this category + +`[java].addPrerequisites(prerequisites: ResourceLocation[])` +Same thing as above, but as a list (adds it to the current ones) + +`[java].sortOrder(order: int)` +Display order. Defaults to `0`. + +| Method | Type | Notes | +| `name` | ==OPTIONAL== | Defaults to formatted id | +| `description` | ==OPTIONAL== | Category will have no description | +| `icon` | ==OPTIONAL== | Category will have no icon | +| `unlockRequirement` | ==OPTIONAL== | Will be unlocked. If it is locked, no research in this category can be started | +| `addPrerequisite`/`addPrerequisites` | ==OPTIONAL== | Will not rely on other categories to be unlocked first | +| `sortOrder` | ==OPTIONAL== | Defaults to `0`. Sort order is used to sort the categories | + +The following is for category modification - methods above are also included with modifications: +## Methods +`[java].removeUnlockRequirement()` +Removes the requirement for another research node to be completed + +`[java].removePrerequisites(category: ResourceLocation)` +Removes the requirement for another category to be unlocked diff --git a/wiki/addons/research-tree/research-nodes/en.yml b/wiki/addons/research-tree/research-nodes/en.yml new file mode 100644 index 00000000..342dd112 --- /dev/null +++ b/wiki/addons/research-tree/research-nodes/en.yml @@ -0,0 +1,2 @@ +title: "Research Nodes" +description: "Add, remove, or modify research nodes" \ No newline at end of file diff --git a/wiki/addons/research-tree/research-nodes/meta.yml b/wiki/addons/research-tree/research-nodes/meta.yml new file mode 100644 index 00000000..a3c243a7 --- /dev/null +++ b/wiki/addons/research-tree/research-nodes/meta.yml @@ -0,0 +1 @@ +script: server diff --git a/wiki/addons/research-tree/research-nodes/page.kubedoc b/wiki/addons/research-tree/research-nodes/page.kubedoc new file mode 100644 index 00000000..7b314f66 --- /dev/null +++ b/wiki/addons/research-tree/research-nodes/page.kubedoc @@ -0,0 +1,61 @@ +# Creating Research Nodes +Everything will go under the `ResearchTree.research` event + +`[java]exists(id: ResourceLocation)` +Return `true` or `false` depending if a research node exists or not. + +`[java]remove(id: ResourceLocation)` +Removes a research node (eg, `some_other_mod:epic_researchable`) + +`[java]modify(id: ResourceLocation)` +Modifies a research node (eg, `another_mod:super_cool_researchable`). For methods, see below + +`[java]create(id: ResourceLocation)` +>>> info +Internally, this constructs a `ResourceLocation` that gets set to `kubejs:[the id you chose]`. +For example, `create('my_research_node')` will get constructed as `kubejs:my_research_node`. +<<< + +## Methods + +`[java].icon(icon: Item)` +The item icon that will be rendered for the node. (eg, `minecraft:dirt` would render dirt, for example) + +`[java].pos(x: int, y: int)` +There is also `position` that does the same thing + +`[java].title(title: Text)` +Overrides the default name (the node's id formatted) with a custom one. Use `Text#of` for the argument + +`[java].description(description: Text)` +Creates a description for the research node + +`[java].prerequisite(prerequisite: ResourceLocation)` +This can be attached multiple times to make other research nodes required to unlock this node. +To get the research node id, enable advanced tooltips via `F3+H` + +`[java].requires(requirement: ResearchRequirement)` +See (link the `helpers#Requirements` here) for possible requirements. + +`[java].reward(reward: ResearchReward)` +See (link the `helpers#Rewards` here) for possible rewards. + +`[java].category(category: ResourceLocation)` +Links the node to a category + +`[java].hidden()` +Hides the node until the parent is completed. The rest of the branch will also show up. + +`[java].ticksPerPercent(ticksPerPercent: int)` +For every `1%` of research, the player must wait the ticks set in `ticksPerPercent` for `1%` of progression. + +| Method | Type | Notes | +| `icon` | ==REQUIRED== | Not required for research node modification | +| `pos` | ==REQUIRED== | Not required for research node modification | +| `title` | ==OPTIONAL== | Defaults to formatted id | +| `description` | ==OPTIONAL== | No description is provided | +| `prerequisite` | ==OPTIONAL== | When none provided, does not rely on other nodes to be unlocked | +| `requires` | ==OPTIONAL== | When none provided, researching begins immedentally | +| `reward` | ==OPTIONAL== | When none provided, no rewards are granted | +| `category` | ==OPTIONAL== | Defaults to the uncategorized section | +| `ticksPerPercent` | ==OPTIONAL== | Defaults to `100` ticks per `1%` (`10000` total ticks) |