/* * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Baritone is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ package baritone.utils; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.WorldType; import net.minecraft.world.biome.Biome; import javax.annotation.Nullable; /** * @author Brady * @since 11/5/2019 */ @SuppressWarnings("NullableProblems") public final class BlockStateInterfaceAccessWrapper implements IBlockAccess { private final BlockStateInterface bsi; BlockStateInterfaceAccessWrapper(BlockStateInterface bsi) { this.bsi = bsi; } @Nullable @Override public TileEntity getTileEntity(BlockPos pos) { throw new UnsupportedOperationException("getTileEntity not supported by BlockStateInterfaceAccessWrapper"); } @Override public int getCombinedLight(BlockPos pos, int lightValue) { throw new UnsupportedOperationException("getCombinedLight not supported by BlockStateInterfaceAccessWrapper"); } @Override public IBlockState getBlockState(BlockPos pos) { // BlockStateInterface#get0(BlockPos) btfo! return this.bsi.get0(pos.getX(), pos.getY(), pos.getZ()); } @Override public boolean isAirBlock(BlockPos pos) { return this.bsi.get0(pos.getX(), pos.getY(), pos.getZ()).getMaterial() == Material.AIR; } @Override public Biome getBiome(BlockPos pos) { throw new UnsupportedOperationException("getBiome not supported by BlockStateInterfaceAccessWrapper"); } @Override public int getStrongPower(BlockPos pos, EnumFacing direction) { throw new UnsupportedOperationException("getStrongPower not supported by BlockStateInterfaceAccessWrapper"); } @Override public WorldType getWorldType() { return this.bsi.world.getWorldType(); } }