-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Realised Block class (doubt it is really usefull). Implemented some m…
…ethods about getting block ids
- Loading branch information
Pavel Fedin
committed
Nov 29, 2016
1 parent
7d9d833
commit c22837b
Showing
6 changed files
with
151 additions
and
11 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,23 +1,91 @@ | ||
package mregioneer.mcaliases; | ||
|
||
|
||
import com.mojang.nbt.ByteArrayTag; | ||
import mregioneer.utils.Coordinates3d; | ||
import mregioneer.utils.Formulae; | ||
import mregioneer.utils.Helpers; | ||
|
||
public class Block { | ||
private final int x; | ||
private final int z; | ||
private final int y; | ||
|
||
private short id_a; | ||
private short id_b; | ||
private final int section_index; | ||
|
||
private final int offset; | ||
|
||
private byte id_a; | ||
private byte id_b; | ||
|
||
private byte[] blocks; | ||
private byte[] add; | ||
|
||
private TileEntity tileEntity = null; | ||
|
||
public Block(Coordinates3d cords, short id_a) { | ||
protected Block(Coordinates3d cords, Section section) { | ||
this.x = cords.getX(); | ||
this.z = cords.getZ(); | ||
this.y = cords.getY(); | ||
|
||
this.id_a = id_a; | ||
this.blocks = ((ByteArrayTag)section.get("Blocks")).data; | ||
|
||
int local_x = Formulae.localBlockFromBlock(x); | ||
int local_y = Formulae.localBlockFromBlock(y); | ||
int local_z = Formulae.localBlockFromBlock(z); | ||
|
||
int section_index = Formulae.sectionFromBlock(y); | ||
this.section_index = section_index; | ||
|
||
this.offset = local_y * 16 * 16 + local_z * 16 + local_x; | ||
|
||
this.id_a = blocks[offset]; | ||
try { | ||
this.add = ((ByteArrayTag)section.get("Add")).data; | ||
this.id_b = Helpers.Nibble4(add, offset); | ||
} catch (NullPointerException e) { | ||
add = null; | ||
this.id_b = 0; | ||
} | ||
} | ||
|
||
public int getX() { | ||
return x; | ||
} | ||
|
||
public int getZ() { | ||
return z; | ||
} | ||
|
||
public int getY() { | ||
return y; | ||
} | ||
|
||
public byte getId_a() { | ||
return id_a; | ||
} | ||
|
||
public void setId_a(byte id_a) { | ||
this.blocks[offset] = id_a; | ||
} | ||
|
||
public byte getId_b() { | ||
return id_b; | ||
} | ||
|
||
/* method should work with 4-bits | ||
public void setId_b(byte id_b) { | ||
this.id_b = id_b; | ||
} | ||
*/ | ||
|
||
/* not implemented yet | ||
public TileEntity getTileEntity() { | ||
return tileEntity; | ||
} | ||
*/ | ||
|
||
public void setTileEntity(TileEntity tileEntity) { | ||
this.tileEntity = tileEntity; | ||
} | ||
} |
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
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
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,8 @@ | ||
package mregioneer.mcaliases; | ||
|
||
/** | ||
* Represents a set of blocks included in a cuboid specified with two coordinates; | ||
*/ | ||
public class Vector { | ||
|
||
} |
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
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