net.minecraft.block.BlockAir Java Examples

The following examples show how to use net.minecraft.block.BlockAir. 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: ObsidianReplaceModule.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
@Listener
public void onReceivePacket(final EventReceivePacket event) {
    if (event.getStage() != EventStageable.EventStage.POST)
        return;

    if (freeCamModule != null && freeCamModule.isEnabled())
        return;

    final Minecraft minecraft = Minecraft.getMinecraft();
    if (event.getPacket() instanceof SPacketBlockChange) {
        final SPacketBlockChange blockChange = (SPacketBlockChange) event.getPacket();
        if (blockChange.getBlockState().getBlock() instanceof BlockAir) {
            final BlockPos blockPosition = blockChange.getBlockPosition();
            final double playerToBlockDistance = calculateVecDistance(
                    minecraft.player.getPositionEyes(1.0f), blockPosition);
            if (playerToBlockDistance <= getReachDistance(minecraft))
                buildPlacementRequest(minecraft, blockPosition);
        }
    }
}
 
Example #2
Source File: JesusModule.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
public static boolean isInLiquid() {
    final Minecraft mc = Minecraft.getMinecraft();

    if (mc.player.fallDistance >= 3.0f) {
        return false;
    }

    if (mc.player != null) {
        boolean inLiquid = false;
        final AxisAlignedBB bb = mc.player.getRidingEntity() != null ? mc.player.getRidingEntity().getEntityBoundingBox() : mc.player.getEntityBoundingBox();
        int y = (int) bb.minY;
        for (int x = MathHelper.floor(bb.minX); x < MathHelper.floor(bb.maxX) + 1; x++) {
            for (int z = MathHelper.floor(bb.minZ); z < MathHelper.floor(bb.maxZ) + 1; z++) {
                final Block block = mc.world.getBlockState(new BlockPos(x, y, z)).getBlock();
                if (!(block instanceof BlockAir)) {
                    if (!(block instanceof BlockLiquid)) {
                        return false;
                    }
                    inLiquid = true;
                }
            }
        }
        return inLiquid;
    }
    return false;
}
 
Example #3
Source File: AACPort.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onUpdate() {
    if(!MovementUtils.isMoving())
        return;

    final float f = mc.thePlayer.rotationYaw * 0.017453292F;
    for (double d = 0.2; d <= ((Speed) LiquidBounce.moduleManager.getModule(Speed.class)).portMax.get(); d += 0.2) {
        final double x = mc.thePlayer.posX - MathHelper.sin(f) * d;
        final double z = mc.thePlayer.posZ + MathHelper.cos(f) * d;

        if(mc.thePlayer.posY < (int) mc.thePlayer.posY + 0.5 && !(BlockUtils.getBlock(new BlockPos(x, mc.thePlayer.posY, z)) instanceof BlockAir))
            break;

        mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(x, mc.thePlayer.posY, z, true));
    }
}
 
Example #4
Source File: WallClimb.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
@EventTarget
public void onBlockBB(final BlockBBEvent event) {
    if(mc.thePlayer == null)
        return;

    final String mode = modeValue.get();

    switch(mode.toLowerCase()) {
        case "checkerclimb":
            if(event.getY() > mc.thePlayer.posY)
                event.setBoundingBox(null);
            break;
        case "clip":
            if(event.getBlock() != null && mc.thePlayer != null && event.getBlock() instanceof BlockAir && event.getY() < mc.thePlayer.posY && mc.thePlayer.isCollidedHorizontally && !mc.thePlayer.isOnLadder() && !mc.thePlayer.isInWater() && !mc.thePlayer.isInLava())
                event.setBoundingBox(new AxisAlignedBB(0, 0, 0, 1, 1, 1).offset(mc.thePlayer.posX, (int) mc.thePlayer.posY - 1, mc.thePlayer.posZ));
            break;
    }
}
 
