StructureBoundingBox .java

net.minecraft.world.gen.structure.StructureBoundingBox (class): members: getComponentToAddBoundingBox, getNewBoundingBox, toNBTTagIntArray, func_175896_b.

net.minecraft.world.gen.structureclass218 linescommon7.8 KB

API Surface (15)

StructureBoundingBox getNewBoundingBox()
StructureBoundingBox getComponentToAddBoundingBox(int p_175897_0_, int p_175897_1_, int p_175897_2_, int p_175897_3_, int p_175897_4_, int p_175897_5_, int p_175897_6_, int p_175897_7_, int p_175897_8_, EnumFacing p_175897_9_)
StructureBoundingBox func_175899_a(int p_175899_0_, int p_175899_1_, int p_175899_2_, int p_175899_3_, int p_175899_4_, int p_175899_5_)
boolean intersectsWith(StructureBoundingBox structurebb)
boolean intersectsWith(int minXIn, int minZIn, int maxXIn, int maxZIn)
void expandTo(StructureBoundingBox sbb)
void offset(int x, int y, int z)
boolean isVecInside(Vec3i vec)
Vec3i func_175896_b()
int getXSize()
int getYSize()
int getZSize()
Vec3i getCenter()
String toString()
NBTTagIntArray toNBTTagIntArray()

Fields & Constants (6)

minX
minY
minZ
maxX
maxY
maxZ

Code Graph: Dependencies (4)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

