Search in sources :

Example 21 with AirBlock

use of net.minecraft.block.AirBlock in project Hypnotic-Client by Hypnotic-Development.

the class PlayerUtils method getDistanceToGround.

public static float getDistanceToGround() {
    if (mc.player.verticalCollision && mc.player.isOnGround()) {
        return 0.0F;
    }
    ClientPlayerEntity e = mc.player;
    for (float a = (float) e.getY(); a > 0.0F; a -= 1.0F) {
        int[] stairs = { 53, 67, 108, 109, 114, 128, 134, 135, 136, 156, 163, 164, 180 };
        int[] exemptIds = { 6, 27, 28, 30, 31, 32, 37, 38, 39, 40, 50, 51, 55, 59, 63, 65, 66, 68, 69, 70, 72, 75, 76, 77, 83, 92, 93, 94, 104, 105, 106, 115, 119, 131, 132, 143, 147, 148, 149, 150, 157, 171, 175, 176, 177 };
        BlockState block = mc.world.getBlockState(new BlockPos(e.getX(), a - 1.0F, e.getZ()));
        if (!(block.getBlock() instanceof AirBlock)) {
            if ((Block.getRawIdFromState(block) == 44) || (Block.getRawIdFromState(block) == 126)) {
                return (float) (e.getY() - a - 0.5D) < 0.0F ? 0.0F : (float) (e.getY() - a - 0.5D);
            }
            int[] arrayOfInt1;
            int j = (arrayOfInt1 = stairs).length;
            for (int i = 0; i < j; i++) {
                int id = arrayOfInt1[i];
                if (Block.getRawIdFromState(block) == id) {
                    return (float) (e.getY() - a - 1.0D) < 0.0F ? 0.0F : (float) (e.getY() - a - 1.0D);
                }
            }
            j = (arrayOfInt1 = exemptIds).length;
            for (int i = 0; i < j; i++) {
                int id = arrayOfInt1[i];
                if (Block.getRawIdFromState(block) == id) {
                    return (float) (e.getY() - a) < 0.0F ? 0.0F : (float) (e.getY() - a);
                }
            }
            return (float) (e.getY() - a + block.getBlock().getMaxHorizontalModelOffset() - 1.0D);
        }
    }
    return 0.0F;
}
Also used : BlockState(net.minecraft.block.BlockState) AirBlock(net.minecraft.block.AirBlock) BlockPos(net.minecraft.util.math.BlockPos) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity)

Aggregations

AirBlock (net.minecraft.block.AirBlock)21 BlockPos (net.minecraft.util.math.BlockPos)13 ItemStack (net.minecraft.item.ItemStack)9 Block (net.minecraft.block.Block)8 BlockState (net.minecraft.block.BlockState)8 AbstractBlockHut (com.minecolonies.api.blocks.AbstractBlockHut)6 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)6 NotNull (org.jetbrains.annotations.NotNull)6 TileEntity (net.minecraft.tileentity.TileEntity)5 Nullable (org.jetbrains.annotations.Nullable)5 BlockUtils (com.ldtteam.structurize.util.BlockUtils)4 Stack (com.minecolonies.api.colony.requestsystem.requestable.Stack)4 IBuilderUndestroyable (com.minecolonies.api.entity.ai.citizen.builder.IBuilderUndestroyable)4 AITarget (com.minecolonies.api.entity.ai.statemachine.AITarget)4 AIWorkerState (com.minecolonies.api.entity.ai.statemachine.states.AIWorkerState)4 IAIState (com.minecolonies.api.entity.ai.statemachine.states.IAIState)4 Blueprint (com.ldtteam.structures.blueprints.v1.Blueprint)3 IStructureHandler (com.ldtteam.structurize.placement.structure.IStructureHandler)3 PlacementSettings (com.ldtteam.structurize.util.PlacementSettings)3 ModBlocks (com.minecolonies.api.blocks.ModBlocks)3