Java 类net.minecraft.block.state.IBlockState 实例源码

项目:Infernum    文件:BlockPedestal.java   
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand,
        EnumFacing side, float hitX, float hitY, float hitZ) {

    if (!world.isRemote && world.getTileEntity(pos) instanceof TilePedestal) {
        TilePedestal pedestal = (TilePedestal) world.getTileEntity(pos);
        if (pedestal.getStack().func_190926_b()) {
            if (!player.getHeldItem(hand).func_190926_b()) {
                pedestal.setStack(player.getHeldItem(hand));
                player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.field_190927_a);
                player.openContainer.detectAndSendChanges();
            }
        } else {
            ItemStack stack = pedestal.getStack();
            pedestal.setStack(ItemStack.field_190927_a);
            if (!player.inventory.addItemStackToInventory(stack)) {
                EntityItem entityItem = new EntityItem(world, pos.getX(), pos.getY() + 1, pos.getZ(), stack);
                world.spawnEntity(entityItem);
            } else {
                player.openContainer.detectAndSendChanges();
            }
        }
    }

    return true;
}
项目:CustomWorldGen    文件:ForgeHooks.java   
public static float blockStrength(IBlockState state, EntityPlayer player, World world, BlockPos pos)
{
    float hardness = state.getBlockHardness(world, pos);
    if (hardness < 0.0F)
    {
        return 0.0F;
    }

    if (!canHarvestBlock(state.getBlock(), player, world, pos))
    {
        return player.getDigSpeed(state, pos) / hardness / 100F;
    }
    else
    {
        return player.getDigSpeed(state, pos) / hardness / 30F;
    }
}
项目:DecompiledMinecraft    文件:BlockTripWire.java   
private void notifyHook(World worldIn, BlockPos pos, IBlockState state)
{
    for (EnumFacing enumfacing : new EnumFacing[] {EnumFacing.SOUTH, EnumFacing.WEST})
    {
        for (int i = 1; i < 42; ++i)
        {
            BlockPos blockpos = pos.offset(enumfacing, i);
            IBlockState iblockstate = worldIn.getBlockState(blockpos);

            if (iblockstate.getBlock() == Blocks.tripwire_hook)
            {
                if (iblockstate.getValue(BlockTripWireHook.FACING) == enumfacing.getOpposite())
                {
                    Blocks.tripwire_hook.func_176260_a(worldIn, blockpos, iblockstate, false, true, i, state);
                }

                break;
            }

            if (iblockstate.getBlock() != Blocks.tripwire)
            {
                break;
            }
        }
    }
}
项目:ExPetrum    文件:BlockSnow.java   
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,  EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    ItemStack itm = playerIn.getHeldItemMainhand();
    if (!itm.isEmpty() && itm.getItem() instanceof ItemBlock && Block.getBlockFromItem(itm.getItem()) == this && state.getValue(LAYERS) < 8)
    {
        if (!playerIn.capabilities.isCreativeMode)
        {
            itm.shrink(1);
        }

        worldIn.setBlockState(pos, state.cycleProperty(LAYERS));
        return true;
    }

    return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
}
项目:BetterBeginningsReborn    文件:BlockCampfire.java   
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
    ItemStack heldItem = player.getHeldItem(hand);

    if (heldItem != ItemStack.EMPTY)
    {
        Item item = heldItem.getItem();

        if (item instanceof ItemFlintAndSteel || item instanceof ItemFireBow)
        {
            return false;
        }
    }

    player.openGui(ModMain.modInstance, BBGuiHandler.CAMPFIRE_ID, world, pos.getX(), pos.getY(), pos.getZ());

    return true;
}
项目:DecompiledMinecraft    文件:EntityEnderman.java   
public void updateTask()
{
    Random random = this.enderman.getRNG();
    World world = this.enderman.worldObj;
    int i = MathHelper.floor_double(this.enderman.posX - 2.0D + random.nextDouble() * 4.0D);
    int j = MathHelper.floor_double(this.enderman.posY + random.nextDouble() * 3.0D);
    int k = MathHelper.floor_double(this.enderman.posZ - 2.0D + random.nextDouble() * 4.0D);
    BlockPos blockpos = new BlockPos(i, j, k);
    IBlockState iblockstate = world.getBlockState(blockpos);
    Block block = iblockstate.getBlock();

    if (EntityEnderman.carriableBlocks.contains(block))
    {
        this.enderman.setHeldBlockState(iblockstate);
        world.setBlockState(blockpos, Blocks.air.getDefaultState());
    }
}
项目:CustomWorldGen    文件:BlockTorch.java   
/**
 * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
 * IBlockstate
 */
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
    if (this.canPlaceAt(worldIn, pos, facing))
    {
        return this.getDefaultState().withProperty(FACING, facing);
    }
    else
    {
        for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
        {
            if (worldIn.isSideSolid(pos.offset(enumfacing.getOpposite()), enumfacing, true))
            {
                return this.getDefaultState().withProperty(FACING, enumfacing);
            }
        }

        return this.getDefaultState();
    }
}
项目:BaseClient    文件:BlockRailBase.java   
private BlockRailBase.Rail findRailAt(BlockPos pos) {
    IBlockState iblockstate = this.world.getBlockState(pos);

    if (BlockRailBase.isRailBlock(iblockstate)) {
        return BlockRailBase.this.new Rail(this.world, pos, iblockstate);
    } else {
        BlockPos lvt_2_1_ = pos.up();
        iblockstate = this.world.getBlockState(lvt_2_1_);

        if (BlockRailBase.isRailBlock(iblockstate)) {
            return BlockRailBase.this.new Rail(this.world, lvt_2_1_, iblockstate);
        } else {
            lvt_2_1_ = pos.down();
            iblockstate = this.world.getBlockState(lvt_2_1_);
            return BlockRailBase.isRailBlock(iblockstate)
                    ? BlockRailBase.this.new Rail(this.world, lvt_2_1_, iblockstate) : null;
        }
    }
}
项目:CustomWorldGen    文件:BlockBanner.java   
@Nullable
private ItemStack getTileDataItemStack(World worldIn, BlockPos pos, IBlockState state)
{
    TileEntity tileentity = worldIn.getTileEntity(pos);

    if (tileentity instanceof TileEntityBanner)
    {
        ItemStack itemstack = new ItemStack(Items.BANNER, 1, ((TileEntityBanner)tileentity).getBaseColor());
        NBTTagCompound nbttagcompound = tileentity.writeToNBT(new NBTTagCompound());
        nbttagcompound.removeTag("x");
        nbttagcompound.removeTag("y");
        nbttagcompound.removeTag("z");
        nbttagcompound.removeTag("id");
        itemstack.setTagInfo("BlockEntityTag", nbttagcompound);
        return itemstack;
    }
    else
    {
        return null;
    }
}
项目:uniquecrops    文件:EntityLivingBlock.java   
@Override
public void onImpact(RayTraceResult result) {

    if (fallingTile == null) {
        this.setDead();
        return;
    }
    BlockPos pos = new BlockPos(result.hitVec);
    if (result.typeOfHit == RayTraceResult.Type.BLOCK) {
        IBlockState state = worldObj.getBlockState(pos);
        if (!(state.getBlock() instanceof BlockCrops)) {
            worldObj.setBlockState(pos.offset(result.sideHit), fallingTile, 3);
            this.setDead();
            return;
        }
    }
    else this.setDead();
}
项目:ModularMachinery    文件:ItemConstructTool.java   
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if(!worldIn.isRemote && player.isCreative() && worldIn.getMinecraftServer().getPlayerList().canSendCommands(player.getGameProfile())) {
        IBlockState clicked = worldIn.getBlockState(pos);
        Block block = clicked.getBlock();
        if(block.equals(BlocksMM.blockController)) {
            PlayerStructureSelectionHelper.finalizeSelection(clicked.getValue(BlockController.FACING), worldIn, pos, player);

            PlayerStructureSelectionHelper.purgeSelection(player);
            PlayerStructureSelectionHelper.sendSelection(player);
        } else {
            PlayerStructureSelectionHelper.toggleInSelection(player, pos);
            PlayerStructureSelectionHelper.sendSelection(player);
        }
    }
    return EnumActionResult.SUCCESS;
}
项目:ForgeHax    文件:Markers.java   
@Override
public void onBlockRenderInLoop(final RenderChunk renderChunk, final Block block, final IBlockState state, final BlockPos pos) {
    if(renderers != null) try {
        renderers.computeIfPresent(renderChunk, (chk, info) -> info.compute(() -> {
            GeometryTessellator tess = info.getTessellator();
            if (tess != null && FastReflection.Fields.BufferBuilder_isDrawing.get(tess.getBuffer(), false)) {
                BlockEntry blockEntry = options.get(state);
                if(blockEntry != null
                        && blockEntry.getReadableProperty(BoundProperty.class).isWithinBoundaries(pos.getY())) {
                    AxisAlignedBB bb = state.getSelectedBoundingBox(Helper.getWorld(), pos);
                    GeometryTessellator.drawLines(
                            tess.getBuffer(),
                            bb.minX, bb.minY, bb.minZ,
                            bb.maxX, bb.maxY, bb.maxZ,
                            GeometryMasks.Line.ALL,
                            blockEntry.getReadableProperty(ColorProperty.class).getAsBuffer()
                    );
                    info.incrementRenderCount();
                }
            }
        }));
    } catch (Exception e) {
        handleException(renderChunk, e);
    }
}
项目:BaseClient    文件:EntityLivingBase.java   
protected void updateFallState(double y, boolean onGroundIn, Block blockIn, BlockPos pos)
{
    if (!this.isInWater())
    {
        this.handleWaterMovement();
    }

    if (!this.worldObj.isRemote && this.fallDistance > 3.0F && onGroundIn)
    {
        IBlockState iblockstate = this.worldObj.getBlockState(pos);
        Block block = iblockstate.getBlock();
        float f = (float)MathHelper.ceiling_float_int(this.fallDistance - 3.0F);

        if (block.getMaterial() != Material.air)
        {
            double d0 = (double)Math.min(0.2F + f / 15.0F, 10.0F);

            if (d0 > 2.5D)
            {
                d0 = 2.5D;
            }

            int i = (int)(150.0D * d0);
            ((WorldServer)this.worldObj).spawnParticle(EnumParticleTypes.BLOCK_DUST, this.posX, this.posY, this.posZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, new int[] {Block.getStateId(iblockstate)});
        }
    }

    super.updateFallState(y, onGroundIn, blockIn, pos);
}
项目:ExPetrum    文件:BlockLog.java   
@Override
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list)
{
    for (int i = 0; i < 5; ++i)
    {
        IBlockState state = this.getDefaultState().withProperty(ExPBlockProperties.TREE_TYPE, EnumTreeType.values()[this.logIndex * 5 + i]);
        int meta = this.getMetaFromState(state);
        list.add(new ItemStack(this, 1, meta));
    }
}
项目:CustomWorldGen    文件:BlockFrostedIce.java   
/**
 * Called when a neighboring block was changed and marks that this state should perform any checks during a neighbor
 * change. Cases may include when redstone power is updated, cactus blocks popping off due to a neighboring solid
 * block, etc.
 */
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn)
{
    if (blockIn == this)
    {
        int i = this.countNeighbors(worldIn, pos);

        if (i < 2)
        {
            this.turnIntoWater(worldIn, pos);
        }
    }
}
项目:Thermionics    文件:ItemHammer.java   
@Override
public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState state, BlockPos pos, EntityLivingBase entityLiving) {
    if (!(entityLiving instanceof EntityPlayer)) return super.onBlockDestroyed(stack, world, state, pos, entityLiving);
    EntityPlayer player = (EntityPlayer)entityLiving;

       if (!world.isRemote && state.getBlockHardness(world, pos) != 0) {
           stack.damageItem(1, player);

           ArrayList<BlockPos> crushGroup = new ArrayList<>();

           //check and break anything nearby of equal or lower hardness
           for(int z=-1; z<=1; z++) {
            for(int y=-1; y<=1; y++) {
                for(int x=-1; x<=1; x++) {
                    if (x==0 && y==0 && z==0) continue;
                    BlockPos crushLocation = pos.add(x, y, z);
                    IBlockState toCrush = world.getBlockState(crushLocation);

                    if (toCrush.getBlockHardness(world, crushLocation) <= state.getBlockHardness(world, pos)) {
                        if (!BLACKLIST.contains(toCrush.getBlock())) {
                            crushGroup.add(crushLocation);
                            stack.damageItem(1, entityLiving);
                        }
                    }
                }
            }
           }

           for(BlockPos cur : crushGroup) {
            if (player instanceof EntityPlayerMP) { //Should be true any time we reach this part of the code
                ToolHelper.auxHarvestBlock(world, cur, (EntityPlayerMP)player);
            }
           }
       }

       return true;
   }
