Search in sources :

Example 1 with HorizontalBlockStateDefinition

use of com.almuradev.content.type.block.type.horizontal.state.HorizontalBlockStateDefinition in project Almura by AlmuraDev.

the class HorizontalBlockImpl method getLightValue.

@Deprecated
@Override
public int getLightValue(final IBlockState state) {
    if (state != null && this.states != null) {
        final HorizontalBlockStateDefinition definition = this.definition(state);
        int lightValue = PrimitiveOptionals.mapToInt(definition.lightEmission, value -> (int) (15f * value)).orElseGet(() -> super.getLightValue(state));
        // System.out.println("getLightValue (state) = " + lightValue);
        return lightValue;
    } else {
        // System.out.println("getLightValue (fallback) = 0");
        return 0;
    }
}
Also used : Entity(net.minecraft.entity.Entity) Explosion(net.minecraft.world.Explosion) EnumMap(java.util.EnumMap) World(net.minecraft.world.World) HorizontalBlockStateDefinition(com.almuradev.content.type.block.type.horizontal.state.HorizontalBlockStateDefinition) BlockHorizontal(net.minecraft.block.BlockHorizontal) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EnumFacing(net.minecraft.util.EnumFacing) PrimitiveOptionals(net.kyori.lunar.PrimitiveOptionals) BlockStateContainer(net.minecraft.block.state.BlockStateContainer) BlockPos(net.minecraft.util.math.BlockPos) BlockRenderLayer(net.minecraft.util.BlockRenderLayer) IBlockState(net.minecraft.block.state.IBlockState) List(java.util.List) Material(net.minecraft.block.material.Material) EntityLivingBase(net.minecraft.entity.EntityLivingBase) Side(net.minecraftforge.fml.relauncher.Side) Map(java.util.Map) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) IBlockAccess(net.minecraft.world.IBlockAccess) Nullable(javax.annotation.Nullable) HorizontalBlockStateDefinition(com.almuradev.content.type.block.type.horizontal.state.HorizontalBlockStateDefinition)

Example 2 with HorizontalBlockStateDefinition

use of com.almuradev.content.type.block.type.horizontal.state.HorizontalBlockStateDefinition in project Almura by AlmuraDev.

the class HorizontalBlockImpl method getCollisionBoundingBox.

@Deprecated
@Nullable
@Override
public AxisAlignedBB getCollisionBoundingBox(final IBlockState state, final IBlockAccess world, final BlockPos pos) {
    final EnumFacing facing = state.getValue(FACING);
    final HorizontalBlockStateDefinition definition = this.definition(facing);
    if (definition.nullCollisionBox) {
        return null;
    }
    final AxisAlignedBB collisionBox = definition.collisionBox(facing);
    return collisionBox != null ? collisionBox : super.getCollisionBoundingBox(state, world, pos);
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EnumFacing(net.minecraft.util.EnumFacing) HorizontalBlockStateDefinition(com.almuradev.content.type.block.type.horizontal.state.HorizontalBlockStateDefinition) Nullable(javax.annotation.Nullable)

Example 3 with HorizontalBlockStateDefinition

use of com.almuradev.content.type.block.type.horizontal.state.HorizontalBlockStateDefinition in project Almura by AlmuraDev.

the class HorizontalBlockImpl method getExplosionResistance.

@Override
public float getExplosionResistance(final World world, final BlockPos pos, @Nullable final Entity exploder, final Explosion explosion) {
    final IBlockState state = world.getBlockState(pos);
    final HorizontalBlockStateDefinition definition = this.definition(state);
    return definition.resistance.isPresent() ? (float) definition.resistance.getAsDouble() : super.getExplosionResistance(exploder);
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) HorizontalBlockStateDefinition(com.almuradev.content.type.block.type.horizontal.state.HorizontalBlockStateDefinition)

Example 4 with HorizontalBlockStateDefinition

use of com.almuradev.content.type.block.type.horizontal.state.HorizontalBlockStateDefinition in project Almura by AlmuraDev.

the class HorizontalBlockImpl method getLightOpacity.

@Deprecated
@Override
public int getLightOpacity(final IBlockState state) {
    final HorizontalBlockStateDefinition definition = this.definition(state);
    int lightOpacity = definition.lightOpacity.orElseGet(() -> super.getLightOpacity(state));
    // System.out.println("getLightOpacity = " + lightOpacity);
    return lightOpacity;
}
Also used : HorizontalBlockStateDefinition(com.almuradev.content.type.block.type.horizontal.state.HorizontalBlockStateDefinition)

Aggregations

HorizontalBlockStateDefinition (com.almuradev.content.type.block.type.horizontal.state.HorizontalBlockStateDefinition)4 Nullable (javax.annotation.Nullable)2 IBlockState (net.minecraft.block.state.IBlockState)2 EnumFacing (net.minecraft.util.EnumFacing)2 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)2 EnumMap (java.util.EnumMap)1 List (java.util.List)1 Map (java.util.Map)1 PrimitiveOptionals (net.kyori.lunar.PrimitiveOptionals)1 BlockHorizontal (net.minecraft.block.BlockHorizontal)1 Material (net.minecraft.block.material.Material)1 BlockStateContainer (net.minecraft.block.state.BlockStateContainer)1 Entity (net.minecraft.entity.Entity)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 BlockRenderLayer (net.minecraft.util.BlockRenderLayer)1 BlockPos (net.minecraft.util.math.BlockPos)1 Explosion (net.minecraft.world.Explosion)1 IBlockAccess (net.minecraft.world.IBlockAccess)1 World (net.minecraft.world.World)1 Side (net.minecraftforge.fml.relauncher.Side)1