Skip to content

Commit

Permalink
feat: add some interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
lt-name committed Feb 1, 2025
1 parent 589176f commit 4eceeb5
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/java/cn/nukkit/level/Position.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package cn.nukkit.level;

import cn.nukkit.block.Block;
import cn.nukkit.blockentity.BlockEntity;
import cn.nukkit.level.format.FullChunk;
import cn.nukkit.math.BlockFace;
import cn.nukkit.math.Vector3;
import cn.nukkit.utils.LevelException;
import org.jetbrains.annotations.NotNull;

import javax.annotation.Nullable;
import java.util.Set;

/**
Expand Down Expand Up @@ -99,6 +101,11 @@ public Position setComponents(@NotNull Vector3 pos) {
return this;
}

@Nullable
public BlockEntity getLevelBlockEntity() {
return this.getValidLevel().getBlockEntity(this);
}

public Block getLevelBlock() {
return this.getValidLevel().getBlock(this);
}
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/cn/nukkit/level/biome/EnumBiome.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,24 @@ public enum EnumBiome {
this.biome = biome;
}

/**
* Return the biome ID corresponding to the current enum instance.
*
* @return The biome ID.
*/
public int getId() {
return this.id;
}

/**
* Return the biome corresponding to the current enum instance.
*
* @return The biome.
*/
public Biome getBiome() {
return this.biome;
}

/**
* You really shouldn't use this method if you can help it, reference the biomes directly!
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import cn.nukkit.level.GlobalBlockPalette;
import cn.nukkit.level.generator.math.Rotation;

import java.util.Objects;

public class BlockState {
public static final BlockState AIR = new BlockState(0);

Expand Down Expand Up @@ -55,4 +57,16 @@ public BlockState rotate(final Rotation rot) {
default -> this;
};
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof BlockState that)) return false;
return id == that.id && meta == that.meta;
}

@Override
public int hashCode() {
return Objects.hash(id, meta);
}
}

0 comments on commit 4eceeb5

Please sign in to comment.