项目:CustomWorldGen    文件:BlockRedstoneTorch.java   
/**
 * Called after the block is set in the Chunk data, but before the Tile Entity is set
 */
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
    if (this.isOn)
    {
        for (EnumFacing enumfacing : EnumFacing.values())
        {
            worldIn.notifyNeighborsOfStateChange(pos.offset(enumfacing), this);
        }
    }
}
项目:Bewitchment    文件:BlockRagingGrass.java   
@SuppressWarnings("deprecation")
@Override
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean p_185477_7_) {
    if (entityIn instanceof EntityLivingBase && (((EntityLivingBase) entityIn).getCreatureAttribute() == EnumCreatureAttribute.ARTHROPOD)) {
        entityIn.attackEntityFrom(DamageSource.MAGIC, 4);
    }
    if (entityIn instanceof EntityLivingBase && (((EntityLivingBase) entityIn).getCreatureAttribute() == EnumCreatureAttribute.UNDEAD)) {
        entityIn.attackEntityFrom(DamageSource.MAGIC, 4);
    }
}
项目:Backmemed    文件:TileEntityEndGateway.java   
private static BlockPos findHighestBlock(World p_184308_0_, BlockPos p_184308_1_, int p_184308_2_, boolean p_184308_3_)
{
    BlockPos blockpos = null;

    for (int i = -p_184308_2_; i <= p_184308_2_; ++i)
    {
        for (int j = -p_184308_2_; j <= p_184308_2_; ++j)
        {
            if (i != 0 || j != 0 || p_184308_3_)
            {
                for (int k = 255; k > (blockpos == null ? 0 : blockpos.getY()); --k)
                {
                    BlockPos blockpos1 = new BlockPos(p_184308_1_.getX() + i, k, p_184308_1_.getZ() + j);
                    IBlockState iblockstate = p_184308_0_.getBlockState(blockpos1);

                    if (iblockstate.isBlockNormalCube() && (p_184308_3_ || iblockstate.getBlock() != Blocks.BEDROCK))
                    {
                        blockpos = blockpos1;
                        break;
                    }
                }
            }
        }
    }

    return blockpos == null ? p_184308_1_ : blockpos;
}
项目:HardVox    文件:OpLightUpdates.java   
private int immediateLightCheck(Region region, PositionIterator chunk, World world, Chunk c, MutableVectorMap<IBlockState> hitMap) {
    int yMax = region.getMaximum().getY();
    // reset precipitation map
    for (int i = 0; i < 16; i++) {
        for (int j = 0; j < 16; j++) {
            BlockPos pos = new BlockPos((c.x << 4) + i, yMax, (c.z << 4) + j);
            c.setBlockState(pos, c.getBlockState(pos));
        }
    }
    // consume iterator
    int ops = chunk.forEachRemaining((x, y, z) -> {
        if (!hitMap.get(x, y, z).isPresent()) {
            return 0;
        }
        int opsIn = 0;
        for (int i = -16; i <= 16; i++) {
            for (int j = -16; j <= 16; j++) {
                for (int k = -16; k <= 16; k++) {
                    opsIn += enlightenBlocks(x + i, y + j, z + k, world) ? 1 : 0;
                }
            }
        }
        return opsIn;
    });

    for (int i = -1; i <= 1; i++) {
        for (int j = -1; j <= 1; j++) {
            ops += relightSky(region, c, i, j) ? CHUNK_SIZE : 0;
        }
    }

    return CHUNK_SIZE + ops;
}
项目:harshencastle    文件:PontusEmeraldOre.java   
@Override
public boolean addHitEffects(IBlockState state, World worldObj, RayTraceResult target, ParticleManager manager) {
    if(world != null && pos != null)
    if (world instanceof WorldServer)
        ((WorldServer)world).spawnParticle(EnumParticleTypes.SMOKE_NORMAL, false, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 6,  0.5, 0.5, 0.6, 0, new int[EnumParticleTypes.SMOKE_NORMAL.getArgumentCount()]);
    return super.addHitEffects(state, worldObj, target, manager);
}
项目:BaseClient    文件:BlockPistonBase.java   
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
    if (!worldIn.isRemote && worldIn.getTileEntity(pos) == null)
    {
        this.checkForMove(worldIn, pos, state);
    }
}
项目:DecompiledMinecraft    文件:BlockPistonMoving.java   
/**
 * Called when a player destroys this Block
 */
