ゴーストブロックの反映が遅い

every 1 tick:
set {_loc1} to location(-1001.5,59.5,37.5,world "w-lobby-new")
set {_loc2} to location(-997.5,63.5,37.5,world "w-lobby-new")
set blocks within {_loc1} and {_loc2} to air
#make players see blocks within {_loc1} and {_loc2} as air
loop players:
location at loop-player is within location(-1050,60,50,world "w-lobby-new") and location(-950,70,-50,world "w-lobby-new")
make loop-player see blocks within {_loc1} and {_loc2} as stone
every 1 tick:
set {_loc1} to location(-1001.5,59.5,37.5,world "w-lobby-new")
set {_loc2} to location(-997.5,63.5,37.5,world "w-lobby-new")
set blocks within {_loc1} and {_loc2} to air
#make players see blocks within {_loc1} and {_loc2} as air
loop players:
location at loop-player is within location(-1050,60,50,world "w-lobby-new") and location(-950,70,-50,world "w-lobby-new")
make loop-player see blocks within {_loc1} and {_loc2} as stone
特定エリアにいる人にだけ壁に見えるコードを書こうとしたのですが ゴーストブロック君右クリックで消してからすぐに復活しません 何なら復活するまでの時間がまばらで使い物にならなかったです これって改善のしようはありますか
3 Replies
月猫ch
月猫chOP13mo ago
今検証したところ 対象のplayerがジャンプすると即座に復活してます
何か
何か13mo ago
ゴーストブロックはサーバーからパケットが送られてクライアントに同期させるので サーバーからのパケットを遮断すれば自然になります
import:
org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack
net.minecraft.server.v1_12_R1.BlockPosition
java.util.ArrayList
com.comphenix.protocol.wrappers.ChunkCoordIntPair
com.comphenix.protocol.wrappers.MultiBlockChangeInfo
com.comphenix.protocol.wrappers.WrappedBlockData

command /test:
trigger:
set {_pos} to location of player
loop 10 times:
loop 10 times:
set {_v} to vector(loop-number-1, loop-number-2, 0)
set_client_block(0, {_pos} ~ {_v}, stone)
set_client_block_target(0, player)

function set_client_block(id: number, pos: location, block: material):
set {_pos} to location of block at {_pos}
#set {cb::palette::%{_id}%::blocks::%{_pos}%} to {_pos}
#set {cb::palette::%{_id}%::blocks::%{_pos}%::block} to {_block}
set {_rx} to mod(x-pos of {_pos}, 16)
set {_y} to y-pos of {_pos}
set {_rz} to mod(z-pos of {_pos}, 16)
set {_chx} to (x-pos of {_pos} - {_rx}) / 16
set {_chz} to (z-pos of {_pos} - {_rz}) / 16
set {_chidx} to "%{_chx}%,%{_chz}%"
set {_pidx} to "%{_rx}%,%{_y}%,%{_rz}%"
set {cb::palette::%{_id}%::chunks::%{_chidx}%} to vector({_chx}, 0, {_chz})
set {cb::palette::%{_id}%::chunks::%{_chidx}%::pos} to {_pos}
set {cb::palette::%{_id}%::chunks::%{_chidx}%::blocks::%{_pidx}%} to {_pos}
set {cb::palette::%{_id}%::chunks::%{_chidx}%::blocks::%{_pidx}%::block} to {_block}
set {cb::palette::%{_id}%::blocks::%{_pos}%} to true


function set_client_block_target(id: number, p: players):
delete {cb::palette::%{_id}%::players::*}
loop {_p::*}:
set {cb::palette::%{_id}%::players::%loop-value%} to loop-value
set {cb::player::%loop-value%} to {_id}
loop create_multi_packets_from_cbid({_id}):
send packet loop-value to {_p::*}
import:
org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack
net.minecraft.server.v1_12_R1.BlockPosition
java.util.ArrayList
com.comphenix.protocol.wrappers.ChunkCoordIntPair
com.comphenix.protocol.wrappers.MultiBlockChangeInfo
com.comphenix.protocol.wrappers.WrappedBlockData

command /test:
trigger:
set {_pos} to location of player
loop 10 times:
loop 10 times:
set {_v} to vector(loop-number-1, loop-number-2, 0)
set_client_block(0, {_pos} ~ {_v}, stone)
set_client_block_target(0, player)

