Java 类net.minecraft.block.BlockLever 实例源码

项目:Cyclic    文件:ItemPasswordRemote.java   
@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
  ItemStack stack = playerIn.getHeldItem(hand);
  if (worldIn.getBlockState(pos).getBlock() instanceof BlockLever) {
    UtilNBT.setItemStackBlockPos(stack, pos);
    if (worldIn.isRemote) {
      UtilChat.addChatMessage(playerIn, this.getUnlocalizedName() + ".saved");
    }
    UtilSound.playSound(playerIn, SoundEvents.BLOCK_LEVER_CLICK);
    return EnumActionResult.SUCCESS;
  }
  else {
    boolean success = false;
    success = trigger(stack, worldIn, playerIn);
    if (success)
      return EnumActionResult.SUCCESS;
    else
      return EnumActionResult.FAIL;
  }
}
项目:Cyclic    文件:ItemPasswordRemote.java   
private boolean trigger(ItemStack stack, World worldIn, EntityPlayer playerIn) {
  BlockPos blockPos = UtilNBT.getItemStackBlockPos(stack);
  if (blockPos == null) {
    if (worldIn.isRemote) {
      UtilChat.addChatMessage(playerIn, this.getUnlocalizedName() + ".invalid");
    }
    return false;
  }
  else {
    IBlockState blockState = worldIn.getBlockState(blockPos);
    if (blockState == null || blockState.getBlock() != Blocks.LEVER) {
      if (worldIn.isRemote) {
        UtilChat.addChatMessage(playerIn, this.getUnlocalizedName() + ".invalid");
      }
      return false;
    }
    else {
      boolean hasPowerHere = blockState.getValue(BlockLever.POWERED);//this.block.getStrongPower(blockState, worldIn, pointer, EnumFacing.UP) > 0;
      setLeverPowerState(worldIn, blockPos, blockState, hasPowerHere);
      UtilSound.playSound(playerIn, SoundEvents.BLOCK_LEVER_CLICK);
      return true;
    }
  }
}
项目:ZeldaSwordSkills    文件:WorldUtils.java   
/**
 * Activates a button or toggles a lever at the given position and notifies neighbors
 * @param state Must contain either a BlockButton or BlockLever
 */
