refactor: 支持 Minecraft 1.21.1 版本
This commit is contained in:
@@ -6,20 +6,18 @@ const LOG_PREFIX = global.LOG_PREFIX;
|
||||
console.info(`${LOG_PREFIX} 加载客户端内容`);
|
||||
|
||||
// 生成客户端资源
|
||||
// event.add(new ResourceLocation(`<命名空间>:<资源相对路径>`), `JSON`);
|
||||
// event.add(new ResourceLocation(`minecraft:models/block/stone`), {});
|
||||
onEvent('client.generate_assets', (event) => {
|
||||
|
||||
if (!Array.isArray(JSON_ASSETS)) {
|
||||
return;
|
||||
}
|
||||
ClientEvents.generateAssets('after_mods', function (event) {
|
||||
|
||||
console.info(`${LOG_PREFIX} 生成客户端资源 - 开始`);
|
||||
|
||||
JSON_ASSETS.forEach((item) => {
|
||||
event.add(new ResourceLocation(item.PATH), item.DATA);
|
||||
});
|
||||
if (Array.isArray(JSON_ASSETS)) {
|
||||
JSON_ASSETS.forEach((item) => {
|
||||
event.json(item.path, item.data);
|
||||
});
|
||||
} else {
|
||||
console.error(`${LOG_PREFIX} 生成客户端资源 - 异常 - 列表不是数组`);
|
||||
}
|
||||
|
||||
console.info(`${LOG_PREFIX} 生成客户端资源 - 完成`);
|
||||
console.info(`${LOG_PREFIX} 生成客户端资源 - 结束`);
|
||||
|
||||
});
|
||||
|
||||
24
kubejs/client_scripts/jsconfig.json
Normal file
24
kubejs/client_scripts/jsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "ES2015",
|
||||
"lib": [
|
||||
"ES5",
|
||||
"ES2015"
|
||||
],
|
||||
"rootDir": ".",
|
||||
"typeRoots": [
|
||||
"../../.probe/client/probe-types"
|
||||
],
|
||||
"baseUrl": "../../.probe/client/probe-types",
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"files": [
|
||||
"../constants.d.ts"
|
||||
],
|
||||
"include": [
|
||||
"./**/*.js",
|
||||
"./**/*.ts",
|
||||
null
|
||||
]
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
#KubeJS Client Properties
|
||||
#Sun Jul 03 17:12:21 SGT 2022
|
||||
backgroundColor=2E3440
|
||||
barBorderColor=ECEFF4
|
||||
exportAtlases=false
|
||||
menuBackgroundBrightness=64
|
||||
disableRecipeBook=false
|
||||
title=【麦子】Minecraft 1.18.2
|
||||
barColor=ECEFF4
|
||||
overrideColors=false
|
||||
fmlLogColor=ECEFF4
|
||||
showTagNames=true
|
||||
fmlMemoryColor=ECEFF4
|
||||
menuBackgroundScale=32.0
|
||||
menuInnerBackgroundBrightness=32
|
||||
@@ -1,9 +0,0 @@
|
||||
#KubeJS Common Properties
|
||||
#Sun Jul 03 17:12:16 SGT 2022
|
||||
announceReload=true
|
||||
disableClassFilter=false
|
||||
serverOnly=false
|
||||
hideServerScriptErrors=false
|
||||
packmode=default
|
||||
printRemappedClasses=false
|
||||
debugInfo=false
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 7.8 KiB |
224
kubejs/constants.d.ts
vendored
Normal file
224
kubejs/constants.d.ts
vendored
Normal file
@@ -0,0 +1,224 @@
|
||||
// 注:需要在 `jsconfig.json` 配置文件的 `files` 字段中包含该文件(若在 `include` 字段中,定义会被覆盖)。
|
||||
|
||||
import type {
|
||||
$BasicBlockJS$Builder,
|
||||
} from 'dev.latvian.mods.kubejs.block.custom.BasicBlockJS$Builder';
|
||||
|
||||
import {
|
||||
$BlockRenderType$$Type,
|
||||
} from 'dev.latvian.mods.kubejs.block.BlockRenderType';
|
||||
|
||||
import type {
|
||||
$ButtonBlockBuilder,
|
||||
} from 'dev.latvian.mods.kubejs.block.custom.ButtonBlockBuilder';
|
||||
|
||||
import type {
|
||||
$CarpetBlockBuilder,
|
||||
} from 'dev.latvian.mods.kubejs.block.custom.CarpetBlockBuilder';
|
||||
|
||||
import type {
|
||||
$CropBlockBuilder,
|
||||
} from 'dev.latvian.mods.kubejs.block.custom.CropBlockBuilder';
|
||||
|
||||
import type {
|
||||
$DetectorBlock$Builder,
|
||||
} from 'dev.latvian.mods.kubejs.block.DetectorBlock$Builder';
|
||||
|
||||
import type {
|
||||
$DoorBlockBuilder
|
||||
} from 'dev.latvian.mods.kubejs.block.custom.DoorBlockBuilder';
|
||||
|
||||
import type {
|
||||
$FallingBlockBuilder,
|
||||
} from 'dev.latvian.mods.kubejs.block.custom.FallingBlockBuilder';
|
||||
|
||||
import type {
|
||||
$FenceBlockBuilder,
|
||||
} from 'dev.latvian.mods.kubejs.block.custom.FenceBlockBuilder';
|
||||
|
||||
import type {
|
||||
$FenceGateBlockBuilder,
|
||||
} from 'dev.latvian.mods.kubejs.block.custom.FenceGateBlockBuilder';
|
||||
|
||||
import type {
|
||||
$HorizontalDirectionalBlockBuilder,
|
||||
} from 'dev.latvian.mods.kubejs.block.custom.HorizontalDirectionalBlockBuilder';
|
||||
|
||||
import type {
|
||||
$PressurePlateBlockBuilder,
|
||||
} from 'dev.latvian.mods.kubejs.block.custom.PressurePlateBlockBuilder';
|
||||
|
||||
import type {
|
||||
$SlabBlockBuilder,
|
||||
} from 'dev.latvian.mods.kubejs.block.custom.SlabBlockBuilder';
|
||||
|
||||
import type {
|
||||
$StairBlockBuilder,
|
||||
} from 'dev.latvian.mods.kubejs.block.custom.StairBlockBuilder';
|
||||
|
||||
import type {
|
||||
$TrapdoorBlockBuilder,
|
||||
} from 'dev.latvian.mods.kubejs.block.custom.TrapdoorBlockBuilder';
|
||||
|
||||
import type {
|
||||
$WallBlockBuilder,
|
||||
} from 'dev.latvian.mods.kubejs.block.custom.WallBlockBuilder';
|
||||
|
||||
import type {
|
||||
$Block,
|
||||
} from 'moe.wolfgirl.probejs.generated.registry.minecraft.Block';
|
||||
|
||||
import {
|
||||
$MapColor$$Type,
|
||||
} from 'net.minecraft.world.level.material.MapColor';
|
||||
|
||||
import {
|
||||
$SoundType$$Type,
|
||||
} from 'net.minecraft.world.level.block.SoundType';
|
||||
|
||||
/** 方块构造器 */
|
||||
type BlockBuilder = (
|
||||
$BasicBlockJS$Builder &
|
||||
$ButtonBlockBuilder &
|
||||
$CarpetBlockBuilder &
|
||||
$CropBlockBuilder &
|
||||
$DetectorBlock$Builder &
|
||||
$DoorBlockBuilder &
|
||||
$FallingBlockBuilder &
|
||||
$FenceBlockBuilder &
|
||||
$FenceGateBlockBuilder &
|
||||
$HorizontalDirectionalBlockBuilder &
|
||||
$PressurePlateBlockBuilder &
|
||||
$SlabBlockBuilder &
|
||||
$StairBlockBuilder &
|
||||
$TrapdoorBlockBuilder &
|
||||
$WallBlockBuilder
|
||||
);
|
||||
|
||||
/** 配置选项 */
|
||||
type SetBlockPropsOpts = {
|
||||
|
||||
/** 碰撞箱配置,默认:null */
|
||||
boxConfig?: [number, number, number, number, number, number, boolean?];
|
||||
|
||||
/** 碰撞箱类型,默认 full */
|
||||
boxType?: 'custom' | 'full' | 'half';
|
||||
|
||||
/** 方块显示名称 */
|
||||
displayName: string;
|
||||
|
||||
/** 坚硬程度,默认:8 */
|
||||
hardness?: number;
|
||||
|
||||
/** 开启碰撞箱,默认:true */
|
||||
hasCollision?: boolean;
|
||||
|
||||
/** 是否为完整方块,默认:true */
|
||||
isSolid?: boolean;
|
||||
|
||||
/** 亮度等级,范围:0 ~ 1,默认:0 */
|
||||
lightLevel?: number;
|
||||
|
||||
/** 地图颜色,默认:none */
|
||||
mapColor?: $MapColor$$Type;
|
||||
|
||||
/** 模型文件路径配置 */
|
||||
modelPath?: {
|
||||
|
||||
/** 方块所属命名空间,示例:`minecraft` */
|
||||
blockNamespace: string;
|
||||
|
||||
/** 方块名称,示例:`stone` */
|
||||
blockName: string;
|
||||
|
||||
/** 模型文件路径,示例:`minecraft:block/stone` */
|
||||
filePath: string;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* 方块渲染类型,默认:solid
|
||||
* - `cutout`: required for blocks with texture like glass
|
||||
* - `translucent`: required for blocks like stained glass
|
||||
*/
|
||||
renderType?: $BlockRenderType$$Type;
|
||||
|
||||
/** 坚固程度,默认:16 */
|
||||
resistance?: number;
|
||||
|
||||
/** 声音类型,默认:stone */
|
||||
soundType?: $SoundType$$Type;
|
||||
|
||||
/** 纹理文件路径,每一面都相同时指定 */
|
||||
textureAll?: string;
|
||||
|
||||
};
|
||||
|
||||
declare global {
|
||||
|
||||
/** 方块注册事件 */
|
||||
type _RegistryBlock = $Block;
|
||||
|
||||
const global: {
|
||||
|
||||
/**
|
||||
* @description 传入值为空时返回指定的默认值
|
||||
* @param v 传入值
|
||||
* @param d 默认值
|
||||
*/
|
||||
defaults<TValue>(v: TValue, d: TValue): TValue;
|
||||
|
||||
/**
|
||||
* @description 设置方块基础属性
|
||||
* @param block 方块
|
||||
* @param options 配置选项
|
||||
*/
|
||||
setBlockProps(block: BlockBuilder, options: SetBlockPropsOpts): boolean;
|
||||
|
||||
/**
|
||||
* @description 设置方块水平旋转属性
|
||||
* @param block 方块
|
||||
* @param type 旋转类型
|
||||
* @param model 模型路径
|
||||
*/
|
||||
setHorizontalFacing(
|
||||
block: BlockBuilder,
|
||||
type: 'revert' | 'same',
|
||||
model: string
|
||||
): boolean;
|
||||
|
||||
/**
|
||||
* @description 写入 JSON 文件
|
||||
* @param path 文件路径,相对于 `.minecraft`
|
||||
* @param data JSON 内容对象
|
||||
*/
|
||||
writeJSON(path: string, data: object): void;
|
||||
|
||||
/** 颜色列表 */
|
||||
COLORS: {
|
||||
[key: string]: {
|
||||
CODE: string;
|
||||
HEX: string;
|
||||
LABEL_CN: string;
|
||||
LABEL_EN: string;
|
||||
};
|
||||
};
|
||||
|
||||
/** 需要在 `client.generate_assets` 生成的 JSON 文件 */
|
||||
JSON_ASSETS: Array<{
|
||||
|
||||
/** JSON 完整路径,示例:`minecraft:models/block/stone` */
|
||||
path: string;
|
||||
|
||||
data: object;
|
||||
|
||||
}>;
|
||||
|
||||
/** 日志前缀 */
|
||||
LOG_PREFIX: string;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
export { };
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": [
|
||||
"ES5",
|
||||
"ES2015"
|
||||
],
|
||||
"typeRoots": [
|
||||
"./probe/generated",
|
||||
"./probe/user"
|
||||
],
|
||||
"target": "ES2015"
|
||||
}
|
||||
}
|
||||
22
kubejs/probe/generated/constants.d.ts
vendored
22
kubejs/probe/generated/constants.d.ts
vendored
@@ -1,22 +0,0 @@
|
||||
/// <reference path="./globals.d.ts" />
|
||||
declare const settings: Internal.ServerSettings;
|
||||
declare const console: Internal.ConsoleJS;
|
||||
declare const RARITY_RARE: Rarity;
|
||||
declare const HOUR: 3600000;
|
||||
declare const SLOT_FEET: EquipmentSlot;
|
||||
declare const SLOT_HEAD: EquipmentSlot;
|
||||
declare const MAIN_HAND: Hand;
|
||||
declare const SLOT_LEGS: EquipmentSlot;
|
||||
declare const AIR_BLOCK: Internal.AirBlock;
|
||||
declare const RARITY_UNCOMMON: Rarity;
|
||||
declare const AIR_ITEM: Internal.AirItem;
|
||||
declare const SLOT_CHEST: EquipmentSlot;
|
||||
declare const RARITY_EPIC: Rarity;
|
||||
declare const Painter: Internal.Painter;
|
||||
declare const SECOND: 1000;
|
||||
declare const MINUTE: 60000;
|
||||
declare const SLOT_OFFHAND: EquipmentSlot;
|
||||
declare const RARITY_COMMON: Rarity;
|
||||
declare const Client: Internal.ClientWrapper;
|
||||
declare const SLOT_MAINHAND: EquipmentSlot;
|
||||
declare const OFF_HAND: Hand;
|
||||
1145
kubejs/probe/generated/events.d.ts
vendored
1145
kubejs/probe/generated/events.d.ts
vendored
File diff suppressed because it is too large
Load Diff
66919
kubejs/probe/generated/globals.d.ts
vendored
66919
kubejs/probe/generated/globals.d.ts
vendored
File diff suppressed because one or more lines are too long
2396
kubejs/probe/generated/java.d.ts
vendored
2396
kubejs/probe/generated/java.d.ts
vendored
File diff suppressed because it is too large
Load Diff
4
kubejs/probe/generated/names.d.ts
vendored
4
kubejs/probe/generated/names.d.ts
vendored
@@ -1,4 +0,0 @@
|
||||
/// <reference path="./globals.d.ts" />
|
||||
const Vec3d: typeof Vec3
|
||||
const Text: typeof Component
|
||||
const Direction: typeof Facing
|
||||
4
kubejs/probe/generated/raw.d.ts
vendored
4
kubejs/probe/generated/raw.d.ts
vendored
@@ -1,4 +0,0 @@
|
||||
interface String {
|
||||
readonly namespace: string,
|
||||
readonly path: string
|
||||
}
|
||||
81
kubejs/probe/generated/registries.d.ts
vendored
81
kubejs/probe/generated/registries.d.ts
vendored
@@ -1,81 +0,0 @@
|
||||
/// <reference path="./globals.d.ts" />
|
||||
declare namespace Registry {
|
||||
class SoundEvent extends Internal.RegistryObjectBuilderTypes$RegistryEventJS<any> {
|
||||
create(id: string, type: "basic"): Internal.SoundEventBuilder;
|
||||
create(id: string): Internal.SoundEventBuilder;
|
||||
}
|
||||
class Fluid extends Internal.RegistryObjectBuilderTypes$RegistryEventJS<any> {
|
||||
create(id: string, type: "basic"): Internal.FluidBuilder;
|
||||
create(id: string): Internal.FluidBuilder;
|
||||
}
|
||||
class Block extends Internal.RegistryObjectBuilderTypes$RegistryEventJS<any> {
|
||||
create(id: string, type: "basic"): Internal.BasicBlockJS$Builder;
|
||||
create(id: string, type: "detector"): Internal.DetectorBlock$Builder;
|
||||
create(id: string, type: "slab"): Internal.SlabBlockBuilder;
|
||||
create(id: string, type: "stairs"): Internal.StairBlockBuilder;
|
||||
create(id: string, type: "fence"): Internal.FenceBlockBuilder;
|
||||
create(id: string, type: "fence_gate"): Internal.FenceGateBlockBuilder;
|
||||
create(id: string, type: "wall"): Internal.WallBlockBuilder;
|
||||
create(id: string, type: "wooden_pressure_plate"): Internal.WoodenPressurePlateBlockBuilder;
|
||||
create(id: string, type: "stone_pressure_plate"): Internal.StonePressurePlateBlockBuilder;
|
||||
create(id: string, type: "wooden_button"): Internal.WoodenButtonBlockBuilder;
|
||||
create(id: string, type: "stone_button"): Internal.StoneButtonBlockBuilder;
|
||||
create(id: string, type: "falling"): Internal.FallingBlockBuilder;
|
||||
create(id: string, type: "crop"): Internal.CropBlockBuilder;
|
||||
create(id: string): Internal.BasicBlockJS$Builder;
|
||||
}
|
||||
class Item extends Internal.RegistryObjectBuilderTypes$RegistryEventJS<any> {
|
||||
create(id: string, type: "basic"): Internal.BasicItemJS$Builder;
|
||||
create(id: string, type: "sword"): Internal.SwordItemBuilder;
|
||||
create(id: string, type: "pickaxe"): Internal.PickaxeItemBuilder;
|
||||
create(id: string, type: "axe"): Internal.AxeItemBuilder;
|
||||
create(id: string, type: "shovel"): Internal.ShovelItemBuilder;
|
||||
create(id: string, type: "hoe"): Internal.HoeItemBuilder;
|
||||
create(id: string, type: "helmet"): Internal.ArmorItemBuilder$Helmet;
|
||||
create(id: string, type: "chestplate"): Internal.ArmorItemBuilder$Chestplate;
|
||||
create(id: string, type: "leggings"): Internal.ArmorItemBuilder$Leggings;
|
||||
create(id: string, type: "boots"): Internal.ArmorItemBuilder$Boots;
|
||||
create(id: string, type: "music_disc"): Internal.RecordItemJS$Builder;
|
||||
create(id: string): Internal.BasicItemJS$Builder;
|
||||
}
|
||||
class Enchantment extends Internal.RegistryObjectBuilderTypes$RegistryEventJS<any> {
|
||||
create(id: string, type: "basic"): Internal.EnchantmentBuilder;
|
||||
create(id: string): Internal.EnchantmentBuilder;
|
||||
}
|
||||
class MobEffect extends Internal.RegistryObjectBuilderTypes$RegistryEventJS<any> {
|
||||
create(id: string, type: "basic"): Internal.BasicMobEffect$Builder;
|
||||
create(id: string): Internal.BasicMobEffect$Builder;
|
||||
}
|
||||
class EntityType extends Internal.RegistryObjectBuilderTypes$RegistryEventJS<any> {
|
||||
}
|
||||
class BlockEntityType extends Internal.RegistryObjectBuilderTypes$RegistryEventJS<any> {
|
||||
}
|
||||
class Potion extends Internal.RegistryObjectBuilderTypes$RegistryEventJS<any> {
|
||||
create(id: string, type: "basic"): Internal.PotionBuilder;
|
||||
create(id: string): Internal.PotionBuilder;
|
||||
}
|
||||
class ParticleType extends Internal.RegistryObjectBuilderTypes$RegistryEventJS<any> {
|
||||
create(id: string, type: "basic"): Internal.ParticleTypeBuilder;
|
||||
create(id: string): Internal.ParticleTypeBuilder;
|
||||
}
|
||||
class Motive extends Internal.RegistryObjectBuilderTypes$RegistryEventJS<any> {
|
||||
create(id: string, type: "basic"): Internal.MotiveBuilder;
|
||||
create(id: string): Internal.MotiveBuilder;
|
||||
}
|
||||
class CustomStat extends Internal.RegistryObjectBuilderTypes$RegistryEventJS<any> {
|
||||
create(id: string, type: "basic"): Internal.CustomStatBuilder;
|
||||
create(id: string): Internal.CustomStatBuilder;
|
||||
}
|
||||
class PointOfInterestType extends Internal.RegistryObjectBuilderTypes$RegistryEventJS<any> {
|
||||
create(id: string, type: "basic"): Internal.PoiTypeBuilder;
|
||||
create(id: string): Internal.PoiTypeBuilder;
|
||||
}
|
||||
class VillagerType extends Internal.RegistryObjectBuilderTypes$RegistryEventJS<any> {
|
||||
create(id: string, type: "basic"): Internal.VillagerTypeBuilder;
|
||||
create(id: string): Internal.VillagerTypeBuilder;
|
||||
}
|
||||
class VillagerProfession extends Internal.RegistryObjectBuilderTypes$RegistryEventJS<any> {
|
||||
create(id: string, type: "basic"): Internal.VillagerProfessionBuilder;
|
||||
create(id: string): Internal.VillagerProfessionBuilder;
|
||||
}
|
||||
}
|
||||
103
kubejs/probe/user/constants.d.ts
vendored
103
kubejs/probe/user/constants.d.ts
vendored
@@ -1,103 +0,0 @@
|
||||
/** 方块构造器 */
|
||||
type B_Builder = Internal.BlockBuilder;
|
||||
|
||||
/** 方块碰撞箱类型 */
|
||||
type B_BoxType = 'custom' | 'full' | 'half';
|
||||
|
||||
/** 方块材质类型 */
|
||||
type B_Material = Internal.MaterialJS_;
|
||||
|
||||
/**
|
||||
* 方块渲染类型
|
||||
* - `cutout`: required for blocks with texture like glass
|
||||
* - `translucent`: required for blocks like stained glass
|
||||
*/
|
||||
type B_RenderType = 'solid' | 'cutout' | 'cutout_mipped' | 'translucent';
|
||||
|
||||
/** 配置选项 */
|
||||
type SetBlockPropsOpts = {
|
||||
/** 碰撞箱配置(自定义) */
|
||||
boxConfig: number[];
|
||||
/** 碰撞箱类型(内置) */
|
||||
boxType: B_BoxType;
|
||||
/** 开启碰撞箱,默认:true */
|
||||
collision: boolean;
|
||||
/** 方块显示名称 */
|
||||
displayName: string;
|
||||
/** 默认:8 */
|
||||
hardness: number;
|
||||
/** 是否为完整方块,默认:true */
|
||||
isSolid: boolean;
|
||||
/** 范围:0 ~ 1 */
|
||||
lightLevel: number;
|
||||
/** 默认:stone */
|
||||
material: B_Material;
|
||||
/** 模型文件路径 */
|
||||
modelPath: string;
|
||||
/** 默认:solid */
|
||||
renderType: B_RenderType;
|
||||
/** 默认:16 */
|
||||
resistance: number;
|
||||
/** fullBlock(未使用)*/
|
||||
isFull: boolean;
|
||||
/** opaque(未使用)*/
|
||||
isOpaque: boolean;
|
||||
/** transparent(未使用)*/
|
||||
transparent: boolean;
|
||||
};
|
||||
|
||||
declare const global: {
|
||||
|
||||
/**
|
||||
* @desc 传入值为空时返回指定的默认值
|
||||
* @param v 传入值
|
||||
* @param d 默认值
|
||||
*/
|
||||
defaults<TValue>(v: TValue, d: TValue): TValue;
|
||||
|
||||
/**
|
||||
* @desc 设置方块基础属性
|
||||
* @param block 方块
|
||||
* @param opts 配置选项
|
||||
*/
|
||||
setBlockProps(block: B_Builder, opts: SetBlockPropsOpts): boolean;
|
||||
|
||||
/**
|
||||
* @desc 设置方块水平旋转属性
|
||||
* @param block 方块
|
||||
* @param type 旋转类型
|
||||
* @param model 模型路径
|
||||
*/
|
||||
setHorizontalFacing(
|
||||
block: B_Builder,
|
||||
type: 'revert' | 'same',
|
||||
model: string
|
||||
): boolean;
|
||||
|
||||
/**
|
||||
* @desc 写入 JSON 文件
|
||||
* @param path 文件路径,相对于 `.minecraft`
|
||||
* @param data JSON 内容对象
|
||||
*/
|
||||
writeJSON(path: string, data: object): void;
|
||||
|
||||
/** 颜色列表 */
|
||||
COLORS: {
|
||||
[key: string]: {
|
||||
CODE: string;
|
||||
HEX: string;
|
||||
LABEL_CN: string;
|
||||
LABEL_EN: string;
|
||||
};
|
||||
};
|
||||
|
||||
/** 需要在 `client.generate_assets` 生成的 JSON 文件 */
|
||||
JSON_ASSETS: Array<{
|
||||
PATH: string;
|
||||
DATA: Internal.JsonElement;
|
||||
}>;
|
||||
|
||||
/** 日志前缀 */
|
||||
LOG_PREFIX: string;
|
||||
|
||||
};
|
||||
@@ -1,8 +1,8 @@
|
||||
// priority: 100
|
||||
|
||||
settings.logAddedRecipes = true;
|
||||
settings.logErroringRecipes = true;
|
||||
settings.logRemovedRecipes = true;
|
||||
settings.logSkippedRecipes = false;
|
||||
// settings.logAddedRecipes = true;
|
||||
// settings.logErroringRecipes = true;
|
||||
// settings.logRemovedRecipes = true;
|
||||
// settings.logSkippedRecipes = false;
|
||||
|
||||
console.info(`${global.LOG_PREFIX} 加载服务端内容`);
|
||||
|
||||
24
kubejs/server_scripts/jsconfig.json
Normal file
24
kubejs/server_scripts/jsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "ES2015",
|
||||
"lib": [
|
||||
"ES5",
|
||||
"ES2015"
|
||||
],
|
||||
"rootDir": ".",
|
||||
"typeRoots": [
|
||||
"../../.probe/server/probe-types"
|
||||
],
|
||||
"baseUrl": "../../.probe/server/probe-types",
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"files": [
|
||||
"../constants.d.ts"
|
||||
],
|
||||
"include": [
|
||||
"./**/*.js",
|
||||
"./**/*.ts",
|
||||
null
|
||||
]
|
||||
}
|
||||
@@ -1,19 +1,19 @@
|
||||
// priority: 0
|
||||
|
||||
// 玩家切换世界时设置为冒险模式(KubeJS Additions)
|
||||
onEvent('player.change_dimension', (event) => {
|
||||
// // 玩家切换世界时设置为冒险模式(KubeJS Additions)
|
||||
// onEvent('player.change_dimension', (event) => {
|
||||
|
||||
const evServer = event.getServer();
|
||||
const evPlayer = event.getPlayer();
|
||||
const player = evServer ? evServer.getPlayer(evPlayer) : null;
|
||||
// const evServer = event.getServer();
|
||||
// const evPlayer = event.getPlayer();
|
||||
// const player = evServer ? evServer.getPlayer(evPlayer) : null;
|
||||
|
||||
if (!player) {
|
||||
console.error('自动切换游戏模式失败:找不到玩家');
|
||||
return;
|
||||
}
|
||||
// if (!player) {
|
||||
// console.error('自动切换游戏模式失败:找不到玩家');
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (player.isCreativeMode()) {
|
||||
player.setGameMode('adventure');
|
||||
}
|
||||
// if (player.isCreativeMode()) {
|
||||
// player.setGameMode('adventure');
|
||||
// }
|
||||
|
||||
});
|
||||
// });
|
||||
|
||||
@@ -1,119 +1,5 @@
|
||||
// priority: 100
|
||||
|
||||
global.defaults = function (v, d) {
|
||||
(typeof d === 'undefined') && (d = null);
|
||||
return ((typeof v === 'undefined' || v === null) ? d : v);
|
||||
};
|
||||
|
||||
global.setBlockProps = function (block, opts) {
|
||||
|
||||
if (!block) {
|
||||
console.error(`${LOG_PREFIX} 设置方块属性失败:缺少“block”参数`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!opts) {
|
||||
opts = {};
|
||||
}
|
||||
|
||||
const boxConfig = defaults(opts.boxConfig, null);
|
||||
const boxType = defaults(opts.boxType, '');
|
||||
const collision = defaults(opts.collision, true);
|
||||
const displayName = defaults(opts.displayName, '');
|
||||
const hardness = defaults(opts.hardness, 8);
|
||||
const isSolid = defaults(opts.isSolid, true);
|
||||
const lightLevel = defaults(opts.lightLevel, 0);
|
||||
const material = defaults(opts.material, 'stone');
|
||||
const modelPath = defaults(opts.modelPath, '');
|
||||
const renderType = defaults(opts.renderType, 'solid');
|
||||
const resistance = defaults(opts.resistance, 16);
|
||||
|
||||
if (boxConfig) {
|
||||
block.box.apply(block, boxConfig);
|
||||
} else if (boxType === 'full') {
|
||||
block.box(0, 0, 0, 16, 16, 16, true);
|
||||
} else if (boxType === 'half') {
|
||||
block.box(0, 0, 0, 16, 8, 16, true);
|
||||
}
|
||||
|
||||
if (!collision) {
|
||||
block.noCollision();
|
||||
}
|
||||
|
||||
if (displayName) {
|
||||
block.displayName(displayName);
|
||||
}
|
||||
|
||||
if (!isSolid) {
|
||||
block.notSolid();
|
||||
}
|
||||
|
||||
if (modelPath) {
|
||||
block.model(modelPath);
|
||||
}
|
||||
|
||||
block.hardness(hardness);
|
||||
block.lightLevel(lightLevel);
|
||||
block.material(material);
|
||||
block.renderType(renderType);
|
||||
block.resistance(resistance);
|
||||
|
||||
return true;
|
||||
|
||||
};
|
||||
|
||||
global.setHorizontalFacing = function (block, type, model) {
|
||||
|
||||
const prop = BlockProperties.HORIZONTAL_FACING;
|
||||
|
||||
// 设置模型旋转
|
||||
block.blockstateJson = {
|
||||
'variants': {
|
||||
'facing=north': { model: model, y: 0 },
|
||||
'facing=east': { model: model, y: 90 },
|
||||
'facing=south': { model: model, y: 180 },
|
||||
'facing=west': { model: model, y: 270 }
|
||||
}
|
||||
};
|
||||
|
||||
// 添加属性
|
||||
block.property(prop);
|
||||
|
||||
// 处理默认状态
|
||||
block.defaultState((ev) => {
|
||||
ev.set(prop, 'north');
|
||||
});
|
||||
|
||||
// 处理放置状态
|
||||
switch (type) {
|
||||
// 与玩家朝向相反
|
||||
case 'revert':
|
||||
block.placementState((ev) => {
|
||||
const d = ev.getHorizontalDirection().getOpposite().toString();
|
||||
ev.set(prop, d);
|
||||
});
|
||||
break;
|
||||
// 与玩家朝向相同
|
||||
case 'same':
|
||||
block.placementState((ev) => {
|
||||
const d = ev.getHorizontalDirection().toString();
|
||||
ev.set(prop, d);
|
||||
});
|
||||
break;
|
||||
// 其他
|
||||
default:
|
||||
console.error(`${LOG_PREFIX} 设置旋转属性失败:参数“type”错误`);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
};
|
||||
|
||||
global.writeJSON = function (path, data) {
|
||||
JsonIO.write(path, data);
|
||||
};
|
||||
|
||||
global.COLORS = {
|
||||
WHITE: {
|
||||
CODE: 'white',
|
||||
@@ -216,4 +102,140 @@ global.COLORS = {
|
||||
global.JSON_ASSETS = [];
|
||||
global.LOG_PREFIX = '[KubeJS]';
|
||||
|
||||
global.defaults = function (v, d) {
|
||||
(typeof d === 'undefined') && (d = null);
|
||||
return ((typeof v === 'undefined' || v === null) ? d : v);
|
||||
};
|
||||
|
||||
global.setBlockProps = function (block, opts) {
|
||||
|
||||
if (!block) {
|
||||
console.error(`${LOG_PREFIX} 设置方块属性失败:缺少“block”参数`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!opts) {
|
||||
opts = {};
|
||||
}
|
||||
|
||||
const boxConfig = defaults(opts.boxConfig, null);
|
||||
const boxType = defaults(opts.boxType, 'full');
|
||||
const displayName = defaults(opts.displayName, '');
|
||||
const hardness = defaults(opts.hardness, 8);
|
||||
const hasCollision = defaults(opts.hasCollision, true);
|
||||
const isSolid = defaults(opts.isSolid, true);
|
||||
const lightLevel = defaults(opts.lightLevel, 0);
|
||||
const mapColor = defaults(opts.mapColor, 'none');
|
||||
const modelPath = defaults(opts.modelPath, null);
|
||||
const renderType = defaults(opts.renderType, 'solid');
|
||||
const resistance = defaults(opts.resistance, 16);
|
||||
const soundType = defaults(opts.soundType, 'stone');
|
||||
const textureAll = defaults(opts.textureAll, '');
|
||||
|
||||
if (boxType === 'custom') {
|
||||
boxConfig && block.box.apply(block, boxConfig);
|
||||
} else if (boxType === 'full') {
|
||||
block.box(0, 0, 0, 16, 16, 16, true);
|
||||
} else if (boxType === 'half') {
|
||||
block.box(0, 0, 0, 16, 8, 16, true);
|
||||
}
|
||||
|
||||
if (displayName) {
|
||||
block.displayName(displayName);
|
||||
}
|
||||
|
||||
if (!hasCollision) {
|
||||
block.noCollision();
|
||||
}
|
||||
|
||||
if (!isSolid) {
|
||||
block.notSolid();
|
||||
}
|
||||
|
||||
if (modelPath) {
|
||||
|
||||
// 生成模型 JSON 文件
|
||||
JSON_ASSETS.push({
|
||||
path: `${modelPath.blockNamespace}:models/block/${modelPath.blockName}`,
|
||||
data: { parent: modelPath.filePath },
|
||||
});
|
||||
|
||||
// // 注:不完全有效,无法使用,会导致方块显示为黑紫方块
|
||||
// block.parentModel(modelPath.filePath);
|
||||
|
||||
}
|
||||
|
||||
if (textureAll) {
|
||||
block.texture(textureAll);
|
||||
// block.texture(Direction.UP, textureAll);
|
||||
// block.texture(Direction.DOWN, textureAll);
|
||||
// block.texture(Direction.NORTH, textureAll);
|
||||
// block.texture(Direction.SOUTH, textureAll);
|
||||
// block.texture(Direction.WEST, textureAll);
|
||||
// block.texture(Direction.EAST, textureAll);
|
||||
}
|
||||
|
||||
block.hardness(hardness);
|
||||
block.lightLevel(lightLevel);
|
||||
block.mapColor(mapColor);
|
||||
block.soundType(soundType);
|
||||
block.renderType(renderType);
|
||||
block.resistance(resistance);
|
||||
|
||||
return true;
|
||||
|
||||
};
|
||||
|
||||
global.setHorizontalFacing = function (block, type, model) {
|
||||
|
||||
const prop = BlockProperties.HORIZONTAL_FACING;
|
||||
|
||||
// // 设置模型旋转
|
||||
// block.blockstateJson = {
|
||||
// 'variants': {
|
||||
// 'facing=north': { model: model, y: 0 },
|
||||
// 'facing=east': { model: model, y: 90 },
|
||||
// 'facing=south': { model: model, y: 180 },
|
||||
// 'facing=west': { model: model, y: 270 }
|
||||
// }
|
||||
// };
|
||||
|
||||
// 添加属性
|
||||
block.property(prop);
|
||||
|
||||
// 处理默认状态
|
||||
block.defaultState((ev) => {
|
||||
ev.set(prop, 'north');
|
||||
});
|
||||
|
||||
// 处理放置状态
|
||||
switch (type) {
|
||||
// 与玩家朝向相反
|
||||
case 'revert':
|
||||
block.placementState((ev) => {
|
||||
const d = ev.getHorizontalDirection().getOpposite().toString();
|
||||
ev.set(prop, d);
|
||||
});
|
||||
break;
|
||||
// 与玩家朝向相同
|
||||
case 'same':
|
||||
block.placementState((ev) => {
|
||||
const d = ev.getHorizontalDirection().toString();
|
||||
ev.set(prop, d);
|
||||
});
|
||||
break;
|
||||
// 其他
|
||||
default:
|
||||
console.error(`${LOG_PREFIX} 设置旋转属性失败:参数“type”错误`);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
};
|
||||
|
||||
global.writeJSON = function (path, data) {
|
||||
JsonIO.write(path, data);
|
||||
};
|
||||
|
||||
console.info(`${global.LOG_PREFIX} 启动`);
|
||||
|
||||
24
kubejs/startup_scripts/jsconfig.json
Normal file
24
kubejs/startup_scripts/jsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "ES2015",
|
||||
"lib": [
|
||||
"ES5",
|
||||
"ES2015"
|
||||
],
|
||||
"rootDir": ".",
|
||||
"typeRoots": [
|
||||
"../../.probe/startup/probe-types"
|
||||
],
|
||||
"baseUrl": "../../.probe/startup/probe-types",
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"files": [
|
||||
"../constants.d.ts"
|
||||
],
|
||||
"include": [
|
||||
"./**/*.js",
|
||||
"./**/*.ts",
|
||||
null
|
||||
]
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
const defaults = global.defaults;
|
||||
const setBlockProps = global.setBlockProps;
|
||||
const setHorizontalFacing = global.setHorizontalFacing;
|
||||
|
||||
const COLORS = global.COLORS;
|
||||
const JSON_ASSETS = global.JSON_ASSETS;
|
||||
@@ -17,6 +16,9 @@ const P_BLOCK = `${MOD_ID}:block`;
|
||||
/** 方块模型文件基础长路径 */
|
||||
const P_BLOCK_MODEL = `${MOD_ID}:models/block`;
|
||||
|
||||
/** 方块透明纹理文件路径 */
|
||||
const P_BLOCK_TRANSPARENT = `${P_BLOCK}/common/transparent`;
|
||||
|
||||
/** 物品模型、纹理文件基础短路径*/
|
||||
const P_ITEM = `${MOD_ID}:item`;
|
||||
|
||||
@@ -27,7 +29,7 @@ console.info(`${LOG_PREFIX} 处理 ${MOD_ID} 相关内容`);
|
||||
|
||||
/**
|
||||
* @description 注册方块 - 砖块
|
||||
* @param {Registry.Block} event
|
||||
* @param {_RegistryBlock} event
|
||||
*/
|
||||
function regBlockBrick(event) {
|
||||
|
||||
@@ -43,15 +45,13 @@ function regBlockBrick(event) {
|
||||
blocks.forEach((config) => {
|
||||
|
||||
const id = `${MOD_ID}:${config.name}`;
|
||||
const block = event.create(id, 'basic');
|
||||
const block = event.create(id);
|
||||
|
||||
setBlockProps(block, {
|
||||
displayName: '砖块',
|
||||
material: 'stone',
|
||||
textureAll: `${P_BLOCK}/${config.texture}`,
|
||||
});
|
||||
|
||||
block.textureAll(`${P_BLOCK}/${config.texture}`);
|
||||
|
||||
});
|
||||
|
||||
console.info(`${LOG_PREFIX} 注册方块 - 砖块 - 完成`);
|
||||
@@ -60,13 +60,13 @@ function regBlockBrick(event) {
|
||||
|
||||
/**
|
||||
* @description 注册方块 - 建筑和家具
|
||||
* @param {Registry.Block} event
|
||||
* @param {_RegistryBlock} event
|
||||
*/
|
||||
function regBlockBuildingAndFurniture(event) {
|
||||
|
||||
console.info(`${LOG_PREFIX} 注册方块 - 建筑和家具 - 开始`);
|
||||
|
||||
const blocks = [
|
||||
const blockList = [
|
||||
// 建筑方块
|
||||
{
|
||||
name: 'building_brick_a',
|
||||
@@ -543,48 +543,52 @@ function regBlockBuildingAndFurniture(event) {
|
||||
},
|
||||
];
|
||||
|
||||
blocks.forEach((config) => {
|
||||
blockList.forEach((config) => {
|
||||
|
||||
const id = `${MOD_ID}:${config.name}`;
|
||||
const block = event.create(id, 'basic');
|
||||
const box = config.box;
|
||||
const label = config.label;
|
||||
const mPath = config.model;
|
||||
const tPath = config.texture;
|
||||
const blockBox = config.box;
|
||||
const blockLabel = config.label;
|
||||
const blockName = config.name;
|
||||
const blockId = `${MOD_ID}:${blockName}`;
|
||||
|
||||
const block = config.orientable ? event.create(blockId, 'cardinal') : event.create(blockId);
|
||||
|
||||
const modelPath0 = config.model;
|
||||
const modelPath1 = modelPath0 ? `${P_BLOCK}/${modelPath0}` : '';
|
||||
|
||||
const texturePath0 = config.texture;
|
||||
const texturePath1 = texturePath0 ? `${P_BLOCK}/${texturePath0}` : '';
|
||||
|
||||
// 设置基础属性
|
||||
if (box) {
|
||||
if (blockBox) {
|
||||
setBlockProps(block, {
|
||||
boxConfig: box,
|
||||
boxConfig: blockBox,
|
||||
boxType: 'custom',
|
||||
displayName: label,
|
||||
displayName: blockLabel,
|
||||
isSolid: false,
|
||||
material: 'stone',
|
||||
modelPath: modelPath1 ? {
|
||||
blockName: blockName,
|
||||
blockNamespace: MOD_ID,
|
||||
filePath: modelPath1,
|
||||
} : null,
|
||||
renderType: 'cutout',
|
||||
textureAll: texturePath1,
|
||||
});
|
||||
} else {
|
||||
setBlockProps(block, {
|
||||
boxConfig: null,
|
||||
boxType: 'full',
|
||||
displayName: label,
|
||||
displayName: blockLabel,
|
||||
isSolid: true,
|
||||
material: 'stone',
|
||||
modelPath: modelPath1 ? {
|
||||
blockName: blockName,
|
||||
blockNamespace: MOD_ID,
|
||||
filePath: modelPath1,
|
||||
} : null,
|
||||
renderType: 'solid',
|
||||
textureAll: texturePath1,
|
||||
});
|
||||
}
|
||||
|
||||
// 设置模型或纹理文件路径
|
||||
if (mPath) {
|
||||
block.model(`${P_BLOCK}/${mPath}`);
|
||||
} else if (tPath) {
|
||||
block.textureAll(`${P_BLOCK}/${tPath}`);
|
||||
}
|
||||
|
||||
// 设置方块旋转
|
||||
if (config.orientable) {
|
||||
setHorizontalFacing(block, 'revert', `${P_BLOCK}/${mPath}`);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
console.info(`${LOG_PREFIX} 注册方块 - 建筑和家具 - 完成`);
|
||||
@@ -593,7 +597,7 @@ function regBlockBuildingAndFurniture(event) {
|
||||
|
||||
/**
|
||||
* @description 注册方块 - 纯色方块
|
||||
* @param {Registry.Block} event
|
||||
* @param {_RegistryBlock} event
|
||||
*/
|
||||
function regBlockColor(event) {
|
||||
|
||||
@@ -728,13 +732,13 @@ function regBlockColor(event) {
|
||||
},
|
||||
];
|
||||
|
||||
const tGrow = `${P_BLOCK}/common/color_grow`;
|
||||
const tNormal = `${P_BLOCK}/common/color_normal`;
|
||||
const textureGrow = `${P_BLOCK}/common/color_grow`;
|
||||
const textureNormal = `${P_BLOCK}/common/color_normal`;
|
||||
|
||||
blocks.forEach((config) => {
|
||||
|
||||
const id = `${MOD_ID}:${config.name}`;
|
||||
const block = event.create(id, 'basic');
|
||||
const block = event.create(id);
|
||||
const colorCfg = config.color;
|
||||
const isGrow = config.grow;
|
||||
|
||||
@@ -742,10 +746,9 @@ function regBlockColor(event) {
|
||||
displayName: config.label,
|
||||
isSolid: false,
|
||||
lightLevel: (isGrow ? 1 : 0),
|
||||
material: 'stone',
|
||||
textureAll: (isGrow ? textureGrow : textureNormal),
|
||||
});
|
||||
|
||||
block.textureAll(isGrow ? tGrow : tNormal);
|
||||
block.color(0, Color.rgba.apply(Color, colorCfg));
|
||||
block.item((item) => {
|
||||
item.color(0, Color.rgba.apply(Color, colorCfg));
|
||||
@@ -759,44 +762,49 @@ function regBlockColor(event) {
|
||||
|
||||
/**
|
||||
* @description 注册方块 - 灯(现代)
|
||||
* @param {Registry.Block} event
|
||||
* @param {_RegistryBlock} event
|
||||
*/
|
||||
function regBlockLampModern(event) {
|
||||
|
||||
console.info(`${LOG_PREFIX} 注册方块 - 现代灯 - 开始`);
|
||||
|
||||
/** 颜色 key 列表 */
|
||||
const keys = Object.keys(COLORS);
|
||||
|
||||
/** 父模型路径 */
|
||||
const parent = `${P_BLOCK}/lamp/modern`;
|
||||
const parentModel = `${P_BLOCK}/lamp/modern`;
|
||||
|
||||
keys.forEach((key) => {
|
||||
|
||||
const color = COLORS[key];
|
||||
const id = `${MOD_ID}:lamp_modern_${color.CODE}`;
|
||||
const block = event.create(id, 'basic');
|
||||
const blockName = `lamp_modern_${color.CODE}`;
|
||||
const blockId = `${MOD_ID}:${blockName}`;
|
||||
const block = event.create(blockId);
|
||||
|
||||
// 纹理文件路径前缀
|
||||
// wheat_plus:block/lamp_modern/color_
|
||||
const tBase = `${P_BLOCK}/lamp_modern/${color.CODE}`;
|
||||
const textureBase = `${P_BLOCK}/lamp_modern/${color.CODE}`;
|
||||
|
||||
setBlockProps(block, {
|
||||
boxType: 'full',
|
||||
displayName: `现代${color.LABEL_CN}灯`,
|
||||
isSolid: false,
|
||||
lightLevel: 1,
|
||||
material: 'glass',
|
||||
renderType: 'translucent',
|
||||
soundType: 'glass',
|
||||
});
|
||||
|
||||
block.modelJson = {
|
||||
parent: parent,
|
||||
textures: {
|
||||
glow: `${tBase}_glow`,
|
||||
core: `${tBase}_core`,
|
||||
particle: `${tBase}_core`
|
||||
}
|
||||
};
|
||||
JSON_ASSETS.push({
|
||||
path: `${P_BLOCK_MODEL}/${blockName}`,
|
||||
data: {
|
||||
parent: parentModel,
|
||||
textures: {
|
||||
glow: `${textureBase}_glow`,
|
||||
core: `${textureBase}_core`,
|
||||
particle: `${textureBase}_core`,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -806,7 +814,7 @@ function regBlockLampModern(event) {
|
||||
|
||||
/**
|
||||
* @description 注册方块 - 灯(简约)
|
||||
* @param {Registry.Block} event
|
||||
* @param {_RegistryBlock} event
|
||||
*/
|
||||
function regBlockLampSimple(event) {
|
||||
|
||||
@@ -839,7 +847,7 @@ function regBlockLampSimple(event) {
|
||||
|
||||
const blockName = config.name;
|
||||
const blockId = `${MOD_ID}:${blockName}`;
|
||||
const block = event.create(blockId, 'stone_button');
|
||||
const block = event.create(blockId, 'button');
|
||||
|
||||
// 用于替换默认模型
|
||||
const modelJSON = { parent: `${P_BLOCK}/${config.model}` };
|
||||
@@ -847,26 +855,26 @@ function regBlockLampSimple(event) {
|
||||
setBlockProps(block, {
|
||||
displayName: config.label,
|
||||
lightLevel: 0.8,
|
||||
material: 'glass',
|
||||
renderType: 'translucent',
|
||||
soundType: 'glass',
|
||||
});
|
||||
|
||||
// 按钮方块默认状态
|
||||
JSON_ASSETS.push({
|
||||
PATH: `${P_BLOCK_MODEL}/${blockName}`,
|
||||
DATA: modelJSON,
|
||||
path: `${P_BLOCK_MODEL}/${blockName}`,
|
||||
data: modelJSON,
|
||||
});
|
||||
|
||||
// 按钮方块按下状态
|
||||
JSON_ASSETS.push({
|
||||
PATH: `${P_BLOCK_MODEL}/${blockName}_pressed`,
|
||||
DATA: modelJSON,
|
||||
path: `${P_BLOCK_MODEL}/${blockName}_pressed`,
|
||||
data: modelJSON,
|
||||
});
|
||||
|
||||
// 按钮物品状态
|
||||
JSON_ASSETS.push({
|
||||
PATH: `${P_ITEM_MODEL}/${blockName}`,
|
||||
DATA: modelJSON,
|
||||
path: `${P_ITEM_MODEL}/${blockName}`,
|
||||
data: modelJSON,
|
||||
});
|
||||
|
||||
});
|
||||
@@ -877,7 +885,7 @@ function regBlockLampSimple(event) {
|
||||
|
||||
/**
|
||||
* @description 注册方块 - 矿车方块
|
||||
* @param {Registry.Block} event
|
||||
* @param {_RegistryBlock} event
|
||||
*/
|
||||
function regBlockMinecart(event) {
|
||||
|
||||
@@ -889,7 +897,7 @@ function regBlockMinecart(event) {
|
||||
/** 纹理文件路径前缀 */
|
||||
const texturePrefix = `${P_BLOCK}/minecart/`;
|
||||
|
||||
const blocks = [
|
||||
const blockList = [
|
||||
{ name: 'mtr_gz_gf_1', label: '广州地铁 - 广佛线' },
|
||||
{ name: 'mtr_gz_gf_2', label: '广州地铁 - 广佛线' },
|
||||
{ name: 'mtr_gz_l1_1', label: '广州地铁 - 一号线' },
|
||||
@@ -942,39 +950,37 @@ function regBlockMinecart(event) {
|
||||
{ name: 'cr_yz25z_wh', label: '中国铁路 - YZ25Z_WH' },
|
||||
];
|
||||
|
||||
blocks.forEach((config) => {
|
||||
blockList.forEach((config) => {
|
||||
|
||||
const blockName = config.name;
|
||||
const blockId = `${MOD_ID}:minecart_${blockName}`;
|
||||
const block = event.create(blockId, 'basic');
|
||||
const block = event.create(blockId, 'cardinal');
|
||||
|
||||
const modelPathL = `${P_BLOCK_MODEL}/minecart/${blockName}`;
|
||||
const modelPathS = `${P_BLOCK}/minecart/${blockName}`;
|
||||
const modelJSON = {
|
||||
parent: modelParent,
|
||||
textures: {
|
||||
main: `${texturePrefix}${blockName}`
|
||||
}
|
||||
};
|
||||
const modelPathL = `${P_BLOCK_MODEL}/minecart_${blockName}`;
|
||||
const modelPathS = `${P_BLOCK}/minecart_${blockName}`;
|
||||
|
||||
// 生成模型 JSON 文件
|
||||
JSON_ASSETS.push({ PATH: modelPathL, DATA: modelJSON });
|
||||
JSON_ASSETS.push({
|
||||
path: modelPathL,
|
||||
data: {
|
||||
parent: modelParent,
|
||||
textures: {
|
||||
main: `${texturePrefix}${blockName}`,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// 设置基础属性
|
||||
setBlockProps(block, {
|
||||
boxConfig: [-3, 0, -6, 19, 16, 22],
|
||||
boxConfig: [-3, 0, -6, 19, 16, 22, true],
|
||||
boxType: 'custom',
|
||||
collision: false,
|
||||
displayName: config.label,
|
||||
hasCollision: false,
|
||||
isSolid: false,
|
||||
material: 'metal',
|
||||
modelPath: modelPathS,
|
||||
renderType: 'cutout',
|
||||
soundType: 'metal',
|
||||
});
|
||||
|
||||
// 设置旋转属性
|
||||
setHorizontalFacing(block, 'same', modelPathS);
|
||||
|
||||
});
|
||||
|
||||
console.info(`${LOG_PREFIX} 注册方块 - 矿车方块 - 完成`);
|
||||
@@ -983,7 +989,7 @@ function regBlockMinecart(event) {
|
||||
|
||||
/**
|
||||
* @description 注册方块 - 强化混凝土
|
||||
* @param {Registry.Block} event
|
||||
* @param {_RegistryBlock} event
|
||||
*/
|
||||
function regBlockReinforcedConcrete(event) {
|
||||
|
||||
@@ -995,22 +1001,21 @@ function regBlockReinforcedConcrete(event) {
|
||||
|
||||
const color = COLORS[key];
|
||||
const id = `${MOD_ID}:reinforced_concrete_${color.CODE}`;
|
||||
const block = event.create(id, 'basic');
|
||||
const block = event.create(id);
|
||||
const texture = `${P_BLOCK}/reinforced_concrete/${color.CODE}`;
|
||||
|
||||
setBlockProps(block, {
|
||||
boxType: 'full',
|
||||
displayName: `${color.LABEL_CN}强化混凝土`,
|
||||
textureAll: texture,
|
||||
});
|
||||
|
||||
block.textureAll(texture);
|
||||
|
||||
});
|
||||
|
||||
// // 覆盖默认语言(en_US)
|
||||
// JSON_ASSETS.push({
|
||||
// PATH: 'minecraft:lang/en_us',
|
||||
// DATA: {
|
||||
// path: 'minecraft:lang/en_us',
|
||||
// data: {
|
||||
// 'block.minecraft.ancient_debris': 'White Reinforced Concrete',
|
||||
// 'block.minecraft.raw_copper_block': 'Gray Reinforced Concrete',
|
||||
// 'block.minecraft.raw_iron_block': 'Light Gray Reinforced Concrete',
|
||||
@@ -1019,8 +1024,8 @@ function regBlockReinforcedConcrete(event) {
|
||||
|
||||
// // 覆盖默认语言(zh_CN)
|
||||
// JSON_ASSETS.push({
|
||||
// PATH: 'minecraft:lang/zh_cn',
|
||||
// DATA: {
|
||||
// path: 'minecraft:lang/zh_cn',
|
||||
// data: {
|
||||
// 'block.minecraft.ancient_debris': '白色强化混凝土',
|
||||
// 'block.minecraft.raw_copper_block': '灰色强化混凝土',
|
||||
// 'block.minecraft.raw_iron_block': '淡灰色强化混凝土',
|
||||
@@ -1033,7 +1038,7 @@ function regBlockReinforcedConcrete(event) {
|
||||
|
||||
/**
|
||||
* @description 注册方块 - 路
|
||||
* @param {Registry.Block} event
|
||||
* @param {_RegistryBlock} event
|
||||
*/
|
||||
function regBlockRoad(event) {
|
||||
|
||||
@@ -1114,35 +1119,33 @@ function regBlockRoad(event) {
|
||||
const label = (config.label || 'Unknown');
|
||||
|
||||
/** 纹理文件相对路径 */
|
||||
const tPath = config.texturePath;
|
||||
const texturePath = config.texturePath;
|
||||
|
||||
/** 是否存在侧边纹理 */
|
||||
const tSide = config.hasSide;
|
||||
const textureSide = config.hasSide;
|
||||
|
||||
// 完整,普通 / 直线
|
||||
if (config.hasNormal) {
|
||||
|
||||
const blockId = `${blockName}_full`;
|
||||
const fullId = `${MOD_ID}:${blockId}`;
|
||||
const block = event.create(fullId, 'basic');
|
||||
const block = event.create(fullId);
|
||||
const suffix = (config.isBlank ? '' : ',直线');
|
||||
|
||||
const modelPathL = `${P_BLOCK_MODEL}/${blockId}`;
|
||||
const modelPathS = `${P_BLOCK}/${blockId}`;
|
||||
const modelJSON = {
|
||||
parent: `${P_BLOCK}/road/base_full`,
|
||||
textures: {
|
||||
content: `${P_BLOCK}/${tPath}`,
|
||||
side: tSide ? `${P_BLOCK}/${tPath}` : undefined
|
||||
}
|
||||
};
|
||||
|
||||
JSON_ASSETS.push({ PATH: modelPathL, DATA: modelJSON });
|
||||
JSON_ASSETS.push({
|
||||
path: `${P_BLOCK_MODEL}/${blockId}`,
|
||||
data: {
|
||||
parent: `${P_BLOCK}/road/base_full`,
|
||||
textures: {
|
||||
content: `${P_BLOCK}/${texturePath}`,
|
||||
side: textureSide ? `${P_BLOCK}/${texturePath}` : P_BLOCK_TRANSPARENT,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
setBlockProps(block, {
|
||||
boxType: 'full',
|
||||
displayName: `${label},完整${suffix}`,
|
||||
modelPath: modelPathS,
|
||||
renderType: 'cutout',
|
||||
});
|
||||
|
||||
@@ -1153,30 +1156,26 @@ function regBlockRoad(event) {
|
||||
|
||||
const blockId = `${blockName}_full_slant`;
|
||||
const fullId = `${MOD_ID}:${blockId}`;
|
||||
const block = event.create(fullId, 'basic');
|
||||
const block = event.create(fullId, 'cardinal');
|
||||
const suffix = ',斜线';
|
||||
|
||||
const modelPathL = `${P_BLOCK_MODEL}/${blockId}`;
|
||||
const modelPathS = `${P_BLOCK}/${blockId}`;
|
||||
const modelJSON = {
|
||||
parent: `${P_BLOCK}/road/base_full`,
|
||||
textures: {
|
||||
content: `${P_BLOCK}/${tPath}_slant`,
|
||||
side: tSide ? `${P_BLOCK}/${tPath}` : undefined
|
||||
}
|
||||
};
|
||||
|
||||
JSON_ASSETS.push({ PATH: modelPathL, DATA: modelJSON });
|
||||
JSON_ASSETS.push({
|
||||
path: `${P_BLOCK_MODEL}/${blockId}`,
|
||||
data: {
|
||||
parent: `${P_BLOCK}/road/base_full`,
|
||||
textures: {
|
||||
content: `${P_BLOCK}/${texturePath}_slant`,
|
||||
side: textureSide ? `${P_BLOCK}/${texturePath}` : P_BLOCK_TRANSPARENT,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
setBlockProps(block, {
|
||||
boxType: 'full',
|
||||
displayName: `${label},完整${suffix}`,
|
||||
modelPath: modelPathS,
|
||||
renderType: 'cutout',
|
||||
});
|
||||
|
||||
setHorizontalFacing(block, 'same', modelPathS);
|
||||
|
||||
}
|
||||
|
||||
// 一半,普通 / 直线
|
||||
@@ -1184,25 +1183,23 @@ function regBlockRoad(event) {
|
||||
|
||||
const blockId = `${blockName}_half`;
|
||||
const fullId = `${MOD_ID}:${blockId}`;
|
||||
const block = event.create(fullId, 'basic');
|
||||
const block = event.create(fullId);
|
||||
const suffix = (config.isBlank ? '' : ',直线');
|
||||
|
||||
const modelPathL = `${P_BLOCK_MODEL}/${blockId}`;
|
||||
const modelPathS = `${P_BLOCK}/${blockId}`;
|
||||
const modelJSON = {
|
||||
parent: `${P_BLOCK}/road/base_half`,
|
||||
textures: {
|
||||
content: `${P_BLOCK}/${tPath}`,
|
||||
side: tSide ? `${P_BLOCK}/${tPath}` : undefined
|
||||
}
|
||||
};
|
||||
|
||||
JSON_ASSETS.push({ PATH: modelPathL, DATA: modelJSON });
|
||||
JSON_ASSETS.push({
|
||||
path: `${P_BLOCK_MODEL}/${blockId}`,
|
||||
data: {
|
||||
parent: `${P_BLOCK}/road/base_half`,
|
||||
textures: {
|
||||
content: `${P_BLOCK}/${texturePath}`,
|
||||
side: textureSide ? `${P_BLOCK}/${texturePath}` : P_BLOCK_TRANSPARENT,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
setBlockProps(block, {
|
||||
boxType: 'half',
|
||||
displayName: `${label},一半${suffix}`,
|
||||
modelPath: modelPathS,
|
||||
renderType: 'cutout',
|
||||
});
|
||||
|
||||
@@ -1213,30 +1210,26 @@ function regBlockRoad(event) {
|
||||
|
||||
const blockId = `${blockName}_half_slant`;
|
||||
const fullId = `${MOD_ID}:${blockId}`;
|
||||
const block = event.create(fullId, 'basic');
|
||||
const block = event.create(fullId, 'cardinal');
|
||||
const suffix = ',斜线';
|
||||
|
||||
const modelPathL = `${P_BLOCK_MODEL}/${blockId}`;
|
||||
const modelPathS = `${P_BLOCK}/${blockId}`;
|
||||
const modelJSON = {
|
||||
parent: `${P_BLOCK}/road/base_half`,
|
||||
textures: {
|
||||
content: `${P_BLOCK}/${tPath}_slant`,
|
||||
side: tSide ? `${P_BLOCK}/${tPath}` : undefined
|
||||
}
|
||||
};
|
||||
|
||||
JSON_ASSETS.push({ PATH: modelPathL, DATA: modelJSON });
|
||||
JSON_ASSETS.push({
|
||||
path: `${P_BLOCK_MODEL}/${blockId}`,
|
||||
data: {
|
||||
parent: `${P_BLOCK}/road/base_half`,
|
||||
textures: {
|
||||
content: `${P_BLOCK}/${texturePath}_slant`,
|
||||
side: textureSide ? `${P_BLOCK}/${texturePath}` : P_BLOCK_TRANSPARENT,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
setBlockProps(block, {
|
||||
boxType: 'half',
|
||||
displayName: `${label},一半${suffix}`,
|
||||
modelPath: modelPathS,
|
||||
renderType: 'cutout',
|
||||
});
|
||||
|
||||
setHorizontalFacing(block, 'same', modelPathS);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
@@ -1247,7 +1240,7 @@ function regBlockRoad(event) {
|
||||
|
||||
/**
|
||||
* @description 注册方块 - 其他 - 基础
|
||||
* @param {Registry.Block} event
|
||||
* @param {_RegistryBlock} event
|
||||
*/
|
||||
function regBlockOtherBasic(event) {
|
||||
|
||||
@@ -1306,46 +1299,50 @@ function regBlockOtherBasic(event) {
|
||||
|
||||
blocks.forEach((config) => {
|
||||
|
||||
const id = `${MOD_ID}:${config.name}`;
|
||||
const block = event.create(id, 'basic');
|
||||
const box = config.box;
|
||||
const label = config.label;
|
||||
const mPath = config.model;
|
||||
const tPath = config.texture;
|
||||
const blockBox = config.box;
|
||||
const blockLabel = config.label;
|
||||
const blockName = config.name;
|
||||
const blockId = `${MOD_ID}:${blockName}`;
|
||||
|
||||
const block = config.orientable ? event.create(blockId, 'cardinal') : event.create(blockId);
|
||||
|
||||
const modelPath0 = config.model;
|
||||
const modelPath1 = modelPath0 ? `${P_BLOCK}/${modelPath0}` : '';
|
||||
|
||||
const texturePath0 = config.texture;
|
||||
const texturePath1 = texturePath0 ? `${P_BLOCK}/${texturePath0}` : '';
|
||||
|
||||
// 设置基础属性
|
||||
if (box) {
|
||||
if (blockBox) {
|
||||
setBlockProps(block, {
|
||||
boxConfig: box,
|
||||
boxConfig: blockBox,
|
||||
boxType: 'custom',
|
||||
displayName: label,
|
||||
displayName: blockLabel,
|
||||
isSolid: false,
|
||||
material: 'stone',
|
||||
modelPath: modelPath1 ? {
|
||||
blockName: blockName,
|
||||
blockNamespace: MOD_ID,
|
||||
filePath: modelPath1,
|
||||
} : null,
|
||||
renderType: 'cutout',
|
||||
textureAll: texturePath1,
|
||||
});
|
||||
} else {
|
||||
setBlockProps(block, {
|
||||
boxConfig: null,
|
||||
boxType: 'full',
|
||||
displayName: label,
|
||||
displayName: blockLabel,
|
||||
isSolid: true,
|
||||
material: 'stone',
|
||||
modelPath: modelPath1 ? {
|
||||
blockName: blockName,
|
||||
blockNamespace: MOD_ID,
|
||||
filePath: modelPath1,
|
||||
} : null,
|
||||
renderType: 'solid',
|
||||
textureAll: texturePath1,
|
||||
});
|
||||
}
|
||||
|
||||
// 设置模型或纹理文件路径
|
||||
if (mPath) {
|
||||
block.model(`${P_BLOCK}/${mPath}`);
|
||||
} else if (tPath) {
|
||||
block.textureAll(`${P_BLOCK}/${tPath}`);
|
||||
}
|
||||
|
||||
// 设置方块旋转
|
||||
if (config.orientable) {
|
||||
setHorizontalFacing(block, 'revert', `${P_BLOCK}/${mPath}`);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
console.info(`${LOG_PREFIX} 注册方块 - 其他 - 基础 - 完成`);
|
||||
@@ -1354,7 +1351,7 @@ function regBlockOtherBasic(event) {
|
||||
|
||||
/**
|
||||
* @description 注册方块 - 其他 - 特殊
|
||||
* @param {Registry.Block} event
|
||||
* @param {_RegistryBlock} event
|
||||
*/
|
||||
function regBlockOtherShaped(event) {
|
||||
|
||||
@@ -1389,13 +1386,10 @@ function regBlockOtherShaped(event) {
|
||||
// 设置基础属性
|
||||
setBlockProps(block, {
|
||||
displayName: config.label,
|
||||
material: 'stone',
|
||||
renderType: 'cutout_mipped',
|
||||
textureAll: config.texture,
|
||||
});
|
||||
|
||||
// 设置方块纹理
|
||||
block.textureAll(config.texture);
|
||||
|
||||
});
|
||||
|
||||
console.info(`${LOG_PREFIX} 注册方块 - 其他 - 特殊 - 完成`);
|
||||
@@ -1403,16 +1397,16 @@ function regBlockOtherShaped(event) {
|
||||
}
|
||||
|
||||
// 注册方块
|
||||
onEvent('block.registry', regBlockBrick);
|
||||
onEvent('block.registry', regBlockBuildingAndFurniture);
|
||||
onEvent('block.registry', regBlockColor);
|
||||
onEvent('block.registry', regBlockLampModern);
|
||||
onEvent('block.registry', regBlockLampSimple);
|
||||
onEvent('block.registry', regBlockMinecart);
|
||||
onEvent('block.registry', regBlockRoad);
|
||||
onEvent('block.registry', regBlockReinforcedConcrete);
|
||||
onEvent('block.registry', regBlockOtherBasic);
|
||||
onEvent('block.registry', regBlockOtherShaped);
|
||||
StartupEvents.registry('block', regBlockBrick);
|
||||
StartupEvents.registry('block', regBlockBuildingAndFurniture);
|
||||
StartupEvents.registry('block', regBlockColor);
|
||||
StartupEvents.registry('block', regBlockLampModern);
|
||||
StartupEvents.registry('block', regBlockLampSimple);
|
||||
StartupEvents.registry('block', regBlockMinecart);
|
||||
StartupEvents.registry('block', regBlockRoad);
|
||||
StartupEvents.registry('block', regBlockReinforcedConcrete);
|
||||
StartupEvents.registry('block', regBlockOtherBasic);
|
||||
StartupEvents.registry('block', regBlockOtherShaped);
|
||||
|
||||
// 注册物品
|
||||
// onEvent('item.registry', function (event) {
|
||||
|
||||
Reference in New Issue
Block a user