refactor(project): support probejs v7.0

This commit is contained in:
2025-12-17 13:15:26 +08:00
parent f7d8b7b7b0
commit 39865e058d
6 changed files with 24 additions and 22 deletions

View File

@@ -9,18 +9,6 @@
"noImplicitAny": true, "noImplicitAny": true,
"esModuleInterop": true, "esModuleInterop": true,
"moduleResolution": "bundler", "moduleResolution": "bundler",
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true
"rootDirs": [ }
"src/server_scripts",
"src/startup_scripts",
"src/client_scripts",
"src/lib"
],
"typeRoots": [
"./types/probe/user",
"./types/probe/generated",
"./types/probe/generated/internals"
]
},
"include": ["./src/**/*.js", "./types/**/*.d.ts"]
} }

View File

@@ -0,0 +1,5 @@
{
"block.kubejs.c4_target": "C4 Target Block",
"block.kubejs.c4": "C4",
"item.kubejs.c4_item": "C4"
}

View File

@@ -0,0 +1,5 @@
{
"block.kubejs.c4_target": "C4 Target Block",
"block.kubejs.c4": "C4",
"item.kubejs.c4_item": "C4"
}

View File

@@ -158,8 +158,7 @@ StartupEvents.registry("block", (event) => {
.create("c4_target") // Create a new block .create("c4_target") // Create a new block
.soundType(SoundType.WOOD) // Set a material (affects the sounds and some properties) .soundType(SoundType.WOOD) // Set a material (affects the sounds and some properties)
.unbreakable() .unbreakable()
.textureAll("minecraft:block/target_top") .textureAll("minecraft:block/target_top");
.displayName(/** @type {any} */ ("C4 Target Block")); // Set a custom name
}); });
StartupEvents.registry("block", (event) => { StartupEvents.registry("block", (event) => {
@@ -171,8 +170,7 @@ StartupEvents.registry("block", (event) => {
.noItem() // Player cannot hold or place the item .noItem() // Player cannot hold or place the item
.noDrops() .noDrops()
.noCollision() // Set no hitbox .noCollision() // Set no hitbox
.textureAll("minecraft:block/tnt_top") .textureAll("minecraft:block/tnt_top");
.displayName(/** @type {any} */ ("C4")); // Set a custom name
}); });
// ==================== Item Registration ==================== // ==================== Item Registration ====================
@@ -231,8 +229,7 @@ StartupEvents.registry("item", (event) => {
itemstack.resetHoverName(); itemstack.resetHoverName();
if (!entity.isPlayer() || entity.uuid === undefined) return; if (!entity.isPlayer() || entity.uuid === undefined) return;
delete lastPlayerInfoMap[entity.uuid.toString()]; delete lastPlayerInfoMap[entity.uuid.toString()];
}) });
.displayName(/** @type {any} */ ("C4"));
}); });
// ==================== Client Side Logic ==================== // ==================== Client Side Logic ====================
@@ -346,7 +343,7 @@ function handleC4UseStarted(event) {
* @param {C4ActivatedEvent} event * @param {C4ActivatedEvent} event
*/ */
function handleC4Activated(event) { function handleC4Activated(event) {
const server = Utils.server; const server = Utils.getServer();
if (server === null) { if (server === null) {
console.error("C4 Handler: Server is not available"); console.error("C4 Handler: Server is not available");
return; return;

View File

@@ -0,0 +1,8 @@
{
"$schema": "https://www.schemastore.org/jsconfig.json",
"extends": "../../jsconfig.json",
"compilerOptions": {
"typeRoots": ["../../types/probe/startup/probe-types/"]
},
"include": ["./**/*", "../../types/*.d.ts"]
}

1
types/EventBus.d.ts vendored
View File

@@ -10,7 +10,6 @@ interface C4UseStartedEvent {
*/ */
interface C4ActivatedEvent { interface C4ActivatedEvent {
level: Internal.Level; level: Internal.Level;
blockPos: { x: number; y: number; z: number };
player: Internal.Player; player: Internal.Player;
explosionTime: number; explosionTime: number;
explosionPower: number; explosionPower: number;