public static void activateButton(World world, IBlockState state, BlockPos pos) {
    Block block = state.getBlock();
    if (!(block instanceof BlockButton) && !(block instanceof BlockLever)) {
        return;
    }
    IProperty powered = (block instanceof BlockButton) ? BlockButton.POWERED : BlockLever.POWERED;
    boolean setPowered = block instanceof BlockButton || !((Boolean) state.getValue(powered)).booleanValue();
    IProperty facing = (block instanceof BlockButton) ? BlockButton.FACING : BlockLever.FACING;
    world.setBlockState(pos, state.withProperty(powered, Boolean.valueOf(setPowered)), 3);
    world.markBlockRangeForRenderUpdate(pos, pos);
    world.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, 0.6F);
    world.notifyNeighborsOfStateChange(pos, state.getBlock());
    world.notifyNeighborsOfStateChange(pos.offset(((BlockLever.EnumOrientation) state.getValue(facing)).getFacing().getOpposite()), state.getBlock());
    world.scheduleUpdate(pos, state.getBlock(), state.getBlock().tickRate(world));
    world.playSoundEffect((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, Sounds.CLICK, 0.3F, 0.6F);
}
项目:Allomancy    文件:BlockIronLever.java   
@Override
public boolean onBlockActivatedAllomantically(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
        boolean isPush) {
    if (worldIn.isRemote) {
        return true;
    }
    if ((!isPush && isLeverPointedAway(state, playerIn)) || (isPush && !isLeverPointedAway(state, playerIn))) {
        state = state.cycleProperty(POWERED);
        worldIn.setBlockState(pos, state, 3);
        float f = ((Boolean) state.getValue(POWERED)).booleanValue() ? 0.6F : 0.5F;
        worldIn.playSound((EntityPlayer) null, pos, SoundEvents.BLOCK_LEVER_CLICK, SoundCategory.BLOCKS, 0.3F, f);
        worldIn.notifyNeighborsOfStateChange(pos, this, false);
        EnumFacing enumfacing = ((BlockLever.EnumOrientation) state.getValue(FACING)).getFacing();
        worldIn.notifyNeighborsOfStateChange(pos.offset(enumfacing.getOpposite()), this, false);
        return true;
    }
    return false;
}
项目:pnc-repressurized    文件:HackableLever.java   
@Override
public void addInfo(World world, BlockPos pos, List<String> curInfo, EntityPlayer player) {
    if (!world.getBlockState(pos).getValue(BlockLever.POWERED)) {
        curInfo.add("pneumaticHelmet.hacking.result.activate");
    } else {
        curInfo.add("pneumaticHelmet.hacking.result.deactivate");
    }
}
项目:pnc-repressurized    文件:HackableLever.java   
@Override
public void addPostHackInfo(World world, BlockPos pos, List<String> curInfo, EntityPlayer player) {
    if (!world.getBlockState(pos).getValue(BlockLever.POWERED)) {
        curInfo.add("pneumaticHelmet.hacking.finished.deactivated");
    } else {
        curInfo.add("pneumaticHelmet.hacking.finished.activated");
    }
}
项目:PurificatiMagicae    文件:MultiblockRegistry.java   
public static void setup()
{
    {
        BlockArray arr = new BlockArray();
        BlockArrayEntry rope = new BlockArrayEntry(BlockRegistry.rope_coil.getDefaultState().withProperty(AxisController.AXIS, EnumFacing.Axis.Z), new ItemStack(ItemRegistry.rope_coil));
        BlockArrayEntry rope_cog = new BlockArrayEntry(BlockRegistry.rope_coil.getDefaultState().withProperty(AxisController.AXIS, EnumFacing.Axis.Z).withProperty(BlockRopeCoil.TYPE, BlockRopeCoil.Type.COG), new ItemStack(ItemRegistry.rope_coil, 1, 1));

        arr.getCheckers().add((BlockArrayEntry entr, IBlockState state, IBlockState worldState, World w, BlockPos pos, Rotation rot) ->
        {
            for(IProperty<?> prop : state.getPropertyKeys())
            {
                if(prop == BlockAnvil.DAMAGE || prop == BlockRopeCoil.TYPE)
                    return state.getValue(prop).equals(worldState.getValue(prop));
            }
            return true;
        });
        arr.getMap().putAll(CollectionUtils.createMap(BlockPos.class, BlockArrayEntry.class,
                new BlockPos(0, 0, 0), new BlockArrayEntry(Blocks.ANVIL, new ItemStack(Blocks.ANVIL)),
                new BlockPos(0, 2, 0), rope,
                new BlockPos(1, 2, 0), rope,
                new BlockPos(1, 0, 0), rope_cog,
                new BlockPos(2, 0, 0), new BlockArrayEntry(Blocks.LEVER.getDefaultState().withProperty(BlockLever.FACING, BlockLever.EnumOrientation.UP_X).withProperty(BlockLever.POWERED, true), new ItemStack(Blocks.LEVER)),
                new BlockPos(1, 0, 1), new BlockArrayEntry(Blocks.LEVER.getDefaultState().withProperty(BlockLever.FACING, BlockLever.EnumOrientation.SOUTH), new ItemStack(Blocks.LEVER))
        ));
        Multiblock.REGISTRY.register(STONE_CRUSHER = new PMMultiblock(0, arr, new BlockPos(1, 0, 0), BlockRegistry.stone_crusher.getDefaultState(), new ModelResourceLocation(Utils.gRL("stone_crusher"), "normal"), Utils.gRL("stone_crusher")));
    }
}
项目:shifted-snow    文件:ClassProviders.java   
public static void addBush() {
  ShiftedSnowApi.addSimpleClassMapping(BlockBush.class, EnumSnowType.MINUS_FULL);
  ShiftedSnowApi.addSimpleClassMapping(BlockSign.class, EnumSnowType.MINUS_FULL);
  ShiftedSnowApi.addSimpleClassMapping(BlockAnvil.class, EnumSnowType.MINUS_FULL);
  ShiftedSnowApi.addSimpleClassMapping(BlockBush.class, EnumSnowType.MINUS_FULL);
  ShiftedSnowApi.addSimpleClassMapping(BlockPressurePlate.class, EnumSnowType.MINUS_FULL);
  ShiftedSnowApi.addSimpleClassMapping(BlockLever.class, EnumSnowType.MINUS_FULL);
  ShiftedSnowApi.addSimpleClassMapping(BlockRailBase.class, EnumSnowType.MINUS_FULL);
  ShiftedSnowApi.addSimpleClassMapping(BlockTripWire.class, EnumSnowType.MINUS_FULL);
  ShiftedSnowApi.addSimpleClassMapping(BlockTripWireHook.class, EnumSnowType.MINUS_FULL);
}
项目:ExoticPower    文件:ItemWrench.java   
public ItemWrench() {
    super();
    this.setCreativeTab(ExoticPower.ept);
    this.setUnlocalizedName("epwrench");
    setFull3D();
    setMaxStackSize(1);
    shiftRotations.add(BlockLever.class);
    shiftRotations.add(BlockButton.class);
    shiftRotations.add(BlockChest.class);
    setHarvestLevel("wrench", 0);
    EPItems.itemList.add(this);
}
项目:Culinary-Cultivation    文件:BlockFanHousing.java   
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, BlockPos neighborPos) {
    if (!world.isRemote) {
        if (neighborBlock instanceof BlockLever) {
            if (isFrontPowered(world, pos, state)) {
                BlockPos right = pos.offset(state.getValue(FACING).rotateAround(Axis.Y).getOpposite());
                if (world.getTileEntity(right) instanceof TileEntitySeparator) {
                    ((TileEntitySeparator) world.getTileEntity(right)).onPowered();
                    world.playSound(null, pos, SoundEvents.ENTITY_MINECART_RIDING, SoundCategory.BLOCKS, 0.4F, 0.6F);
                }
            }
        }
    }
}
项目:Cyclic    文件:ItemPasswordRemote.java   
private void setLeverPowerState(World worldIn, BlockPos blockPos, IBlockState blockState, boolean hasPowerHere) {
  IBlockState stateNew = blockState.withProperty(BlockLever.POWERED, !hasPowerHere);
  boolean success = worldIn.setBlockState(blockPos, stateNew);
  if (success) {
    flagUpdate(worldIn, blockPos, blockState, stateNew);
    flagUpdate(worldIn, blockPos.down(), blockState, stateNew);
    flagUpdate(worldIn, blockPos.up(), blockState, stateNew);
    flagUpdate(worldIn, blockPos.west(), blockState, stateNew);
    flagUpdate(worldIn, blockPos.east(), blockState, stateNew);
    flagUpdate(worldIn, blockPos.north(), blockState, stateNew);
    flagUpdate(worldIn, blockPos.south(), blockState, stateNew);
  }
}
项目:Blocksteps    文件:LeverHandler.java   
@Override
public boolean isValidPeripheral(IBlockAccess world, BlockPos pos, IBlockState state, List<BlockPos> availableBlocks)
{
    EnumFacing enumfacing = ((BlockLever.EnumOrientation)state.getValue(BlockLever.FACING)).getFacing();

    return availableBlocks.contains(pos.offset(enumfacing.getOpposite()));
}
项目:AgriCraft    文件:TileEntityChannelValve.java   
@Override
public IrrigationConnectionType getConnectionType(EnumFacing side) {
    if (WorldHelper.getBlock(this.getWorld(), pos.offset(side), BlockLever.class).isPresent()) {
        return IrrigationConnectionType.AUXILIARY;
    } else {
        return super.getConnectionType(side);
    }
}
项目:FlowstoneEnergy    文件:ItemToolPneumaticFlowwrench.java   
public ItemToolPneumaticFlowwrench() {
    super();
    this.setUnlocalizedName(ModInfo.MODID + ".pneumatic.flowwrench");
    //this.setTextureName(ModInfo.MODID + ":tools/pneumaticFlowwrench");
    this.setMaxStackSize(1);
    shiftRotations.add(BlockLever.class);
    shiftRotations.add(BlockButton.class);
    shiftRotations.add(BlockChest.class);
}
项目:QmunityLib    文件:RedstoneHelper.java   
public static boolean canConnectVanilla(World world, BlockPos pos, ForgeDirection side, ForgeDirection face) {

        if (side == ForgeDirection.UNKNOWN)
            return false;

        Block block = world.getBlock(pos.getX(), pos.getY(), pos.getZ());
        int meta = world.getBlockMetadata(pos.getX(), pos.getY(), pos.getZ());
        int d = Direction.getMovementDirection(side.offsetX, side.offsetZ);

        if ((block == Blocks.unpowered_repeater || block == Blocks.powered_repeater)
                && (face == ForgeDirection.DOWN || face == ForgeDirection.UNKNOWN))
            if (d % 2 == meta % 2)
                return true;

        if (block instanceof BlockLever) {
            meta = meta % 8;
            ForgeDirection leverFace = ((meta == 0 || meta == 7) ? ForgeDirection.UP : ((meta == 5 || meta == 6) ? ForgeDirection.DOWN
                    : (meta == 1 ? ForgeDirection.WEST : (meta == 2 ? ForgeDirection.EAST : (meta == 3 ? ForgeDirection.NORTH
                            : (meta == 4 ? ForgeDirection.SOUTH : ForgeDirection.UNKNOWN))))));
            if (face != ForgeDirection.UNKNOWN && face != leverFace)
                return false;
            return side != leverFace.getOpposite();
        }

        if (block instanceof BlockRedstoneComparator && (face == ForgeDirection.DOWN || face == ForgeDirection.UNKNOWN))
            return side != ForgeDirection.UP;

        if (block instanceof BlockRedstoneWire)
            return face == ForgeDirection.UNKNOWN || face == ForgeDirection.DOWN;

        return block instanceof BlockDoor || block instanceof BlockRedstoneLight || block instanceof BlockTNT
                || block instanceof BlockDispenser || block instanceof BlockNote
                || block instanceof BlockPistonBase;// true;
    }
