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 "OreTile.h"
3#include "net.minecraft.world.item.h"
4#include "net.minecraft.world.level.h"
5
6OreTile::OreTile(int id) : Tile(id, Material::stone)
7{
8}
9
10int OreTile::getResource(int data, Random *random, int playerBonusLevel)
11{
12 if (id == Tile::coalOre_Id) return Item::coal_Id;
13 if (id == Tile::diamondOre_Id) return Item::diamond_Id;
14 if (id == Tile::lapisOre_Id) return Item::dye_powder_Id;
15 if (id == Tile::emeraldOre_Id) return Item::emerald_Id;
16 if (id == Tile::netherQuartz_Id) return Item::netherQuartz_Id;
17 return id;
18}
19
20int OreTile::getResourceCount(Random *random)
21{
22 if (id == Tile::lapisOre_Id) return 4 + random->nextInt(5);
23 return 1;
24}
25
26int OreTile::getResourceCountForLootBonus(int bonusLevel, Random *random)
27{
28 if (bonusLevel > 0 && id != getResource(0, random, bonusLevel))
29 {
30 int bonus = random->nextInt(bonusLevel + 2) - 1;
31 if (bonus < 0)
32 {
33 bonus = 0;
34 }
35 return getResourceCount(random) * (bonus + 1);
36 }
37 return getResourceCount(random);
38}
39
40void OreTile::spawnResources(Level *level, int x, int y, int z, int data, float odds, int playerBonusLevel)
41{
42 Tile::spawnResources(level, x, y, z, data, odds, playerBonusLevel);
43
44 // also spawn experience if the block is broken
45 if (getResource(data, level->random, playerBonusLevel) != id)
46 {
47 int magicCount = 0;
48 if (id == Tile::coalOre_Id)
49 {
50 magicCount = Mth::nextInt(level->random, 0, 2);
51 }
52 else if (id == Tile::diamondOre_Id)
53 {
54 magicCount = Mth::nextInt(level->random, 3, 7);
55 }
56 else if (id == Tile::emeraldOre_Id)
57 {
58 magicCount = Mth::nextInt(level->random, 3, 7);
59 }
60 else if (id == Tile::lapisOre_Id)
61 {
62 magicCount = Mth::nextInt(level->random, 2, 5);
63 }
64 else if (id == Tile::netherQuartz_Id)
65 {
66 magicCount = Mth::nextInt(level->random, 2, 5);
67 }
68 popExperience(level, x, y, z, magicCount);
69 }
70}
71
72int OreTile::getSpawnResourcesAuxValue(int data)
73{
74 // lapis spawns blue dye
75 if (id == Tile::lapisOre_Id) return DyePowderItem::BLUE;
76 return 0;
77}