Example #5
Source File: ObsidianReplaceModule.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
private void buildPlacementRequest(final Minecraft minecraft, final BlockPos position) {
    for (final int[] directionOffset : BLOCK_DIRECTION_OFFSET) {
        final BlockPos relativePosition = position.add(directionOffset[0], directionOffset[1],
                directionOffset[2]);
        final Block structureBlock = minecraft.world.getBlockState(relativePosition).getBlock();
        if (structureBlock instanceof BlockAir || structureBlock instanceof BlockLiquid)
            continue;

        final EnumFacing blockPlacementFace = calculateFaceForPlacement(relativePosition, position);
        if (blockPlacementFace != null && placementRequests.offer(new PlacementRequest(
                relativePosition, blockPlacementFace)))
            return;
    }
}
 
Example #6
Source File: StepModule.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
@Listener
public void onWalkingUpdate(EventUpdateWalkingPlayer event) {
    if (event.getStage() == EventStageable.EventStage.PRE) {
        final Minecraft mc = Minecraft.getMinecraft();

        switch (this.mode.getValue()) {
            case ONE:
                this.selectedPositions = this.oneblockPositions;
                break;
            case TWO:
                this.selectedPositions = this.twoblockPositions;
                break;
        }

        if (mc.player.collidedHorizontally && mc.player.onGround) {
            this.packets++;
        }

        //check if there is a block above our head
        final AxisAlignedBB bb = mc.player.getEntityBoundingBox();

        for (int x = MathHelper.floor(bb.minX); x < MathHelper.floor(bb.maxX + 1.0D); x++) {
            for (int z = MathHelper.floor(bb.minZ); z < MathHelper.floor(bb.maxZ + 1.0D); z++) {
                final Block block = mc.world.getBlockState(new BlockPos(x, bb.maxY + 1, z)).getBlock();
                if (!(block instanceof BlockAir)) {
                    return;
                }
            }
        }

        if (mc.player.onGround && !mc.player.isInsideOfMaterial(Material.WATER) && !mc.player.isInsideOfMaterial(Material.LAVA) && !mc.player.isInWeb && mc.player.collidedVertically && mc.player.fallDistance == 0 && !mc.gameSettings.keyBindJump.pressed && mc.player.collidedHorizontally && !mc.player.isOnLadder() && this.packets > this.selectedPositions.length - 2) {
            for (double position : this.selectedPositions) {
                mc.player.connection.sendPacket(new CPacketPlayer.Position(mc.player.posX, mc.player.posY + position, mc.player.posZ, true));
            }
            mc.player.setPosition(mc.player.posX, mc.player.posY + this.selectedPositions[this.selectedPositions.length - 1], mc.player.posZ);
            this.packets = 0;
        }
    }
}
 
Example #7
Source File: Tower.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@EventTarget
public void onMotion(final MotionEvent event) {
    if (onJumpValue.get() && !mc.gameSettings.keyBindJump.isKeyDown())
        return;

    // Lock Rotation
    if (rotationsValue.get() && keepRotationValue.get() && lockRotation != null)
        RotationUtils.setTargetRotation(lockRotation);

    mc.timer.timerSpeed = timerValue.get();

    final EventState eventState = event.getEventState();

    if (placeModeValue.get().equalsIgnoreCase(eventState.getStateName()))
        place();

    if (eventState == EventState.PRE) {
        placeInfo = null;
        timer.update();

        final boolean isHeldItemBlock = mc.thePlayer.getHeldItem() != null && mc.thePlayer.getHeldItem().getItem() instanceof ItemBlock;
        if (autoBlockValue.get() ? InventoryUtils.findAutoBlockBlock() != -1 || isHeldItemBlock : isHeldItemBlock) {
            if (!stopWhenBlockAbove.get() || BlockUtils.getBlock(new BlockPos(mc.thePlayer.posX,
                    mc.thePlayer.posY + 2, mc.thePlayer.posZ)) instanceof BlockAir)
                move();

            final BlockPos blockPos = new BlockPos(mc.thePlayer.posX, mc.thePlayer.posY - 1D, mc.thePlayer.posZ);
            if (mc.theWorld.getBlockState(blockPos).getBlock() instanceof BlockAir) {
                if (search(blockPos) && rotationsValue.get()) {
                    final VecRotation vecRotation = RotationUtils.faceBlock(blockPos);

                    if (vecRotation != null) {
                        RotationUtils.setTargetRotation(vecRotation.getRotation());
                        placeInfo.setVec3(vecRotation.getVec());
                    }
                }
            }
        }
    }
}
 