项目:QmunityLib    文件:RedstoneHelper.java   
private static boolean isVanillaBlock(World world, BlockPos pos) {

        Block b = world.getBlock(pos.getX(), pos.getY(), pos.getZ());
        return b instanceof BlockRedstoneRepeater || b instanceof BlockLever || b instanceof BlockRedstoneWire
                || b instanceof BlockRedstoneComparator || b instanceof BlockDoor || b instanceof BlockRedstoneLight
                || b instanceof BlockTNT || b instanceof BlockDispenser || b instanceof BlockNote
                || b instanceof BlockPistonBase;
    }
项目:ZeldaSwordSkills    文件:EntityBoomerang.java   
@Override
protected void onImpact(MovingObjectPosition mop) {
    if (mop.typeOfHit == MovingObjectType.ENTITY) {
        if (mop.entityHit != getThrower() && mop.entityHit.attackEntityFrom(getDamageSource(), getDamage())) {
            playSound(Sounds.DAMAGE_SUCCESSFUL_HIT, 1.0F, 1.2F / (rand.nextFloat() * 0.2F + 0.9F));
            if (mop.entityHit instanceof EntityLivingBase && getThrower() != null) {
                EnchantmentHelper.applyThornEnchantments((EntityLivingBase) mop.entityHit, getThrower());
                EnchantmentHelper.applyArthropodEnchantments(getThrower(), mop.entityHit);
            }
        }
    } else {
        BlockPos pos = mop.getBlockPos();
        IBlockState state = worldObj.getBlockState(pos);
        Block block = state.getBlock();
        boolean flag = block.getMaterial().blocksMovement();
        if (block instanceof IBoomerangBlock) {
            flag = ((IBoomerangBlock) block).onBoomerangCollided(worldObj, pos, state, this);
        } else {
            block.onEntityCollidedWithBlock(worldObj, pos, this);
            float hardness = block.getBlockHardness(worldObj, pos);
            if (block.getMaterial() != Material.air && hardness >= 0.0F && hardness < 0.1F && !worldObj.isRemote) {
                worldObj.destroyBlock(pos, true);
            } else if (block instanceof BlockButton || (block instanceof BlockLever &&
                    getBoomerang() != null && getBoomerang().getItem() == ZSSItems.boomerangMagic)) {
                WorldUtils.activateButton(worldObj, state, pos);
                flag = true;
            }
        }
        if (flag && !noClip) {
            noClip = true;
            distance = Math.min(distance, 0);
            setThrowableHeading(-motionX, -motionY, -motionZ, getVelocity(), 1.0F);
        }
    }
}
项目:ZeldaSwordSkills    文件:EntityWhip.java   
/**
 * Returns true if the whip can grapple the block at the position
 */
