ChunkCoordIntPair .java

net.minecraft.world.ChunkCoordIntPair (class): members: getCenterZPosition, getCenterBlock, getCenterXPos, chunkXZ2Int, chunkXPos, chunkZPos, getXStart.

net.minecraft.worldclass114 linescommon2.7 KB

API Surface (12)

long chunkXZ2Int(int x, int z)
int hashCode()
boolean equals(Object p_equals_1_)
int getCenterXPos()
int getCenterZPosition()
int getXStart()
int getZStart()
int getXEnd()
int getZEnd()
BlockPos getBlock(int x, int y, int z)
BlockPos getCenterBlock(int y)
String toString()

Fields & Constants (2)

chunkXPos
chunkZPos

Code Graph: Dependencies (1)

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

Full Source

ChunkCoordIntPair.java114 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.world;
2
3
import net.minecraft.util.BlockPos;
4
5
public class ChunkCoordIntPair
6
{
7
    /** The X position of this Chunk Coordinate Pair */
8
    public final int chunkXPos;
9
10
    /** The Z position of this Chunk Coordinate Pair */
11
    public final int chunkZPos;
12
13
    public ChunkCoordIntPair(int x, int z)
14
    {
15
        this.chunkXPos = x;
16
        this.chunkZPos = z;
17
    }
18
19
    /**
20
     * converts a chunk coordinate pair to an integer (suitable for hashing)
21
     */
22
    public static long chunkXZ2Int(int x, int z)
23
    {
24
        return (long)x & 4294967295L | ((long)z & 4294967295L) << 32;
25
    }
26
27
    public int hashCode()
28
    {
29
        int i = 1664525 * this.chunkXPos + 1013904223;
30
        int j = 1664525 * (this.chunkZPos ^ -559038737) + 1013904223;
31
        return i ^ j;
32
    }
33
34
    public boolean equals(Object p_equals_1_)
35
    {
36
        if (this == p_equals_1_)
37
        {
38
            return true;
39
        }
40
        else if (!(p_equals_1_ instanceof ChunkCoordIntPair))
41
        {
42
            return false;
43
        }
44
        else
45
        {
46
            ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair)p_equals_1_;
47
            return this.chunkXPos == chunkcoordintpair.chunkXPos && this.chunkZPos == chunkcoordintpair.chunkZPos;
48
        }
49
    }
50
51
    public int getCenterXPos()
52
    {
53
        return (this.chunkXPos << 4) + 8;
54
    }
55
56
    public int getCenterZPosition()
57
    {
58
        return (this.chunkZPos << 4) + 8;
59
    }
60
61
    /**
62
     * Get the first world X coordinate that belongs to this Chunk
63
     */
64
    public int getXStart()
65
    {
66
        return this.chunkXPos << 4;
67
    }
68
69
    /**
70
     * Get the first world Z coordinate that belongs to this Chunk
71
     */
72
    public int getZStart()
73
    {
74
        return this.chunkZPos << 4;
75
    }
76
77
    /**
78
     * Get the last world X coordinate that belongs to this Chunk
79
     */
80
    public int getXEnd()
81
    {
82
        return (this.chunkXPos << 4) + 15;
83
    }
84
85
    /**
86
     * Get the last world Z coordinate that belongs to this Chunk
87
     */
88
    public int getZEnd()
89
    {
90
        return (this.chunkZPos << 4) + 15;
91
    }
92
93
    /**
94
     * Get the World coordinates of the Block with the given Chunk coordinates relative to this chunk
95
     */
96
    public BlockPos getBlock(int x, int y, int z)
97
    {
98
        return new BlockPos((this.chunkXPos << 4) + x, y, (this.chunkZPos << 4) + z);
99
    }
100
101
    /**
102
     * Get the coordinates of the Block in the center of this chunk with the given Y coordinate
103
     */
104
    public BlockPos getCenterBlock(int y)
105
    {
106
        return new BlockPos(this.getCenterXPos(), y, this.getCenterZPosition());
107
    }
108
109
    public String toString()
110
    {
111
        return "[" + this.chunkXPos + ", " + this.chunkZPos + "]";
112
    }
113
}
114

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