StructureMineshaftPieces .java

net.minecraft.world.gen.structure.StructureMineshaftPieces (class): members: CHEST_CONTENT_WEIGHT_LIST, registerStructurePieces, Cross, Room, Corridor.

net.minecraft.world.gen.structureclass835 linescommon42.1 KB

API Surface (22)

void registerStructurePieces()
void writeStructureToNBT(NBTTagCompound tagCompound)
void readStructureFromNBT(NBTTagCompound tagCompound)
StructureBoundingBox func_175814_a(List<StructureComponent> p_175814_0_, Random rand, int x, int y, int z, EnumFacing facing)
void buildComponent(StructureComponent componentIn, List<StructureComponent> listIn, Random rand)
boolean generateChestContents(World worldIn, StructureBoundingBox boundingBoxIn, Random rand, int x, int y, int z, List<WeightedRandomChestContent> listIn, int max)
boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn)
void writeStructureToNBT(NBTTagCompound tagCompound)
void readStructureFromNBT(NBTTagCompound tagCompound)
StructureBoundingBox func_175813_a(List<StructureComponent> listIn, Random rand, int x, int y, int z, EnumFacing facing)
void buildComponent(StructureComponent componentIn, List<StructureComponent> listIn, Random rand)
boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn)
void buildComponent(StructureComponent componentIn, List<StructureComponent> listIn, Random rand)
boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn)
void func_181138_a(int p_181138_1_, int p_181138_2_, int p_181138_3_)
void writeStructureToNBT(NBTTagCompound tagCompound)
void readStructureFromNBT(NBTTagCompound tagCompound)
void writeStructureToNBT(NBTTagCompound tagCompound)
void readStructureFromNBT(NBTTagCompound tagCompound)
StructureBoundingBox func_175812_a(List<StructureComponent> listIn, Random rand, int x, int y, int z, EnumFacing facing)
void buildComponent(StructureComponent componentIn, List<StructureComponent> listIn, Random rand)
boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn)

Fields & Constants (1)

CHEST_CONTENT_WEIGHT_LIST

String literals (7)

"incomplete-switch"
"MSCorridor"
"MSCrossing"
"MSRoom"
"MSStairs"
"CaveSpider"
"Entrances"

Full Source

