This repository has been archived by the owner on Dec 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
228 additions
and
197 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
src/main/java/com/lb_stuff/mcmodify/location/LocChunkInDimension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.lb_stuff.mcmodify.location; | ||
|
||
import com.lb_stuff.mcmodify.minecraft.Region; | ||
|
||
/** | ||
* Location of a Chunk in a Dimension. | ||
*/ | ||
public class LocChunkInDimension | ||
{ | ||
public final int x; | ||
public final int z; | ||
public LocChunkInDimension(int cx, int cz) | ||
{ | ||
x = cx; | ||
z = cz; | ||
} | ||
|
||
/** | ||
* Returns the location of this chunk in a region. | ||
* @return The location of this chunk in a region. | ||
*/ | ||
public LocChunkInRegion getLocInRegion() | ||
{ | ||
return new LocChunkInRegion(x - x/Region.CHUNK_X_SIZE*Region.CHUNK_X_SIZE, z - z/Region.CHUNK_Z_SIZE*Region.CHUNK_Z_SIZE); | ||
} | ||
/** | ||
* Returns the region this chunk is in. | ||
* @return The region this chunk is in. | ||
*/ | ||
public LocRegionInDimension getRegionLoc() | ||
{ | ||
return new LocRegionInDimension(x/Region.CHUNK_X_SIZE, z/Region.CHUNK_Z_SIZE); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/lb_stuff/mcmodify/location/LocChunkInRegion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.lb_stuff.mcmodify.location; | ||
|
||
import com.lb_stuff.mcmodify.minecraft.Region; | ||
|
||
/** | ||
* Location of a Chunk in a Region. | ||
*/ | ||
public class LocChunkInRegion | ||
{ | ||
public final int x; | ||
public final int z; | ||
public LocChunkInRegion(int cx, int cz) | ||
{ | ||
if(cx < 0 || cx >= 32 || cz < 0 || cz >= 32) | ||
{ | ||
throw new IllegalArgumentException("Invalid chunk location ("+cx+","+cz+") in region"); | ||
} | ||
x = cx; | ||
z = cz; | ||
} | ||
|
||
/** | ||
* Returns the location of this chunk in a dimension. | ||
* @param loc The region this chunk is in. | ||
* @return The location of this chunk in a dimension. | ||
*/ | ||
public LocChunkInDimension getLocInDimension(LocRegionInDimension loc) | ||
{ | ||
return new LocChunkInDimension(loc.x*Region.CHUNK_X_SIZE + x, loc.z*Region.CHUNK_Z_SIZE + z); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/lb_stuff/mcmodify/location/LocRegionInDimension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.lb_stuff.mcmodify.location; | ||
|
||
import com.lb_stuff.mcmodify.minecraft.Region; | ||
|
||
/** | ||
* Location of a Region in a Dimension. | ||
*/ | ||
public class LocRegionInDimension | ||
{ | ||
public final int x; | ||
public final int z; | ||
public LocRegionInDimension(int cx, int cz) | ||
{ | ||
x = cx; | ||
z = cz; | ||
} | ||
|
||
/** | ||
* Returns whether this region contains the given chunk. | ||
* @param loc The chunk being tested. | ||
* @return Whether this region contains the given chunk. | ||
*/ | ||
public boolean containsChunk(LocChunkInDimension loc) | ||
{ | ||
return | ||
(x+0)*Region.CHUNK_X_SIZE <= loc.x && | ||
(x+1)*Region.CHUNK_X_SIZE > loc.x && | ||
(z+0)*Region.CHUNK_Z_SIZE <= loc.z && | ||
(z+1)*Region.CHUNK_Z_SIZE > loc.z; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.