Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase block ID range from 8-bit to 16-bit #55

Open
satoshinm opened this issue Apr 11, 2017 · 1 comment
Open

Increase block ID range from 8-bit to 16-bit #55

satoshinm opened this issue Apr 11, 2017 · 1 comment

Comments

@satoshinm
Copy link
Owner

The blocks array is 8-bit, supporting up to 256 block types:

// src/item.c
const int blocks[256][6] = {

// src/item.h
extern const int blocks[256][6];

Consider increasing this to 16-bit (for a total of 65536 block types), and testing to ensure elsewhere in the game (save file format, sqlite?) works well with it. Having this many block types may not be necessary yet, but it would be a good idea to plan ahead for future expansion e.g. to support variants of blocks in different orientations fogleman/Craft#116.

@fei2020
Copy link

fei2020 commented Sep 19, 2019

Have you finished it?
I find many places in the code w is regarded as a signed char. Such as light_fill(), map_set and etc.
MapEntry.w is char:

typedef union {
    unsigned int value;
    struct {
        unsigned char x;
        unsigned char y;
        unsigned char z;
	char w;
    } e;
} MapEntry;

It seems a lot of code and algorithms need to be modified to increase block ID range from 8-bit to 16-bit. If I modify MapEntry::e::w be short, main.c.light_fill(...) will be leaded to dead iterator. I just simply add a violent cast in light_fill, it seems works. But I know little about the algorithm of light_fill. I worry it will work wrong in some cases.

void light_fill(
    char *opaque, char *light,
    int x, int y, int z, int w, int force)
{
	w = (char)w;  //add a violent cast simply
	if (x + w < XZ_LO || z + w < XZ_LO) {
        return;
    }
......

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants