Skip to content

Commit

Permalink
Coordinate classes renamed to Point
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Fedin committed Dec 4, 2016
1 parent 2a94174 commit 93de8c2
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 39 deletions.
4 changes: 2 additions & 2 deletions src/main/java/mregioneer/mcaliases/Block.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import com.mojang.nbt.ByteArrayTag;
import com.mojang.nbt.CompoundTag;
import mregioneer.utils.Coordinates3d;
import mregioneer.utils.Point3d;
import mregioneer.utils.Formulae;
import mregioneer.utils.Helpers;

Expand All @@ -26,7 +26,7 @@ public class Block {

private TileEntity tileEntity = null;

protected Block(Coordinates3d cords, Section section) {
protected Block(Point3d cords, Section section) {
this.blocks = ((ByteArrayTag)section.get("Blocks")).data;

this.x = cords.getX();
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/mregioneer/mcaliases/Chunk.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.mojang.nbt.IntTag;
import com.mojang.nbt.ListTag;
import mregioneer.utils.Coordinates2d;
import mregioneer.utils.Coordinates3d;
import mregioneer.utils.Point3d;
import mregioneer.utils.Formulae;

import static mregioneer.utils.Formulae.sectionFromBlock;
Expand Down Expand Up @@ -108,7 +108,7 @@ public void changeBlockId(int x, int y, int z, byte id) {
* @param cords
* @param id
*/
public void changeBlockId(Coordinates3d cords, byte id) {
public void changeBlockId(Point3d cords, byte id) {
int local_x = Formulae.localBlockFromBlock(cords.getX());
int local_y = Formulae.localBlockFromBlock(cords.getY());
int local_z = Formulae.localBlockFromBlock(cords.getZ());
Expand Down Expand Up @@ -164,7 +164,7 @@ public byte getBlockAddId(int x, int y, int z) {
}
}

public Block getBlock(Coordinates3d cords) {
public Block getBlock(Point3d cords) {
byte section_index = (byte) sectionFromBlock(cords.getY());
return new Block(cords, getSection(section_index));
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/mregioneer/mcaliases/Region.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import com.mojang.nbt.CompoundTag;
import com.mojang.nbt.NbtIo;
import mregioneer.utils.Coordinates3d;
import mregioneer.utils.Point3d;
import net.minecraft.world.level.chunk.storage.RegionFile;
import mregioneer.utils.Coordinates2d;
import mregioneer.utils.Formulae;
Expand Down Expand Up @@ -126,7 +126,7 @@ public void save() throws IOException {
* @param id
* @throws IOException
*/
public void changeBlockId(Coordinates3d cords, byte id) throws IOException {
public void changeBlockId(Point3d cords, byte id) throws IOException {
int block_global_x = cords.getX();
int block_global_z = cords.getZ();

Expand All @@ -143,7 +143,7 @@ public void changeBlockId(Coordinates3d cords, byte id) throws IOException {
* @param cords
* @return
*/
public byte getBlockId(Coordinates3d cords) {
public byte getBlockId(Point3d cords) {
int block_global_x = cords.getX();
int block_global_z = cords.getZ();
int block_global_y = cords.getY();
Expand All @@ -157,7 +157,7 @@ public byte getBlockId(Coordinates3d cords) {
return id;
}

public byte getBlockAddId(Coordinates3d cords) {
public byte getBlockAddId(Point3d cords) {
int block_global_x = cords.getX();
int block_global_z = cords.getZ();
int block_global_y = cords.getY();
Expand All @@ -171,7 +171,7 @@ public byte getBlockAddId(Coordinates3d cords) {
return id;
}

public Block getBlock(Coordinates3d cords) {
public Block getBlock(Point3d cords) {
int block_global_x = cords.getX();
int block_global_z = cords.getZ();

Expand Down
18 changes: 9 additions & 9 deletions src/main/java/mregioneer/mcaliases/Vector.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package mregioneer.mcaliases;

import mregioneer.utils.Coordinates3d;
import mregioneer.utils.Point3d;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -13,10 +13,10 @@
*/
public class Vector {

private Coordinates3d cords1;
private Coordinates3d cords2;
private Point3d cords1;
private Point3d cords2;

public Vector(Coordinates3d cords1, Coordinates3d cords2) {
public Vector(Point3d cords1, Point3d cords2) {
int min_x = min(cords1.x, cords2.x);
int max_x = max(cords1.x, cords2.x);

Expand All @@ -26,8 +26,8 @@ public Vector(Coordinates3d cords1, Coordinates3d cords2) {
int min_y = min(cords1.y, cords2.y);
int max_y = max(cords1.y, cords2.y);

this.cords1 = new Coordinates3d(min_x, min_y, min_z);
this.cords2 = new Coordinates3d(max_x, max_y, max_z);
this.cords1 = new Point3d(min_x, min_y, min_z);
this.cords2 = new Point3d(max_x, max_y, max_z);
}

public int getXstart() {
Expand Down Expand Up @@ -55,19 +55,19 @@ public int getZend() {
}


public List<Coordinates3d> getCoordinatesArray() {
public List<Point3d> getCoordinatesArray() {

int height = getZend() - getZstart() + 1;
int width = getXend() - getXstart() + 1;
int depth = getYend() - getYstart() + 1;

//Coordinates3d[] cords_arr = new Coordinates3d[depth * height * width];
ArrayList cords_arr_list = new ArrayList<Coordinates3d>();
ArrayList cords_arr_list = new ArrayList<Point3d>();

for(int z = getZstart(); z <= getZend(); z++) {
for(int y = getYstart(); y <= getYend(); y++) {
for(int x = getXstart(); x <= getXend(); x++) {
cords_arr_list.add(new Coordinates3d(x, y, z));
cords_arr_list.add(new Point3d(x, y, z));
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/mregioneer/mcaliases/World.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package mregioneer.mcaliases;

import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
import mregioneer.utils.Coordinates3d;
import mregioneer.utils.Point3d;
import net.minecraft.world.level.chunk.storage.RegionFile;
import mregioneer.utils.Coordinates2d;

Expand Down Expand Up @@ -93,7 +93,7 @@ public Region getRegion(int x, int z) {
* @param id
* @throws IOException
*/
public void changeBlockID(Coordinates3d cords, byte id) throws IOException {
public void changeBlockID(Point3d cords, byte id) throws IOException {
int region_x = regionFromBlock(cords.getX());
int region_z = regionFromBlock(cords.getZ());

Expand All @@ -106,23 +106,23 @@ public void changeBlockID(Coordinates3d cords, byte id) throws IOException {
* @param cords
* @return
*/
public byte getBlockId(Coordinates3d cords) {
public byte getBlockId(Point3d cords) {
int region_x = regionFromBlock(cords.getX());
int region_z = regionFromBlock(cords.getZ());

Region region = this.getRegion(region_x, region_z);
return region.getBlockId(cords);
}

public byte getBlockAddId(Coordinates3d cords) {
public byte getBlockAddId(Point3d cords) {
int region_x = regionFromBlock(cords.getX());
int region_z = regionFromBlock(cords.getZ());

Region region = this.getRegion(region_x, region_z);
return region.getBlockAddId(cords);
}

public Block getBlock(Coordinates3d cords) {
public Block getBlock(Point3d cords) {
int region_x = regionFromBlock(cords.getX());
int region_z = regionFromBlock(cords.getZ());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
* The class has been created to use as a key for hash maps containing chunks, regions and so on.
* All new inctanses of the class with simular params returns the same hash code
*/
public class Coordinates2d {
public class Point2d {
public final int x;
public final int z;

private final String coordinates_as_string;

public Coordinates2d(int x, int z) {
public Point2d(int x, int z) {
this.x = x;
this.z = z;

Expand Down Expand Up @@ -45,7 +45,7 @@ public boolean equals(Object obj) {
return false;
else
{
Coordinates2d tmp = (Coordinates2d)obj;
Point2d tmp = (Point2d)obj;
return tmp.toString().equals(this.toString());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
* The class has been created to use as a key for hash maps containing chunks, regions and so on.
* All new inctanses of the class with simular params returns the same hash code
*/
public class Coordinates3d {
public class Point3d {
public final int x;
public final int y;
public final int z;

private final String coordinates_as_string;

public Coordinates3d(int x, int y, int z) {
public Point3d(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
Expand Down Expand Up @@ -51,7 +51,7 @@ public boolean equals(Object obj) {
return false;
else
{
Coordinates3d tmp = (Coordinates3d)obj;
Point3d tmp = (Point3d)obj;
return tmp.toString().equals(this.toString());
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/TestBlock.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import mregioneer.mcaliases.Block;
import mregioneer.mcaliases.World;
import mregioneer.utils.Coordinates3d;
import mregioneer.utils.Point3d;
import org.ini4j.Ini;
import org.junit.Test;

Expand All @@ -14,7 +14,7 @@ public class TestBlock {
public void testAdd() {

World world;
Coordinates3d cords = new Coordinates3d(-3, 64, 6);
Point3d cords = new Point3d(-3, 64, 6);
byte id_to_make = 7;

try {
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/TestReadWrite2.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import org.ini4j.Ini;
import org.junit.Test;
import mregioneer.mcaliases.World;
import mregioneer.utils.Coordinates3d;
import mregioneer.utils.Point3d;

import java.io.File;
import java.io.IOException;
Expand All @@ -24,18 +24,18 @@ public void testAdd() {

world = new World(new File (path_to_mca_folder));

Coordinates3d cords;
Point3d cords;
for(int inty = 6; inty < 100; inty++){
for(int intz = -10; intz < 10; intz++){
for(int intx = -10; intx < 10; intx++){
world.changeBlockID(new Coordinates3d(intx, inty, intz), id_to_make);
world.changeBlockID(new Point3d(intx, inty, intz), id_to_make);
}
}
}
world.save();

world = new World(new File (path_to_mca_folder));
cords = new Coordinates3d(1, 66 ,1);
cords = new Point3d(1, 66 ,1);
byte id = world.getBlockId(cords);

assertTrue(id == id_to_make);
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/TestVector.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import mregioneer.mcaliases.Vector;
import mregioneer.utils.Coordinates3d;
import mregioneer.utils.Point3d;
import org.junit.Test;

import java.util.List;

public class TestVector {
@Test
public void testAdd() {
Coordinates3d cords1 = new Coordinates3d(3, 3, 3);
Coordinates3d cords2 = new Coordinates3d(3, 4, 4);
Point3d cords1 = new Point3d(3, 3, 3);
Point3d cords2 = new Point3d(3, 4, 4);

Vector vector = new Vector(cords1, cords2);

Expand Down

0 comments on commit 93de8c2

Please sign in to comment.