Skip to content

Commit

Permalink
Add a shortcut to BlockStateCompat
Browse files Browse the repository at this point in the history
Signed-off-by: Hendrix-Shen <HendrixShen@hendrixshen.top>
  • Loading branch information
Hendrix-Shen committed Aug 18, 2024
1 parent e4e50d6 commit d0f6092
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package top.hendrixshen.magiclib.api.compat.minecraft.world.level;

import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.NotNull;
import top.hendrixshen.magiclib.api.compat.minecraft.world.level.state.BlockStateCompat;
import top.hendrixshen.magiclib.impl.compat.minecraft.world.level.LevelCompatImpl;
import top.hendrixshen.magiclib.util.collect.Provider;

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

BlockState getBlockState(BlockPos blockPos);

BlockStateCompat getBlockStateCompat(BlockPos blockPos);

ResourceLocation getDimensionLocation();

int getMinBuildHeight();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
package top.hendrixshen.magiclib.impl.compat.minecraft.world.level;

import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.NotNull;
import top.hendrixshen.magiclib.api.compat.AbstractCompat;
import top.hendrixshen.magiclib.api.compat.minecraft.world.level.LevelCompat;
import top.hendrixshen.magiclib.api.compat.minecraft.world.level.state.BlockStateCompat;
import top.hendrixshen.magiclib.impl.compat.minecraft.world.level.dimension.DimensionWrapper;

public class LevelCompatImpl extends AbstractCompat<Level> implements LevelCompat {
public LevelCompatImpl(@NotNull Level type) {
super(type);
}

@Override
public BlockState getBlockState(BlockPos blockPos) {
return this.get().getBlockState(blockPos);
}

@Override
public BlockStateCompat getBlockStateCompat(BlockPos blockPos) {
return BlockStateCompat.of(this.getBlockState(blockPos));
}

@Override
public ResourceLocation getDimensionLocation() {
return DimensionWrapper.of(this.get()).getResourceLocation();
Expand Down

0 comments on commit d0f6092

Please sign in to comment.