protected boolean canGrabBlock(Block block, BlockPos pos, EnumFacing face) {
    if (block instanceof IWhipBlock) {
        return ((IWhipBlock) block).canGrabBlock(getType(), getThrower(), worldObj, pos, face);
    }
    switch (getType()) {
    case WHIP_MAGIC:
        // this excludes things like dirt, most plants, etc.
        if (block instanceof BlockSandStone || block instanceof BlockHugeMushroom || 
                (block.getMaterial().blocksMovement() && block.getBlockHardness(worldObj, pos) > 1.0F)) {
            return true;
        } // otherwise, fall through to standard case:
    case WHIP_SHORT:
    case WHIP_LONG:
        int clear = 0;
        if (isSideClear(pos.east()) && isSideClear(pos.west())) {
            ++clear;
        }
        if (isSideClear(pos.up()) && isSideClear(pos.down())) {
            ++clear;
        }
        if (isSideClear(pos.south()) && isSideClear(pos.north())) {
            ++clear;
        }
        return (clear > 1 && (block instanceof BlockFence || block instanceof BlockLog ||
                block instanceof BlockLever || block instanceof BlockSign ||
                block instanceof BlockLadder));
    }
    return false;
}
项目:ZeldaSwordSkills    文件:EntityWhip.java   
/**
 * Returns true if player should swing (player far enough below whip, whip not attached to a lever, etc.)
 */
