mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-12-24 01:17:40 +01:00
Remove a bit of magic, use finals
This commit is contained in:
parent
7513b0499d
commit
3f5500c637
@ -1,12 +1,29 @@
|
||||
package us.myles.ViaVersion.api.minecraft;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class BlockChangeRecord {
|
||||
private short horizontal;
|
||||
private short y;
|
||||
private final short horizontal;
|
||||
private final short y;
|
||||
private int blockId;
|
||||
|
||||
public BlockChangeRecord(short horizontal, short y, int blockId) {
|
||||
this.horizontal = horizontal;
|
||||
this.y = y;
|
||||
this.blockId = blockId;
|
||||
}
|
||||
|
||||
public short getHorizontal() {
|
||||
return horizontal;
|
||||
}
|
||||
|
||||
public short getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public int getBlockId() {
|
||||
return blockId;
|
||||
}
|
||||
|
||||
public void setBlockId(int blockId) {
|
||||
this.blockId = blockId;
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,8 @@
|
||||
package us.myles.ViaVersion.api.minecraft;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum BlockFace {
|
||||
NORTH((byte) 0, (byte) 0, (byte) -1, EnumAxis.Z),
|
||||
SOUTH((byte) 0, (byte) 0, (byte) 1, EnumAxis.Z),
|
||||
@ -16,7 +11,7 @@ public enum BlockFace {
|
||||
TOP((byte) 0, (byte) 1, (byte) 0, EnumAxis.Y),
|
||||
BOTTOM((byte) 0, (byte) -1, (byte) 0, EnumAxis.Y);
|
||||
|
||||
private static Map<BlockFace, BlockFace> opposites = new HashMap<>();
|
||||
private static final Map<BlockFace, BlockFace> opposites = new HashMap<>();
|
||||
|
||||
static {
|
||||
opposites.put(BlockFace.NORTH, BlockFace.SOUTH);
|
||||
@ -27,13 +22,38 @@ public enum BlockFace {
|
||||
opposites.put(BlockFace.BOTTOM, BlockFace.TOP);
|
||||
}
|
||||
|
||||
private byte modX, modY, modZ;
|
||||
private EnumAxis axis;
|
||||
private final byte modX;
|
||||
private final byte modY;
|
||||
private final byte modZ;
|
||||
private final EnumAxis axis;
|
||||
|
||||
BlockFace(byte modX, byte modY, byte modZ, EnumAxis axis) {
|
||||
this.modX = modX;
|
||||
this.modY = modY;
|
||||
this.modZ = modZ;
|
||||
this.axis = axis;
|
||||
}
|
||||
|
||||
public BlockFace opposite() {
|
||||
return opposites.get(this);
|
||||
}
|
||||
|
||||
public byte getModX() {
|
||||
return modX;
|
||||
}
|
||||
|
||||
public byte getModY() {
|
||||
return modY;
|
||||
}
|
||||
|
||||
public byte getModZ() {
|
||||
return modZ;
|
||||
}
|
||||
|
||||
public EnumAxis getAxis() {
|
||||
return axis;
|
||||
}
|
||||
|
||||
public enum EnumAxis {
|
||||
X, Y, Z
|
||||
}
|
||||
|
@ -1,12 +1,25 @@
|
||||
package us.myles.ViaVersion.api.minecraft;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class EulerAngle {
|
||||
private float x;
|
||||
private float y;
|
||||
private float z;
|
||||
private final float x;
|
||||
private final float y;
|
||||
private final float z;
|
||||
|
||||
public EulerAngle(final float x, final float y, final float z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public float getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public float getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public float getZ() {
|
||||
return z;
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,15 @@
|
||||
package us.myles.ViaVersion.api.minecraft;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
public class Position {
|
||||
private int x;
|
||||
private short y;
|
||||
private int z;
|
||||
private final int x;
|
||||
private final short y;
|
||||
private final int z;
|
||||
|
||||
public Position(int x, short y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public Position(Position toCopy) {
|
||||
this(toCopy.getX(), toCopy.getY(), toCopy.getZ());
|
||||
@ -22,10 +19,42 @@ public class Position {
|
||||
return new Position(x + face.getModX(), (short) (y + face.getModY()), z + face.getModZ());
|
||||
}
|
||||
|
||||
public Position shift(BlockFace face) {
|
||||
this.x += face.getModX();
|
||||
this.y += face.getModY();
|
||||
this.z += face.getModZ();
|
||||
return this;
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public short getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Position position = (Position) o;
|
||||
if (x != position.x) return false;
|
||||
if (y != position.y) return false;
|
||||
return z == position.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = x;
|
||||
result = 31 * result + (int) y;
|
||||
result = 31 * result + z;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Position{" +
|
||||
"x=" + x +
|
||||
", y=" + y +
|
||||
", z=" + z +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,37 @@
|
||||
package us.myles.ViaVersion.api.minecraft;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class Vector {
|
||||
private int blockX;
|
||||
private int blockY;
|
||||
private int blockZ;
|
||||
|
||||
public Vector(int blockX, int blockY, int blockZ) {
|
||||
this.blockX = blockX;
|
||||
this.blockY = blockY;
|
||||
this.blockZ = blockZ;
|
||||
}
|
||||
|
||||
public int getBlockX() {
|
||||
return blockX;
|
||||
}
|
||||
|
||||
public void setBlockX(int blockX) {
|
||||
this.blockX = blockX;
|
||||
}
|
||||
|
||||
public int getBlockY() {
|
||||
return blockY;
|
||||
}
|
||||
|
||||
public void setBlockY(int blockY) {
|
||||
this.blockY = blockY;
|
||||
}
|
||||
|
||||
public int getBlockZ() {
|
||||
return blockZ;
|
||||
}
|
||||
|
||||
public void setBlockZ(int blockZ) {
|
||||
this.blockZ = blockZ;
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,25 @@
|
||||
package us.myles.ViaVersion.api.minecraft;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
public class VillagerData {
|
||||
private int type;
|
||||
private int profession;
|
||||
private int level;
|
||||
private final int type;
|
||||
private final int profession;
|
||||
private final int level;
|
||||
|
||||
public VillagerData(final int type, final int profession, final int level) {
|
||||
this.type = type;
|
||||
this.profession = profession;
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public int getProfession() {
|
||||
return profession;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
}
|
||||
|
@ -2,21 +2,19 @@ package us.myles.ViaVersion.api.minecraft.chunks;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
public class BaseChunk implements Chunk {
|
||||
protected int x;
|
||||
protected int z;
|
||||
protected boolean groundUp;
|
||||
protected int bitmask;
|
||||
protected ChunkSection[] sections;
|
||||
protected final int x;
|
||||
protected final int z;
|
||||
protected final boolean groundUp;
|
||||
protected final int bitmask;
|
||||
protected final ChunkSection[] sections;
|
||||
protected int[] biomeData;
|
||||
protected CompoundTag heightMap;
|
||||
protected List<CompoundTag> blockEntities;
|
||||
protected final List<CompoundTag> blockEntities;
|
||||
|
||||
public BaseChunk(int x, int z, boolean groundUp, int bitmask, ChunkSection[] sections, int[] biomeData, List<CompoundTag> blockEntities) {
|
||||
this.x = x;
|
||||
@ -32,4 +30,54 @@ public class BaseChunk implements Chunk {
|
||||
public boolean isBiomeData() {
|
||||
return biomeData != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGroundUp() {
|
||||
return groundUp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBitmask() {
|
||||
return bitmask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkSection[] getSections() {
|
||||
return sections;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getBiomeData() {
|
||||
return biomeData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiomeData(final int[] biomeData) {
|
||||
this.biomeData = biomeData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag getHeightMap() {
|
||||
return heightMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeightMap(final CompoundTag heightMap) {
|
||||
this.heightMap = heightMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CompoundTag> getBlockEntities() {
|
||||
return blockEntities;
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,12 @@
|
||||
package us.myles.ViaVersion.api.minecraft.chunks;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Chunk1_8 extends BaseChunk {
|
||||
@Getter
|
||||
private boolean unloadPacket = false;
|
||||
private boolean unloadPacket;
|
||||
|
||||
public Chunk1_8(int x, int z, boolean groundUp, int bitmask, ChunkSection[] sections, int[] biomeData, List<CompoundTag> blockEntities) {
|
||||
super(x, z, groundUp, bitmask, sections, biomeData, blockEntities);
|
||||
@ -21,7 +19,7 @@ public class Chunk1_8 extends BaseChunk {
|
||||
* @param z coord
|
||||
*/
|
||||
public Chunk1_8(int x, int z) {
|
||||
this(x, z, true, 0, new ChunkSection[16], null, new ArrayList<CompoundTag>());
|
||||
this(x, z, true, 0, new ChunkSection[16], null, new ArrayList<>());
|
||||
this.unloadPacket = true;
|
||||
}
|
||||
|
||||
@ -38,4 +36,8 @@ public class Chunk1_8 extends BaseChunk {
|
||||
public boolean isBiomeData() {
|
||||
return biomeData != null;
|
||||
}
|
||||
|
||||
public boolean isUnloadPacket() {
|
||||
return unloadPacket;
|
||||
}
|
||||
}
|
||||
|
@ -18,13 +18,11 @@ public class ChunkSection {
|
||||
* Length of the sky and block light nibble arrays.
|
||||
*/
|
||||
public static final int LIGHT_LENGTH = 16 * 16 * 16 / 2; // size * size * size / 2 (nibble bit count)
|
||||
private List<Integer> palette = new ArrayList<>();
|
||||
private Map<Integer, Integer> inversePalette = new HashMap<>();
|
||||
private final List<Integer> palette = new ArrayList<>();
|
||||
private final Map<Integer, Integer> inversePalette = new HashMap<>();
|
||||
private final int[] blocks;
|
||||
private NibbleArray blockLight;
|
||||
private NibbleArray skyLight;
|
||||
@Getter
|
||||
@Setter
|
||||
private int nonAirBlocksCount;
|
||||
|
||||
public ChunkSection() {
|
||||
@ -235,4 +233,12 @@ public class ChunkSection {
|
||||
public boolean hasBlockLight() {
|
||||
return blockLight != null;
|
||||
}
|
||||
|
||||
public int getNonAirBlocksCount() {
|
||||
return nonAirBlocksCount;
|
||||
}
|
||||
|
||||
public void setNonAirBlocksCount(int nonAirBlocksCount) {
|
||||
this.nonAirBlocksCount = nonAirBlocksCount;
|
||||
}
|
||||
}
|
||||
|
@ -2,14 +2,11 @@ package us.myles.ViaVersion.api.minecraft.item;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
public class Item {
|
||||
@SerializedName(value = "identifier", alternate = "id")
|
||||
private int identifier;
|
||||
@ -20,4 +17,66 @@ public class Item {
|
||||
public Item(Item toCopy) {
|
||||
this(toCopy.getIdentifier(), toCopy.getAmount(), toCopy.getData(), toCopy.getTag());
|
||||
}
|
||||
|
||||
public int getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public void setIdentifier(int identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public byte getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(byte amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public short getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(short data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public CompoundTag getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void setTag(CompoundTag tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Item item = (Item) o;
|
||||
if (identifier != item.identifier) return false;
|
||||
if (amount != item.amount) return false;
|
||||
if (data != item.data) return false;
|
||||
return tag != null ? tag.equals(item.tag) : item.tag == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = identifier;
|
||||
result = 31 * result + (int) amount;
|
||||
result = 31 * result + (int) data;
|
||||
result = 31 * result + (tag != null ? tag.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Item{" +
|
||||
"identifier=" + identifier +
|
||||
", amount=" + amount +
|
||||
", data=" + data +
|
||||
", tag=" + tag +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user