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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
#include "stdafx.h"
#include "net.minecraft.world.level.h"
#include "net.minecraft.world.entity.boss.enderdragon.h"
#include "net.minecraft.world.level.tile.h"
#include "SpikeFeature.h"
SpikeFeature::SpikeFeature(int tile)
{
this->tile = tile;
//m_iIndex=0;
}
bool SpikeFeature::place(Level *level, Random *random, int x, int y, int z)
{
if (!(level->isEmptyTile(x, y, z) && level->getTile(x, y - 1, z) == tile))
{
return false;
}
int hh = random->nextInt(32) + 6;
int r = random->nextInt(4) + 1;
for (int xx = x - r; xx <= x + r; xx++)
for (int zz = z - r; zz <= z + r; zz++)
{
int xd = xx - x;
int zd = zz - z;
if (xd * xd + zd * zd <= r * r + 1)
{
if (level->getTile(xx, y - 1, zz) != tile)
{
return false;
}
}
}
for (int yy = y; yy < y + hh; yy++)
{
if (yy < Level::genDepth)
{
for (int xx = x - r; xx <= x + r; xx++)
for (int zz = z - r; zz <= z + r; zz++)
{
int xd = xx - x;
int zd = zz - z;
if (xd * xd + zd * zd <= r * r + 1)
{
level->setTileAndData(xx, yy, zz, Tile::obsidian_Id, 0, Tile::UPDATE_CLIENTS);
}
}
} else break;
}
shared_ptr<EnderCrystal> enderCrystal = shared_ptr<EnderCrystal>(new EnderCrystal(level));
enderCrystal->moveTo(x + 0.5f, y + hh, z + 0.5f, random->nextFloat() * 360, 0);
level->addEntity(enderCrystal);
level->setTileAndData(x, y + hh, z, Tile::unbreakable_Id, 0, Tile::UPDATE_CLIENTS);
return true;
}
bool SpikeFeature::placeWithIndex(Level *level, Random *random, int x, int y, int z,int iIndex, int iRadius)
{
app.DebugPrintf("Spike - %d,%d,%d - index %d\n",x,y,z,iIndex);
int hh = 12 + (iIndex*3);
// fill any tiles below the spike
for (int xx = x - iRadius; xx <= x + iRadius; xx++)
{
for (int zz = z - iRadius; zz <= z + iRadius; zz++)
{
int xd = xx - x;
int zd = zz - z;
if (xd * xd + zd * zd <= iRadius * iRadius + 1)
{
int iTileBelow=1;
while((y-iTileBelow>-10) && level->getTile(xx, y - iTileBelow, zz) != tile)
{
if(level->isEmptyTile(xx, y - iTileBelow, zz))
{
// empty tile
level->setTileAndData(xx, y - iTileBelow, zz, Tile::obsidian_Id, 0, Tile::UPDATE_CLIENTS);
}
else
{
level->setTileAndData(xx, y - iTileBelow, zz, Tile::obsidian_Id, 0, Tile::UPDATE_CLIENTS);
}
iTileBelow++;
}
}
}
}
for (int yy = y; yy < y + hh; yy++)
{
if (yy < Level::genDepth)
{
for (int xx = x - iRadius; xx <= x + iRadius; xx++)
{
for (int zz = z - iRadius; zz <= z + iRadius; zz++)
{
int xd = xx - x;
int zd = zz - z;
int iVal = xd * xd + zd * zd;
if ( iVal <= iRadius * iRadius + 1)
{
//level->setTile(xx, yy, zz, Tile::obsidian_Id);
placeBlock(level, xx, yy, zz, Tile::obsidian_Id, 0);
}
}
}
}
else
{
app.DebugPrintf("Breaking out of spike feature\n");
break;
}
}
// cap the last spikes with a fence to stop lucky arrows hitting the crystal
if(iIndex>5)
{
for (int yy = y; yy < y + hh; yy++)
{
if (yy < Level::genDepth)
{
for (int xx = x - 2; xx <= x + 2; xx++)
{
for (int zz = z - 2; zz <= z + 2; zz++)
{
int xd = xx - x;
int zd = zz - z;
int iVal = xd * xd + zd * zd;
if ( iVal >= 2 * 2)
{
if(yy==(y + hh - 1))
{
placeBlock(level, xx, y + hh, zz, Tile::ironFence_Id, 0);
placeBlock(level, xx, y + hh +1, zz, Tile::ironFence_Id, 0);
placeBlock(level, xx, y + hh +2, zz, Tile::ironFence_Id, 0);
}
}
}
}
}
else
{
app.DebugPrintf("Breaking out of spike feature\n");
break;
}
}
// and cap off the top
int yy = y + hh + 3;
if (yy < Level::genDepth)
{
for (int xx = x - 2; xx <= x + 2; xx++)
{
for (int zz = z - 2; zz <= z + 2; zz++)
{
placeBlock(level, xx, yy, zz, Tile::ironFence_Id, 0);
}
}
}
}
shared_ptr<EnderCrystal> enderCrystal = shared_ptr<EnderCrystal>(new EnderCrystal(level));
enderCrystal->moveTo(x + 0.5f, y + hh, z + 0.5f, random->nextFloat() * 360, 0);
level->addEntity(enderCrystal);
placeBlock(level, x, y + hh, z, Tile::unbreakable_Id, 0);
//level->setTile(x, y + hh, z, Tile::unbreakable_Id);
return true;
}
|