private boolean shouldSwing() {
    BlockPos pos = getHitBlockPosition();
    if (pos == null) {
        return false;
    }
    IBlockState state = worldObj.getBlockState(pos);
    Block block = state.getBlock();
    if (block.getMaterial() == Material.air) {
        setDead();
        return false;
    }
    if (block instanceof IWhipBlock) {
        Result result = ((IWhipBlock) block).shouldSwing(this, worldObj, pos, ticksInGround);
        switch (result) {
        case ALLOW: return true;
        case DENY: return false;
        default: // continue on to rest of processing
        }
    }
    if (isDead) { // in case IWhipBlock killed the whip entity
        return false;
    } else if (block instanceof BlockLever) {
        if (ticksInGround > 10 && !worldObj.isRemote) {
            WorldUtils.activateButton(worldObj, state, pos);
            setDead();
        }
        return false;
    } else if (worldObj.isRemote && swingVec == null && getThrower() != null) {
        // make sure thrower's y position is below impact position before starting swing
        return (getThrower().getEntityBoundingBox().maxY) < dataWatcher.getWatchableObjectFloat(HIT_POS_Y);
    }
    return true;
}
项目:ZeldaSwordSkills    文件:BlockGiantLever.java   
public BlockGiantLever() {
    super();
    setHardness(1.0F);
    setStepSound(soundTypeWood);
    setCreativeTab(ZSSCreativeTabs.tabBlocks);
    setBlockBounds(0.125F, 0.0F, 0.125F, 0.875F, 0.8F, 0.875F);
    setDefaultState(blockState.getBaseState().withProperty(FACING, BlockLever.EnumOrientation.NORTH).withProperty(POWERED, Boolean.valueOf(false)));
}
项目:OpenBlocks    文件:ItemWrench.java   
public ItemWrench() {
    setMaxStackSize(1);

    sneakOnly.add(BlockLever.class);
    sneakOnly.add(BlockButton.class);
    sneakOnly.add(BlockChest.class);
}
项目:minecraft-roguelike    文件:Lever.java   
public static void generate(IWorldEditor editor, Cardinal dir, Coord pos, boolean active){

    MetaBlock lever = new MetaBlock(Blocks.LEVER);
    lever.withProperty(BlockLever.POWERED, active);
    if(dir == Cardinal.UP){
        lever.withProperty(BlockLever.FACING, EnumOrientation.UP_X);
    } else if(dir == Cardinal.DOWN){
        lever.withProperty(BlockLever.FACING, EnumOrientation.DOWN_X);
    } else {
        lever.withProperty(BlockLever.FACING, Cardinal.orientation(Cardinal.reverse(dir)));
    }
    lever.set(editor, pos);
}
项目:BaseClient    文件:BetterSnow.java   
private static boolean checkBlock(Block p_checkBlock_0_, IBlockState p_checkBlock_1_)
{
    if (p_checkBlock_0_.isFullCube())
    {
        return false;
    }
    else if (p_checkBlock_0_.isOpaqueCube())
    {
        return false;
    }
    else if (p_checkBlock_0_ instanceof BlockSnow)
    {
        return false;
    }
    else if (!(p_checkBlock_0_ instanceof BlockBush) || !(p_checkBlock_0_ instanceof BlockDoublePlant) && !(p_checkBlock_0_ instanceof BlockFlower) && !(p_checkBlock_0_ instanceof BlockMushroom) && !(p_checkBlock_0_ instanceof BlockSapling) && !(p_checkBlock_0_ instanceof BlockTallGrass))
    {
        if (!(p_checkBlock_0_ instanceof BlockFence) && !(p_checkBlock_0_ instanceof BlockFenceGate) && !(p_checkBlock_0_ instanceof BlockFlowerPot) && !(p_checkBlock_0_ instanceof BlockPane) && !(p_checkBlock_0_ instanceof BlockReed) && !(p_checkBlock_0_ instanceof BlockWall))
        {
            if (p_checkBlock_0_ instanceof BlockRedstoneTorch && p_checkBlock_1_.getValue(BlockTorch.FACING) == EnumFacing.UP)
            {
                return true;
            }
            else
            {
                if (p_checkBlock_0_ instanceof BlockLever)
                {
                    Object object = p_checkBlock_1_.getValue(BlockLever.FACING);

                    if (object == BlockLever.EnumOrientation.UP_X || object == BlockLever.EnumOrientation.UP_Z)
                    {
                        return true;
                    }
                }

                return false;
            }
        }
        else
        {
            return true;
        }
    }
    else
    {
        return true;
    }
}
项目:BaseClient    文件:BetterSnow.java   
private static boolean checkBlock(Block p_checkBlock_0_, IBlockState p_checkBlock_1_)
{
    if (p_checkBlock_0_.isFullCube())
    {
        return false;
    }
    else if (p_checkBlock_0_.isOpaqueCube())
    {
        return false;
    }
    else if (p_checkBlock_0_ instanceof BlockSnow)
    {
        return false;
    }
    else if (!(p_checkBlock_0_ instanceof BlockBush) || !(p_checkBlock_0_ instanceof BlockDoublePlant) && !(p_checkBlock_0_ instanceof BlockFlower) && !(p_checkBlock_0_ instanceof BlockMushroom) && !(p_checkBlock_0_ instanceof BlockSapling) && !(p_checkBlock_0_ instanceof BlockTallGrass))
    {
        if (!(p_checkBlock_0_ instanceof BlockFence) && !(p_checkBlock_0_ instanceof BlockFenceGate) && !(p_checkBlock_0_ instanceof BlockFlowerPot) && !(p_checkBlock_0_ instanceof BlockPane) && !(p_checkBlock_0_ instanceof BlockReed) && !(p_checkBlock_0_ instanceof BlockWall))
        {
            if (p_checkBlock_0_ instanceof BlockRedstoneTorch && p_checkBlock_1_.getValue(BlockTorch.FACING) == EnumFacing.UP)
            {
                return true;
            }
            else
            {
                if (p_checkBlock_0_ instanceof BlockLever)
                {
                    Object object = p_checkBlock_1_.getValue(BlockLever.FACING);

                    if (object == BlockLever.EnumOrientation.UP_X || object == BlockLever.EnumOrientation.UP_Z)
                    {
                        return true;
                    }
                }

                return false;
            }
        }
        else
        {
            return true;
        }
    }
    else
    {
        return true;
    }
}
项目:Backmemed    文件:BetterSnow.java   
private static boolean checkBlock(Block p_checkBlock_0_, IBlockState p_checkBlock_1_)
{
    if (p_checkBlock_1_.isFullCube())
    {
        return false;
    }
    else if (p_checkBlock_1_.isOpaqueCube())
    {
        return false;
    }
    else if (p_checkBlock_0_ instanceof BlockSnow)
    {
        return false;
    }
    else if (!(p_checkBlock_0_ instanceof BlockBush) || !(p_checkBlock_0_ instanceof BlockDoublePlant) && !(p_checkBlock_0_ instanceof BlockFlower) && !(p_checkBlock_0_ instanceof BlockMushroom) && !(p_checkBlock_0_ instanceof BlockSapling) && !(p_checkBlock_0_ instanceof BlockTallGrass))
    {
        if (!(p_checkBlock_0_ instanceof BlockFence) && !(p_checkBlock_0_ instanceof BlockFenceGate) && !(p_checkBlock_0_ instanceof BlockFlowerPot) && !(p_checkBlock_0_ instanceof BlockPane) && !(p_checkBlock_0_ instanceof BlockReed) && !(p_checkBlock_0_ instanceof BlockWall))
        {
            if (p_checkBlock_0_ instanceof BlockRedstoneTorch && p_checkBlock_1_.getValue(BlockTorch.FACING) == EnumFacing.UP)
            {
                return true;
            }
            else
            {
                if (p_checkBlock_0_ instanceof BlockLever)
                {
                    Object object = p_checkBlock_1_.getValue(BlockLever.FACING);

                    if (object == BlockLever.EnumOrientation.UP_X || object == BlockLever.EnumOrientation.UP_Z)
                    {
                        return true;
                    }
                }

                return false;
            }
        }
        else
        {
            return true;
        }
    }
    else
    {
        return true;
    }
}
项目:RemotecraftMod    文件:Core.java   
/**
 * Toggle a redstone lever
 * @param dim Lever dimension
 * @param x Lever X coord
 * @param y Lever Y coord
 * @param z Lever Z coord
 */
