mojira.dev
MCPE-13752

[Internal MCPE] Block registering class is messed up

Oh man Mojang..

Whats wrong with your register Block class?

Its really messed up and unsorted.

In the beginnings, they are listed from highest id to lowest id.

(you have to read from bottom to top)

Sand
StillLava
FlowingLava
StillWater
FlowingWater
Bedrock
Sapling
WoodPlanks
Cobblestone
Dirt
Grass
Stone
Air

But then, especially after id 127 (Lit redstone lamp) the class really messed up.

EmeraldOre // thats 129.. wheres EmeraldBlock, the 130?
Cocoa // Where is activator rail?
LitRedStoneLamp

NetherBrickStairs
NetherBrick // okay.. its next to nether brick stair.. but..
StoneBrickStairs
DarkOakStairs
AcaciaStairs
WoodButton // WHY IN HOLY SKY BIOME IS THIS HERE?!
JungleStairs
BirchStairs
SpruceStairs

How it actually should be looking like:

REDSTONE_LAMP = 123
LIT_REDSTONE_LAMP = 124
ACTIVATOR_RAIL = 126
COCOA = 127
SANDSTONE_STAIRS = 128
EMERALD_ORE = 129
ENDERCHEST = 130 //?
TRIPWIRE_HOOK = 131
TRIPWIRE = 132
EMERALD_BLOCK = 133
SPRUCE_WOOD_STAIRS = 134
BIRCH_WOOD_STAIRS = 135
JUNGLE_WOOD_STAIRS = 136

I know, this no actual "bug".. but thats bad practice i think. A cleanup will maybe help you in future development, due to MCPE being a GREAT project.

I am glad if i was able to help you a bit. Thanks ^^

Comments 6

Do you think this is a bug? Maybe, it's Intended

😃 Intended mess?
"I know, this no actual "bug".. but thats bad practice i think. A cleanup will maybe help you in future development, due to MCPE being a GREAT project."

^^ Its code style, you know 😉
Clean code is always better for the future. It works without being cleaned up, and yea, if you need an id, you can search and replace, to get the id.
And also.. for example you would create an array, that has this kind of style:
Array(
id -> block name
id2 -> block name 2
)

Sorted arrays are faster in code processing. For example in array search functions, in array pop (remove last), etc

"Maybe, it's Intended".. well.. I can't see any reason not to sort it, but the change is just for better internal handling.

Changing ID's will change world saves, therefor we would have to convert them.
Currently we try to get the IDs to be similar to PC, without breaking anything that doesn't need breaking.
Its important to me at least that you can search the interwebs for your block id's (even-tho on PC you can use names) and use them as if there was only one minecraft.
it seems PC however ran out of ID's halfway through, and started filling up the unused ID's.

The unsorted isn't intended, but the overhead is also rather minor for us, we could win way more performance in other places, which is why we tackle those first 🙂

Thank you Daniel for taking your time to explain that in detail 🙂

@Daniel Wustenhoff it would only be the internal order, not changing ID's 😉

@MissMarzenia Welcome 🙂

I meant the other Daniel, but sure.

thebigsmileXD

(Unassigned)

Unconfirmed

Tablet - Android - Samsung Galaxy Note

0.14.0

Retrieved