StructureMineshaftPieces.java835 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.world.gen.structure;
2
3
import com.google.common.collect.Lists;
4
import java.util.List;
5
import java.util.Random;
6
import net.minecraft.block.material.Material;
7
import net.minecraft.block.state.IBlockState;
8
import net.minecraft.entity.item.EntityMinecartChest;
9
import net.minecraft.init.Blocks;
10
import net.minecraft.init.Items;
11
import net.minecraft.item.EnumDyeColor;
12
import net.minecraft.item.Item;
13
import net.minecraft.nbt.NBTTagCompound;
14
import net.minecraft.nbt.NBTTagList;
15
import net.minecraft.tileentity.TileEntity;
16
import net.minecraft.tileentity.TileEntityMobSpawner;
17
import net.minecraft.util.BlockPos;
18
import net.minecraft.util.EnumFacing;
19
import net.minecraft.util.WeightedRandomChestContent;
20
import net.minecraft.world.World;
21
22
@SuppressWarnings("incomplete-switch")
23
public class StructureMineshaftPieces
24
{
25
    private static final List<WeightedRandomChestContent> CHEST_CONTENT_WEIGHT_LIST = Lists.newArrayList(new WeightedRandomChestContent[] {new WeightedRandomChestContent(Items.iron_ingot, 0, 1, 5, 10), new WeightedRandomChestContent(Items.gold_ingot, 0, 1, 3, 5), new WeightedRandomChestContent(Items.redstone, 0, 4, 9, 5), new WeightedRandomChestContent(Items.dye, EnumDyeColor.BLUE.getDyeDamage(), 4, 9, 5), new WeightedRandomChestContent(Items.diamond, 0, 1, 2, 3), new WeightedRandomChestContent(Items.coal, 0, 3, 8, 10), new WeightedRandomChestContent(Items.bread, 0, 1, 3, 15), new WeightedRandomChestContent(Items.iron_pickaxe, 0, 1, 1, 1), new WeightedRandomChestContent(Item.getItemFromBlock(Blocks.rail), 0, 4, 8, 1), new WeightedRandomChestContent(Items.melon_seeds, 0, 2, 4, 10), new WeightedRandomChestContent(Items.pumpkin_seeds, 0, 2, 4, 10), new WeightedRandomChestContent(Items.saddle, 0, 1, 1, 3), new WeightedRandomChestContent(Items.iron_horse_armor, 0, 1, 1, 1)});
26
27
    public static void registerStructurePieces()
28
    {
29
        MapGenStructureIO.registerStructureComponent(StructureMineshaftPieces.Corridor.class, "MSCorridor");
30
        MapGenStructureIO.registerStructureComponent(StructureMineshaftPieces.Cross.class, "MSCrossing");
31
        MapGenStructureIO.registerStructureComponent(StructureMineshaftPieces.Room.class, "MSRoom");
32
        MapGenStructureIO.registerStructureComponent(StructureMineshaftPieces.Stairs.class, "MSStairs");
33
    }
34
35
    private static StructureComponent func_175892_a(List<StructureComponent> listIn, Random rand, int x, int y, int z, EnumFacing facing, int type)
36
    {
37
        int i = rand.nextInt(100);
38
39
        if (i >= 80)
40
        {
41
            StructureBoundingBox structureboundingbox = StructureMineshaftPieces.Cross.func_175813_a(listIn, rand, x, y, z, facing);
42
43
            if (structureboundingbox != null)
44
            {
45
                return new StructureMineshaftPieces.Cross(type, rand, structureboundingbox, facing);
46
            }
47
        }
48
        else if (i >= 70)
49
        {
50
            StructureBoundingBox structureboundingbox1 = StructureMineshaftPieces.Stairs.func_175812_a(listIn, rand, x, y, z, facing);
51
52
            if (structureboundingbox1 != null)
53
            {
54
                return new StructureMineshaftPieces.Stairs(type, rand, structureboundingbox1, facing);
55
            }
56
        }
57
        else
58
        {
59
            StructureBoundingBox structureboundingbox2 = StructureMineshaftPieces.Corridor.func_175814_a(listIn, rand, x, y, z, facing);
60
61
            if (structureboundingbox2 != null)
62
            {
63
                return new StructureMineshaftPieces.Corridor(type, rand, structureboundingbox2, facing);
64
            }
65
        }
66
67
        return null;
68
    }
69
70
    private static StructureComponent func_175890_b(StructureComponent componentIn, List<StructureComponent> listIn, Random rand, int x, int y, int z, EnumFacing facing, int type)
71
    {
72
        if (type > 8)
73
        {
74
            return null;
75
        }
76
        else if (Math.abs(x - componentIn.getBoundingBox().minX) <= 80 && Math.abs(z - componentIn.getBoundingBox().minZ) <= 80)
77
        {
78
            StructureComponent structurecomponent = func_175892_a(listIn, rand, x, y, z, facing, type + 1);
79
80
            if (structurecomponent != null)
81
            {
82
                listIn.add(structurecomponent);
83
                structurecomponent.buildComponent(componentIn, listIn, rand);
84
            }
85
86
            return structurecomponent;
87
        }
88
        else
89
        {
90
            return null;
91
        }
92
    }
93
94
    public static class Corridor extends StructureComponent
95
    {
96
        private boolean hasRails;
97
        private boolean hasSpiders;
98
        private boolean spawnerPlaced;
99
        private int sectionCount;
100
101
        public Corridor()
102
        {
103
        }
104
105
        protected void writeStructureToNBT(NBTTagCompound tagCompound)
106
        {
107
            tagCompound.setBoolean("hr", this.hasRails);
108
            tagCompound.setBoolean("sc", this.hasSpiders);
109
            tagCompound.setBoolean("hps", this.spawnerPlaced);
110
            tagCompound.setInteger("Num", this.sectionCount);
111
        }
112
113
        protected void readStructureFromNBT(NBTTagCompound tagCompound)
114
        {
115
            this.hasRails = tagCompound.getBoolean("hr");
116
            this.hasSpiders = tagCompound.getBoolean("sc");
117
            this.spawnerPlaced = tagCompound.getBoolean("hps");
118
            this.sectionCount = tagCompound.getInteger("Num");
119
        }
120
121
        public Corridor(int type, Random rand, StructureBoundingBox structurebb, EnumFacing facing)
122
        {
123
            super(type);
124
            this.coordBaseMode = facing;
125
            this.boundingBox = structurebb;
126
            this.hasRails = rand.nextInt(3) == 0;
127
            this.hasSpiders = !this.hasRails && rand.nextInt(23) == 0;
128
129
            if (this.coordBaseMode != EnumFacing.NORTH && this.coordBaseMode != EnumFacing.SOUTH)
130
            {
131
                this.sectionCount = structurebb.getXSize() / 5;
132
            }
133
            else
134
            {
135
                this.sectionCount = structurebb.getZSize() / 5;
136
            }
137
        }
138
139
        public static StructureBoundingBox func_175814_a(List<StructureComponent> p_175814_0_, Random rand, int x, int y, int z, EnumFacing facing)
140
        {
141
            StructureBoundingBox structureboundingbox = new StructureBoundingBox(x, y, z, x, y + 2, z);
142
            int i;
143
144
            for (i = rand.nextInt(3) + 2; i > 0; --i)
145
            {
146
                int j = i * 5;
147
148
                switch (facing)
149
                {
150
                    case NORTH:
151
                        structureboundingbox.maxX = x + 2;
152
                        structureboundingbox.minZ = z - (j - 1);
153
                        break;
154
155
                    case SOUTH:
156
                        structureboundingbox.maxX = x + 2;
157
                        structureboundingbox.maxZ = z + (j - 1);
158
                        break;
159
160
                    case WEST:
161
                        structureboundingbox.minX = x - (j - 1);
162
                        structureboundingbox.maxZ = z + 2;
163
                        break;
164
165
                    case EAST:
166
                        structureboundingbox.maxX = x + (j - 1);
167
                        structureboundingbox.maxZ = z + 2;
168
                }
169
170
                if (StructureComponent.findIntersecting(p_175814_0_, structureboundingbox) == null)
171
                {
172
                    break;
173
                }
174
            }
175
176
            return i > 0 ? structureboundingbox : null;
177
        }
178
179
        public void buildComponent(StructureComponent componentIn, List<StructureComponent> listIn, Random rand)
180
        {
181
            int i = this.getComponentType();
182
            int j = rand.nextInt(4);
183
184
            if (this.coordBaseMode != null)
185
            {
186
                switch (this.coordBaseMode)
187
                {
188
                    case NORTH:
189
                        if (j <= 1)
190
                        {
191
                            StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX, this.boundingBox.minY - 1 + rand.nextInt(3), this.boundingBox.minZ - 1, this.coordBaseMode, i);
192
                        }
193
                        else if (j == 2)
194
                        {
195
                            StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX - 1, this.boundingBox.minY - 1 + rand.nextInt(3), this.boundingBox.minZ, EnumFacing.WEST, i);
196
                        }
197
                        else
198
                        {
199
                            StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.maxX + 1, this.boundingBox.minY - 1 + rand.nextInt(3), this.boundingBox.minZ, EnumFacing.EAST, i);
200
                        }
201
202
                        break;
203
204
                    case SOUTH:
205
                        if (j <= 1)
206
                        {
207
                            StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX, this.boundingBox.minY - 1 + rand.nextInt(3), this.boundingBox.maxZ + 1, this.coordBaseMode, i);
208
                        }
209
                        else if (j == 2)
210
                        {
211
                            StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX - 1, this.boundingBox.minY - 1 + rand.nextInt(3), this.boundingBox.maxZ - 3, EnumFacing.WEST, i);
212
                        }