public void toggleLever(int dim, int x, int y, int z) {
    WorldServer world = mc.getIntegratedServer().worldServerForDimension(mc.thePlayer.dimension);

    if (dim == mc.thePlayer.dimension) {
        if (world.getBlockState(new BlockPos(x, y, z)).getBlock() != null) {
            Block block = world.getBlockState(new BlockPos(x, y, z)).getBlock();
            if (block == Blocks.LEVER) {

                int i1 = world.getBlockState(new BlockPos(x, y, z)).getBlock().getMetaFromState(world.getBlockState(new BlockPos(x, y, z)));
                int j1 = i1 & 7;
                int k1 = 8 - (i1 & 8);

                BlockPos blockPos = new BlockPos(x, y, z);
                IBlockState blockState = world.getBlockState(blockPos);
                boolean isPowered = ((Boolean) blockState.getValue(BlockLever.POWERED)).booleanValue();

                world.setBlockState(blockPos, blockState.withProperty(BlockLever.POWERED, Boolean.valueOf(!isPowered)));

                // TODO Is this working correctly?
                ResourceLocation resourceLocation = new ResourceLocation("remotecraft", "random.click");
                SoundEvent soundEvent = new SoundEvent(resourceLocation);
                world.playSound( x + 0.5D, y + 0.5D, z + 0.5D, soundEvent, SoundCategory.BLOCKS, 0.3F, ((Boolean) blockState.getValue(BlockLever.POWERED)).booleanValue() ? 0.6F : 0.5F, false);

                // Notify block update
                world.notifyNeighborsOfStateChange(new BlockPos(x, y, z), block);

                // Notify the block being directly powered
                if (j1 == 1) {
                    world.notifyNeighborsOfStateChange(new BlockPos(x - 1 , y, z), block);
                } else if (j1 == 2) {
                    world.notifyNeighborsOfStateChange(new BlockPos(x + 1, y, z), block);
                } else if (j1 == 3) {
                    world.notifyNeighborsOfStateChange(new BlockPos(x, y, z - 1), block);
                } else if (j1 == 4) {
                    world.notifyNeighborsOfStateChange(new BlockPos(x, y, z + 1), block);
                } else if (j1 != 5 && j1 != 6) {
                    if (j1 == 0 || j1 == 7) {
                        world.notifyNeighborsOfStateChange(new BlockPos(x, y + 1, z), block);
                    }
                } else {
                    world.notifyNeighborsOfStateChange(new BlockPos(x, y - 1, z), block);
                }

            } else {
                //mc.ingameGUI.getChatGUI().printChatMessage("[Remotecraft] Error. Block is not a Lever.");
                System.out.println("[Remotecraft] Error. Block is not a Lever.");
            }
        } else {
            //mc.ingameGUI.getChatGUI().printChatMessage("[Remotecraft] Error. No block found.");
            System.out.println("[Remotecraft] Error. No block found.");
        }
    } else {
        //mc.ingameGUI.getChatGUI().printChatMessage("[Remotecraft] Error. Not in the same dimension.");
        System.out.println("[Remotecraft] Error. Not in the same dimension.");
    }
}
项目:MC-Prefab    文件:BuildBlock.java   
private static EnumOrientation getLeverOrientation(StructureConfiguration configuration, Block foundBlock, BuildBlock block, EnumFacing assumedNorth)
{
    EnumOrientation leverOrientation = EnumOrientation.NORTH;

    if (foundBlock instanceof BlockLever)
    {
        // Levers have a special facing.
        leverOrientation = BlockLever.EnumOrientation.valueOf(block.getProperty("facing").getValue().toUpperCase());

        if (leverOrientation.getFacing() == EnumFacing.DOWN
                || leverOrientation.getFacing() == EnumFacing.UP)
        {
            if (leverOrientation.getFacing() == EnumFacing.DOWN)
            {
                leverOrientation = 
                        configuration.houseFacing == assumedNorth || configuration.houseFacing == assumedNorth.getOpposite() 
                            ? leverOrientation : 
                                leverOrientation == EnumOrientation.DOWN_X 
                            ? EnumOrientation.DOWN_Z : EnumOrientation.DOWN_X;
            }
            else
            {
                leverOrientation = 
                        configuration.houseFacing == assumedNorth || configuration.houseFacing == assumedNorth.getOpposite() 
                            ? leverOrientation : 
                                leverOrientation == EnumOrientation.UP_X 
                            ? EnumOrientation.UP_Z : EnumOrientation.UP_X;
            }
        }
        else
        {
            EnumFacing facing = leverOrientation.getFacing();

            if (configuration.houseFacing.rotateY() == assumedNorth)
            {               
                facing = facing.rotateY();
            }
            else if (configuration.houseFacing.getOpposite() == assumedNorth)
            {
            }
            else if (configuration.houseFacing.rotateYCCW() == assumedNorth)
            {
                facing = facing.rotateYCCW();
            }
            else
            {
                facing = facing.getOpposite();
            }

            for (EnumOrientation tempOrientation : EnumOrientation.values())
            {
                if (tempOrientation.getFacing() == facing)
                {
                    leverOrientation = tempOrientation;
                    break;
                }
            }
        }
    }

    return leverOrientation;
}
项目:TaleCraft    文件:Invoke.java   
public static final void trigger(World world, BlockPos position, IBlockState state, EnumTriggerState state2) {
    Block block = state.getBlock();

    if(block instanceof TCITriggerableBlock){
        ((TCITriggerableBlock) state.getBlock()).trigger(world, position, state2);
        return;
    }

    if(block instanceof BlockCommandBlock) {
        ((TileEntityCommandBlock)world.getTileEntity(position)).getCommandBlockLogic().trigger(world);
        return;
    }

    // Just for the heck of it!
    if(block instanceof BlockTNT) {
        ((BlockTNT) block).explode(world, position, state.withProperty(BlockTNT.EXPLODE, Boolean.TRUE), null);
        world.setBlockToAir(position);
        return;
    }

    if(block instanceof BlockDispenser) {
        block.updateTick(world, position, state, TaleCraft.random);
        return;
    }

    if(block instanceof BlockDropper) {
        block.updateTick(world, position, state, TaleCraft.random);
        return;
    }

    // XXX: Experimental: This could break with any update.
    if(block instanceof BlockLever) {
        state = state.cycleProperty(BlockLever.POWERED);
        world.setBlockState(position, state, 3);
        world.playSound(position.getX() + 0.5D, position.getY() + 0.5D, position.getZ() + 0.5D, SoundEvents.BLOCK_LEVER_CLICK, SoundCategory.BLOCKS, 0.3F, state.getValue(BlockLever.POWERED).booleanValue() ? 0.6F : 0.5F, false);
        world.notifyNeighborsOfStateChange(position, block, true);
        EnumFacing enumfacing1 = state.getValue(BlockLever.FACING).getFacing();
        world.notifyNeighborsOfStateChange(position.offset(enumfacing1.getOpposite()), block, true);
        return;
    }

    // XXX: Experimental: This could break with any update.
    if(block instanceof BlockButton) {
        world.setBlockState(position, state.withProperty(BlockButton.POWERED, Boolean.valueOf(true)), 3);
        world.markBlockRangeForRenderUpdate(position, position);
        world.playSound(position.getX() + 0.5D, position.getY() + 0.5D, position.getZ() + 0.5D, SoundEvents.BLOCK_STONE_BUTTON_CLICK_ON, SoundCategory.BLOCKS, 0.3F, 0.6F, false); //TODO There are multiple button click sounds
        world.notifyNeighborsOfStateChange(position, block, true);
        world.notifyNeighborsOfStateChange(position.offset(state.getValue(BlockDirectional.FACING).getOpposite()), block, true);
        world.scheduleUpdate(position, block, block.tickRate(world));
    }

    // XXX: Implement more vanilla triggers?
}
项目:Structures    文件:RotationHelper.java   
private static BlockType getBlockType(Block block) {

    if(block instanceof BlockBed || block instanceof BlockPumpkin || block instanceof BlockFenceGate || block instanceof BlockEndPortalFrame
        || block instanceof BlockCocoa) {
      return BlockType.BED;
    }
    if(block instanceof BlockRail) {
      return BlockType.RAIL;
    }
    if(block instanceof BlockRailPowered || block instanceof BlockRailDetector) {
      return BlockType.RAIL_POWERED;
    }
    if(block instanceof BlockStairs) {
      return BlockType.STAIR;
    }
    if(block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockFurnace || block instanceof BlockLadder
        || block == Blocks.wall_sign) {
      return BlockType.CHEST;
    }
    if(block == Blocks.standing_sign) {
      return BlockType.SIGNPOST;
    }
    if(block instanceof BlockDoor) {
      return BlockType.DOOR;
    }
    if(block instanceof BlockButton) {
      return BlockType.BUTTON;
    }
    if(block instanceof BlockRedstoneRepeater || block instanceof BlockRedstoneComparator) {
      return BlockType.REDSTONE_REPEATER;
    }
    if(block instanceof BlockTrapDoor) {
      return BlockType.TRAPDOOR;
    }
    if(block instanceof BlockHugeMushroom) {
      return BlockType.MUSHROOM_CAP;
    }
    if(block instanceof BlockVine) {
      return BlockType.VINE;
    }
    if(block instanceof BlockSkull) {
      return BlockType.SKULL;
    }
    if(block instanceof BlockAnvil) {
      return BlockType.ANVIL;
    }
    if(block instanceof BlockLog) {
      return BlockType.LOG;
    }
    if(block instanceof BlockDispenser || block instanceof BlockPistonBase || block instanceof BlockPistonExtension || block instanceof BlockHopper) {
      return BlockType.DISPENSER;
    }
    if(block instanceof BlockTorch) {
      return BlockType.TORCH;
    }
    if(block instanceof BlockLever) {
      return BlockType.LEVER;
    }
    if(block instanceof BlockTripWireHook) {
      return BlockType.TRIP_WIRE_HOOK;
    }

    return null;
  }