StructureBoundingBox.java218 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.world.gen.structure;
2
3
import com.google.common.base.Objects;
4
import net.minecraft.nbt.NBTTagIntArray;
5
import net.minecraft.util.BlockPos;
6
import net.minecraft.util.EnumFacing;
7
import net.minecraft.util.Vec3i;
8
9
public class StructureBoundingBox
10
{
11
    /** The first x coordinate of a bounding box. */
12
    public int minX;
13
14
    /** The first y coordinate of a bounding box. */
15
    public int minY;
16
17
    /** The first z coordinate of a bounding box. */
18
    public int minZ;
19
20
    /** The second x coordinate of a bounding box. */
21
    public int maxX;
22
23
    /** The second y coordinate of a bounding box. */
24
    public int maxY;
25
26
    /** The second z coordinate of a bounding box. */
27
    public int maxZ;
28
29
    public StructureBoundingBox()
30
    {
31
    }
32
33
    public StructureBoundingBox(int[] coords)
34
    {
35
        if (coords.length == 6)
36
        {
37
            this.minX = coords[0];
38
            this.minY = coords[1];
39
            this.minZ = coords[2];
40
            this.maxX = coords[3];
41
            this.maxY = coords[4];
42
            this.maxZ = coords[5];
43
        }
44
    }
45
46
    /**
47
     * returns a new StructureBoundingBox with MAX values
48
     */
49
    public static StructureBoundingBox getNewBoundingBox()
50
    {
51
        return new StructureBoundingBox(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE);
52
    }
53
54
    /**
55
     * Create a bounding box with the specified dimensions and rotate it. Used to project a possible new component
56
     * Bounding Box - to check if it would cut anything already spawned
57
     */
58
    public static StructureBoundingBox getComponentToAddBoundingBox(int p_175897_0_, int p_175897_1_, int p_175897_2_, int p_175897_3_, int p_175897_4_, int p_175897_5_, int p_175897_6_, int p_175897_7_, int p_175897_8_, EnumFacing p_175897_9_)
59
    {
60
        switch (p_175897_9_)
61
        {
62
            case NORTH:
63
                return new StructureBoundingBox(p_175897_0_ + p_175897_3_, p_175897_1_ + p_175897_4_, p_175897_2_ - p_175897_8_ + 1 + p_175897_5_, p_175897_0_ + p_175897_6_ - 1 + p_175897_3_, p_175897_1_ + p_175897_7_ - 1 + p_175897_4_, p_175897_2_ + p_175897_5_);
64
65
            case SOUTH:
66
                return new StructureBoundingBox(p_175897_0_ + p_175897_3_, p_175897_1_ + p_175897_4_, p_175897_2_ + p_175897_5_, p_175897_0_ + p_175897_6_ - 1 + p_175897_3_, p_175897_1_ + p_175897_7_ - 1 + p_175897_4_, p_175897_2_ + p_175897_8_ - 1 + p_175897_5_);
67
68
            case WEST:
69
                return new StructureBoundingBox(p_175897_0_ - p_175897_8_ + 1 + p_175897_5_, p_175897_1_ + p_175897_4_, p_175897_2_ + p_175897_3_, p_175897_0_ + p_175897_5_, p_175897_1_ + p_175897_7_ - 1 + p_175897_4_, p_175897_2_ + p_175897_6_ - 1 + p_175897_3_);
70
71
            case EAST:
72
                return new StructureBoundingBox(p_175897_0_ + p_175897_5_, p_175897_1_ + p_175897_4_, p_175897_2_ + p_175897_3_, p_175897_0_ + p_175897_8_ - 1 + p_175897_5_, p_175897_1_ + p_175897_7_ - 1 + p_175897_4_, p_175897_2_ + p_175897_6_ - 1 + p_175897_3_);
73
74
            default:
75
                return new StructureBoundingBox(p_175897_0_ + p_175897_3_, p_175897_1_ + p_175897_4_, p_175897_2_ + p_175897_5_, p_175897_0_ + p_175897_6_ - 1 + p_175897_3_, p_175897_1_ + p_175897_7_ - 1 + p_175897_4_, p_175897_2_ + p_175897_8_ - 1 + p_175897_5_);
76
        }
77
    }
78
79
    public static StructureBoundingBox func_175899_a(int p_175899_0_, int p_175899_1_, int p_175899_2_, int p_175899_3_, int p_175899_4_, int p_175899_5_)
80
    {
81
        return new StructureBoundingBox(Math.min(p_175899_0_, p_175899_3_), Math.min(p_175899_1_, p_175899_4_), Math.min(p_175899_2_, p_175899_5_), Math.max(p_175899_0_, p_175899_3_), Math.max(p_175899_1_, p_175899_4_), Math.max(p_175899_2_, p_175899_5_));
82
    }
83
84
    public StructureBoundingBox(StructureBoundingBox structurebb)
85
    {
86
        this.minX = structurebb.minX;
87
        this.minY = structurebb.minY;
88
        this.minZ = structurebb.minZ;
89
        this.maxX = structurebb.maxX;
90
        this.maxY = structurebb.maxY;
91
        this.maxZ = structurebb.maxZ;
92
    }
93
94
    public StructureBoundingBox(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax)
95
    {
96
        this.minX = xMin;
97
        this.minY = yMin;
98
        this.minZ = zMin;
99
        this.maxX = xMax;
100
        this.maxY = yMax;
101
        this.maxZ = zMax;
102
    }
103
104
    public StructureBoundingBox(Vec3i vec1, Vec3i vec2)
105
    {
106
        this.minX = Math.min(vec1.getX(), vec2.getX());
107
        this.minY = Math.min(vec1.getY(), vec2.getY());
108
        this.minZ = Math.min(vec1.getZ(), vec2.getZ());
109
        this.maxX = Math.max(vec1.getX(), vec2.getX());
110
        this.maxY = Math.max(vec1.getY(), vec2.getY());
111
        this.maxZ = Math.max(vec1.getZ(), vec2.getZ());
112
    }
113
114
    public StructureBoundingBox(int xMin, int zMin, int xMax, int zMax)
115
    {
116
        this.minX = xMin;
117
        this.minZ = zMin;
118
        this.maxX = xMax;
119
        this.maxZ = zMax;
120
        this.minY = 1;
121
        this.maxY = 512;
122
    }
123
124
    /**
125
     * Discover if bounding box can fit within the current bounding box object.
126
     */
127
    public boolean intersectsWith(StructureBoundingBox structurebb)
128
    {
129
        return this.maxX >= structurebb.minX && this.minX <= structurebb.maxX && this.maxZ >= structurebb.minZ && this.minZ <= structurebb.maxZ && this.maxY >= structurebb.minY && this.minY <= structurebb.maxY;
130
    }
131
132
    /**
133
     * Discover if a coordinate is inside the bounding box area.
134
     */
135
    public boolean intersectsWith(int minXIn, int minZIn, int maxXIn, int maxZIn)
136
    {
137
        return this.maxX >= minXIn && this.minX <= maxXIn && this.maxZ >= minZIn && this.minZ <= maxZIn;
138
    }
139
140
    /**
141
     * Expands a bounding box's dimensions to include the supplied bounding box.
142
     */
143
    public void expandTo(StructureBoundingBox sbb)
144
    {
145
        this.minX = Math.min(this.minX, sbb.minX);
146
        this.minY = Math.min(this.minY, sbb.minY);
147
        this.minZ = Math.min(this.minZ, sbb.minZ);
148
        this.maxX = Math.max(this.maxX, sbb.maxX);
149
        this.maxY = Math.max(this.maxY, sbb.maxY);
150
        this.maxZ = Math.max(this.maxZ, sbb.maxZ);
151
    }
152
153
    /**
154
     * Offsets the current bounding box by the specified coordinates. Args: x, y, z
155
     */
156
    public void offset(int x, int y, int z)
157
    {
158
        this.minX += x;
159
        this.minY += y;
160
        this.minZ += z;
161
        this.maxX += x;
162
        this.maxY += y;
163
        this.maxZ += z;
164
    }
165
166
    /**
167
     * Checks if given Vec3i is inside of StructureBoundingBox
168
     */
169
    public boolean isVecInside(Vec3i vec)
170
    {
171
        return vec.getX() >= this.minX && vec.getX() <= this.maxX && vec.getZ() >= this.minZ && vec.getZ() <= this.maxZ && vec.getY() >= this.minY && vec.getY() <= this.maxY;
172
    }
173
174
    public Vec3i func_175896_b()
175
    {
176
        return new Vec3i(this.maxX - this.minX, this.maxY - this.minY, this.maxZ - this.minZ);
177
    }
178
179
    /**
180
     * Get dimension of the bounding box in the x direction.
181
     */
182
    public int getXSize()
183
    {
184
        return this.maxX - this.minX + 1;
185
    }
186
187
    /**
188
     * Get dimension of the bounding box in the y direction.
189
     */
190
    public int getYSize()
191
    {
192
        return this.maxY - this.minY + 1;
193
    }
194
195
    /**
196
     * Get dimension of the bounding box in the z direction.
197
     */
198
    public int getZSize()
199
    {
200
        return this.maxZ - this.minZ + 1;
201
    }
202
203
    public Vec3i getCenter()
204
    {
205
        return new BlockPos(this.minX + (this.maxX - this.minX + 1) / 2, this.minY + (this.maxY - this.minY + 1) / 2, this.minZ + (this.maxZ - this.minZ + 1) / 2);
206
    }
207
208
    public String toString()
209
    {
210
        return Objects.toStringHelper(this).add("x0", this.minX).add("y0", this.minY).add("z0", this.minZ).add("x1", this.maxX).add("y1", this.maxY).add("z1", this.maxZ).toString();
211
    }
212
213
    public NBTTagIntArray toNBTTagIntArray()
214
    {
215
        return new NBTTagIntArray(new int[] {this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ});
216
    }
217
}
218

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