Example #8
Source File: YPort.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onMotion() {
    if(!safeJump && !mc.gameSettings.keyBindJump.isKeyDown() && !mc.thePlayer.isOnLadder() && !mc.thePlayer.isInsideOfMaterial(Material.water) && !mc.thePlayer.isInsideOfMaterial(Material.lava) && !mc.thePlayer.isInWater() && ((!(this.getBlock(-1.1) instanceof BlockAir) && !(this.getBlock(-1.1) instanceof BlockAir)) || (!(this.getBlock(-0.1) instanceof BlockAir) && mc.thePlayer.motionX != 0.0 && mc.thePlayer.motionZ != 0.0 && !mc.thePlayer.onGround && mc.thePlayer.fallDistance < 3.0f && mc.thePlayer.fallDistance > 0.05)) && this.level == 3)
        mc.thePlayer.motionY = -0.3994;

    double xDist = mc.thePlayer.posX - mc.thePlayer.prevPosX;
    double zDist = mc.thePlayer.posZ - mc.thePlayer.prevPosZ;
    this.lastDist = Math.sqrt(xDist * xDist + zDist * zDist);

    if(!MovementUtils.isMoving())
        safeJump = true;
    else if(mc.thePlayer.onGround)
        safeJump = false;
}
 
Example #9
Source File: Fly.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@EventTarget
public void onBB(final BlockBBEvent event) {
    if (mc.thePlayer == null) return;

    final String mode = modeValue.get();

    if (event.getBlock() instanceof BlockAir && (mode.equalsIgnoreCase("Hypixel") ||
            mode.equalsIgnoreCase("BoostHypixel") || mode.equalsIgnoreCase("Rewinside") ||
            (mode.equalsIgnoreCase("Mineplex") && mc.thePlayer.inventory.getCurrentItem() == null)) && event.getY() < mc.thePlayer.posY)
        event.setBoundingBox(AxisAlignedBB.fromBounds(event.getX(), event.getY(), event.getZ(), event.getX() + 1, mc.thePlayer.posY, event.getZ() + 1));
}
 
Example #10
Source File: Phase.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@EventTarget
public void onBlockBB(final BlockBBEvent event) {
    if(mc.thePlayer != null && BlockUtils.collideBlockIntersects(mc.thePlayer.getEntityBoundingBox(), block -> !(block instanceof BlockAir)) && event.getBoundingBox() != null && event.getBoundingBox().maxY > mc.thePlayer.getEntityBoundingBox().minY && !modeValue.get().equalsIgnoreCase("Mineplex")) {
        final AxisAlignedBB axisAlignedBB = event.getBoundingBox();

        event.setBoundingBox(new AxisAlignedBB(axisAlignedBB.maxX, mc.thePlayer.getEntityBoundingBox().minY, axisAlignedBB.maxZ, axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ));
    }
}
 
Example #11
Source File: MinecraftTypeHelper.java    From malmo with MIT License 5 votes vote down vote up
/**
 * Attempts to parse the block type string.
 * @param s The string to parse.
 * @return The block type, or null if the string is not recognised.
 */
public static IBlockState ParseBlockType( String s )
{
    if( s == null )
        return null; 
    Block block = (Block)Block.REGISTRY.getObject(new ResourceLocation( s ));
    if( block instanceof BlockAir && !s.equals("air") ) // Minecraft returns BlockAir when it doesn't recognise the string
        return null; // unrecognised string
    return block.getDefaultState();
}
 
Example #12
Source File: ItemBlockPneumaticCraft.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public ItemBlockPneumaticCraft(Block block){
    super(block);
    if(block instanceof BlockPneumaticCraft) {
        this.block = (BlockPneumaticCraft)block;
    } else {
        if(!(block instanceof BlockPneumaticPlantBase) && !(block instanceof BlockAir) && !(block instanceof BlockFluidBase)) {
            Log.warning("Block " + block.getUnlocalizedName() + " does not extend BlockPneumaticCraft! No tooltip displayed");
        }
    }
}
 
Example #13
Source File: WallClimb.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
@EventTarget
public void onUpdate(MotionEvent event) {
    if(event.getEventState() != EventState.POST)
        return;

    switch(modeValue.get().toLowerCase()) {
        case "clip":
            if(mc.thePlayer.motionY < 0)
                glitch = true;

            if(mc.thePlayer.isCollidedHorizontally) {
                switch(clipMode.get().toLowerCase()) {
                    case "jump":
                        if(mc.thePlayer.onGround)
                            mc.thePlayer.jump();
                        break;
                    case "fast":
                        if(mc.thePlayer.onGround)
                            mc.thePlayer.motionY = .42;
                        else if(mc.thePlayer.motionY < 0)
                            mc.thePlayer.motionY = -0.3;
                        break;
                }
            }
            break;
        case "checkerclimb":
            final boolean isInsideBlock = BlockUtils.collideBlockIntersects(mc.thePlayer.getEntityBoundingBox(), block -> !(block instanceof BlockAir));
            final float motion = checkerClimbMotionValue.get();

            if(isInsideBlock && motion != 0F)
                mc.thePlayer.motionY = motion;
            break;
        case "aac3.3.12":
            if(mc.thePlayer.isCollidedHorizontally && !mc.thePlayer.isOnLadder()) {
                waited++;

                if(waited == 1)
                    mc.thePlayer.motionY = 0.43;

                if(waited == 12)
                    mc.thePlayer.motionY = 0.43;

                if(waited == 23)
                    mc.thePlayer.motionY = 0.43;

                if(waited == 29)
                    mc.thePlayer.setPosition(mc.thePlayer.posX, mc.thePlayer.posY + 0.5, mc.thePlayer.posZ);

                if(waited >= 30)
                    waited = 0;
            }else if(mc.thePlayer.onGround)
                waited = 0;
            break;
        case "aacglide":
            if(!mc.thePlayer.isCollidedHorizontally || mc.thePlayer.isOnLadder())
                return;

            mc.thePlayer.motionY = -0.19;
            break;
    }
}
 
