SkyBlock v3
Fixed a bug with generation of englisch language file, it was not generated for new installations.
Reply
Thanks given by:
Updated:
- Fixed cBlockArea:Write call
- Player was not send to island on "/skyblock play"
Reply
Thanks given by:
Doing a rework of my plugin:
  • 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
Here a few pictures on imgur.com how it currently looks.

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


@xoft Would it be okay to add a function to cBlockArea that would count all blocks and return a lua table in that format?
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++  Smile
Reply
Thanks given by:
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.
Reply
Thanks given by:
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

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.
Reply
Thanks given by:
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
Reply
Thanks given by:
I have already tested something like that and it's slower than the solution where I use CountSpecificBlocks that will be called 147 times Smile
Reply
Thanks given by:
Could you try that again but with `tbCounted` as a local variable instead of global?
Reply
Thanks given by:
This variable will be cleared before the blocks are counted. There will be no change.
Reply
Thanks given by:
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.
Reply
Thanks given by:




Users browsing this thread: 5 Guest(s)