213
                        else
214
                        {
215
                            StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.maxX + 1, this.boundingBox.minY - 1 + rand.nextInt(3), this.boundingBox.maxZ - 3, EnumFacing.EAST, i);
216
                        }
217
218
                        break;
219
220
                    case WEST:
221
                        if (j <= 1)
222
                        {
223
                            StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX - 1, this.boundingBox.minY - 1 + rand.nextInt(3), this.boundingBox.minZ, this.coordBaseMode, i);
224
                        }
225
                        else if (j == 2)
226
                        {
227
                            StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX, this.boundingBox.minY - 1 + rand.nextInt(3), this.boundingBox.minZ - 1, EnumFacing.NORTH, i);
228
                        }
229
                        else
230
                        {
231
                            StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX, this.boundingBox.minY - 1 + rand.nextInt(3), this.boundingBox.maxZ + 1, EnumFacing.SOUTH, i);
232
                        }
233
234
                        break;
235
236
                    case EAST:
237
                        if (j <= 1)
238
                        {
239
                            StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.maxX + 1, this.boundingBox.minY - 1 + rand.nextInt(3), this.boundingBox.minZ, this.coordBaseMode, i);
240
                        }
241
                        else if (j == 2)
242
                        {
243
                            StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.maxX - 3, this.boundingBox.minY - 1 + rand.nextInt(3), this.boundingBox.minZ - 1, EnumFacing.NORTH, i);
244
                        }
245
                        else
246
                        {
247
                            StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.maxX - 3, this.boundingBox.minY - 1 + rand.nextInt(3), this.boundingBox.maxZ + 1, EnumFacing.SOUTH, i);
248
                        }
249
                }
250
            }
251
252
            if (i < 8)
253
            {
254
                if (this.coordBaseMode != EnumFacing.NORTH && this.coordBaseMode != EnumFacing.SOUTH)
255
                {
256
                    for (int i1 = this.boundingBox.minX + 3; i1 + 3 <= this.boundingBox.maxX; i1 += 5)
257
                    {
258
                        int j1 = rand.nextInt(5);
259
260
                        if (j1 == 0)
261
                        {
262
                            StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, i1, this.boundingBox.minY, this.boundingBox.minZ - 1, EnumFacing.NORTH, i + 1);
263
                        }
264
                        else if (j1 == 1)
265
                        {
266
                            StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, i1, this.boundingBox.minY, this.boundingBox.maxZ + 1, EnumFacing.SOUTH, i + 1);
267
                        }
268
                    }
269
                }
270
                else
271
                {
272
                    for (int k = this.boundingBox.minZ + 3; k + 3 <= this.boundingBox.maxZ; k += 5)
273
                    {
274
                        int l = rand.nextInt(5);
275
276
                        if (l == 0)
277
                        {
278
                            StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX - 1, this.boundingBox.minY, k, EnumFacing.WEST, i + 1);
279
                        }
280
                        else if (l == 1)
281
                        {
282
                            StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.maxX + 1, this.boundingBox.minY, k, EnumFacing.EAST, i + 1);
283
                        }
284
                    }
285
                }
286
            }
287
        }
288
289
        protected boolean generateChestContents(World worldIn, StructureBoundingBox boundingBoxIn, Random rand, int x, int y, int z, List<WeightedRandomChestContent> listIn, int max)
290
        {
291
            BlockPos blockpos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z));
292
293
            if (boundingBoxIn.isVecInside(blockpos) && worldIn.getBlockState(blockpos).getBlock().getMaterial() == Material.air)