项目:AllPI    文件:BlockPropertyUtils.java   
public static BlockLever.EnumOrientation getBlockPropertyAsOrientation(World par1World, BlockPos pos, PropertyEnum property){
    return ((BlockLever.EnumOrientation) par1World.getBlockState(pos).getValue(property));
}
项目:AllPI    文件:BlockPropertyUtils.java   
public static BlockLever.EnumOrientation getBlockPropertyAsOrientation(World par1World, int par2, int par3, int par4, PropertyEnum property){
    return ((BlockLever.EnumOrientation) par1World.getBlockState(BlockUtils.toPos(par2, par3, par4)).getValue(property));
}
项目:SecurityCraft    文件:BlockUtils.java   
public static BlockLever.EnumOrientation getBlockPropertyAsOrientation(World par1World, BlockPos pos, PropertyEnum<?> property){
    return ((BlockLever.EnumOrientation) par1World.getBlockState(pos).getValue(property));
}
项目:SecurityCraft    文件:BlockUtils.java   
public static BlockLever.EnumOrientation getBlockPropertyAsOrientation(World par1World, int par2, int par3, int par4, PropertyEnum<?> property){
    return ((BlockLever.EnumOrientation) par1World.getBlockState(toPos(par2, par3, par4)).getValue(property));
}
项目:SecurityCraft    文件:BlockUtils.java   
public static BlockLever.EnumOrientation getBlockPropertyAsOrientation(World par1World, BlockPos pos, PropertyEnum<?> property){
    return ((BlockLever.EnumOrientation) par1World.getBlockState(pos).getValue(property));
}
项目:SecurityCraft    文件:BlockUtils.java   
public static BlockLever.EnumOrientation getBlockPropertyAsOrientation(World par1World, int par2, int par3, int par4, PropertyEnum<?> property){
    return ((BlockLever.EnumOrientation) par1World.getBlockState(toPos(par2, par3, par4)).getValue(property));
}
项目:SecurityCraft    文件:BlockUtils.java   
public static BlockLever.EnumOrientation getBlockPropertyAsOrientation(World par1World, BlockPos pos, PropertyEnum property){
    return ((BlockLever.EnumOrientation) par1World.getBlockState(pos).getValue(property));
}
项目:SecurityCraft    文件:BlockUtils.java   
public static BlockLever.EnumOrientation getBlockPropertyAsOrientation(World par1World, int par2, int par3, int par4, PropertyEnum property){
    return ((BlockLever.EnumOrientation) par1World.getBlockState(toPos(par2, par3, par4)).getValue(property));
}
项目:SecurityCraft    文件:BlockUtils.java   
public static BlockLever.EnumOrientation getBlockPropertyAsOrientation(World par1World, BlockPos pos, PropertyEnum property){
    return ((BlockLever.EnumOrientation) par1World.getBlockState(pos).getValue(property));
}
项目:SecurityCraft    文件:BlockUtils.java   
public static BlockLever.EnumOrientation getBlockPropertyAsOrientation(World par1World, int par2, int par3, int par4, PropertyEnum property){
    return ((BlockLever.EnumOrientation) par1World.getBlockState(toPos(par2, par3, par4)).getValue(property));
}
项目:SecurityCraft    文件:BlockUtils.java   
public static BlockLever.EnumOrientation getBlockPropertyAsOrientation(World par1World, BlockPos pos, PropertyEnum<?> property){
    return ((BlockLever.EnumOrientation) par1World.getBlockState(pos).getValue(property));
}