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
|
package jp.plusplus.fbs.world.structure;
import jp.plusplus.fbs.Registry;
import jp.plusplus.fbs.block.BlockCore;
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.world.World;
import net.minecraft.world.gen.structure.StructureBoundingBox;
import net.minecraft.world.gen.structure.StructureComponent;
import java.util.Random;
/**
* Createdby pluslus_Fon 2015/06/06.
* 1つの図書館からだいたい16.8冊手に入る?
*/
public class StructureSealedLib1 extends StructureComponent {
private boolean chest=false;
public StructureSealedLib1(){}
public StructureSealedLib1(int par1, Random rand, int x, int y, int z) {
this.coordBaseMode = 0;
//y=6+rand.nextInt(40-6+1);
this.boundingBox = new StructureBoundingBox(x, y, z, x + 11, y+6, z + 11);
}
@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 rand, StructureBoundingBox box) {
int[] bx={1,1,2,3, 7,8,9,9, 9,9,8,7, 3,2,1,1};
int[] bz={3,2,1,1, 1,1,2,3, 7,8,9,9, 9,9,8,7};
int[] wx={1,9,9,1};
int[] wz={1,1,9,9};
int[] tx={1,5,9,5};
int[] tz={5,1,5,9};
this.fillWithBlocks(world, box, 0, 0, 0, 10, 5, 10, BlockCore.plank, BlockCore.plank, false);
this.fillWithBlocks(world, box, 1, 1, 1, 9, 4, 9, Blocks.air, Blocks.air, false);
for(int i=0;i<bx.length;i++){
for(int k=0;k<4;k++){
this.placeBlockAtCurrentPosition(world, BlockCore.bookshelf, getNum(rand, 2), bx[i], 1+k, bz[i], box);
}
}
for(int i=0;i<wx.length;i++){
for(int k=0;k<4;k++){
this.placeBlockAtCurrentPosition(world, BlockCore.plank, 0, wx[i], 1+k, wz[i], box);
}
}
for(int i=0;i<3;i++){
for(int n=0;n<3;n++){
for(int k=0;k<4;k++){
if(i==1 && n==1){
//if(k>0) this.placeBlockAtCurrentPosition(world, BlockCore.plank, 0, 4+i, 1+k, 4+n, box);
}
else this.placeBlockAtCurrentPosition(world, BlockCore.bookshelf, getNum(rand, 4), 4+i, 1+k, 4+n, box);
}
}
}
/*
for(int k=0;k<4;k++){
this.placeBlockAtCurrentPosition(world, BlockCore.plank, 0, 5, 1+k, 5, box);
}
*/
for(int i=0;i<tx.length;i++){
this.placeBlockAtCurrentPosition(world, Blocks.torch, 0, tx[i], 2, tz[i], box);
}
//chest
if(!chest){
int cx=getXWithOffset(5, 5), cy=getYWithOffset(1), cz=getZWithOffset(5, 5);
if(box.isVecInside(cx, cy, cz) && world.getBlock(cx, cy, cz)!=Blocks.chest){
world.setBlock(cx, cy, cz, Blocks.chest, 0, 2);
TileEntity te=world.getTileEntity(cx,cy,cz);
if(te instanceof TileEntityChest){
TileEntityChest e=(TileEntityChest)te;
ItemStack[] items=new ItemStack[e.getSizeInventory()];
Registry.GetChestContents(0, items, 0.15f);
for(int i=0;i<items.length;i++){
e.setInventorySlotContents(i, items[i]);
}
}
chest=true;
}
}
//placeBlockAtCurrentPosition(world, Blocks.chest, 0, 5, 1, 5, box);
//world.setBlock(i1, j1, k1, Blocks.chest, 0, 2);
//FMLLog.severe("generated at "+box.getCenterX()+","+box.getCenterY()+","+box.getCenterZ());
return true;
}
protected int getNum(Random rand, int max){
if(rand.nextFloat()<=0.15f){
return 1+rand.nextInt(max);
}
return 0;
}
}
|