最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

[MCBE] 紅包/抽獎系統(tǒng) (微信紅包算法)

2023-02-19 12:39 作者:bili_414576228  | 我要投稿

///提醒: 此指令系統(tǒng)不是隨隨便便粘貼復制就能做成的,您需要擁有一定的指令與數(shù)學基礎。

///使用之前,先確保你有一個名為Redpacket的記分板或著其他名字的記分板(需要把指令中大寫的"Redpacket"改成記分板名)。


1鏈: times≥2時random算法

/scoreboard players test times Redpacket 2 *

RU

/scoreboard players test random Redpacket 0 0

CC

/scoreboard players random random Redpacket 1 2147483647

CC

/scoreboard players operation operation Redpacket = int Redpacket

CC

/scoreboard players operation operation Redpacket /= times Redpacket

CC

/scoreboard players operation operation Redpacket *= 2x Redpacket

CC

/scoreboard players operation random Redpacket %= operation Redpacket

CC

/scoreboard players test random Redpacket 1 *

CC

/scoreboard players operation int Redpacket -= random Redpacket

CC

/scoreboard players remove times Redpacket 1

CC


2鏈: times=1取int余數(shù)

/scoreboard players test times Redpacket 1 1

RU

/scoreboard players test random Redpacket 0 0

CC

/scoreboard players operation random Redpacket >< int Redpacket

CC

/scoreboard players set times Redpacket 0

CC


///int為輸入值,times為次數(shù),random值為輸出值

///算法講解

--/如果random=0,times≥2,在2^31-1整數(shù)極限中取random值,計算(int/times)*2值作為operation范圍,random/operation取余數(shù),若余數(shù)大于0則輸出。

--/如果random=0,times=1,將int與random對調并將times重置至0。


3鏈: 紅包接受機制

///可自定義。僅作參考。

/scoreboard players add @a Redpacket 0

RU

/scoreboard players test times Redpacket 1 *

CU

/titleraw @a[scores={Redpacket=0}] actionbar {"rawtext":[{"text":"§c§l新的紅包待領取!\n§e抬頭以搶紅包!"}]}

CC

/scoreboard players test times Redpacket 1 *

CU

/execute @a[scores={Redpacket=0},c=1,rx=-89] ~~~ tellraw @a {"rawtext":[{"text":"§l§e>>>§d "},{"selector":"@a[scores={Redpacket=0},c=1,rx=-89]"},{"text":" §e抽到了§6 "},{"score":{"name":"random","objective":"Redpacket"}},{"text":" §e個鉆石!"}]}

CC

/scoreboard players set @a[scores={Redpacket=0},c=1,rx=-89] Redpacket 1000

CC

/scoreboard players operation @a[scores={Redpacket=1000},c=1,rx=-89] Redpacket += random Redpacket

CC

/scoreboard players set random Redpacket 0

CC

/execute @a[scores={Redpacket=1000}] ~~~ scoreboard players test times Redpacket * 0

CU

/scoreboard players reset @a Redpacket

CC

/give @a[scores={Redpacket=1001..}] diamond 1

CU

/scoreboard players remove @a[scores={Redpacket=1001..}] Redpacket 1

CC


4鏈: 啟動紅包分發(fā)

///該指令鏈設定int=1000 times=10??勺远x分發(fā)數(shù)量,次數(shù),如何分發(fā)。僅供參考。

///注: int值要大于(times+1)值。否則可能會random計算出一個超級大數(shù)(random/0取余,沒有數(shù)學意義,不能正常觸發(fā))

/scoreboard players set int Redpacket 1000

I

/scoreboard players set times Redpacket 10

CU

/scoreboard players set random Redpacket 0

CU

/scoreboard players set 2x Redpacket 2

CU


使用原版標準縮寫:

第一位:

I(Impulse)--脈沖

C(Chain)--鏈

R(Repeat)--重復

第二位:

C(Conditional)--有條件的

U(Unconditional)--無條件的

[MCBE] 紅包/抽獎系統(tǒng) (微信紅包算法)的評論 (共 條)

分享到微博請遵守國家法律
宝应县| 札达县| 太仓市| 巴彦淖尔市| 江川县| 浮山县| 宁强县| 黎平县| 通许县| 永修县| 贵州省| 莱芜市| 汝州市| 右玉县| 平武县| 凉山| 锦屏县| 昆山市| 紫云| 尉氏县| 微山县| 庄河市| 应用必备| 松原市| 本溪市| 莱芜市| 霍林郭勒市| 克拉玛依市| 新营市| 武平县| 潼南县| 乐安县| 利辛县| 海丰县| 克拉玛依市| 横峰县| 湘乡市| 镇雄县| 五原县| 遂溪县| 福泉市|