Skip to content

Commit d0f6092

Browse files
committed
Add a shortcut to BlockStateCompat
Signed-off-by: Hendrix-Shen <[email protected]>
1 parent e4e50d6 commit d0f6092

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

magiclib-minecraft-api/src/main/java/top/hendrixshen/magiclib/api/compat/minecraft/world/level/LevelCompat.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package top.hendrixshen.magiclib.api.compat.minecraft.world.level;
22

3+
import net.minecraft.core.BlockPos;
34
import net.minecraft.resources.ResourceLocation;
45
import net.minecraft.world.level.Level;
6+
import net.minecraft.world.level.block.state.BlockState;
57
import org.jetbrains.annotations.NotNull;
8+
import top.hendrixshen.magiclib.api.compat.minecraft.world.level.state.BlockStateCompat;
69
import top.hendrixshen.magiclib.impl.compat.minecraft.world.level.LevelCompatImpl;
710
import top.hendrixshen.magiclib.util.collect.Provider;
811

@@ -11,6 +14,10 @@ public interface LevelCompat extends Provider<Level> {
1114
return new LevelCompatImpl(level);
1215
}
1316

17+
BlockState getBlockState(BlockPos blockPos);
18+
19+
BlockStateCompat getBlockStateCompat(BlockPos blockPos);
20+
1421
ResourceLocation getDimensionLocation();
1522

1623
int getMinBuildHeight();

magiclib-minecraft-api/src/main/java/top/hendrixshen/magiclib/impl/compat/minecraft/world/level/LevelCompatImpl.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
11
package top.hendrixshen.magiclib.impl.compat.minecraft.world.level;
22

3+
import net.minecraft.core.BlockPos;
34
import net.minecraft.resources.ResourceLocation;
45
import net.minecraft.world.level.Level;
6+
import net.minecraft.world.level.block.state.BlockState;
57
import org.jetbrains.annotations.NotNull;
68
import top.hendrixshen.magiclib.api.compat.AbstractCompat;
79
import top.hendrixshen.magiclib.api.compat.minecraft.world.level.LevelCompat;
10+
import top.hendrixshen.magiclib.api.compat.minecraft.world.level.state.BlockStateCompat;
811
import top.hendrixshen.magiclib.impl.compat.minecraft.world.level.dimension.DimensionWrapper;
912

1013
public class LevelCompatImpl extends AbstractCompat<Level> implements LevelCompat {
1114
public LevelCompatImpl(@NotNull Level type) {
1215
super(type);
1316
}
1417

18+
@Override
19+
public BlockState getBlockState(BlockPos blockPos) {
20+
return this.get().getBlockState(blockPos);
21+
}
22+
23+
@Override
24+
public BlockStateCompat getBlockStateCompat(BlockPos blockPos) {
25+
return BlockStateCompat.of(this.getBlockState(blockPos));
26+
}
27+
1528
@Override
1629
public ResourceLocation getDimensionLocation() {
1730
return DimensionWrapper.of(this.get()).getResourceLocation();

0 commit comments

Comments
 (0)