294
            {
295
                int i = rand.nextBoolean() ? 1 : 0;
296
                worldIn.setBlockState(blockpos, Blocks.rail.getStateFromMeta(this.getMetadataWithOffset(Blocks.rail, i)), 2);
297
                EntityMinecartChest entityminecartchest = new EntityMinecartChest(worldIn, (double)((float)blockpos.getX() + 0.5F), (double)((float)blockpos.getY() + 0.5F), (double)((float)blockpos.getZ() + 0.5F));
298
                WeightedRandomChestContent.generateChestContents(rand, listIn, entityminecartchest, max);
299
                worldIn.spawnEntityInWorld(entityminecartchest);
300
                return true;
301
            }
302
            else
303
            {
304
                return false;
305
            }
306
        }
307
308
        public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn)
309
        {
310
            if (this.isLiquidInStructureBoundingBox(worldIn, structureBoundingBoxIn))
311
            {
312
                return false;
313
            }
314
            else
315
            {
316
                int i = 0;
317
                int j = 2;
318
                int k = 0;
319
                int l = 2;
320
                int i1 = this.sectionCount * 5 - 1;
321
                this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 0, 0, 2, 1, i1, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
322
                this.func_175805_a(worldIn, structureBoundingBoxIn, randomIn, 0.8F, 0, 2, 0, 2, 2, i1, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
323
324
                if (this.hasSpiders)
325
                {
326
                    this.func_175805_a(worldIn, structureBoundingBoxIn, randomIn, 0.6F, 0, 0, 0, 2, 1, i1, Blocks.web.getDefaultState(), Blocks.air.getDefaultState(), false);
327
                }
328
329
                for (int j1 = 0; j1 < this.sectionCount; ++j1)
330
                {
331
                    int k1 = 2 + j1 * 5;
332
                    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 0, k1, 0, 1, k1, Blocks.oak_fence.getDefaultState(), Blocks.air.getDefaultState(), false);
333
                    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 2, 0, k1, 2, 1, k1, Blocks.oak_fence.getDefaultState(), Blocks.air.getDefaultState(), false);
334
335
                    if (randomIn.nextInt(4) == 0)
336
                    {
337
                        this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 2, k1, 0, 2, k1, Blocks.planks.getDefaultState(), Blocks.air.getDefaultState(), false);
338
                        this.fillWithBlocks(worldIn, structureBoundingBoxIn, 2, 2, k1, 2, 2, k1, Blocks.planks.getDefaultState(), Blocks.air.getDefaultState(), false);
339
                    }
340
                    else
341
                    {
342
                        this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 2, k1, 2, 2, k1, Blocks.planks.getDefaultState(), Blocks.air.getDefaultState(), false);
343
                    }
344
345
                    this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.1F, 0, 2, k1 - 1, Blocks.web.getDefaultState());
346
                    this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.1F, 2, 2, k1 - 1, Blocks.web.getDefaultState());
347
                    this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.1F, 0, 2, k1 + 1, Blocks.web.getDefaultState());
348
                    this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.1F, 2, 2, k1 + 1, Blocks.web.getDefaultState());
349
                    this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.05F, 0, 2, k1 - 2, Blocks.web.getDefaultState());
350
                    this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.05F, 2, 2, k1 - 2, Blocks.web.getDefaultState());
351
                    this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.05F, 0, 2, k1 + 2, Blocks.web.getDefaultState());
352
                    this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.05F, 2, 2, k1 + 2, Blocks.web.getDefaultState());
353
                    this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.05F, 1, 2, k1 - 1, Blocks.torch.getStateFromMeta(EnumFacing.UP.getIndex()));
354
                    this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.05F, 1, 2, k1 + 1, Blocks.torch.getStateFromMeta(EnumFacing.UP.getIndex()));
355
356
                    if (randomIn.nextInt(100) == 0)
357
                    {
358
                        this.generateChestContents(worldIn, structureBoundingBoxIn, randomIn, 2, 0, k1 - 1, WeightedRandomChestContent.func_177629_a(StructureMineshaftPieces.CHEST_CONTENT_WEIGHT_LIST, new WeightedRandomChestContent[] {Items.enchanted_book.getRandom(randomIn)}), 3 + randomIn.nextInt(4));
359
                    }
360
361
                    if (randomIn.nextInt(100) == 0)
362
                    {
363
                        this.generateChestContents(worldIn, structureBoundingBoxIn, randomIn, 0, 0, k1 + 1, WeightedRandomChestContent.func_177629_a(StructureMineshaftPieces.CHEST_CONTENT_WEIGHT_LIST, new WeightedRandomChestContent[] {Items.enchanted_book.getRandom(randomIn)}), 3 + randomIn.nextInt(4));
364
                    }
365
366
                    if (this.hasSpiders && !this.spawnerPlaced)
367
                    {
368
                        int l1 = this.getYWithOffset(0);
369
                        int i2 = k1 - 1 + randomIn.nextInt(3);
370
                        int j2 = this.getXWithOffset(1, i2);
371
                        i2 = this.getZWithOffset(1, i2);
372
                        BlockPos blockpos = new BlockPos(j2, l1, i2);
373
374
                        if (structureBoundingBoxIn.isVecInside(blockpos))
375
                        {
376
                            this.spawnerPlaced = true;
377
                            worldIn.setBlockState(blockpos, Blocks.mob_spawner.getDefaultState(), 2);
378
                            TileEntity tileentity = worldIn.getTileEntity(blockpos);
379
380
                            if (tileentity instanceof TileEntityMobSpawner)
381
                            {
382
                                ((TileEntityMobSpawner)tileentity).getSpawnerBaseLogic().setEntityName("CaveSpider");
383
                            }
384
                        }
385
                    }
