aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/StoneMonsterTile.cpp
blob: ad5982f8724ae79c04a5175683dbb34799876ec1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include "stdafx.h"
#include "net.minecraft.world.entity.monster.h"
#include "net.minecraft.world.level.h"
#include "StoneMonsterTile.h"

const unsigned int StoneMonsterTile::STONE_MONSTER_NAMES[STONE_MONSTER_NAMES_LENGTH] = {	IDS_TILE_STONE_SILVERFISH,
													IDS_TILE_STONE_SILVERFISH_COBBLESTONE,
													IDS_TILE_STONE_SILVERFISH_STONE_BRICK,
												};

StoneMonsterTile::StoneMonsterTile(int id) : Tile(id, Material::clay)
{
    setDestroyTime(0);
}

Icon *StoneMonsterTile::getTexture(int face, int data)
{
    if (data == HOST_COBBLE)
	{
        return Tile::stoneBrick->getTexture(face);
    }
    if (data == HOST_STONEBRICK)
	{
        return Tile::stoneBrickSmooth->getTexture(face);
    }
    return Tile::rock->getTexture(face);
}

void StoneMonsterTile::registerIcons(IconRegister *iconRegister)
{
	// None
}

void StoneMonsterTile::destroy(Level *level, int x, int y, int z, int data)
{
    if (!level->isClientSide)
	{
		// 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
		if(level->countInstanceOf( eTYPE_MONSTER, false) < 70 )
		{
			// Also limit the amount of silverfish specifically
			if(level->countInstanceOf( eTYPE_SILVERFISH, true) < 15 )
			{
				std::shared_ptr<Silverfish> silverfish = std::shared_ptr<Silverfish>(new Silverfish(level));
				silverfish->moveTo(x + .5, y, z + .5, 0, 0);
				level->addEntity(silverfish);

				silverfish->spawnAnim();
			}
		}
    }
    Tile::destroy(level, x, y, z, data);
}

int StoneMonsterTile::getResourceCount(Random *random)
{
	return 0;
}

bool StoneMonsterTile::isCompatibleHostBlock(int block)
{
	return block == Tile::rock_Id || block == Tile::stoneBrick_Id || block == Tile::stoneBrickSmooth_Id;
}

int StoneMonsterTile::getDataForHostBlock(int block)
{
    if (block == Tile::stoneBrick_Id)
	{
        return HOST_COBBLE;
    }
    if (block == Tile::stoneBrickSmooth_Id)
	{
        return HOST_STONEBRICK;
    }
    return HOST_ROCK;
}

Tile *StoneMonsterTile::getHostBlockForData(int data)
{
	switch (data)
	{
	case HOST_COBBLE:
		return Tile::stoneBrick;
	case HOST_STONEBRICK:
		return Tile::stoneBrickSmooth;
	default:
		return Tile::rock;
	}
}

std::shared_ptr<ItemInstance> StoneMonsterTile::getSilkTouchItemInstance(int data)
{
    Tile *tile = Tile::rock;
    if (data == HOST_COBBLE)
	{
        tile = Tile::stoneBrick;
    }
    if (data == HOST_STONEBRICK)
	{
        tile = Tile::stoneBrickSmooth;
    }
    return std::shared_ptr<ItemInstance>(new ItemInstance(tile));
}

int StoneMonsterTile::cloneTileData(Level *level, int x, int y, int z)
{
	return level->getData(x, y, z);
}

unsigned int StoneMonsterTile::getDescriptionId(int iData /*= -1*/)
{
	if(iData < 0 ) iData = 0;
	return StoneMonsterTile::STONE_MONSTER_NAMES[iData];
}