So I'm trying to make an efficient game where there is a grid system and every grid has a number that is able to identify what kind of block is located there. This lets me just have an array of numbers rather than an array of block-objects.
But now here is my problem, when I want to call a method from one of block classes, I only have a number to reference it. And I don't want to have a giant switch block to try and determine which block it is.
So in short, how can I get an specific int to reference a certain class without a massive if chain or switch block?
I believe Minecraft does something like this. All the blocks are saved in memory as a number, and then when the game wants to draw or call a method on one of the blocks, it uses the number at that location to reference to block to call the method. How does it do this?