05-19-2017, 04:33 PM
07-29-2017, 04:06 AM
Updated:
- Fixed cBlockArea:Write call
- Player was not send to island on "/skyblock play"
- Fixed cBlockArea:Write call
- Player was not send to island on "/skyblock play"
10-06-2019, 06:00 AM
Doing a rework of my plugin:
Be aware, that I am still reworking this. Also this version is not compatible with the old one, to many changes.
The changes are in a own branch named rework on github: https://github.com/Seadragon91/SkyBlock/tree/rework
Would it be okay to add a function to cBlockArea that would count all blocks and return a lua table in that format?
I thought when I would get all blocks from the chunk. I could do this above, but the result was much worse then the current solution and that uses cBlockArea:CountSpecificBlocks to count all blocks, and it does that currently 147 times..
If that would be okay, how can I export a lua table that contains a lua table in c++
- Moved challenges into a inventory, every level has a own page with it's challenges
- Can be opened with command /challenges. Hover over the yellow glass to see the info of a challenge
- Copied the challenges from my old java plugin, changed them to json file and updated them
- Fixed bug in chunk generation, biome was always ocean... should be plains. Animals will now spawn
- Fixed crash in calculating the island value, when player left the server
- Improved the calculation of the island value, needless calculations done
- Fixed a bug when running /skyblock play, player would not be moved to the skyblock world
Be aware, that I am still reworking this. Also this version is not compatible with the old one, to many changes.
The changes are in a own branch named rework on github: https://github.com/Seadragon91/SkyBlock/tree/rework
The format would be then: tbCountedBlocks is a table tbCountedBlocks[<id>] -> table tbCountedBlocks[<id>][<meta>] -> amount of blocks
I thought when I would get all blocks from the chunk. I could do this above, but the result was much worse then the current solution and that uses cBlockArea:CountSpecificBlocks to count all blocks, and it does that currently 147 times..
If that would be okay, how can I export a lua table that contains a lua table in c++

10-06-2019, 08:38 AM
Any reason why you can't implement the function in the plugin itself? WorldEdit is able to do large actions on a cBlockArea, so I'm sure SkyBlock van as well.
10-06-2019, 05:31 PM
This are the results from my skyblock plugin for a single chunk, all in milliseconds. The difference is that sykblock is mostly of air and with that I don't need let cuberite count the air blocks and this is much faster.
Function CountAllNonAirBlocksAndMetas in cBlockArea
The reason for 147 times with CountSpecificBlocks is that I check for 147 block id / metas in the island area to calculate the points of a island area.
Tested that function in WorldEdit in a normal generated world, the amount of air blocks I can get by just subtracting the found blocks with the volume:
Changes in WorldEdit
That's the results I have.
Function CountAllNonAirBlocksAndMetas in cBlockArea
Calc(for loop): 25 Calc(CountAllNonAirBlocksAndMetas): 1 Calc(CountSpecificBlocks): 13 Calc(for loop): 26 Calc(CountAllNonAirBlocksAndMetas): 0 Calc(CountSpecificBlocks): 14 Calc(for loop): 28 Calc(CountAllNonAirBlocksAndMetas): 1 Calc(CountSpecificBlocks): 14 Calc(for loop): 25 Calc(CountAllNonAirBlocksAndMetas): 1 Calc(CountSpecificBlocks (147 times)): 14
The reason for 147 times with CountSpecificBlocks is that I check for 147 block id / metas in the island area to calculate the points of a island area.
Tested that function in WorldEdit in a normal generated world, the amount of air blocks I can get by just subtracting the found blocks with the volume:
Changes in WorldEdit
Area Size: 101 * 234 * 100 Current: 1197 ms New: 159 ms Area Size: 101 * 244* 100 Current: 1253 ms New: 185 ms
That's the results I have.
10-06-2019, 08:16 PM
This seems to work pretty well to count all the blocks:
local BlockArea = cBlockArea() BlockArea:Read(World, SrcCuboid, cBlockArea.baTypes + cBlockArea.baMetas) local output = {}; for X = SrcCuboid.p1.x, SrcCuboid.p2.x do for Y = SrcCuboid.p1.y, SrcCuboid.p2.y do for Z = SrcCuboid.p1.z, SrcCuboid.p2.z do local blocktype, meta = BlockArea:GetBlockTypeMeta(X, Y, Z); local type = output[blocktype] or {}; type[meta] = (type[meta] or 0) + 1; output[blocktype] = type; end end end for blocktype, metas in pairs(output) do print(blocktype); for meta, num in pairs(metas) do print("\t" .. meta .. ": " .. num); end end
10-06-2019, 08:38 PM
I have already tested something like that and it's slower than the solution where I use CountSpecificBlocks that will be called 147 times 

10-06-2019, 08:41 PM
Could you try that again but with `tbCounted` as a local variable instead of global?
10-06-2019, 08:47 PM
This variable will be cleared before the blocks are counted. There will be no change.
10-06-2019, 09:02 PM
Global variables are saved in _G (a table) which means the tbCounted variable has to be fetched again every time in the loop. Local variables are written to a register which is much faster.