當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。