i need a way to have my plugin fill
#1
im working on a minigame plugin and i didnt get setblock to work

function PlayerJoined(Player)
    local World = Player:GetWorld()
    local position = Vector3i(0, 500, 0)
    local bedrock = 7
    World:FastSetBlock(position, bedrock, 0)
end
Reply
Thanks given by:
#2
Minecraft coordinates use y for height, so you're trying to set a block at y=500 which can't be done because Cuberite only supports heights from 0 to 255.
You can also use the E_BLOCK_XYZ enums so you don't have to declare every block.

1
2
3
4
5
6
-- Sets the block where the player is to bedrock
function PlayerJoined(Player)
    local World = Player:GetWorld()
    local position = Player:GetPosition():Floor():addedY(-1);
    World:FastSetBlock(position, E_BLOCK_BEDROCK, 0)
end
Reply
Thanks given by: Alland20201
#3
Alland20201 Wrote:Thanks! tho i need a way to fill a 3x3 plattform. do u know how without some messy code

You could use a loop for both x and z coordinate to do that like this:
1
2
3
4
5
6
7
function PlacePlatformAt(world, middlepoint, radius)
    for x = -radius, radius do
        for z = -radius, radius do
            world:FastSetBlock(middlepoint:addedXZ(x,z), E_BLOCK_BEDROCK, 0)
        end
    end
end


You could also use the cBlockArea api which is more performant:
1
2
3
4
5
6
function PlacePlatformAt(world, middlepoint, radius)
    local ba = cBlockArea()
    ba:Create(radius * 2 + 1, 1, radius * 2 + 1, cBlockArea.baTypes + cBlockArea.baMetas)
    ba:Fill(cBlockArea.baTypes + cBlockArea.baMetas, E_BLOCK_BEDROCK, 0, 0, 0);
    ba:Write(world, middlepoint:addedXZ(-radius, -radius), cBlockArea.baTypes + cBlockArea.baMetas);
end
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)