Skip to content

Commit

Permalink
auto flash
Browse files Browse the repository at this point in the history
  • Loading branch information
xBoyMinemc committed Sep 2, 2023
1 parent e97af73 commit 89d047b
Show file tree
Hide file tree
Showing 28 changed files with 2,346 additions and 257 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/qodana_code_quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Qodana
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
- 1.20.13-code-rewriting

jobs:
qodana:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: 'Qodana Scan'
uses: JetBrains/[email protected]
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
50 changes: 46 additions & 4 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 0 additions & 69 deletions entities/#U4e00#U53ea#U591c#U7a7a.json

This file was deleted.

2 changes: 1 addition & 1 deletion entities/ceyk.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"minecraft:fire_immune": true,
"minecraft:inventory": {
"inventory_size": 1048576,
"inventory_size": 91000,
"container_type": "container"
// "restrict_to_owner": true
},
Expand Down
29 changes: 29 additions & 0 deletions qodana.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#-------------------------------------------------------------------------------#
# Qodana analysis is configured by qodana.yaml file #
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
#-------------------------------------------------------------------------------#
version: "1.0"

#Specify inspection profile for code analysis
profile:
name: qodana.starter

#Enable inspections
#include:
# - name: <SomeEnabledInspectionId>

#Disable inspections
#exclude:
# - name: <SomeDisabledInspectionId>
# paths:
# - <path/where/not/run/inspection>

#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
#bootstrap: sh ./prepare-qodana.sh

#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
#plugins:
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)

#Specify Qodana linter for analysis (Applied in CI/CD pipeline)
linter: jetbrains/qodana-js:latest
4 changes: 4 additions & 0 deletions scripts/lib/PureEval.es.curry.min.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// src/summon.js
const summon = (total, fn) => {
const summoner = (...args) => fn.apply(null, args);
Reflect.defineProperty(summoner, "length", { value: total });
return summoner;
};
// src/curry.js
const curry = (fun) => {
if (fun.length < 2 || fun.origin)
return fun;
Expand All @@ -12,3 +14,5 @@ const curry = (fun) => {
};
const uncurry = (fun) => fun.origin;
export default curry;
// const a =(x:number,y:string,z:object) : number=>1
// const b = curry(a)
5 changes: 5 additions & 0 deletions scripts/lib/xboyEvents/entityDeadByHurt.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ const entityDeadByHurt = new EventSignal();
world.events.entityHurt.subscribe(event => event.hurtEntity.getComponent("minecraft:health")["current"] <= 0
? entityDeadByHurt.trigger(event)
: 0);
/*
const test = (event)=>event.hurtEntity.dimension.runCommandAsync("me "+(event.hurtEntity.nameTag === '' ? event.hurtEntity.typeId : event.hurtEntity.nameTag)+"#x=>"+event.hurtEntity.location.x+"#y=>"+event.hurtEntity.location.y+"#z=>"+event.hurtEntity.location.z +"被杀死"+"\u000a触发自事件world.events.entityDeadByHurt" )
entityDeadByHurt.subscribe(event=>test(event))
*/
export default entityDeadByHurt;
37 changes: 35 additions & 2 deletions scripts/lib/xboyEvents/fishingHookSpawned.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,28 @@ const queue = {
};
world.events.itemUse.subscribe((event) => {
event.itemStack.typeId === "minecraft:fishing_rod"
? (queue.playerFishingArray.push(event.source)) : 0;
? (
// world.getDimension("overworld").runCommandAsync("tell @a[tag=xboy] queue.playerFishingArray.push(event.source)=>"+queue.playerFishingArray.push(event.source)),
// world.getDimension("overworld").runCommandAsync("tell @a[tag=xboy] queue.fishingHookDespawned_HookArray=>"+queue.fishingHookDespawned_HookArray.size)
queue.playerFishingArray.push(event.source)) : 0;
});
const around = (v, r) => v > -r && v < r;
world.events.entitySpawn.subscribe(({ entity: entity }) => {
// world.getDimension("overworld").runCommandAsync("tell @a[tag=xboy] size fishingHookDespawned_HookArray=>"+queue.fishingHookDespawned_HookArray.size)
// entity.runCommandAsync("me "+entity.typeId)
// entity.runCommandAsync("tell @a[tag=xboy] length playerFishingArray "+queue.playerFishingArray.length)
let Fisher;
try {
entity?.typeId === "minecraft:fishing_hook"
?
((Fisher = queue.playerFishingArray.find(playerFishing => around(entity.location.x - playerFishing.location.x - playerFishing.getVelocity().x, 3)
((Fisher = queue.playerFishingArray.find(playerFishing =>
// (
// entity.runCommandAsync("tell @a[tag=xboy] length x "+(entity.location.x - playerFishing.location.x - playerFishing.getVelocity().x)),
// entity.runCommandAsync("tell @a[tag=xboy] length y "+(entity.location.y - playerFishing.location.y - playerFishing.getVelocity().y)),
// entity.runCommandAsync("tell @a[tag=xboy] length z "+(entity.location.z - playerFishing.location.z - playerFishing.getVelocity().z)),
// entity.runCommandAsync("tell @a[tag=xboy] ==========================================")
// ) &&
around(entity.location.x - playerFishing.location.x - playerFishing.getVelocity().x, 3) // @ts-ignore
&& around(entity.location.y - playerFishing.location.y - playerFishing.getVelocity().y, ("你问我0.08哪里来的我就杀了你", "你问我为什么在这里code shit我还是会杀了你", 3))
&& around(entity.location.z - playerFishing.location.z - playerFishing.getVelocity().z, 3)))
?
Expand All @@ -28,13 +41,33 @@ world.events.entitySpawn.subscribe(({ entity: entity }) => {
0;
}
catch (error) {
// world.getDimension("overworld").runCommandAsync("tell @a[tag=xboy] error"+error)
// world.getDimension("overworld").runCommandAsync("tell @a[tag=xboy] lifetimeState"+entity.location)
// world.getDimension("overworld").runCommandAsync("tell @a[tag=xboy] error"+entity.dimension.id)
}
});
world.events.tick.subscribe((t) => {
//这里清空干嘛的
// queue.playerFishingArray = [];
queue.fishingHookDespawned_TickArray.length ? queue.fishingHookDespawned_TickArray.pop()() : 0;
const fishingHookArray = Array.from(world.getDimension("overworld").getEntities({ type: "minecraft:fishing_hook" }));
const HookIdArray = fishingHookArray.map(Hook => Hook.id);
// queue.fishingHookDespawned_HookArray.forEach((Fisher,HookId)=>console.error(Fisher,HookId)) //TEST
queue.fishingHookDespawned_HookArray.forEach((Fisher, HookId) => HookIdArray.includes(HookId) ? 0 : (fishingHookDespawned.trigger({ HookId: HookId, Fisher: Fisher, fishingHookDespawned_TickArray: queue.fishingHookDespawned_TickArray }), queue.fishingHookDespawned_HookArray.delete(HookId)));
//写完感觉效率逆天,但想了想,能够有几个钩子,这又不是海鲜市场,满池子钩子里没有一 滴水
});
/*
*/
console.error(("#########"));
// fishingHookSpawned.subscribe(event=>{
// console.error("fishingHookSpawned")
// world.getDimension("overworld").runCommandAsync("me ##鱼钩生成\u000a鱼钩id=>"+event.HookId+"\u000a发起者id=>"+event.Fisher.id);
// })
//
// console.error(("#########"))
// fishingHookDespawned.subscribe(event=>{
// console.error("fishingHookDespawned")
// world.getDimension("overworld").runCommandAsync("me ##鱼钩销毁\u000a鱼钩id=>"+event.HookId+"\u000a发起者id=>"+event.Fisher.id);
// // 工具人们.forEach(_=> _==undefined?0:_.id===event.Fisher.id?event.fishingHookDespawned_TickArray.push(()=>(_.useItemInSlot(0)?_.stopUsingItem():0)):0)
// })
export { fishingHookSpawned, fishingHookDespawned };
1 change: 1 addition & 0 deletions scripts/lib/xboyEvents/preload.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import "./tick";
// ################preload################
import("./index.js");
7 changes: 7 additions & 0 deletions scripts/lib/xboyEvents/reloadFromCmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,16 @@ world.events.playerJoin.subscribe(event => reloadFromCmd.players.add(event.playe
world.events.playerLeave.subscribe(event => reloadFromCmd.players.delete(event.playerId));
world.events.tick.subscribe(() => {
const onlinePlayers = world.getAllPlayers();
//
if (reloadFromCmd.players.size !== onlinePlayers.length || !onlinePlayers.every((_) => reloadFromCmd.players.has(_.id))) {
reloadFromCmd.trigger(null);
reloadFromCmd.restart();
}
});
/*
world.events.reloadFromCmd.subscribe(()=>{
console.error("你没事reload干嘛呢?")
})
*/
export default reloadFromCmd;
7 changes: 7 additions & 0 deletions scripts/lib/xboyEvents/tick.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
/// <reference path="../../@types/globalThis.d.ts" />
import { system } from "@minecraft/server";
import EventSignal from "./EventSignal";
const tick = new EventSignal();
world.events.tick = tick;
system.runInterval(() => world.events.tick.trigger(null), 1);
/*
world.events.tick.subscribe(()=>{
world.getDimension("overworld").runCommandAsync("say world.events.tick.subscribe suc")
})
*/
// export default tick
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const Events = {
dataDrivenEntityTriggerEvent: af.dataDrivenEntityTriggerEvent,
effectAdd: af.effectAdd,
entityDie: af.entityDie,
// entityHit: af.entityHit, // pupupu 裂开
entityHit: af.entityHitBlock,
entityHitEntity: af.entityHitEntity,
entityHitBlock: af.entityHitBlock,
Expand All @@ -69,6 +70,7 @@ export const Events = {
itemStopUseOn: af.itemStopUseOn,
itemUse: af.itemUse,
itemUseOn: af.itemUseOn,
// leverActivate: af.leverActivate,//有*?
leverActivate: af.leverAction,
messageReceive: af.messageReceive,
pistonActivate: af.pistonActivate,
Expand All @@ -83,6 +85,9 @@ export const Events = {
weatherChange: af.weatherChange,
worldInitialize: af.worldInitialize,
};
//不会写
// @ts-ignore
globalThis.world = Object.assign(_world, { events: Events });
// globalThis.GameTest = {"register":register};
globalThis.Location = Location;
globalThis.BlockLocation = BlockLocation;
Loading

0 comments on commit 89d047b

Please sign in to comment.