386
                }
387
388
                for (int k2 = 0; k2 <= 2; ++k2)
389
                {
390
                    for (int i3 = 0; i3 <= i1; ++i3)
391
                    {
392
                        int j3 = -1;
393
                        IBlockState iblockstate1 = this.getBlockStateFromPos(worldIn, k2, j3, i3, structureBoundingBoxIn);
394
395
                        if (iblockstate1.getBlock().getMaterial() == Material.air)
396
                        {
397
                            int k3 = -1;
398
                            this.setBlockState(worldIn, Blocks.planks.getDefaultState(), k2, k3, i3, structureBoundingBoxIn);
399
                        }
400
                    }
401
                }
402
403
                if (this.hasRails)
404
                {
405
                    for (int l2 = 0; l2 <= i1; ++l2)
406
                    {
407
                        IBlockState iblockstate = this.getBlockStateFromPos(worldIn, 1, -1, l2, structureBoundingBoxIn);
408
409
                        if (iblockstate.getBlock().getMaterial() != Material.air && iblockstate.getBlock().isFullBlock())
410
                        {
411
                            this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.7F, 1, 0, l2, Blocks.rail.getStateFromMeta(this.getMetadataWithOffset(Blocks.rail, 0)));
412
                        }
413
                    }
414
                }
415
416
                return true;
417
            }
418
        }
419
    }
420
421
    public static class Cross extends StructureComponent
422
    {
423
        private EnumFacing corridorDirection;
424
        private boolean isMultipleFloors;
425
426
        public Cross()
427
        {
428
        }
429
430
        protected void writeStructureToNBT(NBTTagCompound tagCompound)
431
        {
432
            tagCompound.setBoolean("tf", this.isMultipleFloors);
433
            tagCompound.setInteger("D", this.corridorDirection.getHorizontalIndex());
434
        }
435
436
        protected void readStructureFromNBT(NBTTagCompound tagCompound)
437
        {
438
            this.isMultipleFloors = tagCompound.getBoolean("tf");
439
            this.corridorDirection = EnumFacing.getHorizontal(tagCompound.getInteger("D"));
440
        }
441
442
        public Cross(int type, Random rand, StructureBoundingBox structurebb, EnumFacing facing)
443
        {
444
            super(type);
445
            this.corridorDirection = facing;
446
            this.boundingBox = structurebb;
447
            this.isMultipleFloors = structurebb.getYSize() > 3;
448
        }
449
450
        public static StructureBoundingBox func_175813_a(List<StructureComponent> listIn, Random rand, int x, int y, int z, EnumFacing facing)
451
        {
452
            StructureBoundingBox structureboundingbox = new StructureBoundingBox(x, y, z, x, y + 2, z);
453
454
            if (rand.nextInt(4) == 0)
455
            {
456
                structureboundingbox.maxY += 4;
457
            }
458
459
            switch (facing)
460
            {
461
                case NORTH:
462
                    structureboundingbox.minX = x - 1;
463
                    structureboundingbox.maxX = x + 3;
464
                    structureboundingbox.minZ = z - 4;
465
                    break;
466
467
                case SOUTH:
468
                    structureboundingbox.minX = x - 1;
469
                    structureboundingbox.maxX = x + 3;
470
                    structureboundingbox.maxZ = z + 4;
471
                    break;
472
473
                case WEST:
474
                    structureboundingbox.minX = x - 4;
475
                    structureboundingbox.minZ = z - 1;
476
                    structureboundingbox.maxZ = z + 3;
477
                    break;
478
479
                case EAST:
480
                    structureboundingbox.maxX = x + 4;
481
                    structureboundingbox.minZ = z - 1;
482
                    structureboundingbox.maxZ = z + 3;
483
            }
484
485
            return StructureComponent.findIntersecting(listIn, structureboundingbox) != null ? null : structureboundingbox;
486
        }
487
488
        public void buildComponent(StructureComponent componentIn, List<StructureComponent> listIn, Random rand)
489
        {
490
            int i = this.getComponentType();
491
492
            switch (this.corridorDirection)
493
            {
494
                case NORTH:
495
                    StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.minZ - 1, EnumFacing.NORTH, i);
496
                    StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX - 1, this.boundingBox.minY, this.boundingBox.minZ + 1, EnumFacing.WEST, i);
497
                    StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.maxX + 1, this.boundingBox.minY, this.boundingBox.minZ + 1, EnumFacing.EAST, i);
498
                    break;
499
500
                case SOUTH:
501
                    StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.maxZ + 1, EnumFacing.SOUTH, i);
502
                    StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX - 1, this.boundingBox.minY, this.boundingBox.minZ + 1, EnumFacing.WEST, i);
503
                    StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.maxX + 1, this.boundingBox.minY, this.boundingBox.minZ + 1, EnumFacing.EAST, i);
504
                    break;
505
506
                case WEST:
