the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 58 lines 1.7 kB view raw
1#include "stdafx.h" 2#include "SandFeature.h" 3#include "net.minecraft.world.level.h" 4#include "net.minecraft.world.level.tile.h" 5 6SandFeature::SandFeature(int radius, int tile) 7{ 8 this->tile = tile; 9 this->radius = radius; 10} 11 12bool SandFeature::place(Level *level, Random *random, int x, int y, int z) 13{ 14 if (level->getMaterial(x, y, z) != Material::water) return false; 15 16 // 4J - optimisation. Without this, we can end up creating a huge number of HeavyTiles to be ticked 17 // a few frames away. I think instatick ought to be fine here - we're only turning rock into gravel, 18 // so should instantly know if we've made a rock with nothing underneath and that should fall. 19 level->setInstaTick(true); 20 21 int r = random->nextInt(radius-2)+2; 22 int yr = 2; 23 24 // 4J Stu Added to stop tree features generating areas previously place by game rule generation 25 if(app.getLevelGenerationOptions() != NULL) 26 { 27 LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions(); 28 bool intersects = levelGenOptions->checkIntersects(x - r, y - yr, z - r, x + r, y + yr, z + r); 29 if(intersects) 30 { 31 level->setInstaTick(false); 32 //app.DebugPrintf("Skipping reeds feature generation as it overlaps a game rule structure\n"); 33 return false; 34 } 35 } 36 37 for (int xx = x - r; xx <= x + r; xx++) 38 { 39 for (int zz = z - r; zz <= z + r; zz++) 40 { 41 int xd = xx - x; 42 int zd = zz - z; 43 if (xd * xd + zd * zd > r * r) continue; 44 for (int yy = y - yr; yy <= y + yr; yy++) 45 { 46 int t = level->getTile(xx, yy, zz); 47 if (t == Tile::dirt_Id || t == Tile::grass_Id) 48 { 49 level->setTileAndData(xx, yy, zz, tile, 0, Tile::UPDATE_CLIENTS); 50 } 51 } 52 } 53 } 54 55 level->setInstaTick(false); 56 57 return true; 58}