Optimized fields

This commit is contained in:
Ziver Koc 2020-03-15 03:50:20 +01:00
parent f8353d4354
commit 4b4fbcf5b0
2 changed files with 8 additions and 8 deletions

View file

@ -17,8 +17,8 @@ public class Block {
private long offset_x = 0; private long offset_x = 0;
private long offset_y = 0; private long offset_y = 0;
private int[][] height = new int[BLOCK_SIZE][BLOCK_SIZE]; private byte[][] height = new byte[BLOCK_SIZE][BLOCK_SIZE];
private int[][] groundType = new int[BLOCK_SIZE][BLOCK_SIZE]; private short[][] groundType = new short[BLOCK_SIZE][BLOCK_SIZE];
public Block(long x, long y) { public Block(long x, long y) {
offset_x = x; offset_x = x;
@ -46,7 +46,7 @@ public class Block {
} }
public void setHeight(long x, long y, int height) { public void setHeight(long x, long y, byte height) {
this.height[getLocalX(x)][getLocalY(y)] = height; this.height[getLocalX(x)][getLocalY(y)] = height;
} }
public int getHeight(long x, long y) { public int getHeight(long x, long y) {
@ -57,10 +57,10 @@ public class Block {
public void setGroundType(long x, long y, GroundType groundType) { public void setGroundType(long x, long y, GroundType groundType) {
setGroundType(x, y, groundType.getId()); setGroundType(x, y, groundType.getId());
} }
public void setGroundType(long x, long y, int groundTypeId) { public void setGroundType(long x, long y, short groundTypeId) {
this.groundType[getLocalX(x)][getLocalY(y)] = groundTypeId; this.groundType[getLocalX(x)][getLocalY(y)] = groundTypeId;
} }
public int getGroundType(long x, long y) { public short getGroundType(long x, long y) {
return groundType[getLocalX(x)][getLocalY(y)]; return groundType[getLocalX(x)][getLocalY(y)];
} }
} }

View file

@ -6,16 +6,16 @@ package se.cookery.world;
public final class GroundType { public final class GroundType {
// Variables // Variables
private final int id; private final short id;
private final String name; private final String name;
protected GroundType(int id, String name) { protected GroundType(short id, String name) {
this.id = id; this.id = id;
this.name = name; this.name = name;
} }
public int getId() { public short getId() {
return id; return id;
} }