net.minecraft.world.IBlockReader Java Examples

The following examples show how to use net.minecraft.world.IBlockReader. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RayTracer.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static BlockRayTraceResult retraceBlock(IBlockReader world, PlayerEntity player, BlockPos pos) {
    Vec3d startVec = getStartVec(player);
    Vec3d endVec = getEndVec(player);
    BlockState state = world.getBlockState(pos);
    VoxelShape baseShape = state.getShape(world, pos);
    BlockRayTraceResult baseTraceResult = baseShape.rayTrace(startVec, endVec, pos);
    if (baseTraceResult != null) {
        BlockRayTraceResult raytraceTraceShape = state.getRaytraceShape(world, pos).rayTrace(startVec, endVec, pos);
        if (raytraceTraceShape != null) {
            return raytraceTraceShape;
        }
    }
    return baseTraceResult;
}
 
Example #2
Source File: BlockEnderTank.java    From EnderStorage with MIT License 5 votes vote down vote up
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
    VoxelShape shape = TANK_SHAPE;
    TileEntity t = worldIn.getTileEntity(pos);
    if (t instanceof TileEnderTank) {
        TileEnderTank tile = (TileEnderTank) t;
        shape = SHAPES[tile.rotation];
    }
    return shape;
}
 
Example #3
Source File: BlockEnderChest.java    From EnderStorage with MIT License 5 votes vote down vote up
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
    VoxelShape shape = CHEST_SHAPE;
    TileEntity t = worldIn.getTileEntity(pos);
    if (t instanceof TileEnderChest) {
        TileEnderChest tile = (TileEnderChest) t;
        shape = SHAPES[tile.rotation][tile.getRadianLidAngle(0) >= 0 ? 0 : 1];
    }
    return shape;
}
 
Example #4
Source File: AbstractBakedPropertiesModel.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Set<TextureAtlasSprite> getHitEffects(@Nonnull BlockRayTraceResult traceResult, BlockState state, IBlockReader world, BlockPos pos, IModelData modelData) {
    Vector3 vec = new Vector3(traceResult.getHitVec()).subtract(traceResult.getPos());
    return getAllQuads(state, modelData).stream()//
            .filter(quad -> quad.getFace() == traceResult.getFace())//
            .filter(quad -> checkDepth(quad, vec, traceResult.getFace()))//
            .map(BakedQuad::func_187508_a)//
            .collect(Collectors.toSet());//
}
 
Example #5
Source File: CCBakeryModel.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Set<TextureAtlasSprite> getDestroyEffects(BlockState state, IBlockReader world, BlockPos pos, IModelData data) {
    //TODO, Destroy may need IModelData
    IBakedModel model = ModelBakery.getCachedModel(state, EmptyModelData.INSTANCE);
    if (model instanceof IModelParticleProvider) {
        return ((IModelParticleProvider) model).getDestroyEffects(state, world, pos, data);
    }
    return Collections.emptySet();
}
 
Example #6
Source File: BlockEnderStorage.java    From EnderStorage with MIT License 5 votes vote down vote up
@Override
public int getLightValue(BlockState state, IBlockReader world, BlockPos pos) {
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof TileFrequencyOwner) {
        return ((TileFrequencyOwner) tile).getLightValue();
    }
    return 0;
}
 
Example #7
Source File: CCBakeryModel.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Set<TextureAtlasSprite> getHitEffects(BlockRayTraceResult traceResult, BlockState state, IBlockReader world, BlockPos pos, IModelData data) {
    IBakedModel model = ModelBakery.getCachedModel(state, data);
    if (model instanceof IModelParticleProvider) {
        return ((IModelParticleProvider) model).getHitEffects(traceResult, state, world, pos, data);
    }
    return Collections.emptySet();
}
 
Example #8
Source File: BlockEnderStorage.java    From EnderStorage with MIT License 4 votes vote down vote up
@Override
public boolean canConnectRedstone(BlockState state, IBlockReader world, BlockPos pos, Direction side) {
    TileEntity tile = world.getTileEntity(pos);
    return tile instanceof TileFrequencyOwner && ((TileFrequencyOwner) tile).redstoneInteraction();
}
 
Example #9
Source File: DryingRackBlock.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world)
{
    return new DryingRackTileEntity();
}
 
