Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
skyraah committed Sep 20, 2024
2 parents 22b8e58 + 6b452a3 commit bbcb664
Show file tree
Hide file tree
Showing 52 changed files with 2,768 additions and 2,213 deletions.
10 changes: 8 additions & 2 deletions .vitepress/config/lang/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const en_US = <DefaultTheme.Config>{
description: "A site containing docs for Minecraft developing.",
themeConfig: {
nav: [
{text: "Cooperation Guide", link: "/en/doc/rules"},
{
text: "KubeJS",
items: [
Expand Down Expand Up @@ -58,7 +57,14 @@ export const en_US = <DefaultTheme.Config>{
},
],
},
{ text: "Guide", link: "/en/doc/guide" },
{text: "Cooperation Guide", link: "/en/doc/rules"},
{text: "Guide", items: [
{text: "Minecraft", link: "/en/doc/guide/minecraft"},
{text: "KubeJS", link: "/en/doc/guide/KubeJS"},
{text: "Pixelart", link: "/en/doc/guide/pixelart"},
{text: "Art Resource", link: "/en/doc/guide/resource"},
{text: "Community", link: "/en/doc/guide/community"},
]},
],
sidebar: sidebars("en"),
outline: {
Expand Down
10 changes: 8 additions & 2 deletions .vitepress/config/lang/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const zh_CN = <DefaultTheme.Config>{
description: "一个包含 Minecraft 开发文档的网站。",
themeConfig: {
nav: [
{text: "合作须知", link: "/zh/doc/rules"},
{
text: "KubeJS",
items: [
Expand Down Expand Up @@ -59,7 +58,14 @@ export const zh_CN = <DefaultTheme.Config>{
},
]
},
{ text: "导航", link: "/zh/doc/guide" },
{text: "合作须知", link: "/zh/doc/rules"},
{text: "导航", items: [
{text: "我的世界", link: "/zh/doc/guide/minecraft"},
{text: "KubeJS", link: "/zh/doc/guide/KubeJS"},
{text: "像素艺术", link: "/zh/doc/guide/pixelart"},
{text: "美术资源", link: "/zh/doc/guide/resource"},
{text: "社区交流", link: "/zh/doc/guide/community"},
]},
],
sidebar: sidebars("zh"),
outline: {
Expand Down
6 changes: 3 additions & 3 deletions docs/zh/doc/guide.md → docs/en/doc/guide/KubeJS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
layout: doc
title: CrychicDoc导航
title: KubeJS
layoutClass: m-nav-layout
sidebar: false

Expand All @@ -13,11 +13,11 @@ showComment: false
metadata: false
outline: [2,2]
---
<style src="../../../.vitepress/theme/style/nav.scss"></style>
<style src="../../../../.vitepress/theme/style/nav.scss"></style>

<script setup>
import { ref } from "vue";
import { NAV_DATA } from '../Components/guide.ts'
import { NAV_DATA } from './guidets/KubeJS.ts'
const NAV_DATAS = ref(NAV_DATA)
</script>

Expand Down
26 changes: 26 additions & 0 deletions docs/en/doc/guide/community.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
layout: doc
title: Community Link
layoutClass: m-nav-layout
sidebar: false

prev: false
next: false
editLink: false
editor: false
gitChangelog: false
showComment: false
metadata: false
outline: [2,2]
---
<style src="../../../../.vitepress/theme/style/nav.scss"></style>

<script setup>
import { ref } from "vue";
import { NAV_DATA } from './guidets/community.ts'
const NAV_DATAS = ref(NAV_DATA)
</script>

# {{ $frontmatter.title }}
## This part is still pending.
<MNavLinks v-for="{title, items} in NAV_DATAS" :title="title" :items="items"/>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NavData } from '../../../.vitepress/utils/type'
import type { NavData } from '../../../../../.vitepress/utils/type'

export const NAV_DATA: NavData[] = [
{
Expand Down
289 changes: 289 additions & 0 deletions docs/en/doc/guide/guidets/community.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { NavData } from '../../../.vitepress/utils/type'
import type { NavData } from '../../../../../.vitepress/utils/type'

export const NAV_DATA: NavData[] = [
{
title: "Minecraft Useful Links",
items: [
{
title: "Minecraft wiki",
link: "https://zh.minecraft.wiki/",
icon: "https://zh.minecraft.wiki/images/Wiki.png"
link: "https://https://minecraft.wiki/",
icon: "https://https://minecraft.wiki/images/Wiki.png"
},
{
title: "modtinth",
Expand Down
289 changes: 289 additions & 0 deletions docs/en/doc/guide/guidets/pixelart.ts

Large diffs are not rendered by default.

289 changes: 289 additions & 0 deletions docs/en/doc/guide/guidets/resource.ts

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/en/doc/guide.md → docs/en/doc/guide/minecraft.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
layout: doc
title: CrychicDoc Guide
title: Minecraft
layoutClass: m-nav-layout
sidebar: false

Expand All @@ -13,11 +13,11 @@ showComment: false
metadata: false
outline: [2,2]
---
<style src="../../../.vitepress/theme/style/nav.scss"></style>
<style src="../../../../.vitepress/theme/style/nav.scss"></style>

<script setup>
import { ref } from "vue";
import { NAV_DATA } from '../Components/guide.ts'
import { NAV_DATA } from './guidets/minecraft.ts'
const NAV_DATAS = ref(NAV_DATA)
</script>

Expand Down
26 changes: 26 additions & 0 deletions docs/en/doc/guide/pixelart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
layout: doc
title: Pixel Art
layoutClass: m-nav-layout
sidebar: false

prev: false
next: false
editLink: false
editor: false
gitChangelog: false
showComment: false
metadata: false
outline: [2,2]
---
<style src="../../../../.vitepress/theme/style/nav.scss"></style>

<script setup>
import { ref } from "vue";
import { NAV_DATA } from './guidets/pixelart.ts'
const NAV_DATAS = ref(NAV_DATA)
</script>

# {{ $frontmatter.title }}

<MNavLinks v-for="{title, items} in NAV_DATAS" :title="title" :items="items"/>
26 changes: 26 additions & 0 deletions docs/en/doc/guide/resource.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
layout: doc
title: Art resources
layoutClass: m-nav-layout
sidebar: false

prev: false
next: false
editLink: false
editor: false
gitChangelog: false
showComment: false
metadata: false
outline: [2,2]
---
<style src="../../../../.vitepress/theme/style/nav.scss"></style>

<script setup>
import { ref } from "vue";
import { NAV_DATA } from './guidets/resource.ts'
const NAV_DATAS = ref(NAV_DATA)
</script>

# {{ $frontmatter.title }}
## This part is still pending.
<MNavLinks v-for="{title, items} in NAV_DATAS" :title="title" :items="items"/>
1 change: 0 additions & 1 deletion docs/en/modpack/kubejs/1.20.1/KubeJSCourse/.gitignore

This file was deleted.

This file was deleted.

Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
## kubejs提供的直接调用的事件
在游戏里还能遇到很多事件,在合适的时候选择合适的事件,可以给游戏添加不错的效果,不会令人觉得这个魔改整合包怎么只修改了配方这种感觉,可以通过事件来给整合包添加不一样的玩法内容

[所有事件及使用示例](../KubejsBasic/AllEvent)
[所有事件及使用示例](../KubeJSBasic/AllEvent)
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# ForgeEvent的使用
> 孤梦注:可千万不要玩forge事件啊,玩了你就要长脑子了!!!
`ForgeEvent`是写在**startup**里的,这个一定得注意!

ForgeEvent不仅仅只能调用到forge提供的事件,如果其他模组在源代码(指的Java代码)里直接继承了`Event`类,也是可以被ForgeEvent捕捉下来的,类似的示例:[机械动力修改流体管道流体和流体产生块](../KubeJSProjects/Meng/SmallProject/CreatePipeCollision.md)

ForgeEvent是可以搭配着[loadClass](./JavaLoadClass.md)一起使用的

## forge提供的事件
forge本身提供了非常多的事件可以使我们捕捉到游戏内的事情,但是我们一个个去翻又太过麻烦,这里孤梦就推荐使用[crt文档](https://docs.blamejared.com/1.20.1/en)去找对应的事件!

[crt文档](https://docs.blamejared.com/1.20.1/en)的forge栏里的event目录下是非常好的ForgeEvent文档

我们可以现在crt文档里找到对应的事件,然后再去[forge的GitHub](https://github.com/MinecraftForge/MinecraftForge/tree/1.20.1/src/main/java/net/minecraftforge/event)上去找到相应事件的类

## 关于使用
```js
ForgeEvents.onEvent("事件类",event=>{
//关于事件的code
})
```
因为每个事件给出的方法是有可能不一样的,所以这里无法举例,且提供不了详细的函数使用(这里也可以简单参考一下crt文档提供的事件的使用函数)

## 事件的“热加载”
绝大部分的事件都是可以“热加载”的,但是需要使用一点手段

在前面我们学习了[global全局变量](./GlobalVariable.md),我们可以在事件里嵌入一个[global全局变量](./GlobalVariable.md),将事件处理引出来,像下面这样写
```js
ForgeEvents.onEvent("事件类",event=>{
global.eventTest(event);
})

global.eventTest = event =>{
//事件处理
}
```
这样我们在游戏里只需要输入 `/kjs reload startup_scripts` 就可以进行事件处理的热加载了

## 注意事项
startup是非常脆弱的,稍不注意就会大退然后报错,说你的“犀牛”有问题,

所以建议在测试的过程中使用`try catch`包裹处理一下报错,能够减少闪退的次数

具体像下面这样写(沿用上面代码)

```js
global.eventTest = event =>{
try{
//事件处理
}catch(err){
console.error(err);
}
}
```
这样在报错时,可以在`/logs/kubejs/startup.log`里看见因为什么报错,然后去调整代码,一定不要因为错误被catch了就不管不顾了,除非你的这个错误是在意料之中的,并且出现报错后也有对应的处理,不会导致一直重复报错
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ console.log(global.testObj.b)
但是使用了global之后,就可以在全局进行调用

## 用处
在项目[祭坛合成](../KubejsProjects/Meng/AltarComposition.md)中就有使用到全局变量
在项目[祭坛合成](../KubeJSProjects/Meng/AltarComposition.md)中就有使用到全局变量
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# LoadClass使用
> 孤梦注:千万不要玩Java.loadClass啊,这东西比较废人
在使用Java.loadClass时,孤梦建议是你有一定的Java基础,至少得知道类、类路径、静态、对象、访问修饰符等概念

在绝大多数时候我们都用不到loadClass

loadclass就是kjs提供给我们用来加载java类的

这使得KubeJS的可玩性非常高,比如[注册AE存储元件和对应的组件](../KubeJSProjects/Meng/RegComponent&Storage.md)就使用到了非常多的loadClass

## 关于使用
```js
let class = Java.loadClass("类路径");
```
在使用ProbeJS时,在绝大多数时候都会为你补齐类路径,但是ProbeJS并不是所有的类都有对应的路径,所以这个时候你可以去翻一下对应模组的GitHub开源链接,查找到你需要的类,并将其路径复制过来

在你使用`Java.loadClass`class时候,你可以直接去调用到里面的`public static`的方法或者变量常量等

但是有些内容调用不到,你就可以和写java一样去`new`这个类

沿用上面的内容
```js
let newClass = new class();
```
这里的`new class()`括号里可能会需要传参有的也不需要,这里根据对应类提供的源码来写

## 总结
总的来说你如果需要更好的使用`Java.loadClass`你是需要有一定的Java基础,这不是靠一个篇章能说明白的事情
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

在kubejs当中我们是可以直接跨文件调用方法参数等内容的,但是大前提是这个文件是加载游戏级高的

这里注意一下,这里的跨文件但是不难跨端,比如你无法在`startup`里调用`server`里的方法,如果真的需要可以看[global全局变量](../KubejsAdvanced/GlobalVariable.md)
这里注意一下,这里的跨文件但是不难跨端,比如你无法在`startup`里调用`server`里的方法,如果真的需要可以看[global全局变量](../KubeJSAdvanced/GlobalVariable.md)

kubejs提供了一个注释来标注文件的优先级 `// priority: 10`

Expand Down
Loading

0 comments on commit bbcb664

Please sign in to comment.