Skip to content

Commit

Permalink
gamerule playerssleepingpercentage
Browse files Browse the repository at this point in the history
  • Loading branch information
xBoyMinemc committed May 20, 2024
1 parent 400c4b2 commit 0caa362
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 33 deletions.
12 changes: 6 additions & 6 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"format_version": 2,
"header": {
"name": "§t1.20.60 v1 §e§lFlash§fFakePlayerPack",
"description": "凑合也能用】1.20.60 \n开启实验性游戏内容(测试版 API)-游戏内输入“假人帮助”或“假人创建” 对着假人右键(蹲或不蹲两个菜单) ,当前版本充满了可能有的bug,还请凑活 无关QQ群:122957051:",
"name": "§t1.20.80 v1 §e§lFlash§fFakePlayerPack",
"description": "适配】1.20.80 \n开启实验性游戏内容(测试版 API)-游戏内输入“假人帮助”或“假人创建” 对着假人右键(蹲或不蹲两个菜单) ,当前版本充满了可能有的bug,还请凑活 无关QQ群:122957051:",
"uuid": "aa101e99-abb4-448d-b58f-71e9da43064e",
"version": [
1,
20,
601
801
],
"min_engine_version": [
1,
20,
60
80
]
},
"modules": [
{
"version": [
1,
20,
601
801
],
"type": "script",
"uuid": "10101e99-abc1-5488-ba76-71e9da441300",
Expand All @@ -31,7 +31,7 @@
"dependencies": [
{
"module_name": "@minecraft/server",
"version": "1.9.0-beta"
"version": "1.11.0-beta"
},
{
"module_name": "@minecraft/server-gametest",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
},
"dependencies": {
"@minecraft/common": "^1.1.0",
"@minecraft/server": "^1.9.0-beta.1.20.60-stable",
"@minecraft/server": "^1.11.0-beta.1.20.80-stable",
"@minecraft/server-gametest": "^1.0.0-beta.1.20.50-stable",
"@minecraft/server-ui": "^1.2.0-beta.1.20.50-stable",
"@minecraft/vanilla-data": "^1.20.80",
"archiver": "^6.0.1"
}
}
6 changes: 3 additions & 3 deletions packer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const fs = require('fs');
const archiver = require('archiver');


const pkNew = '万人血书版'
const mcVersion = [1,20,60];
const pkNew = '适配'
const mcVersion = [1,20,80];
const pkVersion = 1


Expand Down Expand Up @@ -41,7 +41,7 @@ const manifest_json = {
"dependencies": [
{
"module_name": "@minecraft/server",
"version": "1.9.0-beta"
"version": "1.11.0-beta"
},
{
"module_name": "@minecraft/server-gametest",
Expand Down
5 changes: 3 additions & 2 deletions scripts/xTerrain/plugins/breakBlock.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SimulatedPlayerEnum, testWorldLocation } from '../main';
import { CommandRegistry } from '../../lib/yumeCommand/CommandRegistry';
import { getSimPlayer } from '../../lib/xboyPackage/Util';
import { world, system, Vector } from "@minecraft/server";
import { world, system } from "@minecraft/server";
export const BreakBlockSimulatedPlayerList = new Set();
const commandRegistry = new CommandRegistry();
const noArgs = ({ args, entity, isEntity }) => {
Expand All @@ -23,11 +23,12 @@ world.afterEvents.chatSend.subscribe(({ message, sender }) => {
sender.sendMessage(commandRegistry.showList().toString());
}
});
const Vector_subtract = ({ x, y, z }, { x: u, y: v, z: w }) => ({ x: x - u, y: y - v, z: z - w });
const breaks = () => {
BreakBlockSimulatedPlayerList.forEach((simIndex) => {
const blockLocation = SimulatedPlayerEnum[simIndex].getBlockFromViewDirection({ maxDistance: 4 })?.block?.location;
if (blockLocation)
SimulatedPlayerEnum[simIndex].breakBlock(Vector.subtract(blockLocation, testWorldLocation));
SimulatedPlayerEnum[simIndex].breakBlock(Vector_subtract(blockLocation, testWorldLocation));
});
};
system.runInterval(breaks, 0);
6 changes: 3 additions & 3 deletions scripts/xTerrain/plugins/task.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { SimulatedPlayerEnum, testWorldLocation } from '../main';
import SIGN from '../../lib/xboyPackage/YumeSignEnum';
import { system, world, Vector } from '@minecraft/server';
import { system, world } from '@minecraft/server';
import { getEntitiesNear, getPlayerNear } from '../../lib/xboyPackage/Util';
const SimulatedPlayerStates = {};
const Vector_subtract = ({ x, y, z }, { x: u, y: v, z: w }) => ({ x: x - u, y: y - v, z: z - w });
function AUTO_BEHAVIOR() {
let SimulatedPlayerCount = 0;
const AllPlayerCount = world.getAllPlayers().length;
Expand Down Expand Up @@ -41,7 +42,7 @@ function AUTO_BEHAVIOR() {
SimulatedPlayerStates[SimPlayer.id]["o"] || (SimulatedPlayerStates[SimPlayer.id]["o"] = SimPlayer.location);
const r = (x, _x, v) => x - _x > v || x - _x < -v;
const r3 = (o, _o, v) => o.x - _o.x > v || o.x - _o.x < -v || o.y - _o.y > v || o.y - _o.y < -v || o.z - _o.z > v || o.z - _o.z < -v;
const fix = (location) => Vector.subtract(location, testWorldLocation);
const fix = (location) => Vector_subtract(location, testWorldLocation);
if (entities.length > 0) {
const target = entities[0];
if (!r3(target.location, SimPlayer.location, 4)) {
Expand All @@ -56,6 +57,5 @@ function AUTO_BEHAVIOR() {
}
}
}
SimulatedPlayerCount && world.getDimension('minecraft:overworld').runCommand('gamerule playerssleepingpercentage ' + Math.floor(100 * SimulatedPlayerCount / AllPlayerCount));
}
system.runInterval(AUTO_BEHAVIOR, 0);
7 changes: 2 additions & 5 deletions tscripts/xTerrain/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import type {
initializedEventSignal,
spawnedEvent,
spawnedEventSignal,
World
} from '../@types/globalThis'
import type { Dimension, Vector3 } from '@minecraft/server'

import { register } from '@minecraft/server-gametest'


import verify from '../lib/xboyPackage/scoreBase/verifyDataBase'
import ScoreBase from '../lib/xboyPackage/scoreBase/rw'
import EventSignal from '../lib/xboyEvents/EventSignal'

import { SIGN } from '../lib/xboyPackage/YumeSignEnum'
Expand All @@ -30,7 +28,7 @@ import './plugins/gui'
import './plugins/autoFishing'
import './plugins/killedBySimPlayer'
import './plugins/setting'
import {playerMove} from "../lib/xboyEvents/move";
import { playerMove } from "../lib/xboyEvents/move";


const overworld = world.getDimension('overworld')
Expand Down Expand Up @@ -211,5 +209,4 @@ playerMove.subscribe(init)
// // world.events.reloadFromCmd.unsubscribe(reload)
// }
// world.events.reloadFromCmd.subscribe(()=>reload())
// export function a(){console.error('a一次') }
//写一个100次的for循环
// export function a(){console.error('a一次') }
13 changes: 3 additions & 10 deletions tscripts/xTerrain/plugins/breakBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '../main'
import { CommandRegistry } from '../../lib/yumeCommand/CommandRegistry'
import { getSimPlayer } from '../../lib/xboyPackage/Util'
import { world, system, Vector } from "@minecraft/server"
import { world, system, Vector3 } from "@minecraft/server"


export const BreakBlockSimulatedPlayerList:Set<string> = new Set()
Expand Down Expand Up @@ -46,21 +46,14 @@ world.afterEvents.chatSend.subscribe(({message, sender})=>{
}
})

const Vector_subtract = ({x,y,z}:Vector3, {x:u,y:v,z:w}:Vector3)=>({x:x-u,y:y-v,z:z-w})

// task
const breaks = ()=>{
// TEST
// for (let simulatedPlayerListKey in SimulatedPlayerList) {
//
// const blockLocation = SimulatedPlayerList[simulatedPlayerListKey].getBlockFromViewDirection({maxDistance: 4})?.block?.location
// if (blockLocation)
// SimulatedPlayerList[simulatedPlayerListKey].breakBlock(Vector.subtract(blockLocation, testWorldLocation))
//
// }
BreakBlockSimulatedPlayerList.forEach((simIndex)=> {
const blockLocation = SimulatedPlayerEnum[simIndex].getBlockFromViewDirection({maxDistance: 4})?.block?.location
if (blockLocation)
SimulatedPlayerEnum[simIndex].breakBlock(Vector.subtract(blockLocation, testWorldLocation))
SimulatedPlayerEnum[simIndex].breakBlock(Vector_subtract(blockLocation, testWorldLocation))
})
}
system.runInterval(breaks,0)
Expand Down
7 changes: 4 additions & 3 deletions tscripts/xTerrain/plugins/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import type { SimulatedPlayer } from '@minecraft/server-gametest'
import {SimulatedPlayerEnum, testWorldLocation} from '../main'
import SIGN from '../../lib/xboyPackage/YumeSignEnum'
import type { EntityHealthComponent, Vector3 } from '@minecraft/server'
import { system, world, Vector } from '@minecraft/server'
import { system, world } from '@minecraft/server'
import { getEntitiesNear, getPlayerNear } from '../../lib/xboyPackage/Util'

// @ts-ignore
const SimulatedPlayerStates : ({ "str-SimPlayer.id": { o: Vector3 }}) = {}

const Vector_subtract = ({x,y,z}:Vector3, {x:u,y:v,z:w}:Vector3)=>({x:x-u,y:y-v,z:z-w})
// behavior
function AUTO_BEHAVIOR(){

Expand Down Expand Up @@ -58,7 +59,7 @@ function AUTO_BEHAVIOR(){
const r = (x:number,_x:number,v:number)=>x-_x>v||x-_x<-v
const r3 = (o:Vector3,_o:Vector3,v:number)=>o.x-_o.x>v||o.x-_o.x<-v || o.y-_o.y>v||o.y-_o.y<-v || o.z-_o.z>v||o.z-_o.z<-v
// const fix = (o:Vector3)=>({x:o.x-30000000+1,y:o.y,z:o.z-3})
const fix = (location:Vector3)=>Vector.subtract(location, testWorldLocation)
const fix = (location:Vector3)=>Vector_subtract(location, testWorldLocation)
// && r3(SimulatedPlayerStates[SimPlayer]["o"],SimPlayer.location,16)
if(entities.length>0 ){

Expand All @@ -81,7 +82,7 @@ function AUTO_BEHAVIOR(){
}

// /gamerule playerssleepingpercentage 50%
SimulatedPlayerCount && world.getDimension('minecraft:overworld').runCommand('gamerule playerssleepingpercentage '+Math.floor(100*SimulatedPlayerCount/AllPlayerCount))
// SimulatedPlayerCount && world.getDimension('minecraft:overworld').runCommand('gamerule playerssleepingpercentage '+Math.floor(100*SimulatedPlayerCount/AllPlayerCount))
}

system.runInterval(AUTO_BEHAVIOR,0)
Expand Down

0 comments on commit 0caa362

Please sign in to comment.