Example #10
Source File: DryingRackBlock.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context)
{
    return (state.get(FACING).getHorizontalIndex() % 2) == 0 ? shape1 : shape2;
}
 
Example #11
Source File: SawmillBlock.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world)
{
    return new SawmillTileEntity();
}
 
Example #12
Source File: SawmillBlock.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public int getLightValue(BlockState state, IBlockReader world, BlockPos pos)
{
    return state.get(POWERED) ? 15 : 0;
}
 
Example #13
Source File: ChoppingBlock.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context)
{
    return SHAPE;
}
 
Example #14
Source File: ChoppingBlock.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world)
{
    return new ChoppingBlockTileEntity();
}
 
Example #15
Source File: AbstractBakedPropertiesModel.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public Set<TextureAtlasSprite> getDestroyEffects(BlockState state, IBlockReader world, BlockPos pos, IModelData data) {
    return getAllQuads(state, data).stream().map(BakedQuad::func_187508_a).collect(Collectors.toSet());
}
 
Example #16
Source File: RenderBlock.java    From MiningGadgets with MIT License 4 votes vote down vote up
@Override
public boolean isNormalCube(BlockState state, IBlockReader worldIn, BlockPos pos) {
    return false;
}
 
Example #17
Source File: BlockEnderStorage.java    From EnderStorage with MIT License 4 votes vote down vote up
@Override
public ItemStack getPickBlock(BlockState state, RayTraceResult rayTraceResult, IBlockReader world, BlockPos pos, PlayerEntity player) {
    TileFrequencyOwner tile = (TileFrequencyOwner) world.getTileEntity(pos);
    return createItem(tile.getFrequency());
}
 
Example #18
Source File: BlockEnderChest.java    From EnderStorage with MIT License 4 votes vote down vote up
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
    return new TileEnderChest();
}
 
Example #19
Source File: BlockEnderTank.java    From EnderStorage with MIT License 4 votes vote down vote up
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
    return new TileEnderTank();
}
 
Example #20
Source File: MinersLight.java    From MiningGadgets with MIT License 4 votes vote down vote up
@Override
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
    return true;
}
 
Example #21
Source File: MinersLight.java    From MiningGadgets with MIT License 4 votes vote down vote up
/**
 * @deprecated call via {@link BlockState#getPushReaction()} whenever possible. Implementing/overriding is fine.
 */
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext selectionContext) {
    return SHAPE;
}
 
Example #22
Source File: MinersLight.java    From MiningGadgets with MIT License 4 votes vote down vote up
@Override
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
    return VoxelShapes.empty();
}
 
Example #23
Source File: ModificationTable.java    From MiningGadgets with MIT License 4 votes vote down vote up
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
    return new ModificationTableTileEntity();
}
 
Example #24
Source File: RenderBlock.java    From MiningGadgets with MIT License 4 votes vote down vote up
@Override
@OnlyIn(Dist.CLIENT)
public float getAmbientOcclusionLightValue(BlockState state, IBlockReader worldIn, BlockPos pos) {
    return 1.0f;
}
 
Example #25
Source File: RenderBlock.java    From MiningGadgets with MIT License 4 votes vote down vote up
@Override
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
    return 0;
}
 
Example #26
Source File: RenderBlock.java    From MiningGadgets with MIT License 4 votes vote down vote up
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
    return new RenderBlockTileEntity();
}
 
Example #27
Source File: IModelParticleProvider.java    From CodeChickenLib with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Used to retrieve the particles to randomly choose from for hit particles.
 *
 * @param traceResult The trace result.
 * @param state       The state, getActualState and getExtendedState has been called.
 * @param world       The world.
 * @param pos         The pos.
 * @return A Set of Textures to use.
 */
Set<TextureAtlasSprite> getHitEffects(@Nonnull BlockRayTraceResult traceResult, BlockState state, IBlockReader world, BlockPos pos, IModelData modelData);
 
Example #28
Source File: IModelParticleProvider.java    From CodeChickenLib with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Used to retrieve the destroy particles for the block.
 *
 * @param state The state, getActualState and getExtendedState has been called.
 * @param world The world.
 * @param pos   The pos.
 * @return A Set of Textures to use.
 */
Set<TextureAtlasSprite> getDestroyEffects(BlockState state, IBlockReader world, BlockPos pos, IModelData data);