507
                    StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.minZ - 1, EnumFacing.NORTH, i);
508
                    StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.maxZ + 1, EnumFacing.SOUTH, i);
509
                    StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX - 1, this.boundingBox.minY, this.boundingBox.minZ + 1, EnumFacing.WEST, i);
510
                    break;
511
512
                case EAST:
513
                    StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.minZ - 1, EnumFacing.NORTH, i);
514
                    StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.maxZ + 1, EnumFacing.SOUTH, i);
515
                    StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.maxX + 1, this.boundingBox.minY, this.boundingBox.minZ + 1, EnumFacing.EAST, i);
516
            }
517
518
            if (this.isMultipleFloors)
519
            {
520
                if (rand.nextBoolean())
521
                {
522
                    StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX + 1, this.boundingBox.minY + 3 + 1, this.boundingBox.minZ - 1, EnumFacing.NORTH, i);
523
                }
524
525
                if (rand.nextBoolean())
526
                {
527
                    StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX - 1, this.boundingBox.minY + 3 + 1, this.boundingBox.minZ + 1, EnumFacing.WEST, i);
528
                }
529
530
                if (rand.nextBoolean())
531
                {
532
                    StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.maxX + 1, this.boundingBox.minY + 3 + 1, this.boundingBox.minZ + 1, EnumFacing.EAST, i);
533
                }
534
535
                if (rand.nextBoolean())
536
                {
537
                    StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX + 1, this.boundingBox.minY + 3 + 1, this.boundingBox.maxZ + 1, EnumFacing.SOUTH, i);
538
                }
539
            }
540
        }
541
542
        public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn)
543
        {
544
            if (this.isLiquidInStructureBoundingBox(worldIn, structureBoundingBoxIn))
545
            {
546
                return false;
547
            }
548
            else
549
            {
550
                if (this.isMultipleFloors)
551
                {
552
                    this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.minZ, this.boundingBox.maxX - 1, this.boundingBox.minY + 3 - 1, this.boundingBox.maxZ, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
553
                    this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.minZ + 1, this.boundingBox.maxX, this.boundingBox.minY + 3 - 1, this.boundingBox.maxZ - 1, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
554
                    this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX + 1, this.boundingBox.maxY - 2, this.boundingBox.minZ, this.boundingBox.maxX - 1, this.boundingBox.maxY, this.boundingBox.maxZ, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
555
                    this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX, this.boundingBox.maxY - 2, this.boundingBox.minZ + 1, this.boundingBox.maxX, this.boundingBox.maxY, this.boundingBox.maxZ - 1, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
556
                    this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX + 1, this.boundingBox.minY + 3, this.boundingBox.minZ + 1, this.boundingBox.maxX - 1, this.boundingBox.minY + 3, this.boundingBox.maxZ - 1, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
557
                }
558
                else
559
                {
560
                    this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.minZ, this.boundingBox.maxX - 1, this.boundingBox.maxY, this.boundingBox.maxZ, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
561
                    this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.minZ + 1, this.boundingBox.maxX, this.boundingBox.maxY, this.boundingBox.maxZ - 1, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
562
                }
563
564
                this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.minZ + 1, this.boundingBox.minX + 1, this.boundingBox.maxY, this.boundingBox.minZ + 1, Blocks.planks.getDefaultState(), Blocks.air.getDefaultState(), false);
565
                this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.maxZ - 1, this.boundingBox.minX + 1, this.boundingBox.maxY, this.boundingBox.maxZ - 1, Blocks.planks.getDefaultState(), Blocks.air.getDefaultState(), false);
566
                this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.maxX - 1, this.boundingBox.minY, this.boundingBox.minZ + 1, this.boundingBox.maxX - 1, this.boundingBox.maxY, this.boundingBox.minZ + 1, Blocks.planks.getDefaultState(), Blocks.air.getDefaultState(), false);
567
                this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.maxX - 1, this.boundingBox.minY, this.boundingBox.maxZ - 1, this.boundingBox.maxX - 1, this.boundingBox.maxY, this.boundingBox.maxZ - 1, Blocks.planks.getDefaultState(), Blocks.air.getDefaultState(), false);
568
569
                for (int i = this.boundingBox.minX; i <= this.boundingBox.maxX; ++i)
570
                {
571
                    for (int j = this.boundingBox.minZ; j <= this.boundingBox.maxZ; ++j)
572
                    {
573
                        if (this.getBlockStateFromPos(worldIn, i, this.boundingBox.minY - 1, j, structureBoundingBoxIn).getBlock().getMaterial() == Material.air)
574
                        {
575
                            this.setBlockState(worldIn, Blocks.planks.getDefaultState(), i, this.boundingBox.minY - 1, j, structureBoundingBoxIn);
576
                        }
577
                    }
578
                }
579
580
                return true;
581
            }
582
        }
583
    }
584
585
    public static class Room extends StructureComponent
