Skip to content

Commit

Permalink
适配1.21.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ENIACJushi committed Jun 15, 2024
1 parent 8ab06b0 commit 21af2de
Show file tree
Hide file tree
Showing 19 changed files with 80 additions and 71 deletions.
7 changes: 7 additions & 0 deletions Docs/TODO.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@

## 计划

适配1.21.0

- 为驯服函数 `.tame(Player)` 补充参数
- Player.selectedSlot 改为 Player.selectedSlotIndex;
- dimension.fillBlocks(Vector, Vector, bl) 改为 dimension.fillBlocks(BlockVolume, bl)

使用新版本的 .tame(Player) 和 tamedToPlayerId,实现不需要跟随式寻主的女仆驯服操作;
庭灯:可以存储P点、为附近的女仆提供buff,打掉之后P点会以lore的形式存储在物品之中(需要测试lore中是否能包含translate文本)
御币改为长按连发
* 扫帚,玩家坐上去之后视角向上按前进就可以飞,参考minecar的飞行矿车。
Expand Down
5 changes: 5 additions & 0 deletions Docs/update/changelog-server-github.url
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,11
[InternetShortcut]
IDList=
URL=https://github.com/MicrosoftDocs/minecraft-creator/commits/main/creator/ScriptAPI/minecraft/server/changelog.md
5 changes: 5 additions & 0 deletions Docs/update/changelog-server-ui.url
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,11
[InternetShortcut]
IDList=
URL=https://learn.microsoft.com/zh-cn/minecraft/creator/scriptapi/minecraft/server-ui/changelog
5 changes: 5 additions & 0 deletions Docs/update/changelog-server.url
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,11
[InternetShortcut]
IDList=
URL=https://learn.microsoft.com/zh-cn/minecraft/creator/scriptapi/minecraft/server/changelog
5 changes: 5 additions & 0 deletions Docs/update/npm-server-ui.url
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,11
[InternetShortcut]
IDList=
URL=https://www.npmjs.com/package/@minecraft/server-ui
5 changes: 5 additions & 0 deletions Docs/update/npm-server.url
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,11
[InternetShortcut]
IDList=
URL=https://www.npmjs.com/package/@minecraft/server
2 changes: 1 addition & 1 deletion Docs/发烟测试.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
10. 查看女仆信息,是否会回血;
11. `隐藏背包`,观察背包是否隐藏;
12. `显示背包`,观察背包是否显示;
13. 设置杀敌数,`升级女仆`,查看属性是否变化;
13. 设置杀敌数,`升级女仆`,查看属性是否变化; `/scriptevent thlm:admin setmkill:1000`
14.`照相机`拍照,再放下,再次检查女仆信息是否改变;
15. 手持`NPC工具`,将其转化为 NPC,
16. 试验`手办``雕塑`是否正常工作
Expand Down
8 changes: 4 additions & 4 deletions TouHouLittleMaid_BP/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"header": {
"name": "TouHou Little Maid BE",
"uuid": "fed26523-2c16-4560-9076-aff6ad49a1e3",
"version": [ 1, 2, 4 ],
"version": [ 1, 3, 0 ],
"description": "Author: ENIAC_Jushi",
"min_engine_version": [ 1, 20, 30 ]
},
Expand All @@ -13,18 +13,18 @@
"language": "javascript",
"uuid": "9439f1f5-116d-4f4a-8e23-9adc2b9d4721",
"entry": "scripts/index.js",
"version": [ 1, 2, 4 ]
"version": [ 1, 3, 0 ]
},
{
"type": "data",
"uuid": "f3249f90-9682-4b1a-a084-e111881b678f",
"version": [ 1, 2, 4 ]
"version": [ 1, 3, 0 ]
}
],
"dependencies": [
{
"module_name": "@minecraft/server",
"version": "1.11.0-beta"
"version": "1.12.0-beta"
},
{
"module_name": "@minecraft/server-ui",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class AltarStructureHelper extends MultiBlockStructrueManager{

// Place item then trigger craft event, pop item, or do nothing.
let container = player.getComponent("inventory").container;
let slot = player.selectedSlot;
let slot = player.selectedSlotIndex;
let itemStack = container.getItem(slot);
// There are no items on the platform.
if(itemEntity == null){
Expand Down
30 changes: 12 additions & 18 deletions TouHouLittleMaid_BP/scripts/src/blocks/GarageKit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ItemUseOnBeforeEvent, EquipmentSlot, Block, Direction, system, Dimension, Entity, ItemStack, DataDrivenEntityTriggerAfterEvent, BlockPermutation, Player } from "@minecraft/server";
import { ItemUseOnBeforeEvent, EquipmentSlot, Block, Direction, system, Dimension, Entity, ItemStack, DataDrivenEntityTriggerAfterEvent, BlockPermutation, Player, BlockVolume, BlockVolumeBase } from "@minecraft/server";
import { Vector } from "../libs/VectorMC";
import { StrMaid } from "../maid/StrMaid";
import { ActionbarMessage, getRandomInteger, logger, lore2Str, str2Lore, title_player_actionbar_object, title_player_actionbar_translate } from "../libs/ScarletToolKit";
Expand Down Expand Up @@ -113,10 +113,7 @@ export class GarageKit{
maid.teleport(maid.location, {"facingLocation":
new Vector(maid.location.x + facing[0], maid.location.y, maid.location.z + facing[1])});
// 占位方块
dimension.fillBlocks(
startLocation, startLocation,
blockGarageKit
)
dimension.fillBlocks(new BlockVolume(startLocation, startLocation), blockGarageKit);
}
// 生成雕塑
else{
Expand All @@ -137,10 +134,7 @@ export class GarageKit{
maid.teleport(maid.location, {"facingLocation":
new Vector(maid.location.x + facing[0], maid.location.y, maid.location.z + facing[1])});
// 占位方块
dimension.fillBlocks(
event.block.location, endLocation,
blockStatues
);
dimension.fillBlocks(new BlockVolume(event.block.location, endLocation), blockStatues);
}

let item = equippable.getEquipment(EquipmentSlot.Mainhand);
Expand Down Expand Up @@ -213,13 +207,13 @@ export class GarageKit{
)

// 使用fill,提高对大体积区域的检测速度
let amount = maid.dimension.fillBlocks(startLocation, endLocation, "minecraft:structure_void",
{"matchingBlock": BlockPermutation.resolve("minecraft:air")});
if(amount > 0){
maid.dimension.fillBlocks(startLocation, endLocation, "minecraft:air",
{"matchingBlock": BlockPermutation.resolve("minecraft:structure_void")});
maid.dimension.fillBlocks(startLocation, endLocation, "minecraft:clay",
{"matchingBlock": BlockPermutation.resolve(blockStatues)});
let statuesBlocks = maid.dimension.getBlocks(
new BlockVolume(startLocation, endLocation),
{"includeTypes": [blockStatues]},
true
);
if(statuesBlocks.getCapacity() < space.x*space.y*space.z){
maid.dimension.fillBlocks(statuesBlocks, "minecraft:clay");
EntityMaid.despawn(maid);
}
}; break;
Expand Down Expand Up @@ -290,7 +284,7 @@ export class GarageKit{
let rotation = player.getRotation();

// 放置方块
dimension.fillBlocks(location, location,
dimension.fillBlocks(new BlockVolume(location, location),
BlockPermutation.resolve(blockGarageKit, {"thlm:solid": true}));

///// 放置实体 /////
Expand Down Expand Up @@ -328,7 +322,7 @@ export class GarageKit{

// 消耗物品
let container = player.getComponent("inventory").container;
let slot = player.selectedSlot;
let slot = player.selectedSlotIndex;
if(event.itemStack.amount===1){
container.setItem(slot);
}
Expand Down
6 changes: 3 additions & 3 deletions TouHouLittleMaid_BP/scripts/src/blocks/GoldMicrowaver.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Direction, Block, BlockPermutation, Dimension, ItemUseOnBeforeEvent, DataDrivenEntityTriggerAfterEvent, Entity, ItemStack, Player } from "@minecraft/server";
import { Direction, Block, BlockPermutation, Dimension, ItemUseOnBeforeEvent, DataDrivenEntityTriggerAfterEvent, Entity, ItemStack, Player, BlockVolume } from "@minecraft/server";
import { VectorMC } from "../libs/VectorMC";
import { logger, getPlayerMainHand, setPlayerMainHand } from "../libs/ScarletToolKit";

Expand Down Expand Up @@ -249,7 +249,7 @@ export class GoldMicrowaver{
}

// 放置方块
dimension.fillBlocks(location, location,
dimension.fillBlocks(new BlockVolume(location, location),
BlockPermutation.resolve("touhou_little_maid:gold_microwaver",
{"thlm:direction":directionNum, "thlm:door":false, "thlm:item":0, "thlm:status":false}));

Expand All @@ -261,7 +261,7 @@ export class GoldMicrowaver{

// 消耗物品
let container = player.getComponent("inventory").container;
let slot = player.selectedSlot;
let slot = player.selectedSlotIndex;
if(event.itemStack.amount===1){
container.setItem(slot);
}
Expand Down
26 changes: 13 additions & 13 deletions TouHouLittleMaid_BP/scripts/src/controller/Command.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ export class CommandManager{
"touhou_little_maid:camera",
"touhou_little_maid:chisel",
"minecraft:clay",
"minecraft:flint_and_stell",
"minecraft:flint_and_steel",
"minecraft:netherrack",
// "touhou_little_maid:film",
// "touhou_little_maid:garage_kit",
Expand Down Expand Up @@ -324,18 +324,18 @@ export class CommandManager{
}
pl.sendMessage(info);
}
let blockInv = block.getComponent(BlockComponentTypes.Inventory);
if(blockInv !== undefined){
let container = blockInv.container;
if(container !== undefined){
for(let i = 0; i < container.size; i++){
let item = container.getItem(i);
if(item !== undefined){
Tool.logger(`${item.typeId} ${item.amount}`);
}
}
}
}
// let blockInv = block.getComponent(BlockComponentTypes.Inventory);
// if(blockInv !== undefined){
// let container = blockInv.container;
// if(container !== undefined){
// for(let i = 0; i < container.size; i++){
// let item = container.getItem(i);
// if(item !== undefined){
// Tool.logger(`${item.typeId} ${item.amount}`);
// }
// }
// }
// }
// 手持物品
let item = Tool.getPlayerMainHand(pl);
if(item!==undefined) pl.sendMessage(`item: ${item.typeId}`);
Expand Down
4 changes: 2 additions & 2 deletions TouHouLittleMaid_BP/scripts/src/danmaku/DanmakuManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ const GoheiDefault = DanmakuType.PELLET;
export function gohei_activate(ev){
try{
let pl = ev.source;
let slot = pl.selectedSlot
let slot = pl.selectedSlotIndex
let container = pl.getComponent("inventory").container;
let item = container.getItem(slot);

Expand Down Expand Up @@ -185,7 +185,7 @@ export function gohei_transform(ev, danmakuName){

// Set item
let player = ev.source;
player.getComponent("inventory").container.setItem(player.selectedSlot, itemStack);
player.getComponent("inventory").container.setItem(player.selectedSlotIndex, itemStack);

// Send message
player.sendMessage({rawtext:[{translate: "message.touhou_little_maid:hakurei_gohei.switch"}, {translate: `danmaku.${DanmakuType.getName(GoheiSequence[index])}.name`}]});
Expand Down
5 changes: 3 additions & 2 deletions TouHouLittleMaid_BP/scripts/src/libs/scarletToolKit.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ export function pointInArea_3D(x,y,z,areaStart_x,areaStart_y,areaStart_z,areaEnd
*/
export function getPlayerMainHand(player){
let container = player.getComponent("inventory").container;
let slot = player.selectedSlot;
let slot = player.selectedSlotIndex;
// pl.getComponent("equippable").getEquipment(EquipmentSlot.Mainhand);
return container.getItem(slot);
}
/**
Expand All @@ -132,7 +133,7 @@ export function getPlayerMainHand(player){
*/
export function setPlayerMainHand(player, item=undefined){
let container = player.getComponent("inventory").container;
let slot = player.selectedSlot;
let slot = player.selectedSlotIndex;
if(item===undefined){
container.setItem(slot);
}
Expand Down
26 changes: 4 additions & 22 deletions TouHouLittleMaid_BP/scripts/src/maid/MaidManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,18 +282,9 @@ export class MaidManager{
// 消耗照片
Tool.setPlayerMainHand(event.source);

// 如果最近的玩家是主人,直接设置主人
// 设置主人
system.runTimeout(()=>{
let closestPlayer = dimension.getPlayers({"closest":1, "location": location})[0];
if(closestPlayer.id === player.id){
maid.getComponent("tameable").tame();
}
// 否则给予玩家一个苹果,自己驯服
else{
let apple = new ItemStack("minecraft:apple", 1);
apple.nameTag="§cApple!"
event.source.dimension.spawnItem(apple, event.source.location);
}
maid.getComponent("tameable").tame(event.source);
}, 1);

}
Expand Down Expand Up @@ -349,18 +340,9 @@ export class MaidManager{
// 转换物品
Tool.setPlayerMainHand(event.source, new ItemStack("touhou_little_maid:smart_slab_empty", 1));

// 设置主人
system.runTimeout(()=>{
// 如果最近的玩家是主人,直接设置主人
let closestPlayer = dimension.getPlayers({"closest":1, "location": location})[0];
if(closestPlayer.id === player.id){
maid.getComponent("tameable").tame();
}
// 否则给予玩家一个苹果,自己驯服
else{
let apple = new ItemStack("minecraft:apple", 1);
apple.nameTag="§cApple!"
event.source.dimension.spawnItem(apple, event.source.location);
}
maid.getComponent("tameable").tame(event.source);
}, 1);
}
/**
Expand Down
2 changes: 1 addition & 1 deletion TouHouLittleMaid_BP/scripts/src/maid/MaidTarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ export class Farm{
SpeedController.afterSearch(maid, count, Farm.maxLack, Farm.minCount);
}
function* newSearchJob(){
let areaLength = range*2+1;
let areaLength = range*2+2;
let searchMatrix = new Array(areaLength);
for(let i = 0; i < areaLength; i++){
searchMatrix[i] = new Array(areaLength).fill(false)
Expand Down
4 changes: 2 additions & 2 deletions TouHouLittleMaid_RP/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"name": "TouHou Little Maid BE",
"description": "Author: ENIAC_Jushi",
"uuid": "919b50d9-d6ab-40bb-828d-9e2f40f664a5",
"version": [ 1, 2, 4 ],
"version": [ 1, 3, 0 ],
"min_engine_version": [ 1, 20, 30 ]
},
"modules": [
{
"type": "resources",
"uuid": "8edf11fe-0a52-4481-ae27-1cc206a01919",
"version": [ 1, 2, 4 ]
"version": [ 1, 3, 0 ]
}
],
"dependencies": [
Expand Down
2 changes: 1 addition & 1 deletion TouHouLittleMaid_RP/texts/en_us.lang
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
message.tlm.player_join1=§e[TLM] Touhou Little Maid 1.2.4
message.tlm.player_join1=§e[TLM] Touhou Little Maid 1.3.0
message.tlm.player_join2=§e Visit mcmod.cn for complete tutorial.

##### UI #####
Expand Down
2 changes: 1 addition & 1 deletion TouHouLittleMaid_RP/texts/zh_CN.lang
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
message.tlm.player_join1=§e[TLM] 车万女仆 1.2.4
message.tlm.player_join1=§e[TLM] 车万女仆 1.3.0
message.tlm.player_join2=§e 访问 mcmod.cn 获取全部教程。

##### UI #####
Expand Down

0 comments on commit 21af2de

Please sign in to comment.