the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "net.minecraft.world.level.biome.h"
3#include "net.minecraft.world.level.newbiome.layer.h"
4#include "net.minecraft.world.level.h"
5#include "BiomeOverrideLayer.h"
6
7
8BiomeOverrideLayer::BiomeOverrideLayer(int seedMixup) : Layer(seedMixup)
9{
10 m_biomeOverride = byteArray( width * height );
11
12#ifdef _UNICODE
13 wstring path = L"GAME:\\GameRules\\biomemap.bin";
14 HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
15#else
16#ifdef _WINDOWS64
17 string path = "GameRules\\biomemap.bin";
18#else
19 string path = "GAME:\\GameRules\\biomemap.bin";
20#endif
21 HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
22#endif
23 if( file == INVALID_HANDLE_VALUE )
24 {
25 DWORD error = GetLastError();
26 //assert(false);
27 app.DebugPrintf("Biome override not found, using plains as default\n");
28
29 memset(m_biomeOverride.data,Biome::plains->id,m_biomeOverride.length);
30 }
31 else
32 {
33
34#ifdef _DURANGO
35 __debugbreak(); // TODO
36 DWORD bytesRead,dwFileSize = 0;
37#else
38 DWORD bytesRead,dwFileSize = GetFileSize(file,NULL);
39#endif
40 if(dwFileSize > m_biomeOverride.length)
41 {
42 app.DebugPrintf("Biomemap binary is too large!!\n");
43 __debugbreak();
44 }
45 BOOL bSuccess = ReadFile(file,m_biomeOverride.data,dwFileSize,&bytesRead,NULL);
46
47 if(bSuccess==FALSE)
48 {
49 app.FatalLoadError();
50 }
51
52 CloseHandle(file);
53 }
54}
55
56intArray BiomeOverrideLayer::getArea(int xo, int yo, int w, int h)
57{
58 intArray result = IntCache::allocate(w * h);
59
60 int xOrigin = xo + width/2;
61 int yOrigin = yo + height/2;
62 if(xOrigin < 0 ) xOrigin = 0;
63 if(xOrigin >= width) xOrigin = width - 1;
64 if(yOrigin < 0 ) yOrigin = 0;
65 if(yOrigin >= height) yOrigin = height - 1;
66 for (int y = 0; y < h; y++)
67 {
68 for (int x = 0; x < w; x++)
69 {
70 int curX = xOrigin + x;
71 int curY = yOrigin + y;
72 if(curX >= width) curX = width - 1;
73 if(curY >= height) curY = height - 1;
74 int index = curX + curY * width;
75
76 unsigned char headerValue = m_biomeOverride[index];
77 result[x + y * w] = headerValue;
78 }
79 }
80 return result;
81}