Search in sources :

Example 1 with BlockSwitchItem

use of me.wallhacks.spark.util.player.itemswitcher.itemswitchers.BlockSwitchItem in project Spark-Client by Spark-Client-Development.

the class BlockInteractUtil method tryPlaceBlockOnBlock.

public static BlockPlaceResult tryPlaceBlockOnBlock(BlockPos pos, EnumFacing face, BlockSwitchItem switcher, ItemSwitcher.switchType switchType, boolean clientSided, boolean checkEntities, int rotationStayTicks, boolean allowSendMultipleRotPacket) {
    if (!mc.world.getBlockState(pos).getMaterial().isReplaceable())
        return BlockPlaceResult.FAILED;
    Item willuse = Spark.switchManager.predictItem(switcher, ItemSwitcher.usedHand.Both, switchType);
    if (!(willuse instanceof ItemBlock) && !(willuse instanceof ItemSkull) && willuse != Items.SKULL && willuse != Items.WATER_BUCKET && willuse != Items.LAVA_BUCKET)
        return BlockPlaceResult.FAILED;
    if (checkEntities && !blockCollisionCheck(pos, ((ItemBlock) willuse).getBlock()))
        return BlockPlaceResult.FAILED;
    if (face == null)
        return BlockPlaceResult.FAILED;
    BlockPos placeOn = pos.offset(face, -1);
    if (mc.world.getBlockState(placeOn).getBlock().isReplaceable(mc.world, placeOn))
        return BlockPlaceResult.FAILED;
    Vec3d hitVec = getPointOnBlockFace(placeOn, face);
    if (hitVec == null)
        return BlockPlaceResult.FAILED;
    EnumHand hand = Spark.switchManager.Switch(switcher, ItemSwitcher.usedHand.Both, switchType);
    if (hand == null)
        return BlockPlaceResult.FAILED;
    if (AntiCheatConfig.getInstance().getBlockRotate())
        if (!Spark.rotationManager.rotate(Spark.rotationManager.getLegitRotations(hitVec), AntiCheatConfig.getInstance().getBlockRotStep(), rotationStayTicks, allowSendMultipleRotPacket))
            return BlockPlaceResult.WAIT;
    mc.playerController.syncCurrentPlayItem();
    return processRightClickBlockForPlace(placeOn, face, clientSided, hand, hitVec) ? BlockPlaceResult.PLACED : BlockPlaceResult.FAILED;
}
Also used : SpecBlockSwitchItem(me.wallhacks.spark.util.player.itemswitcher.itemswitchers.SpecBlockSwitchItem) Item(net.minecraft.item.Item) EntityItem(net.minecraft.entity.item.EntityItem) BlockSwitchItem(me.wallhacks.spark.util.player.itemswitcher.itemswitchers.BlockSwitchItem) EnumHand(net.minecraft.util.EnumHand) BlockPos(net.minecraft.util.math.BlockPos) ItemBlock(net.minecraft.item.ItemBlock) Vec3d(net.minecraft.util.math.Vec3d) ItemSkull(net.minecraft.item.ItemSkull)

Example 2 with BlockSwitchItem

use of me.wallhacks.spark.util.player.itemswitcher.itemswitchers.BlockSwitchItem in project Spark-Client by Spark-Client-Development.

the class BlockInteractUtil method tryPlaceBlock.

public static BlockPlaceResult tryPlaceBlock(BlockPos pos, BlockSwitchItem switcher, ItemSwitcher.switchType switchType, boolean clientSided, boolean checkEntities, int rotationStayTicks, boolean allowSendMultipleRotPacket) {
    if (!mc.world.getBlockState(pos).getMaterial().isReplaceable())
        return BlockPlaceResult.FAILED;
    Item willuse = null;
    if (switcher != null) {
        willuse = Spark.switchManager.predictItem(switcher, ItemSwitcher.usedHand.Both, switchType);
        if (!(willuse instanceof ItemBlock) && !(willuse instanceof ItemSkull) && willuse != Items.SKULL && willuse != Items.WATER_BUCKET && willuse != Items.LAVA_BUCKET)
            return BlockPlaceResult.FAILED;
    }
    if (checkEntities && !blockCollisionCheck(pos, willuse == null || !(willuse instanceof ItemBlock) ? null : ((ItemBlock) willuse).getBlock()))
        return BlockPlaceResult.FAILED;
    EnumFacing face = getDirForPlacingBlockAtPos(pos);
    if (face == null)
        return BlockPlaceResult.FAILED;
    BlockPos placeOn = pos.offset(face, -1);
    Vec3d hitVec = getPointOnBlockFace(placeOn, face);
    if (hitVec == null)
        return BlockPlaceResult.FAILED;
    EnumHand hand = Spark.switchManager.Switch(switcher, ItemSwitcher.usedHand.Both, switchType);
    if (hand == null)
        return BlockPlaceResult.FAILED;
    if (AntiCheatConfig.getInstance().getBlockRotate())
        if (!Spark.rotationManager.rotate(Spark.rotationManager.getLegitRotations(hitVec), AntiCheatConfig.getInstance().getBlockRotStep(), rotationStayTicks, allowSendMultipleRotPacket))
            return BlockPlaceResult.WAIT;
    mc.playerController.syncCurrentPlayItem();
    return processRightClickBlockForPlace(placeOn, face, clientSided, hand, hitVec) ? BlockPlaceResult.PLACED : BlockPlaceResult.FAILED;
}
Also used : SpecBlockSwitchItem(me.wallhacks.spark.util.player.itemswitcher.itemswitchers.SpecBlockSwitchItem) Item(net.minecraft.item.Item) EntityItem(net.minecraft.entity.item.EntityItem) BlockSwitchItem(me.wallhacks.spark.util.player.itemswitcher.itemswitchers.BlockSwitchItem) EnumFacing(net.minecraft.util.EnumFacing) EnumHand(net.minecraft.util.EnumHand) BlockPos(net.minecraft.util.math.BlockPos) ItemBlock(net.minecraft.item.ItemBlock) Vec3d(net.minecraft.util.math.Vec3d) ItemSkull(net.minecraft.item.ItemSkull)

Aggregations

BlockSwitchItem (me.wallhacks.spark.util.player.itemswitcher.itemswitchers.BlockSwitchItem)2 SpecBlockSwitchItem (me.wallhacks.spark.util.player.itemswitcher.itemswitchers.SpecBlockSwitchItem)2 EntityItem (net.minecraft.entity.item.EntityItem)2 Item (net.minecraft.item.Item)2 ItemBlock (net.minecraft.item.ItemBlock)2 ItemSkull (net.minecraft.item.ItemSkull)2 EnumHand (net.minecraft.util.EnumHand)2 BlockPos (net.minecraft.util.math.BlockPos)2 Vec3d (net.minecraft.util.math.Vec3d)2 EnumFacing (net.minecraft.util.EnumFacing)1