Search in sources :

Example 1 with BlockEio

use of crazypants.enderio.base.BlockEio in project EnderIO by SleepyTrousers.

the class TOPCompatibility method addProbeInfo.

@Override
public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData hitData) {
    if (mode == ProbeMode.DEBUG) {
        probeInfo.text(blockState.toString());
    }
    if (probeInfo != null && world != null && blockState != null && hitData != null && (blockState.getBlock() instanceof BlockEio || blockState.getBlock() instanceof IPaintable)) {
        TileEntity tileEntity = BlockEnder.getAnyTileEntitySafe(world, NullHelper.notnull(hitData.getPos(), "JEI wants it so"));
        if (tileEntity != null) {
            EioBox eiobox = new EioBox(probeInfo);
            TOPData data = new TOPData(tileEntity, hitData);
            mkOwner(mode, eiobox, data);
            mkPaint(mode, eiobox, data);
            mkNotificationLine(mode, eiobox, data);
            mkProgressLine(mode, eiobox, data);
            mkRfLine(mode, eiobox, data);
            mkXPLine(mode, eiobox, data);
            mkRedstoneLine(mode, eiobox, data);
            mkSideConfigLine(mode, eiobox, data);
            mkRangeLine(mode, eiobox, data);
            mkTankLines(mode, eiobox, data);
            mkItemFillLevelLine(mode, eiobox, data);
            eiobox.finish();
            EioBox mobbox = new EioBox(probeInfo);
            mkMobsBox(mode, mobbox, world, data);
            mobbox.finish();
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BlockEio(crazypants.enderio.base.BlockEio) IPaintable(crazypants.enderio.base.paint.IPaintable)

Example 2 with BlockEio

use of crazypants.enderio.base.BlockEio in project EnderIO by SleepyTrousers.

the class ItemYetaWrench method onItemUseFirst.

@Override
@Nonnull
public EnumActionResult onItemUseFirst(@Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side, float hitX, float hitY, float hitZ, @Nonnull EnumHand hand) {
    if (world.isRemote) {
        // If its client side we have to return pass so this method is called on server, where we need to perform the op
        return EnumActionResult.PASS;
    }
    final IBlockState blockState = world.getBlockState(pos);
    IBlockState bs = blockState;
    Block block = bs.getBlock();
    boolean ret = false;
    RightClickBlock e = new RightClickBlock(player, hand, pos, side, new Vec3d(hitX, hitY, hitZ));
    if (MinecraftForge.EVENT_BUS.post(e) || e.getResult() == Result.DENY || e.getUseBlock() == Result.DENY || e.getUseItem() == Result.DENY) {
        return EnumActionResult.PASS;
    }
    if (block instanceof BlockDoor) {
        EnumDoorHalf half = bs.getValue(BlockDoor.HALF);
        if (half == EnumDoorHalf.UPPER) {
            pos = pos.down();
        }
    }
    if (!player.isSneaking() && block.rotateBlock(world, pos, side)) {
        ret = true;
    } else if (block instanceof IBlockPaintableBlock && !player.isSneaking() && !YetaUtil.shouldHeldItemHideFacades(player)) {
        IBlockState paintSource = ((IBlockPaintableBlock) block).getPaintSource(blockState, world, pos);
        if (paintSource != null) {
            final IBlockState rotatedPaintSource = PaintUtil.rotate(paintSource);
            if (rotatedPaintSource != paintSource) {
                ((IBlockPaintableBlock) block).setPaintSource(blockState, world, pos, rotatedPaintSource);
            }
            ret = true;
        }
    }
    // so 'onBlockActivated' is never called
    if (!ret && player.isSneaking() && block instanceof BlockEio<?>) {
        BlockEio<?> beio = (BlockEio<?>) block;
        if (beio.shouldWrench(world, pos, player, side)) {
            beio.onBlockActivated(world, pos, bs, player, hand, side, hitX, hitY, hitZ);
            ret = true;
        }
    }
    if (ret) {
        player.swingArm(hand);
    }
    return ret ? EnumActionResult.SUCCESS : EnumActionResult.PASS;
}
Also used : BlockDoor(net.minecraft.block.BlockDoor) EnumDoorHalf(net.minecraft.block.BlockDoor.EnumDoorHalf) IBlockState(net.minecraft.block.state.IBlockState) BlockEio(crazypants.enderio.base.BlockEio) RightClickBlock(net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock) IBlockPaintableBlock(crazypants.enderio.base.paint.IPaintable.IBlockPaintableBlock) IYetaAwareBlock(crazypants.enderio.base.machine.interfaces.IYetaAwareBlock) Block(net.minecraft.block.Block) RightClickBlock(net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock) IBlockPaintableBlock(crazypants.enderio.base.paint.IPaintable.IBlockPaintableBlock) Vec3d(net.minecraft.util.math.Vec3d) Nonnull(javax.annotation.Nonnull)

Aggregations

BlockEio (crazypants.enderio.base.BlockEio)2 IYetaAwareBlock (crazypants.enderio.base.machine.interfaces.IYetaAwareBlock)1 IPaintable (crazypants.enderio.base.paint.IPaintable)1 IBlockPaintableBlock (crazypants.enderio.base.paint.IPaintable.IBlockPaintableBlock)1 Nonnull (javax.annotation.Nonnull)1 Block (net.minecraft.block.Block)1 BlockDoor (net.minecraft.block.BlockDoor)1 EnumDoorHalf (net.minecraft.block.BlockDoor.EnumDoorHalf)1 IBlockState (net.minecraft.block.state.IBlockState)1 TileEntity (net.minecraft.tileentity.TileEntity)1 Vec3d (net.minecraft.util.math.Vec3d)1 RightClickBlock (net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock)1