586
    {
587
        private List<StructureBoundingBox> roomsLinkedToTheRoom = Lists.<StructureBoundingBox>newLinkedList();
588
589
        public Room()
590
        {
591
        }
592
593
        public Room(int type, Random rand, int x, int z)
594
        {
595
            super(type);
596
            this.boundingBox = new StructureBoundingBox(x, 50, z, x + 7 + rand.nextInt(6), 54 + rand.nextInt(6), z + 7 + rand.nextInt(6));
597
        }
598
599
        public void buildComponent(StructureComponent componentIn, List<StructureComponent> listIn, Random rand)
600
        {
601
            int i = this.getComponentType();
602
            int j = this.boundingBox.getYSize() - 3 - 1;
603
604
            if (j <= 0)
605
            {
606
                j = 1;
607
            }
608
609
            int k;
610
611
            for (k = 0; k < this.boundingBox.getXSize(); k = k + 4)
612
            {
613
                k = k + rand.nextInt(this.boundingBox.getXSize());
614
615
                if (k + 3 > this.boundingBox.getXSize())
616
                {
617
                    break;
618
                }
619
620
                StructureComponent structurecomponent = StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX + k, this.boundingBox.minY + rand.nextInt(j) + 1, this.boundingBox.minZ - 1, EnumFacing.NORTH, i);
621
622
                if (structurecomponent != null)
623
                {
624
                    StructureBoundingBox structureboundingbox = structurecomponent.getBoundingBox();
625
                    this.roomsLinkedToTheRoom.add(new StructureBoundingBox(structureboundingbox.minX, structureboundingbox.minY, this.boundingBox.minZ, structureboundingbox.maxX, structureboundingbox.maxY, this.boundingBox.minZ + 1));
626
                }
627
            }
628
629
            for (k = 0; k < this.boundingBox.getXSize(); k = k + 4)
630
            {
631
                k = k + rand.nextInt(this.boundingBox.getXSize());
632
633
                if (k + 3 > this.boundingBox.getXSize())
634
                {
635
                    break;
636
                }
637
638
                StructureComponent structurecomponent1 = StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX + k, this.boundingBox.minY + rand.nextInt(j) + 1, this.boundingBox.maxZ + 1, EnumFacing.SOUTH, i);
639
640
                if (structurecomponent1 != null)
641
                {
642
                    StructureBoundingBox structureboundingbox1 = structurecomponent1.getBoundingBox();
643
                    this.roomsLinkedToTheRoom.add(new StructureBoundingBox(structureboundingbox1.minX, structureboundingbox1.minY, this.boundingBox.maxZ - 1, structureboundingbox1.maxX, structureboundingbox1.maxY, this.boundingBox.maxZ));
644
                }
645
            }
646
647
            for (k = 0; k < this.boundingBox.getZSize(); k = k + 4)
648
            {
649
                k = k + rand.nextInt(this.boundingBox.getZSize());
650
651
                if (k + 3 > this.boundingBox.getZSize())
652
                {
653
                    break;
654
                }
655
656
                StructureComponent structurecomponent2 = StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX - 1, this.boundingBox.minY + rand.nextInt(j) + 1, this.boundingBox.minZ + k, EnumFacing.WEST, i);
657
658
                if (structurecomponent2 != null)
659
                {
660
                    StructureBoundingBox structureboundingbox2 = structurecomponent2.getBoundingBox();
661
                    this.roomsLinkedToTheRoom.add(new StructureBoundingBox(this.boundingBox.minX, structureboundingbox2.minY, structureboundingbox2.minZ, this.boundingBox.minX + 1, structureboundingbox2.maxY, structureboundingbox2.maxZ));
662
                }
663
            }
664
665
            for (k = 0; k < this.boundingBox.getZSize(); k = k + 4)
666
            {
667
                k = k + rand.nextInt(this.boundingBox.getZSize());
668
669
                if (k + 3 > this.boundingBox.getZSize())
670
                {
671
                    break;
672
                }
673
674
                StructureComponent structurecomponent3 = StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.maxX + 1, this.boundingBox.minY + rand.nextInt(j) + 1, this.boundingBox.minZ + k, EnumFacing.EAST, i);
675
676
                if (structurecomponent3 != null)
677
                {
678
                    StructureBoundingBox structureboundingbox3 = structurecomponent3.getBoundingBox();
679
                    this.roomsLinkedToTheRoom.add(new StructureBoundingBox(this.boundingBox.maxX - 1, structureboundingbox3.minY, structureboundingbox3.minZ, this.boundingBox.maxX, structureboundingbox3.maxY, structureboundingbox3.maxZ));
680
                }
681
            }
682
        }
683
684
        public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn)
685
        {
686
            if (this.isLiquidInStructureBoundingBox(worldIn, structureBoundingBoxIn))
687
            {
688
                return false;
689
            }
690
            else
691
            {
692
                this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.minZ, this.boundingBox.maxX, this.boundingBox.minY, this.boundingBox.maxZ, Blocks.dirt.getDefaultState(), Blocks.air.getDefaultState(), true);
693
                this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX, this.boundingBox.minY + 1, this.boundingBox.minZ, this.boundingBox.maxX, Math.min(this.boundingBox.minY + 3, this.boundingBox.maxY), this.boundingBox.maxZ, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
694
695
                for (StructureBoundingBox structureboundingbox : this.roomsLinkedToTheRoom)
696
                {
697
                    this.fillWithBlocks(worldIn, structureBoundingBoxIn, structureboundingbox.minX, structureboundingbox.maxY - 2, structureboundingbox.minZ, structureboundingbox.maxX, structureboundingbox.maxY, structureboundingbox.maxZ, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
698
                }
699
700
                this.randomlyRareFillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX, this.boundingBox.minY + 4, this.boundingBox.minZ, this.boundingBox.maxX, this.boundingBox.maxY, this.boundingBox.maxZ, Blocks.air.getDefaultState(), false);
701
                return true;
702
            }