Example #14
Source File: Teleport.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
@EventTarget
public void onRender3D(final Render3DEvent event) {
    if(modeValue.get().equals("AAC3.5.0"))
        return;

    final Vec3 lookVec = new Vec3(mc.thePlayer.getLookVec().xCoord * 300, mc.thePlayer.getLookVec().yCoord * 300, mc.thePlayer.getLookVec().zCoord * 300);
    final Vec3 posVec = new Vec3(mc.thePlayer.posX, mc.thePlayer.posY + 1.62, mc.thePlayer.posZ);

    objectPosition = mc.thePlayer.worldObj.rayTraceBlocks(posVec, posVec.add(lookVec), false, ignoreNoCollision.get(), false);

    if (objectPosition == null || objectPosition.getBlockPos() == null)
        return;

    final BlockPos belowBlockPos = new BlockPos(objectPosition.getBlockPos().getX(), objectPosition.getBlockPos().getY() - 1, objectPosition.getBlockPos().getZ());
    
    fixedY = BlockUtils.getBlock(objectPosition.getBlockPos()) instanceof BlockFence ? (mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, mc.thePlayer.getEntityBoundingBox().offset(objectPosition.getBlockPos().getX() + 0.5D - mc.thePlayer.posX, objectPosition.getBlockPos().getY() + 1.5D - mc.thePlayer.posY, objectPosition.getBlockPos().getZ() + 0.5D - mc.thePlayer.posZ)).isEmpty() ? 0.5D : 0D) : BlockUtils.getBlock(belowBlockPos) instanceof BlockFence ? (!mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, mc.thePlayer.getEntityBoundingBox().offset(objectPosition.getBlockPos().getX() + 0.5D - mc.thePlayer.posX, objectPosition.getBlockPos().getY() + 0.5D - mc.thePlayer.posY, objectPosition.getBlockPos().getZ() + 0.5D - mc.thePlayer.posZ)).isEmpty() || BlockUtils.getBlock(objectPosition.getBlockPos()).getCollisionBoundingBox(mc.theWorld, objectPosition.getBlockPos(), BlockUtils.getBlock(objectPosition.getBlockPos()).getDefaultState()) == null ? 0D : 0.5D - BlockUtils.getBlock(objectPosition.getBlockPos()).getBlockBoundsMaxY()) : BlockUtils.getBlock(objectPosition.getBlockPos()) instanceof BlockSnow ? BlockUtils.getBlock(objectPosition.getBlockPos()).getBlockBoundsMaxY() - 0.125D : 0D;
    
    final int x = objectPosition.getBlockPos().getX();
    final double y = (BlockUtils.getBlock(objectPosition.getBlockPos()).getCollisionBoundingBox(mc.theWorld, objectPosition.getBlockPos(), BlockUtils.getBlock(objectPosition.getBlockPos()).getDefaultState()) == null ? objectPosition.getBlockPos().getY() + BlockUtils.getBlock(objectPosition.getBlockPos()).getBlockBoundsMaxY() : BlockUtils.getBlock(objectPosition.getBlockPos()).getCollisionBoundingBox(mc.theWorld, objectPosition.getBlockPos(), BlockUtils.getBlock(objectPosition.getBlockPos()).getDefaultState()).maxY) - 1D + fixedY;
    final int z = objectPosition.getBlockPos().getZ();

    if(!(BlockUtils.getBlock(objectPosition.getBlockPos()) instanceof BlockAir)) {
        final RenderManager renderManager = mc.getRenderManager();

        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glEnable(GL_BLEND);
        glLineWidth(2F);
        glDisable(GL_TEXTURE_2D);
        glDisable(GL_DEPTH_TEST);
        glDepthMask(false);
        RenderUtils.glColor(modeValue.get().equalsIgnoreCase("minesucht") && mc.thePlayer.getPosition().getY() != y + 1 ? new Color(255, 0, 0, 90) : !mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, mc.thePlayer.getEntityBoundingBox().offset(x + 0.5D - mc.thePlayer.posX, y + 1D - mc.thePlayer.posY, z + 0.5D - mc.thePlayer.posZ)).isEmpty() ? new Color(255, 0, 0, 90) : new Color(0, 255, 0, 90));
        RenderUtils.drawFilledBox(new AxisAlignedBB(x - renderManager.renderPosX, (y + 1) - renderManager.renderPosY, z - renderManager.renderPosZ, x - renderManager.renderPosX + 1.0D, y + 1.2D - renderManager.renderPosY, z - renderManager.renderPosZ + 1.0D));
        glEnable(GL_TEXTURE_2D);
        glEnable(GL_DEPTH_TEST);
        glDepthMask(true);
        glDisable(GL_BLEND);

        RenderUtils.renderNameTag(Math.round(mc.thePlayer.getDistance(x + 0.5D, y + 1D, z + 0.5D)) + "m", x + 0.5, y + 1.7, z + 0.5);
        GlStateManager.resetColor();
    }
}