public void onBlockDestroyedByPlayer(World worldIn, BlockPos pos, IBlockState state)
{
    BlockPos blockpos = pos.offset(((EnumFacing)state.getValue(FACING)).getOpposite());
    IBlockState iblockstate = worldIn.getBlockState(blockpos);

    if (iblockstate.getBlock() instanceof BlockPistonBase && ((Boolean)iblockstate.getValue(BlockPistonBase.EXTENDED)).booleanValue())
    {
        worldIn.setBlockToAir(blockpos);
    }
}
项目:CharcoalPit    文件:BlockPotteryKiln.java   
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
    if(state.getValue(TYPE)==EnumKilnTypes.EMPTY)
        return AABB_EMPTY;
    if(state.getValue(TYPE)==EnumKilnTypes.THATCH)
        return AABB_THATCH;
    return FULL_BLOCK_AABB;
}
项目:BaseClient    文件:BlockRedstoneComparator.java   
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (this.isRepeaterPowered)
    {
        worldIn.setBlockState(pos, this.getUnpoweredState(state).withProperty(POWERED, Boolean.valueOf(true)), 4);
    }

    this.onStateChange(worldIn, pos, state);
}
项目:BaseClient    文件:BlockRailDetector.java   
private void updatePoweredState(World worldIn, BlockPos pos, IBlockState state)
{
    boolean flag = ((Boolean)state.getValue(POWERED)).booleanValue();
    boolean flag1 = false;
    List<EntityMinecart> list = this.<EntityMinecart>findMinecarts(worldIn, pos, EntityMinecart.class, new Predicate[0]);

    if (!list.isEmpty())
    {
        flag1 = true;
    }

    if (flag1 && !flag)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(true)), 3);
        worldIn.notifyNeighborsOfStateChange(pos, this);
        worldIn.notifyNeighborsOfStateChange(pos.down(), this);
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
    }

    if (!flag1 && flag)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(false)), 3);
        worldIn.notifyNeighborsOfStateChange(pos, this);
        worldIn.notifyNeighborsOfStateChange(pos.down(), this);
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
    }

    if (flag1)
    {
        worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
    }

    worldIn.updateComparatorOutputLevel(pos, this);
}
项目:BaseClient    文件:BlockBeacon.java   
public static void updateColorAsync(final World worldIn, final BlockPos glassPos)
{
    HttpUtil.field_180193_a.submit(new Runnable()
    {
        public void run()
        {
            Chunk chunk = worldIn.getChunkFromBlockCoords(glassPos);

            for (int i = glassPos.getY() - 1; i >= 0; --i)
            {
                final BlockPos blockpos = new BlockPos(glassPos.getX(), i, glassPos.getZ());

                if (!chunk.canSeeSky(blockpos))
                {
                    break;
                }

                IBlockState iblockstate = worldIn.getBlockState(blockpos);

                if (iblockstate.getBlock() == Blocks.beacon)
                {
                    ((WorldServer)worldIn).addScheduledTask(new Runnable()
                    {
                        public void run()
                        {
                            TileEntity tileentity = worldIn.getTileEntity(blockpos);

                            if (tileentity instanceof TileEntityBeacon)
                            {
                                ((TileEntityBeacon)tileentity).updateBeacon();
                                worldIn.addBlockEvent(blockpos, Blocks.beacon, 1, 0);
                            }
                        }
                    });
                }
            }
        }
    });
}
项目:Got-Wood    文件:BlockBambooLog.java   
protected final void checkAndDropBlock(World world, BlockPos pos, IBlockState state) {
    boolean drop = world.getBlockState(pos.down()).getBlock() != this && !world.getBlockState(pos.down()).isNormalCube();
    if (drop && !world.isRemote) {
        world.destroyBlock(pos, true);
        breakBlock(world, pos, state);
    }
}
项目:Solar    文件:BlockQimranut.java   
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
    getTile(TileQimranut.class, world, pos).ifPresent(qimranut -> {
        ItemStack stack = getItem(world, pos, state);
        spawnAsEntity(world, pos, stack);
    });
    super.breakBlock(world, pos, state);
}
项目:CustomWorldGen    文件:StructureComponent.java   
protected IBlockState getBlockStateFromPos(World worldIn, int x, int y, int z, StructureBoundingBox boundingboxIn)
{
    int i = this.getXWithOffset(x, z);
    int j = this.getYWithOffset(y);
    int k = this.getZWithOffset(x, z);
    BlockPos blockpos = new BlockPos(i, j, k);
    return !boundingboxIn.isVecInside(blockpos) ? Blocks.AIR.getDefaultState() : worldIn.getBlockState(blockpos);
}
项目:BaseClient    文件:BlockFurnace.java   
private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state)
{
    if (!worldIn.isRemote)
    {
        Block block = worldIn.getBlockState(pos.north()).getBlock();
        Block block1 = worldIn.getBlockState(pos.south()).getBlock();
        Block block2 = worldIn.getBlockState(pos.west()).getBlock();
        Block block3 = worldIn.getBlockState(pos.east()).getBlock();
        EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);

        if (enumfacing == EnumFacing.NORTH && block.isFullBlock() && !block1.isFullBlock())
        {
            enumfacing = EnumFacing.SOUTH;
        }
        else if (enumfacing == EnumFacing.SOUTH && block1.isFullBlock() && !block.isFullBlock())
        {
            enumfacing = EnumFacing.NORTH;
        }
        else if (enumfacing == EnumFacing.WEST && block2.isFullBlock() && !block3.isFullBlock())
        {
            enumfacing = EnumFacing.EAST;
        }
        else if (enumfacing == EnumFacing.EAST && block3.isFullBlock() && !block2.isFullBlock())
        {
            enumfacing = EnumFacing.WEST;
        }

        worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
    }
}
项目:DecompiledMinecraft    文件:BlockStem.java   
public int getRenderColor(IBlockState state)
{
    if (state.getBlock() != this)
    {
        return super.getRenderColor(state);
    }
    else
    {
        int i = ((Integer)state.getValue(AGE)).intValue();
        int j = i * 32;
        int k = 255 - i * 8;
        int l = i * 4;
        return j << 16 | k << 8 | l;
    }
}
项目:BaseClient    文件:BlockNewLeaf.java   
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
    if (!worldIn.isRemote && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.shears)
    {
        player.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
        spawnAsEntity(worldIn, pos, new ItemStack(Item.getItemFromBlock(this), 1, ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata() - 4));
    }
    else
    {
        super.harvestBlock(worldIn, player, pos, state, te);
    }
}
项目:Bewitchment    文件:BlockRagingGrass.java   
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state) {
    if (state.getBlock() == this) {
        IBlockState soil = worldIn.getBlockState(pos.down());
        return soil.getBlock().canSustainPlant(soil, worldIn, pos.down(), net.minecraft.util.EnumFacing.UP, this);
    }
    return this.canSustainBush(worldIn.getBlockState(pos.down()));
}
项目:DecompiledMinecraft    文件:BlockVine.java   
private boolean recheckGrownSides(World worldIn, BlockPos pos, IBlockState state)
{
    IBlockState iblockstate = state;

    for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
    {
        PropertyBool propertybool = getPropertyFor(enumfacing);

        if (((Boolean)state.getValue(propertybool)).booleanValue() && !this.canPlaceOn(worldIn.getBlockState(pos.offset(enumfacing)).getBlock()))
        {
            IBlockState iblockstate1 = worldIn.getBlockState(pos.up());

            if (iblockstate1.getBlock() != this || !((Boolean)iblockstate1.getValue(propertybool)).booleanValue())
            {
                state = state.withProperty(propertybool, Boolean.valueOf(false));
            }
        }
    }

    if (getNumGrownFaces(state) == 0)
    {
        return false;
    }
    else
    {
        if (iblockstate != state)
        {
            worldIn.setBlockState(pos, state, 2);
        }

        return true;
    }
}
项目:Backmemed    文件:BlockDoublePlant.java   
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
    if (state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER)
    {
        return worldIn.getBlockState(pos.down()).getBlock() == this;
    }
    else
    {
        IBlockState iblockstate = worldIn.getBlockState(pos.up());
        return iblockstate.getBlock() == this && super.canBlockStay(worldIn, pos, iblockstate);
    }
}
项目:DecompiledMinecraft    文件:BlockRedstoneRepeater.java   
protected IBlockState getUnpoweredState(IBlockState poweredState)
{
    Integer integer = (Integer)poweredState.getValue(DELAY);
    Boolean obool = (Boolean)poweredState.getValue(LOCKED);
    EnumFacing enumfacing = (EnumFacing)poweredState.getValue(FACING);
    return Blocks.unpowered_repeater.getDefaultState().withProperty(FACING, enumfacing).withProperty(DELAY, integer).withProperty(LOCKED, obool);
}
项目:Backmemed    文件:BlockCommandBlock.java   
/**
 * Called by ItemBlocks after a block is set in the world, to allow post-place logic
 */
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
    TileEntity tileentity = worldIn.getTileEntity(pos);

    if (tileentity instanceof TileEntityCommandBlock)
    {
        TileEntityCommandBlock tileentitycommandblock = (TileEntityCommandBlock)tileentity;
        CommandBlockBaseLogic commandblockbaselogic = tileentitycommandblock.getCommandBlockLogic();

        if (stack.hasDisplayName())
        {
            commandblockbaselogic.setName(stack.getDisplayName());
        }

        if (!worldIn.isRemote)
        {
            NBTTagCompound nbttagcompound = stack.getTagCompound();

            if (nbttagcompound == null || !nbttagcompound.hasKey("BlockEntityTag", 10))
            {
                commandblockbaselogic.setTrackOutput(worldIn.getGameRules().getBoolean("sendCommandFeedback"));
                tileentitycommandblock.setAuto(this == Blocks.CHAIN_COMMAND_BLOCK);
            }

            if (tileentitycommandblock.getMode() == TileEntityCommandBlock.Mode.SEQUENCE)
            {
                boolean flag = worldIn.isBlockPowered(pos);
                tileentitycommandblock.setPowered(flag);
            }
        }
    }
}
项目:DecompiledMinecraft    文件:BlockTripWire.java   
/**
 * Convert the BlockState into the correct metadata value
 */
public int getMetaFromState(IBlockState state)
{
    int i = 0;

    if (((Boolean)state.getValue(POWERED)).booleanValue())
    {
        i |= 1;
    }

    if (((Boolean)state.getValue(SUSPENDED)).booleanValue())
    {
        i |= 2;
    }

    if (((Boolean)state.getValue(ATTACHED)).booleanValue())
    {
        i |= 4;
    }

    if (((Boolean)state.getValue(DISARMED)).booleanValue())
    {
        i |= 8;
    }

    return i;
}
项目:DecompiledMinecraft    文件:BlockTrapDoor.java   
/**
 * Called when a neighboring block changes.
 */
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
    if (!worldIn.isRemote)
    {
        BlockPos blockpos = pos.offset(((EnumFacing)state.getValue(FACING)).getOpposite());

        if (!isValidSupportBlock(worldIn.getBlockState(blockpos).getBlock()))
        {
            worldIn.setBlockToAir(pos);
            this.dropBlockAsItem(worldIn, pos, state, 0);
        }
        else
        {
            boolean flag = worldIn.isBlockPowered(pos);

            if (flag || neighborBlock.canProvidePower())
            {
                boolean flag1 = ((Boolean)state.getValue(OPEN)).booleanValue();

                if (flag1 != flag)
                {
                    worldIn.setBlockState(pos, state.withProperty(OPEN, Boolean.valueOf(flag)), 2);
                    worldIn.playAuxSFXAtEntity((EntityPlayer)null, flag ? 1003 : 1006, pos, 0);
                }
            }
        }
    }
}