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


Java IBlockState.getBlock方法代码示例

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


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

示例1: canPlaceBlockOnSide

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack)
{
    BlockPos blockpos = pos;
    IProperty iproperty = this.singleSlab.getVariantProperty();
    Object object = this.singleSlab.getVariant(stack);
    IBlockState iblockstate = worldIn.getBlockState(pos);

    if (iblockstate.getBlock() == this.singleSlab)
    {
        boolean flag = iblockstate.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP;

        if ((side == EnumFacing.UP && !flag || side == EnumFacing.DOWN && flag) && object == iblockstate.getValue(iproperty))
        {
            return true;
        }
    }

    pos = pos.offset(side);
    IBlockState iblockstate1 = worldIn.getBlockState(pos);
    return iblockstate1.getBlock() == this.singleSlab && object == iblockstate1.getValue(iproperty) ? true : super.canPlaceBlockOnSide(worldIn, blockpos, side, player, stack);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:22,代码来源:ItemSlab.java

示例2: toggleDoor

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public void toggleDoor(World worldIn, BlockPos pos, boolean open)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);

    if (iblockstate.getBlock() == this)
    {
        BlockPos blockpos = iblockstate.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER ? pos : pos.down();
        IBlockState iblockstate1 = pos == blockpos ? iblockstate : worldIn.getBlockState(blockpos);

        if (iblockstate1.getBlock() == this && ((Boolean)iblockstate1.getValue(OPEN)).booleanValue() != open)
        {
            worldIn.setBlockState(blockpos, iblockstate1.withProperty(OPEN, Boolean.valueOf(open)), 2);
            worldIn.markBlockRangeForRenderUpdate(blockpos, pos);
            worldIn.playAuxSFXAtEntity((EntityPlayer)null, open ? 1003 : 1006, pos, 0);
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:18,代码来源:BlockDoor.java

示例3: onBlockActivated

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (this.blockMaterial == Material.iron)
    {
        return true;
    }
    else
    {
        BlockPos blockpos = state.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER ? pos : pos.down();
        IBlockState iblockstate = pos.equals(blockpos) ? state : worldIn.getBlockState(blockpos);

        if (iblockstate.getBlock() != this)
        {
            return false;
        }
        else
        {
            state = iblockstate.cycleProperty(OPEN);
            worldIn.setBlockState(blockpos, state, 2);
            worldIn.markBlockRangeForRenderUpdate(blockpos, pos);
            worldIn.playAuxSFXAtEntity(playerIn, ((Boolean)state.getValue(OPEN)).booleanValue() ? 1003 : 1006, pos, 0);
            return true;
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:26,代码来源:BlockDoor.java

示例4: isConnectedTo

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public static boolean isConnectedTo(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing direction)
{
    BlockPos blockpos = pos.offset(direction);
    IBlockState iblockstate = worldIn.getBlockState(blockpos);
    Block block = iblockstate.getBlock();

    if (block == Blocks.tripwire_hook)
    {
        EnumFacing enumfacing = direction.getOpposite();
        return iblockstate.getValue(BlockTripWireHook.FACING) == enumfacing;
    }
    else if (block == Blocks.tripwire)
    {
        boolean flag = ((Boolean)state.getValue(SUSPENDED)).booleanValue();
        boolean flag1 = ((Boolean)iblockstate.getValue(SUSPENDED)).booleanValue();
        return flag == flag1;
    }
    else
    {
        return false;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:23,代码来源:BlockTripWire.java

示例5: 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

示例6: renderTileEntityAt

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
@Override
public void renderTileEntityAt(@Nonnull TileArtisia te, double x, double y, double z, float partialTicks, int digProgress) {
	
	IBlockState state = te.getWorld().getBlockState(te.getPos());
	if (state != null && state.getBlock() == UCBlocks.cropArtisia) {
		ItemStack stack = te.getItem();
		if (stack != null) {
			GlStateManager.pushMatrix();
			GlStateManager.translate((float)x + 0.5F, (float)y + 1.25F, (float)z + 0.5F);
			renderItem(stack);
			GlStateManager.popMatrix();
		}
	}
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:15,代码来源:RenderCraftItem.java

示例7: isReplaceable

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
/**
 * Whether this Block can be replaced directly by other blocks (true for e.g. tall grass)
 */
public boolean isReplaceable(IBlockAccess worldIn, BlockPos pos)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);

    if (iblockstate.getBlock() != this)
    {
        return true;
    }
    else
    {
        BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = (BlockDoublePlant.EnumPlantType)iblockstate.getActualState(worldIn, pos).getValue(VARIANT);
        return blockdoubleplant$enumplanttype == BlockDoublePlant.EnumPlantType.FERN || blockdoubleplant$enumplanttype == BlockDoublePlant.EnumPlantType.GRASS;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:18,代码来源:BlockDoublePlant.java

示例8: onBlockDestroyedByPlayer

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

示例9: onRightClick

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
@SubscribeEvent
public void onRightClick(PlayerInteractEvent.RightClickBlock event)
{
	if (!event.getWorld().isRemote)
	{
		EntityPlayer player = event.getEntityPlayer();
		IExPPlayer data = IExPPlayer.of(player);
		if (data.getThirst() < data.getMaxThirst(true) - 200)
		{
			RayTraceResult rtr = event.getWorld().rayTraceBlocks(player.getPositionEyes(1), player.getPositionEyes(1).add(player.getLook(1).scale(3)), true, false, false);
			if (rtr != null && rtr.typeOfHit == Type.BLOCK)
			{
				BlockPos pos = rtr.getBlockPos();
				IBlockState hit = event.getWorld().getBlockState(pos);
				if (hit.getBlock() instanceof IWater && !((IWater)hit.getBlock()).isSalt(event.getWorld(), pos))
				{
					int level = hit.getValue(BlockFluidBase.LEVEL);
					if (level > 0)
					{
						event.getWorld().setBlockState(pos, hit.withProperty(BlockFluidBase.LEVEL, level - 1));
					}
					else
					{
						event.getWorld().setBlockToAir(pos);
					}
					
					data.setThirst(data.getThirst() + 200, true);
					event.getWorld().playSound(null, pos, SoundEvents.ENTITY_GENERIC_DRINK, SoundCategory.PLAYERS, 1, 1);
				}
			}
		}
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:34,代码来源:ExPHandlerServer.java

示例10: canBlockStay

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

示例11: setBlockBoundsBasedOnState

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);

    if (iblockstate.getBlock() == this)
    {
        float f = 0.125F;

        switch ((EnumFacing)iblockstate.getValue(FACING))
        {
            case NORTH:
                this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
                break;

            case SOUTH:
                this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
                break;

            case WEST:
                this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
                break;

            case EAST:
            default:
                this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:29,代码来源:BlockLadder.java

示例12: getDataBlocks

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public Map<BlockPos, String> getDataBlocks(BlockPos pos, PlacementSettings placementIn)
{
    Map<BlockPos, String> map = Maps.<BlockPos, String>newHashMap();
    StructureBoundingBox structureboundingbox = placementIn.getBoundingBox();

    for (Template.BlockInfo template$blockinfo : this.blocks)
    {
        BlockPos blockpos = transformedBlockPos(placementIn, template$blockinfo.pos).add(pos);

        if (structureboundingbox == null || structureboundingbox.isVecInside(blockpos))
        {
            IBlockState iblockstate = template$blockinfo.blockState;

            if (iblockstate.getBlock() == Blocks.STRUCTURE_BLOCK && template$blockinfo.tileentityData != null)
            {
                TileEntityStructure.Mode tileentitystructure$mode = TileEntityStructure.Mode.valueOf(template$blockinfo.tileentityData.getString("mode"));

                if (tileentitystructure$mode == TileEntityStructure.Mode.DATA)
                {
                    map.put(blockpos, template$blockinfo.tileentityData.getString("metadata"));
                }
            }
        }
    }

    return map;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:28,代码来源:Template.java

示例13: canBlockStay

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
    if (pos.getY() >= 0 && pos.getY() < 256)
    {
        IBlockState iblockstate = worldIn.getBlockState(pos.down());
        return iblockstate.getBlock() == Blocks.mycelium ? true : (iblockstate.getBlock() == Blocks.dirt && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.PODZOL ? true : worldIn.getLight(pos) < 13 && this.canPlaceBlockOn(iblockstate.getBlock()));
    }
    else
    {
        return false;
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:13,代码来源:BlockMushroom.java

示例14: showBarrierParticles

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public void showBarrierParticles(int p_184153_1_, int p_184153_2_, int p_184153_3_, int p_184153_4_, Random random, boolean p_184153_6_, BlockPos.MutableBlockPos pos)
{
    int i = p_184153_1_ + this.rand.nextInt(p_184153_4_) - this.rand.nextInt(p_184153_4_);
    int j = p_184153_2_ + this.rand.nextInt(p_184153_4_) - this.rand.nextInt(p_184153_4_);
    int k = p_184153_3_ + this.rand.nextInt(p_184153_4_) - this.rand.nextInt(p_184153_4_);
    pos.setPos(i, j, k);
    IBlockState iblockstate = this.getBlockState(pos);
    iblockstate.getBlock().randomDisplayTick(iblockstate, this, pos, random);

    if (p_184153_6_ && iblockstate.getBlock() == Blocks.BARRIER)
    {
        this.spawnParticle(EnumParticleTypes.BARRIER, (double)((float)i + 0.5F), (double)((float)j + 0.5F), (double)((float)k + 0.5F), 0.0D, 0.0D, 0.0D, new int[0]);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:15,代码来源:WorldClient.java

示例15: damageBlock

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public static float damageBlock(BlockPos pos, EntityLivingBase living, World world, float damage) {
	IBlockState state = world.getBlockState(pos);
	Block block = state.getBlock();
	if (block.isAir(state, world, pos) || state.getMaterial() == Material.WATER || state.getMaterial() == Material.LAVA || state.getBlockHardness(world, pos) < 0)
		return damage;

	DestroyBlockEntry finalEntry = null;
	int entryId = 0;
	int emptyId = -1;
	for (int i = 0; i < BlockEventBus.destroyProgress.size(); i++) {
		DestroyBlockEntry entry = BlockEventBus.destroyProgress.get(i);
		if (emptyId == -1 && entry == null)
			emptyId = i;
		if (entry != null && entry.world == world && entry.pos.equals(pos)) {
			finalEntry = entry;
			entryId = i;
			break;
		}
	}
	if (finalEntry == null) {
		finalEntry = new DestroyBlockEntry(pos, world);
		if (emptyId != -1) {
			 BlockEventBus.destroyProgress.set(emptyId, finalEntry);
			entryId = emptyId;
		} else {
			 BlockEventBus.destroyProgress.add(finalEntry);
			entryId =  BlockEventBus.destroyProgress.size() - 1;
		}

	}

	/*if (block instanceof BlockChest) {
		((TileEntityChest) world.getTileEntity(pos)).setLootTable(LootTableList.CHESTS_NETHER_BRIDGE, living.getRNG().nextLong());
	}*/
	float hardness = BlockLauncher.getHardness(state, world);

	finalEntry.curDamage += damage;

	if (living != null)
		world.sendBlockBreakProgress(Math.min(Integer.MAX_VALUE, 0xFFFF + entryId), pos, (int) ((finalEntry.curDamage / hardness) * 10));

	if (finalEntry.curDamage >= hardness) {
		if (living != null && living instanceof EntityPlayer)
			block.harvestBlock(world, (EntityPlayer) living, pos, state, null, ItemStack.EMPTY);
		else {
			block.dropBlockAsItem(world, pos, state, 0);
		}
		BlockEventBus.destroyProgress.remove(finalEntry);

		boolean flag = (living == null || !(living instanceof EntityPlayer) && world.isAirBlock(pos)) || block.removedByPlayer(state, world, pos, (EntityPlayer) living, true);

		if (flag) {
			if (living != null) {
				world.playEvent(2001, pos, Block.getStateId(state));
				world.sendBlockBreakProgress(Math.min(Integer.MAX_VALUE, 0xFFFF + entryId), pos, -1);
			}
			block.onBlockDestroyedByPlayer(world, pos, state);

		}
		return finalEntry.curDamage - hardness;
	}
	return 0;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:64,代码来源:BlockLauncher.java


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