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.entity.monster.h"
3#include "net.minecraft.world.level.h"
4#include "net.minecraft.world.level.tile.h"
5#include "StoneMonsterTile.h"
6
7const unsigned int StoneMonsterTile::STONE_MONSTER_NAMES[STONE_MONSTER_NAMES_LENGTH] = { IDS_TILE_STONE_SILVERFISH,
8 IDS_TILE_STONE_SILVERFISH_COBBLESTONE,
9 IDS_TILE_STONE_SILVERFISH_STONE_BRICK,
10};
11
12StoneMonsterTile::StoneMonsterTile(int id) : Tile(id, Material::clay)
13{
14 setDestroyTime(0);
15}
16
17Icon *StoneMonsterTile::getTexture(int face, int data)
18{
19#ifndef _CONTENT_PACKAGE
20 if(app.DebugArtToolsOn())
21 {
22 return Tile::fire->getTexture(face, 0);
23 }
24#endif
25 if (data == HOST_COBBLE)
26 {
27 return Tile::cobblestone->getTexture(face);
28 }
29 if (data == HOST_STONEBRICK)
30 {
31 return Tile::stoneBrick->getTexture(face);
32 }
33 return Tile::stone->getTexture(face);
34}
35
36void StoneMonsterTile::registerIcons(IconRegister *iconRegister)
37{
38 // None
39}
40
41void StoneMonsterTile::destroy(Level *level, int x, int y, int z, int data)
42{
43 if (!level->isClientSide)
44 {
45 // 4J - limit total amount of monsters. The normal map spawning limits these to 50, and mobspawning tiles limit to 60, so give ourselves a bit of headroom here to also be able to make silverfish
46 if(level->countInstanceOf( eTYPE_MONSTER, false) < 70 )
47 {
48 // Also limit the amount of silverfish specifically
49 if(level->countInstanceOf( eTYPE_SILVERFISH, true) < 15 )
50 {
51 shared_ptr<Silverfish> silverfish = shared_ptr<Silverfish>(new Silverfish(level));
52 silverfish->moveTo(x + .5, y, z + .5, 0, 0);
53 level->addEntity(silverfish);
54
55 silverfish->spawnAnim();
56 }
57 }
58 }
59 Tile::destroy(level, x, y, z, data);
60}
61
62int StoneMonsterTile::getResourceCount(Random *random)
63{
64 return 0;
65}
66
67bool StoneMonsterTile::isCompatibleHostBlock(int block)
68{
69 return block == Tile::stone_Id || block == Tile::cobblestone_Id || block == Tile::stoneBrick_Id;
70}
71
72int StoneMonsterTile::getDataForHostBlock(int block)
73{
74 if (block == Tile::cobblestone_Id)
75 {
76 return HOST_COBBLE;
77 }
78 if (block == Tile::stoneBrick_Id)
79 {
80 return HOST_STONEBRICK;
81 }
82 return HOST_ROCK;
83}
84
85Tile *StoneMonsterTile::getHostBlockForData(int data)
86{
87 switch (data)
88 {
89 case HOST_COBBLE:
90 return Tile::cobblestone;
91 case HOST_STONEBRICK:
92 return Tile::stoneBrick;
93 default:
94 return Tile::stone;
95 }
96}
97
98shared_ptr<ItemInstance> StoneMonsterTile::getSilkTouchItemInstance(int data)
99{
100 Tile *tile = Tile::stone;
101 if (data == HOST_COBBLE)
102 {
103 tile = Tile::cobblestone;
104 }
105 if (data == HOST_STONEBRICK)
106 {
107 tile = Tile::stoneBrick;
108 }
109 return shared_ptr<ItemInstance>(new ItemInstance(tile));
110}
111
112int StoneMonsterTile::cloneTileData(Level *level, int x, int y, int z)
113{
114 return level->getData(x, y, z);
115}
116
117unsigned int StoneMonsterTile::getDescriptionId(int iData /*= -1*/)
118{
119 if(iData < 0 ) iData = 0;
120 return StoneMonsterTile::STONE_MONSTER_NAMES[iData];
121}