function set_client_block(id: number, pos: location, block: material):
set {_pos} to location of block at {_pos}
#set {cb::palette::%{_id}%::blocks::%{_pos}%} to {_pos}
#set {cb::palette::%{_id}%::blocks::%{_pos}%::block} to {_block}
set {_rx} to mod(x-pos of {_pos}, 16)
set {_y} to y-pos of {_pos}
set {_rz} to mod(z-pos of {_pos}, 16)
set {_chx} to (x-pos of {_pos} - {_rx}) / 16
set {_chz} to (z-pos of {_pos} - {_rz}) / 16
set {_chidx} to "%{_chx}%,%{_chz}%"
set {_pidx} to "%{_rx}%,%{_y}%,%{_rz}%"
set {cb::palette::%{_id}%::chunks::%{_chidx}%} to vector({_chx}, 0, {_chz})
set {cb::palette::%{_id}%::chunks::%{_chidx}%::pos} to {_pos}
set {cb::palette::%{_id}%::chunks::%{_chidx}%::blocks::%{_pidx}%} to {_pos}
set {cb::palette::%{_id}%::chunks::%{_chidx}%::blocks::%{_pidx}%::block} to {_block}
set {cb::palette::%{_id}%::blocks::%{_pos}%} to true


function set_client_block_target(id: number, p: players):
delete {cb::palette::%{_id}%::players::*}
loop {_p::*}:
set {cb::palette::%{_id}%::players::%loop-value%} to loop-value
set {cb::player::%loop-value%} to {_id}
loop create_multi_packets_from_cbid({_id}):
send packet loop-value to {_p::*}
function create_multi_packets_from_cbid(id: number) :: packets:
loop {cb::palette::%{_id}%::chunks::*}:
set {_packet} to new play_server_multi_block_change packet
{_packet}.getChunkCoordIntPairs().writeSafely(0, new ChunkCoordIntPair(x of loop-value, z of loop-value))
set {_blocks} to new ArrayList()
loop {cb::palette::%{_id}%::chunks::%loop-index%::blocks::*}:
set {_block} to {cb::palette::%{_id}%::chunks::%loop-index-1%::blocks::%loop-index-2%::block}
set {_data} to WrappedBlockData.createData((type of {_block}).getMaterial(), data of {_block})
{_blocks}.add(new MultiBlockChangeInfo(loop-value-2, {_data}))
{_packet}.getMultiBlockChangeInfoArrays().writeSafely(0, {_blocks}.toArray())
add {_packet} to {_res::*}
return {_res::*}

function send_single_block_change(pos: location, block: material, p: players):
set {_packet} to new play_server_block_change packet
set location pinfo 0 of {_packet} to {_pos}
set blockdata pinfo 0 of {_packet} to {_block}
send packet {_packet} to {_p::*}

on packet event play_server_block_change:
set {_id} to {cb::player::%player%}
set {_pos} to (location pinfo 0 of event-packet).add(0.5, 0.5, 0.5)
set {_block} to blockdata pinfo 0 of event-packet
if {cb::palette::%{_id}%::blocks::%{_pos}%} is set:
if {_block} is air:
cancel event
function create_multi_packets_from_cbid(id: number) :: packets:
loop {cb::palette::%{_id}%::chunks::*}:
set {_packet} to new play_server_multi_block_change packet
{_packet}.getChunkCoordIntPairs().writeSafely(0, new ChunkCoordIntPair(x of loop-value, z of loop-value))
set {_blocks} to new ArrayList()
loop {cb::palette::%{_id}%::chunks::%loop-index%::blocks::*}:
set {_block} to {cb::palette::%{_id}%::chunks::%loop-index-1%::blocks::%loop-index-2%::block}
set {_data} to WrappedBlockData.createData((type of {_block}).getMaterial(), data of {_block})
{_blocks}.add(new MultiBlockChangeInfo(loop-value-2, {_data}))
{_packet}.getMultiBlockChangeInfoArrays().writeSafely(0, {_blocks}.toArray())
add {_packet} to {_res::*}
return {_res::*}

function send_single_block_change(pos: location, block: material, p: players):
set {_packet} to new play_server_block_change packet
set location pinfo 0 of {_packet} to {_pos}
set blockdata pinfo 0 of {_packet} to {_block}
send packet {_packet} to {_p::*}

on packet event play_server_block_change:
set {_id} to {cb::player::%player%}
set {_pos} to (location pinfo 0 of event-packet).add(0.5, 0.5, 0.5)
set {_block} to blockdata pinfo 0 of event-packet
if {cb::palette::%{_id}%::blocks::%{_pos}%} is set:
if {_block} is air:
cancel event
chunk毎にデータをまとめておいてあとからmulti block changeで送信すればスムーズに通信できます
月猫ch
月猫chOP13mo ago
なるほど、パケットを遮断… コードお借りします><
Want results from more Discord servers?
Add your server