summaryrefslogtreecommitdiff
path: root/src/main/java/jp/plusplus/fbs/world/crack/structure/MapGenSchool.java
blob: 8a07ad177d5a184df3ae1e3bbbcb1f160da9998e (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
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
package jp.plusplus.fbs.world.crack.structure;

import jp.plusplus.fbs.FBS;
import jp.plusplus.fbs.Registry;
import jp.plusplus.fbs.block.BlockCore;
import jp.plusplus.fbs.block.BlockSchoolTable;
import net.minecraft.block.BlockMobSpawner;
import net.minecraft.block.BlockStairs;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.tileentity.TileEntityMobSpawner;
import net.minecraft.world.World;
import net.minecraft.world.gen.structure.MapGenStructure;
import net.minecraft.world.gen.structure.StructureBoundingBox;
import net.minecraft.world.gen.structure.StructureComponent;
import net.minecraft.world.gen.structure.StructureStart;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Created by plusplus_F on 2015/11/08.
 * がっこう!
 */
public class MapGenSchool extends MapGenStructure {
    public static final int HALL_WIDTH =5;
    public static final int FLOOR_HEIGHT =6;
    public static final int ROOM_SIZE =9;
    public static final int HALL1_NUM =3;
    public static final int FLOOR_NUM =3;

    @Override
    public String func_143025_a() {
        return "School";
    }

    @Override
    protected boolean canSpawnStructureAtCoords(int p_75047_1_, int p_75047_2_) {
        return p_75047_1_==0 & p_75047_2_==0;
    }

    @Override
    protected StructureStart getStructureStart(int i, int j) {
        return new Start(this.worldObj, this.rand, i, j);
    }

    public static class Start extends StructureStart{
        public Start(){}

        public Start(World p_i2060_1_, Random rand, int x, int z) {
            super(x, z);// 構造物の構成パーツを決定する
            // 基点はComponentSampleDungeon1

            //高さを求める
            int maxY=300;
            for(int i=0;i<16;i++){
                for(int k=0;k<16;k++){
                    int t= p_i2060_1_.getHeightValue(x, z);
                    if(maxY>t) maxY=t;
                }
            }

            Hall1 hall1 = new Hall1(0, rand, (x << 4) + 2, maxY, (z << 4) + 2);
            this.components.add(hall1);

            // 次のパーツを得る
            hall1.buildComponent(hall1, components, rand);

            // 次のパーツが決定していないパーツは一時的にstructureComponentsに保持されるので、空になるまで次のパーツの決定を続ける
            List<StructureComponent> list = hall1.structureComponents;
            while(!list.isEmpty()) {
                int k = rand.nextInt(list.size());
                StructureComponent structurecomponent = list.remove(k);
                structurecomponent.buildComponent(hall1, this.components, rand);
            }

            // 構造物全体の占有範囲を更新する
            this.updateBoundingBox();
        }
    }

    public static class Hall1 extends StructureComponent{
        // 構成パーツリストを記憶するためのリスト
        public ArrayList<StructureComponent> structureComponents = new ArrayList();
        public int count;

        public Hall1() {}
        public Hall1(int par1, Random par2Random, int x, int y, int z) {
            this(par1, par2Random, x, y, z, 3, 0);
        }
        public Hall1(int par1, Random par2Random, int x, int y, int z, int dir, int c){
            this.coordBaseMode = dir;
            switch(this.coordBaseMode) {
                case 0:
                    this.boundingBox=new StructureBoundingBox(x,y,z,x+ HALL_WIDTH,y+ FLOOR_HEIGHT,z+ ROOM_SIZE);
                    break;
                case 1:
                    this.boundingBox=new StructureBoundingBox(x,y,z,x+ ROOM_SIZE,y+ FLOOR_HEIGHT,z+ HALL_WIDTH);
                    break;
                case 2:
                    this.boundingBox=new StructureBoundingBox(x,y,z,x+ HALL_WIDTH,y+ FLOOR_HEIGHT,z+ ROOM_SIZE);
                    break;
                case 3:
                    this.boundingBox=new StructureBoundingBox(x,y,z,x+ ROOM_SIZE,y+ FLOOR_HEIGHT,z+ HALL_WIDTH);
                    break;
            }
            count=c;
        }

        @Override
        public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) {
            FBS.logger.info("coord:"+coordBaseMode);

            //廊下
            int cx = this.boundingBox.minX, cy = this.boundingBox.minY, cz = this.boundingBox.minZ;
            switch (this.coordBaseMode) {
                case 0:
                    cx = this.boundingBox.minX;
                    cz = this.boundingBox.minZ - (ROOM_SIZE + 1);
                    break;
                case 1:
                    cx = this.boundingBox.maxX + 1;
                    cz = this.boundingBox.minZ;
                    break;
                case 2:
                    cx = this.boundingBox.minX;
                    cz = this.boundingBox.maxZ + 1;
                    break;
                case 3:
                    cx = this.boundingBox.minX - (ROOM_SIZE + 1);
                    cz = this.boundingBox.minZ;
                    break;
            }
            Hall2 h1 = new Hall2(0, par3Random, cx, cy, cz, coordBaseMode, 0, true);
            ((Hall1) par1StructureComponent).structureComponents.add(h1);
            par2List.add(h1);

            switch (this.coordBaseMode) {
                case 2:
                    cx = this.boundingBox.minX;
                    cz = this.boundingBox.minZ - (ROOM_SIZE + 1);
                    break;
                case 3:
                    cx = this.boundingBox.maxX + 1;
                    cz = this.boundingBox.minZ;
                    break;
                case 0:
                    cx = this.boundingBox.minX;
                    cz = this.boundingBox.maxZ + 1;
                    break;
                case 1:
                    cx = this.boundingBox.minX - (ROOM_SIZE + 1);
                    cz = this.boundingBox.minZ;
                    break;
            }
            h1 = new Hall2(0, par3Random, cx, cy, cz, coordBaseMode, 0, false);
            ((Hall1) par1StructureComponent).structureComponents.add(h1);
            par2List.add(h1);

            //階段
            if(count<FLOOR_NUM){
                int rx = boundingBox.minX, ry = boundingBox.minY, rz = boundingBox.minZ;
                switch (this.coordBaseMode) {
                    case 0:
                        rx = this.boundingBox.minX - (ROOM_SIZE + 1);
                        rz = this.boundingBox.minZ;
                        break;
                    case 1:
                        rx = this.boundingBox.maxX;
                        rz = this.boundingBox.minZ + (ROOM_SIZE + 1);
                        break;
                    case 2:
                        rx = this.boundingBox.minX - (ROOM_SIZE + 1);
                        rz = this.boundingBox.maxZ;
                        break;
                    case 3:
                        rx = this.boundingBox.minX;
                        rz = this.boundingBox.minZ - (ROOM_SIZE + 1);
                        break;
                }
                Stairway rm = new Stairway(0, par3Random, rx, ry, rz, coordBaseMode, count);
                ((Hall1) par1StructureComponent).structureComponents.add(rm);
                par2List.add(rm);
            }
        }

        @Override
        protected void func_143012_a(NBTTagCompound nbttagcompound) {}
        @Override
        protected void func_143011_b(NBTTagCompound nbttagcompound) {}

        @Override
        public boolean addComponentParts(World world, Random random, StructureBoundingBox structureboundingbox) {
            // 占有範囲(structureboundingbox)内の指定範囲を指定ブロック&メタデータで埋める
            // 占有範囲(structureboundingbox)内の指定範囲を空気ブロックで埋める
            this.fillWithMetadataBlocks(world, structureboundingbox, 0, 0, 0, HALL_WIDTH, FLOOR_HEIGHT, ROOM_SIZE, BlockCore.plank, 0, Blocks.air, 0, false);
            this.fillWithAir(world, structureboundingbox, 1, 1, 1, HALL_WIDTH - 1, FLOOR_HEIGHT - 1, ROOM_SIZE - 1);

            //道を空ける
            this.fillWithAir(world, structureboundingbox, 1, 1, 0, HALL_WIDTH - 1, FLOOR_HEIGHT - 1, 0);
            this.fillWithAir(world, structureboundingbox, 1, 1, ROOM_SIZE, HALL_WIDTH - 1, FLOOR_HEIGHT - 1, ROOM_SIZE);

            //接続用の道を空ける
            this.fillWithAir(world, structureboundingbox, 0, 1, 1, 0, FLOOR_HEIGHT - 1, ROOM_SIZE - 1);
            if(count==0) this.fillWithAir(world, structureboundingbox, HALL_WIDTH, 1, 3, HALL_WIDTH, 3, 6);
            return true;
        }
    }
    public static class Hall2 extends Hall1{
        boolean nextDir;
        public Hall2(int par1, Random par2Random, int x, int y, int z, int dir, int c, boolean next){
            super(par1, par2Random, x, y, z, dir, c);
            nextDir=next;
        }

        @Override
        public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) {
            //廊下
            if (count < HALL1_NUM) {
                int cx = this.boundingBox.minX, cy = this.boundingBox.minY, cz = this.boundingBox.minZ;
                if (nextDir) {
                    //入り口から向かって右(北側)
                    switch (this.coordBaseMode) {
                        case 0:
                            cx = this.boundingBox.minX;
                            cz = this.boundingBox.minZ - (ROOM_SIZE + 1);
                            break;
                        case 1:
                            cx = this.boundingBox.maxX + 1;
                            cz = this.boundingBox.minZ;
                            break;
                        case 2:
                            cx = this.boundingBox.minX;
                            cz = this.boundingBox.maxZ + 1;
                            break;
                        case 3:
                            cx = this.boundingBox.minX - (ROOM_SIZE + 1);
                            cz = this.boundingBox.minZ;
                            break;
                    }
                } else {
                    switch (this.coordBaseMode) {
                        case 2:
                            cx = this.boundingBox.minX;
                            cz = this.boundingBox.minZ - (ROOM_SIZE + 1);
                            break;
                        case 3:
                            cx = this.boundingBox.maxX + 1;
                            cz = this.boundingBox.minZ;
                            break;
                        case 1:
                            cx = this.boundingBox.minX;
                            cz = this.boundingBox.maxZ + 1;
                            break;
                        case 0:
                            cx = this.boundingBox.minX - (ROOM_SIZE + 1);
                            cz = this.boundingBox.minZ;
                            break;
                    }
                }
                Hall2 h2 = new Hall2(0, par3Random, cx, cy, cz, coordBaseMode, count + 1, nextDir);
                ((Hall1) par1StructureComponent).structureComponents.add(h2);
                par2List.add(h2);
            }
            //ランダムで部屋を1つ
            int rx = boundingBox.minX, ry = boundingBox.minY, rz = boundingBox.minZ;
            switch (this.coordBaseMode) {
                case 0:
                    rx = this.boundingBox.minX - (ROOM_SIZE + 1);
                    rz = this.boundingBox.minZ;
                    break;
                case 1:
                    rx = this.boundingBox.maxX;
                    rz = this.boundingBox.minZ - (ROOM_SIZE + 1);
                    break;
                case 2:
                    rx = this.boundingBox.minX - (ROOM_SIZE + 1);
                    rz = this.boundingBox.maxZ;
                    break;
                case 3:
                    rx = this.boundingBox.minX;
                    rz = this.boundingBox.minZ - (ROOM_SIZE + 1);
                    break;
            }

            RoomBase rm;
            int rr=par3Random.nextInt(3);
            if(rr==0) rm = new RoomStudy(0, par3Random, rx, ry, rz, coordBaseMode);
            else if(rr==1) rm = new RoomZombie(0, par3Random, rx, ry, rz, coordBaseMode);
            else rm = new RoomClassroom(0, par3Random, rx, ry, rz, coordBaseMode);

            ((Hall1) par1StructureComponent).structureComponents.add(rm);
            par2List.add(rm);
        }

        @Override
        public boolean addComponentParts(World world, Random random, StructureBoundingBox structureboundingbox) {
            // 占有範囲(structureboundingbox)内の指定範囲を指定ブロック&メタデータで埋める
            // 占有範囲(structureboundingbox)内の指定範囲を空気ブロックで埋める
            this.fillWithMetadataBlocks(world, structureboundingbox, 0, 0, 0, HALL_WIDTH, FLOOR_HEIGHT, ROOM_SIZE, BlockCore.plank, 0, Blocks.air, 0, false);
            this.fillWithAir(world, structureboundingbox, 1, 1, 1, HALL_WIDTH - 1, FLOOR_HEIGHT - 1, ROOM_SIZE - 1);

            //道を空ける
            if (count == HALL1_NUM) {
                if (nextDir)
                    this.fillWithAir(world, structureboundingbox, 1, 1, ROOM_SIZE, HALL_WIDTH - 1, FLOOR_HEIGHT - 1, ROOM_SIZE);
                else this.fillWithAir(world, structureboundingbox, 1, 1, 0, HALL_WIDTH - 1, FLOOR_HEIGHT - 1, 0);
            } else {
                this.fillWithAir(world, structureboundingbox, 1, 1, 0, HALL_WIDTH - 1, FLOOR_HEIGHT - 1, 0);
                if (count < 5)
                    this.fillWithAir(world, structureboundingbox, 1, 1, ROOM_SIZE, HALL_WIDTH - 1, FLOOR_HEIGHT - 1, ROOM_SIZE);
            }

            //接続用の道を空ける
            this.fillWithAir(world, structureboundingbox, 0, 1, 2, 0, 3, 3);
            this.fillWithAir(world, structureboundingbox, 0, 1, 6, 0, 3, 7);

            //窓
            this.fillWithMetadataBlocks(world, structureboundingbox, HALL_WIDTH, 2, 2, HALL_WIDTH, FLOOR_HEIGHT - 2, 7, Blocks.glass_pane, 0, Blocks.air, 0, false);

            return true;
        }
    }

    public static class Stairway extends StructureComponent{
        public int count;
        public Stairway() {}
        public Stairway(int par1, Random par2Random, int x, int y, int z, int dir, int count){
            this.coordBaseMode = dir;
            this.count=count;
            switch(this.coordBaseMode) {
                case 0:
                    this.boundingBox=new StructureBoundingBox(x,y,z,x+ ROOM_SIZE,y+ FLOOR_HEIGHT*2,z+ ROOM_SIZE);
                    break;
                case 1:
                    this.boundingBox=new StructureBoundingBox(x,y,z,x+ ROOM_SIZE,y+ FLOOR_HEIGHT*2,z+ ROOM_SIZE);
                    break;
                case 2:
                    this.boundingBox=new StructureBoundingBox(x,y,z,x+ ROOM_SIZE,y+ FLOOR_HEIGHT*2,z+ ROOM_SIZE);
                    break;
                case 3:
                    this.boundingBox=new StructureBoundingBox(x,y,z,x+ ROOM_SIZE,y+ FLOOR_HEIGHT*2,z+ ROOM_SIZE);
                    break;
            }
        }

        @Override
        public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) {
            //階段
            int rx = boundingBox.minX, ry = boundingBox.maxY-FLOOR_HEIGHT, rz = boundingBox.minZ;

            switch (this.coordBaseMode) {
                case 2:
                    rx = this.boundingBox.maxX+1;
                    rz = this.boundingBox.minZ;
                    break;
                case 3:
                    rx = this.boundingBox.minX;
                    rz = this.boundingBox.maxZ+1;
                    break;
                case 0:
                    rx = this.boundingBox.minX-(ROOM_SIZE+1);
                    rz = this.boundingBox.minZ;
                    break;
                case 1:
                    rx = this.boundingBox.minX;
                    rz = this.boundingBox.maxZ-(ROOM_SIZE+1);
                    break;
            }
            /*
            switch (this.coordBaseMode) {
                case 2:
                    rx = this.boundingBox.maxX+1;
                    rz = this.boundingBox.minZ+ROOM_SIZE;
                    break;
                case 3:
                    rx = this.boundingBox.maxX+ROOM_SIZE;
                    rz = this.boundingBox.maxZ+1;
                    break;
                case 0:
                    rx = this.boundingBox.minX - (HALL_WIDTH + 1);
                    rz = this.boundingBox.minZ;
                    break;
                case 1:
                    rx = this.boundingBox.minX - ROOM_SIZE;
                    rz = this.boundingBox.minZ - (HALL_WIDTH + 1);
                    break;
            }
            */

            Hall1 h1 = new Hall1(0, par3Random, rx, ry, rz, coordBaseMode, count + 1);
            ((Hall1) par1StructureComponent).structureComponents.add(h1);
            par2List.add(h1);
        }

        @Override
        protected void func_143012_a(NBTTagCompound p_143012_1_) {}

        @Override
        protected void func_143011_b(NBTTagCompound p_143011_1_) {}

        @Override
        public boolean addComponentParts(World world, Random p_74875_2_, StructureBoundingBox structureboundingbox) {
            this.fillWithMetadataBlocks(world, structureboundingbox, 0, 0, 0, ROOM_SIZE, FLOOR_HEIGHT*2, ROOM_SIZE, BlockCore.plank, 0, Blocks.air, 0, false);
            this.fillWithAir(world, structureboundingbox, 1, 1, 1, ROOM_SIZE-1, FLOOR_HEIGHT*2-1, ROOM_SIZE-1);

            int metaL=getMetadataWithOffset(Blocks.oak_stairs, 1), metaR=getMetadataWithOffset(Blocks.oak_stairs, 0);

            //接続穴
            this.fillWithAir(world, structureboundingbox, ROOM_SIZE, 1, 1, ROOM_SIZE, FLOOR_HEIGHT*2-1, ROOM_SIZE-1);
            if(count>0){
                this.fillWithAir(world, structureboundingbox, 1, 0, 1, ROOM_SIZE, 0, ROOM_SIZE-1);

                this.placeBlockAtCurrentPosition(world, Blocks.oak_stairs, metaR, ROOM_SIZE, 0, 3, structureboundingbox);
                this.placeBlockAtCurrentPosition(world, Blocks.oak_stairs, metaR, ROOM_SIZE, 0, 4, structureboundingbox);
                this.placeBlockAtCurrentPosition(world, Blocks.oak_stairs, metaR, ROOM_SIZE, 0, 5, structureboundingbox);
                this.placeBlockAtCurrentPosition(world, Blocks.oak_stairs, metaR, ROOM_SIZE, 0, 6, structureboundingbox);
            }

            //階段 0x4=0,
            for(int i=0;i<3;i++){
                this.placeBlockAtCurrentPosition(world, Blocks.oak_stairs, metaL, ROOM_SIZE-i, 1+i, 1, structureboundingbox);
                this.placeBlockAtCurrentPosition(world, Blocks.oak_stairs, metaL, ROOM_SIZE-i, 1+i, 2, structureboundingbox);
                this.placeBlockAtCurrentPosition(world, Blocks.oak_stairs, metaL, ROOM_SIZE-i, 1+i, 7, structureboundingbox);
                this.placeBlockAtCurrentPosition(world, Blocks.oak_stairs, metaL, ROOM_SIZE-i, 1+i, 8, structureboundingbox);

                this.placeBlockAtCurrentPosition(world, Blocks.oak_stairs, metaR, ROOM_SIZE+i-2, 4+i, 3, structureboundingbox);
                this.placeBlockAtCurrentPosition(world, Blocks.oak_stairs, metaR, ROOM_SIZE+i-2, 4+i, 4, structureboundingbox);
                this.placeBlockAtCurrentPosition(world, Blocks.oak_stairs, metaR, ROOM_SIZE+i-2, 4+i, 5, structureboundingbox);
                this.placeBlockAtCurrentPosition(world, Blocks.oak_stairs, metaR, ROOM_SIZE+i-2, 4+i, 6, structureboundingbox);
            }

            this.fillWithMetadataBlocks(world, structureboundingbox, 1, 3, 1, 6, 3, ROOM_SIZE-1, BlockCore.plank, 0, Blocks.air, 0, false);

            return true;
        }

    }

    public static class Entrance extends StructureComponent{
        public Entrance() {}
        public Entrance(int par1, Random par2Random, int x, int y, int z, int dir) {
            this.coordBaseMode=dir;
            this.boundingBox=new StructureBoundingBox(x,y,z,x+ HALL_WIDTH,y+ FLOOR_HEIGHT,z+ HALL_WIDTH);
        }

        @Override
        protected void func_143012_a(NBTTagCompound p_143012_1_) {}

        @Override
        protected void func_143011_b(NBTTagCompound p_143011_1_) {}

        @Override
        public boolean addComponentParts(World world, Random p_74875_2_, StructureBoundingBox structureboundingbox) {
            this.fillWithMetadataBlocks(world, structureboundingbox, 0, 0, 0, HALL_WIDTH, FLOOR_HEIGHT, HALL_WIDTH, BlockCore.plank, 0, Blocks.air, 0, false);
            this.fillWithAir(world, structureboundingbox, 1, 1, 1, HALL_WIDTH -1, FLOOR_HEIGHT -1, HALL_WIDTH -1);

            this.fillWithAir(world, structureboundingbox, 1, 1, 0, HALL_WIDTH-1, 3, 0);
            this.fillWithAir(world, structureboundingbox, 1, 1, HALL_WIDTH, HALL_WIDTH-1, 3, HALL_WIDTH);

            return true;
        }

    }

    public static class RoomBase extends StructureComponent {
        public RoomBase() {}
        public RoomBase(int par1, Random par2Random, int x, int y, int z, int dir) {
            this.coordBaseMode = dir;
            this.boundingBox = new StructureBoundingBox(x, y, z, x + ROOM_SIZE, y+FLOOR_HEIGHT, z + ROOM_SIZE);
        }

        protected boolean hasWindow(){ return true; }

        @Override
        protected void func_143012_a(NBTTagCompound nbttagcompound) {}
        @Override
        protected void func_143011_b(NBTTagCompound nbttagcompound) {}

        @Override
        public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) {
            //何にも派生しない
        }

        @Override
        public boolean addComponentParts(World world, Random random, StructureBoundingBox structureboundingbox) {
            this.fillWithMetadataBlocks(world, structureboundingbox, 0, 0, 0, ROOM_SIZE, FLOOR_HEIGHT, ROOM_SIZE, BlockCore.plank, 0, Blocks.air, 0, false);
            this.fillWithAir(world, structureboundingbox, 1, 1, 1, ROOM_SIZE-1, FLOOR_HEIGHT-1, ROOM_SIZE-1);

            this.fillWithAir(world, structureboundingbox, ROOM_SIZE, 1, 2, ROOM_SIZE, 3, 3);
            this.fillWithAir(world, structureboundingbox, ROOM_SIZE, 1, 6, ROOM_SIZE, 3, 7);

            if(hasWindow()){
                this.fillWithMetadataBlocks(world, structureboundingbox, 0, 2, 2, 0, FLOOR_HEIGHT - 2, 3, Blocks.glass_pane, 0, Blocks.air, 0, false);
                this.fillWithMetadataBlocks(world, structureboundingbox, 0, 2, 6, 0, FLOOR_HEIGHT - 2, 7, Blocks.glass_pane, 0, Blocks.air, 0, false);
            }

            return true;
        }
    }

    public static class RoomStudy extends RoomBase{
        public RoomStudy() {}
        public RoomStudy(int par1, Random par2Random, int x, int y, int z, int dir) {
            super(par1, par2Random, x, y, z, dir);}

        @Override
        protected boolean hasWindow(){ return true; }

        @Override
        public boolean addComponentParts(World world, Random random, StructureBoundingBox structureboundingbox) {
            super.addComponentParts(world, random, structureboundingbox);

            //本
            for(int y=1;y<=FLOOR_HEIGHT-2;y++){
                for(int z=1;z<=ROOM_SIZE-1;z++){
                    //this.placeBlockAtCurrentPosition(world, BlockCore.bookshelf, getBookNum(random, 3), 1, y, z, structureboundingbox);

                    if(z!=4 && z!=5){
                        this.placeBlockAtCurrentPosition(world, BlockCore.bookshelf, getBookNum(random, 3), 3, y, z, structureboundingbox);
                        this.placeBlockAtCurrentPosition(world, BlockCore.bookshelf, getBookNum(random, 3), 5, y, z, structureboundingbox);
                    }
                    else {
                        this.placeBlockAtCurrentPosition(world, BlockCore.bookshelf, getBookNum(random, 3), 7, y, z, structureboundingbox);
                    }
                }
            }

            return true;
        }

        protected int getBookNum(Random rand, int max){
            return 2+rand.nextInt(max);
        }
    }

    public static class RoomClassroom extends RoomBase{
        public RoomClassroom() {}
        public RoomClassroom(int par1, Random par2Random, int x, int y, int z, int dir) {
            super(par1, par2Random, x, y, z, dir);
        }

        @Override
        public boolean addComponentParts(World world, Random random, StructureBoundingBox structureboundingbox) {
            super.addComponentParts(world, random, structureboundingbox);

            int meta=0;
            switch (coordBaseMode){
                case 0:
                    meta=2;
                    break;
                case 1:
                    meta=5;
                    break;
                case 2:
                    meta=3;
                    break;
                case 3:
                    meta=4;
                    break;
            }

            //学校の机
            for(int i=0;i<3;i++){
                for(int k=0;k<4;k++){
                    placeBlockAtCurrentPosition(world, BlockCore.schoolTable, meta, 1+k*2, 1, 2+i*2, structureboundingbox);
                }
            }

            //教壇
            fillWithMetadataBlocks(world, structureboundingbox, 2, 1, 8, 7, 1, 8, Blocks.wooden_slab, 0, Blocks.air, 0, false);

            return true;
        }
    }

    public static class RoomZombie extends RoomBase{
        private boolean chest=false;

        public RoomZombie() {}
        public RoomZombie(int par1, Random par2Random, int x, int y, int z, int dir) {
            super(par1, par2Random, x, y, z, dir);
        }

        @Override
        protected void func_143012_a(NBTTagCompound tag) {
            tag.setBoolean("Chest", this.chest);
        }
        @Override
        protected void func_143011_b(NBTTagCompound tag) {
            chest = tag.getBoolean("Chest");
        }

        @Override
        public boolean addComponentParts(World world, Random random, StructureBoundingBox structureboundingbox) {
            super.addComponentParts(world, random, structureboundingbox);

            placeBlockAtCurrentPosition(world, Blocks.mob_spawner, 0, 4, 1, 4, structureboundingbox);
            TileEntity te=world.getTileEntity(getXWithOffset(4, 4), getYWithOffset(1), getZWithOffset(4, 4));
            if(te instanceof TileEntityMobSpawner){
                ((TileEntityMobSpawner) te).func_145881_a().setEntityName("Zombie");
                te.markDirty();
            }

            //chest
            if(!chest){
                int cx=getXWithOffset(1, ROOM_SIZE-1), cy=getYWithOffset(1), cz=getZWithOffset(1, ROOM_SIZE-1);
                if(structureboundingbox.isVecInside(cx, cy, cz) && world.getBlock(cx, cy, cz)!=Blocks.chest){
                    world.setBlock(cx, cy, cz, Blocks.chest, 0, 2);
                    te=world.getTileEntity(cx,cy,cz);
                    if(te instanceof TileEntityChest){
                        TileEntityChest e=(TileEntityChest)te;
                        ItemStack[] items=new ItemStack[e.getSizeInventory()];
                        Registry.GetChestContents(2, items, 0.25f);
                        for(int i=0;i<items.length;i++){
                            e.setInventorySlotContents(i, items[i]);
                        }
                    }
                    chest=true;
                }
            }

            return true;
        }
    }
}