703
        }
704
705
        public void func_181138_a(int p_181138_1_, int p_181138_2_, int p_181138_3_)
706
        {
707
            super.func_181138_a(p_181138_1_, p_181138_2_, p_181138_3_);
708
709
            for (StructureBoundingBox structureboundingbox : this.roomsLinkedToTheRoom)
710
            {
711
                structureboundingbox.offset(p_181138_1_, p_181138_2_, p_181138_3_);
712
            }
713
        }
714
715
        protected void writeStructureToNBT(NBTTagCompound tagCompound)
716
        {
717
            NBTTagList nbttaglist = new NBTTagList();
718
719
            for (StructureBoundingBox structureboundingbox : this.roomsLinkedToTheRoom)
720
            {
721
                nbttaglist.appendTag(structureboundingbox.toNBTTagIntArray());
722
            }
723
724
            tagCompound.setTag("Entrances", nbttaglist);
725
        }
726
727
        protected void readStructureFromNBT(NBTTagCompound tagCompound)
728
        {
729
            NBTTagList nbttaglist = tagCompound.getTagList("Entrances", 11);
730
731
            for (int i = 0; i < nbttaglist.tagCount(); ++i)
732
            {
733
                this.roomsLinkedToTheRoom.add(new StructureBoundingBox(nbttaglist.getIntArrayAt(i)));
734
            }
735
        }
736
    }
737
738
    public static class Stairs extends StructureComponent
739
    {
740
        public Stairs()
741
        {
742
        }
743
744
        public Stairs(int type, Random rand, StructureBoundingBox structurebb, EnumFacing facing)
745
        {
746
            super(type);
747
            this.coordBaseMode = facing;
748
            this.boundingBox = structurebb;
749
        }
750
751
        protected void writeStructureToNBT(NBTTagCompound tagCompound)
752
        {
753
        }
754
755
        protected void readStructureFromNBT(NBTTagCompound tagCompound)
756
        {
757
        }
758
759
        public static StructureBoundingBox func_175812_a(List<StructureComponent> listIn, Random rand, int x, int y, int z, EnumFacing facing)
760
        {
761
            StructureBoundingBox structureboundingbox = new StructureBoundingBox(x, y - 5, z, x, y + 2, z);
762
763
            switch (facing)
764
            {
765
                case NORTH:
766
                    structureboundingbox.maxX = x + 2;
767
                    structureboundingbox.minZ = z - 8;
768
                    break;
769
770
                case SOUTH:
771
                    structureboundingbox.maxX = x + 2;
772
                    structureboundingbox.maxZ = z + 8;
773
                    break;
774
775
                case WEST:
776
                    structureboundingbox.minX = x - 8;
777
                    structureboundingbox.maxZ = z + 2;
778
                    break;
779
780
                case EAST:
781
                    structureboundingbox.maxX = x + 8;
782
                    structureboundingbox.maxZ = z + 2;
783
            }
784
785
            return StructureComponent.findIntersecting(listIn, structureboundingbox) != null ? null : structureboundingbox;
786
        }
787
788
        public void buildComponent(StructureComponent componentIn, List<StructureComponent> listIn, Random rand)
789
        {
790
            int i = this.getComponentType();
791
792
            if (this.coordBaseMode != null)
793
            {
794
                switch (this.coordBaseMode)
795
                {
796
                    case NORTH:
797
                        StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.minZ - 1, EnumFacing.NORTH, i);
798
                        break;
799
800
                    case SOUTH:
801
                        StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.maxZ + 1, EnumFacing.SOUTH, i);
802
                        break;
803
804
                    case WEST:
805
                        StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX - 1, this.boundingBox.minY, this.boundingBox.minZ, EnumFacing.WEST, i);
806
                        break;
807
808
                    case EAST:
809
                        StructureMineshaftPieces.func_175890_b(componentIn, listIn, rand, this.boundingBox.maxX + 1, this.boundingBox.minY, this.boundingBox.minZ, EnumFacing.EAST, i);
810
                }
811
            }
812
        }
813
814
        public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn)
815
        {
816
            if (this.isLiquidInStructureBoundingBox(worldIn, structureBoundingBoxIn))
817
            {
818
                return false;
819
            }
820
            else
821
            {
822
                this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 5, 0, 2, 7, 1, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
823
                this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 0, 7, 2, 2, 8, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
824
825
                for (int i = 0; i < 5; ++i)
826
                {
827
                    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 5 - i - (i < 4 ? 1 : 0), 2 + i, 2, 7 - i, 2 + i, Blocks.air.getDefaultState(), Blocks.air.getDefaultState(), false);
828
                }
829
830
                return true;
831
            }
832
        }
833
    }
834
}
835

Deobfuscated MCP 1.8.9 source of StructureMineshaftPieces from Marcelektro/MavenMCP-1.8.9 (net/minecraft/world/gen/structure/StructureMineshaftPieces.java), stored verbatim.