mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
test removing client-side logic in headless (base pack scripts/components)
This commit is contained in:
parent
fc80feeb84
commit
2afadb4ae6
6 changed files with 26 additions and 25 deletions
|
|
@ -26,7 +26,6 @@ function on_save()
|
|||
end
|
||||
|
||||
if not VC_HEADLESS then
|
||||
local SCALE = 0.3
|
||||
local scale = {1, 1, 1}
|
||||
local rotation = mat4.rotate({
|
||||
math.random(), math.random(), math.random()
|
||||
|
|
@ -35,8 +34,8 @@ if not VC_HEADLESS then
|
|||
do
|
||||
local matrix = mat4.idt()
|
||||
rig:set_model(0, item.model_name(dropitem.id))
|
||||
local bodysize = math.min(scale[1], scale[2], scale[3]) * SCALE
|
||||
body:set_size({scale[1] * SCALE, bodysize, scale[3] * SCALE})
|
||||
local bodysize = math.min(scale[1], scale[2], scale[3])
|
||||
body:set_size({scale[1], bodysize, scale[3]})
|
||||
mat4.mul(matrix, rotation, matrix)
|
||||
mat4.scale(matrix, scale, matrix)
|
||||
rig:set_matrix(0, matrix)
|
||||
|
|
@ -103,9 +102,7 @@ function on_sensor_enter(index, oid)
|
|||
if timer < 0.0 and index == 0 then
|
||||
entity:despawn()
|
||||
inventory.add(player.get_inventory(pid), dropitem.id, dropitem.count, dropitem.data)
|
||||
if not VC_HEADLESS then
|
||||
audio.play_sound_2d("events/pickup", 0.5, 0.8 + math.random() * 0.4, "regular")
|
||||
end
|
||||
audio.play_sound_2d("events/pickup", 0.5, 0.8 + math.random() * 0.4, "regular")
|
||||
end
|
||||
if index == 1 then
|
||||
target = oid
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
local tsf = entity.transform
|
||||
local body = entity.rigidbody
|
||||
local rig = entity.skeleton
|
||||
|
||||
local blockid = ARGS.block
|
||||
local blockstates = ARGS.states or 0
|
||||
|
|
@ -12,7 +11,8 @@ else
|
|||
SAVED_DATA.states = blockstates
|
||||
end
|
||||
|
||||
do -- setup visuals
|
||||
if not VC_HEADLESS then-- setup visuals
|
||||
local rig = entity.skeleton
|
||||
local id = block.index(blockid)
|
||||
local rotation = block.decompose_state(blockstates)[1]
|
||||
local textures = block.get_textures(id)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
local tsf = entity.transform
|
||||
local body = entity.rigidbody
|
||||
local rig = entity.skeleton
|
||||
local mob = entity:require_component("core:mob")
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,26 @@
|
|||
local offsets = {}
|
||||
for lx=-1,1 do
|
||||
for ly=-1,1 do
|
||||
for lz=-1,1 do
|
||||
offsets[(lx * 3 + ly) * 3 + lz] = {lx, ly, lz}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function on_random_update(x, y, z)
|
||||
local dirtid = block.index('base:dirt');
|
||||
if block.is_solid_at(x, y+1, z) then
|
||||
block.set(x, y, z, dirtid, 0)
|
||||
else
|
||||
local grassblockid = block.index('base:grass_block')
|
||||
for lx=-1,1 do
|
||||
for ly=-1,1 do
|
||||
for lz=-1,1 do
|
||||
if block.get(x + lx, y + ly, z + lz) == dirtid then
|
||||
if not block.is_solid_at(x + lx, y + ly + 1, z + lz) then
|
||||
block.set(x + lx, y + ly, z + lz, grassblockid, 0)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
local grassblockid = block.index('base:grass_block')
|
||||
for _, offset in ipairs(offsets) do
|
||||
local nx, ny, nz = x + offset[1], y + offset[2], z + offset[3]
|
||||
|
||||
if block.get(nx, ny, nz) == dirtid and
|
||||
not block.is_solid_at(nx, ny + 1, nz) then
|
||||
block.set(nx, ny, nz, grassblockid, 0)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
function on_block_broken(id, x, y, z, playerid)
|
||||
if gfx then
|
||||
if not VC_HEADLESS then
|
||||
local size = {block.get_size(id)}
|
||||
gfx.particles.emit({
|
||||
x + size[1] * 0.5,
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ function on_physics_update(delta)
|
|||
local front = mat4.mul(rot, {0, 0, -1})
|
||||
local pos = tsf:get_pos()
|
||||
|
||||
if hud and pid == hud.get_player() then
|
||||
if not VC_HEADLESS and pid == hud.get_player() then
|
||||
process_player_inputs(pid, rot, delta)
|
||||
end
|
||||
mob.look_at(vec3.add(pos, front))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue