当前位置: 首页>>代码示例>>Java>>正文


Java IBlockState类代码示例

本文整理汇总了Java中net.minecraft.block.state.IBlockState的典型用法代码示例。如果您正苦于以下问题:Java IBlockState类的具体用法?Java IBlockState怎么用?Java IBlockState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IBlockState类属于net.minecraft.block.state包,在下文中一共展示了IBlockState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onBlockActivated

import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
@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;
}
 
开发者ID:the-realest-stu,项目名称:Infernum,代码行数:27,代码来源:BlockPedestal.java

示例2: blockStrength

import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
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;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:18,代码来源:ForgeHooks.java

示例3: notifyHook

import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
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;
            }
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:27,代码来源:BlockTripWire.java

示例4: onBlockActivated

import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
@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);
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:18,代码来源:BlockSnow.java

示例5: onBlockActivated

import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
@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;
}
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:20,代码来源:BlockCampfire.java

示例6: updateTask

import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
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());
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:18,代码来源:EntityEnderman.java

示例7: onBlockPlaced

import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
/**
 * 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();
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:24,代码来源:BlockTorch.java

示例8: findRailAt

import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
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;
		}
	}
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:20,代码来源:BlockRailBase.java

示例9: getTileDataItemStack

import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
@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;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:22,代码来源:BlockBanner.java

示例10: onImpact

import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
@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();
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:19,代码来源:EntityLivingBlock.java

示例11: onItemUse

import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
@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;
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:18,代码来源:ItemConstructTool.java

示例12: onBlockRenderInLoop

import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:26,代码来源:Markers.java

示例13: updateFallState

import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
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);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:30,代码来源:EntityLivingBase.java

示例14: getSubBlocks

import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
@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));
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:11,代码来源:BlockLog.java

示例15: neighborChanged

import net.minecraft.block.state.IBlockState; //导入依赖的package包/类
/**
 * 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);
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:18,代码来源:BlockFrostedIce.java


注:本文中的net.minecraft.block.state.IBlockState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。