-2
\$\begingroup\$

I'm wondering if Minecraft has class for every type of block or blocks are just IDs in code.

EDIT

And what about data like transparency, resistance, hardness, tool, etc? Are they hardcoded or stored external?

\$\endgroup\$
3
  • 1
    \$\begingroup\$ I'm voting to close this question as off-topic because questions about how another game implements things are considered off-topic. \$\endgroup\$
    – user1430
    Commented Mar 5, 2015 at 15:11
  • \$\begingroup\$ @JoshPetrie ok, i didn't know that, sorry. \$\endgroup\$ Commented Mar 5, 2015 at 15:16
  • \$\begingroup\$ The reason why such questions are considered off-topic is because the answer won't help you much with your own project. 1. what's right for someone else's project might not also be right for your own and 2. just because someone else picked this solution doesn't necessarily mean that the solution is optimal even for them. Yes, even when they are very successfully. Extraordinary software engineering skills and extraordinary commercial success do not necessary correlate. \$\endgroup\$
    – Philipp
    Commented Mar 5, 2015 at 15:59

1 Answer 1

3
\$\begingroup\$

Class Based as a quick lookup learns. Every block is defined in a loose file and extends Block.

package tutorial.generic;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;

public class GenericBlock extends Block 
{

    public GenericBlock (Material material) 
    {
            super(material);
    }
}
\$\endgroup\$
4
  • \$\begingroup\$ That's may be the main reason why Minecraft is so unoptimized. \$\endgroup\$ Commented Mar 5, 2015 at 14:59
  • \$\begingroup\$ As for change in your question. How about actually clicking on the links and reading the web page? \$\endgroup\$
    – Eejin
    Commented Mar 5, 2015 at 15:05
  • \$\begingroup\$ @nikoliazekter That's certainly not the main reason or even a reason at all. \$\endgroup\$
    – Philipp
    Commented Mar 5, 2015 at 16:03
  • \$\begingroup\$ @Philipp do you know about data locality? I guess that can be the case. Minecraft needs to update a lot of blocks every frame and if their information doesn't store in contiguous array then there will be a lot of cache misses. And this means game frequently has to get new portion of data from RAM which is extremely slow in comparison with CPU speed. \$\endgroup\$ Commented Mar 5, 2015 at 17:12

Not the answer you're looking for? Browse other questions tagged .