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


Java Blocks.DIRT属性代码示例

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


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

示例1: doTest

private void doTest(boolean inOrder, boolean enoughDamage)
{
    DamageableShapelessOreRecipe recipe = new DamageableShapelessOreRecipe(new ResourceLocation("group"),
                                                                           new int[] {enoughDamage ? 5 : 5000, 0},
                                                                           new ItemStack(Blocks.DIRT), new ItemStack(Items.WOODEN_SWORD), new ItemStack(Items.APPLE));
    InventoryCrafting inv = new InventoryCrafting(new Container()
    {
        @Override
        public boolean canInteractWith(EntityPlayer playerIn)
        {
            return false;
        }
    }, 3, 3);
    inv.setInventorySlotContents(inOrder ? 3 : 4, new ItemStack(Items.WOODEN_SWORD));
    inv.setInventorySlotContents(inOrder ? 4 : 3, new ItemStack(Items.APPLE));

    assertSame(enoughDamage, recipe.matches(inv, null));

    if (enoughDamage)
    {
        NonNullList<ItemStack> remaining = recipe.getRemainingItems(inv);
        assertSame(Items.WOODEN_SWORD, remaining.get(inOrder ? 3 : 4).getItem());
        assertEquals(5, remaining.get(inOrder ? 3 : 4).getItemDamage());
    }
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:25,代码来源:DamageableShapelessOreRecipeTest.java

示例2: getDyeCraftingResult

private static ItemStack getDyeCraftingResult(int meta) {
	
	switch (meta) {
		default: return new ItemStack(Items.GHAST_TEAR);
		case 1: return new ItemStack(Items.FIRE_CHARGE, 8, 0);
		case 2: return new ItemStack(Items.DRAGON_BREATH);
		case 3: return new ItemStack(Items.DIAMOND);
		case 4: return new ItemStack(Items.GOLD_INGOT);
		case 5: return new ItemStack(Items.SLIME_BALL, 4, 0);
		case 6: return new ItemStack(Items.SADDLE);
		case 7: return new ItemStack(Blocks.CLAY, 8, 0);
		case 8: return new ItemStack(Items.IRON_INGOT, 2, 0);
		case 9: return new ItemStack(Blocks.STAINED_HARDENED_CLAY, 16, EnumDyeColor.CYAN.getMetadata());
		case 10: return new ItemStack(Items.CHORUS_FRUIT);
		case 11: return new ItemStack(Blocks.PRISMARINE, 8, 0);
		case 12: return new ItemStack(Blocks.DIRT, 3, 0);
		case 13: return new ItemStack(Items.EMERALD);
		case 14: return new ItemStack(Items.NETHER_WART);
		case 15: return new ItemStack(Items.SKULL, 1, 1);
	}
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:21,代码来源:UCRecipes.java

示例3: placePodzolAt

private void placePodzolAt(World worldIn, BlockPos pos)
{
    for (int i = 2; i >= -3; --i)
    {
        BlockPos blockpos = pos.up(i);
        IBlockState iblockstate = worldIn.getBlockState(blockpos);
        Block block = iblockstate.getBlock();

        if (block == Blocks.GRASS || block == Blocks.DIRT)
        {
            this.setBlockAndNotifyAdequately(worldIn, blockpos, PODZOL);
            break;
        }

        if (iblockstate.getMaterial() != Material.AIR && i < 0)
        {
            break;
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:20,代码来源:WorldGenMegaPineTree.java

示例4: ensureDirtsUnderneath

/**
 * returns whether or not there is dirt underneath the block where the tree will be grown.
 * It also generates dirt around the block in a 2x2 square if there is dirt underneath the blockpos.
 */
private boolean ensureDirtsUnderneath(BlockPos pos, World worldIn)
{
    BlockPos blockpos = pos.down();
    Block block = worldIn.getBlockState(blockpos).getBlock();

    if ((block == Blocks.GRASS || block == Blocks.DIRT) && pos.getY() >= 2)
    {
        this.setDirtAt(worldIn, blockpos);
        this.setDirtAt(worldIn, blockpos.east());
        this.setDirtAt(worldIn, blockpos.south());
        this.setDirtAt(worldIn, blockpos.south().east());
        return true;
    }
    else
    {
        return false;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:22,代码来源:WorldGenHugeTrees.java

示例5: matches

@Override
public boolean matches(World world, BlockPos pos) {
    IBlockState state = world.getBlockState(pos);
    Block block = state.getBlock();

    switch (this.plantType) {
        case Desert:
            return block == Blocks.SAND || block == Blocks.HARDENED_CLAY || block == Blocks.STAINED_HARDENED_CLAY || block == Blocks.DIRT;
        case Nether:
            return block == Blocks.SOUL_SAND;
        case Crop:
            return block == Blocks.FARMLAND;
        case Cave:
            return block.isSideSolid(state, world, pos, EnumFacing.UP);
        case Plains:
            return block == Blocks.GRASS || block == Blocks.DIRT || block == Blocks.FARMLAND || block == Blocks.MYCELIUM;
        case Water:
            return state.getMaterial() == Material.WATER && state.getValue(BlockLiquid.LEVEL) == 0;
        case Beach:
            boolean isBeach = block == Blocks.GRASS || block == Blocks.DIRT || block == Blocks.SAND || block == Blocks.MYCELIUM;
            boolean hasWater = (world.getBlockState(pos.east()).getMaterial() == Material.WATER ||
                world.getBlockState(pos.west()).getMaterial() == Material.WATER ||
                world.getBlockState(pos.north()).getMaterial() == Material.WATER ||
                world.getBlockState(pos.south()).getMaterial() == Material.WATER);
            return isBeach && hasWater;
        default:
            return false;
    }
}
 
开发者ID:LasmGratel,项目名称:FoodCraft-Reloaded,代码行数:29,代码来源:BlockQuery.java

示例6: tryAndSpawn

private void tryAndSpawn(World w, MutableBlockPos p) {
	int oy = p.getY();
	for (int dy = -5; dy <= 5; dy++) {
		p.setY(oy + dy);
		if ((w.isAirBlock(p) || w.getBlockState(p).getBlock().isReplaceable(w, p)) && w.getBlockState(p.down()).getBlock() == Blocks.DIRT) {
			w.setBlockState(p, this.getDefaultState().withProperty(placed, false), 3);
			return;
		}
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:10,代码来源:BlockMoonbell.java

示例7: updateTick

public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    super.updateTick(worldIn, pos, state, rand);

    if (worldIn.getLightFromNeighbors(pos.up()) >= 9)
    {
        float f = BlockCrops.getGrowthChance(this, worldIn, pos);

        if(net.minecraftforge.common.ForgeHooks.onCropsGrowPre(worldIn, pos, state, rand.nextInt((int)(25.0F / f) + 1) == 0))
        {
            int i = ((Integer)state.getValue(AGE)).intValue();

            if (i < 7)
            {
                state = state.withProperty(AGE, Integer.valueOf(i + 1));
                worldIn.setBlockState(pos, state, 2);
            }
            else
            {
                for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
                {
                    if (worldIn.getBlockState(pos.offset(enumfacing)).getBlock() == this.crop)
                    {
                        return;
                    }
                }

                pos = pos.offset(EnumFacing.Plane.HORIZONTAL.random(rand));
                IBlockState soil = worldIn.getBlockState(pos.down());
                Block block = soil.getBlock();

                if (worldIn.isAirBlock(pos) && (block.canSustainPlant(soil, worldIn, pos.down(), EnumFacing.UP, this) || block == Blocks.DIRT || block == Blocks.GRASS))
                {
                    worldIn.setBlockState(pos, this.crop.getDefaultState());
                }
            }
            net.minecraftforge.common.ForgeHooks.onCropsGrowPost(worldIn, pos, state, worldIn.getBlockState(pos));
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:40,代码来源:BlockStem.java

示例8: updateTick

public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (!worldIn.isRemote)
    {
        if (worldIn.getLightFromNeighbors(pos.up()) < 4 && worldIn.getBlockState(pos.up()).getLightOpacity() > 2)
        {
            worldIn.setBlockState(pos, Blocks.DIRT.getDefaultState());
        }
        else
        {
            if (worldIn.getLightFromNeighbors(pos.up()) >= 9)
            {
                for (int i = 0; i < 4; ++i)
                {
                    BlockPos blockpos = pos.add(rand.nextInt(3) - 1, rand.nextInt(5) - 3, rand.nextInt(3) - 1);

                    if (blockpos.getY() >= 0 && blockpos.getY() < 256 && !worldIn.isBlockLoaded(blockpos))
                    {
                        return;
                    }

                    IBlockState iblockstate = worldIn.getBlockState(blockpos.up());
                    IBlockState iblockstate1 = worldIn.getBlockState(blockpos);

                    if (iblockstate1.getBlock() == Blocks.DIRT && iblockstate1.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT && worldIn.getLightFromNeighbors(blockpos.up()) >= 4 && iblockstate.getLightOpacity() <= 2)
                    {
                        worldIn.setBlockState(blockpos, Blocks.GRASS.getDefaultState());
                    }
                }
            }
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:33,代码来源:BlockGrass.java

示例9: setDirtAt

/**
 * sets dirt at a specific location if it isn't already dirt
 */
protected void setDirtAt(World worldIn, BlockPos pos)
{
    if (worldIn.getBlockState(pos).getBlock() != Blocks.DIRT)
    {
        this.setBlockAndNotifyAdequately(worldIn, pos, Blocks.DIRT.getDefaultState());
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:10,代码来源:WorldGenAbstractTree.java

示例10: canBlockStay

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.canSustainBush(iblockstate));
    }
    else
    {
        return false;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:12,代码来源:BlockMushroom.java

示例11: updateTick

@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (!worldIn.isRemote)
    {
        if (worldIn.getLightFromNeighbors(pos.up()) < 4 && worldIn.getBlockState(pos.up()).getLightOpacity(worldIn, pos.up()) > 2)
        {
            worldIn.setBlockState(pos, Blocks.DIRT.getDefaultState());
        }
        else
        {
            if (worldIn.getLightFromNeighbors(pos.up()) >= 9)
            {
                for (int i = 0; i < 4; ++i)
                {
                    BlockPos blockpos = pos.add(rand.nextInt(3) - 1, rand.nextInt(5) - 3, rand.nextInt(3) - 1);

                    if (blockpos.getY() >= 0 && blockpos.getY() < 256 && !worldIn.isBlockLoaded(blockpos))
                    {
                        return;
                    }

                    IBlockState iblockstate = worldIn.getBlockState(blockpos.up());
                    IBlockState iblockstate1 = worldIn.getBlockState(blockpos);

                    if (iblockstate1.getBlock() == Blocks.DIRT && iblockstate1.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT && worldIn.getLightFromNeighbors(blockpos.up()) >= 4 && iblockstate.getLightOpacity(worldIn, pos.up()) <= 2)
                    {
                        worldIn.setBlockState(blockpos, UCBlocks.oldGrass.getDefaultState());
                    }
                }
            }
        }
    }
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:34,代码来源:BlockOldGrass.java

示例12: onLivingUpdate

@Override
public void onLivingUpdate() {
    super.onLivingUpdate();
    //Block stuff
    List<Block> listBlocks = ImmutableList.copyOf(Block.REGISTRY);
    int blockListSize = listBlocks.size();
    int randomBlockInt = rand.nextInt(blockListSize);
    Block block = Block.getBlockById(randomBlockInt);
    Item itemBlock = Item.getItemFromBlock(block);



    if(!this.world.isRemote && timeToDiamond == 0 || timeToDiamond == -1){
        //I am creating a list of blocks I do not want the pig to drop from registy.
        List<Item> blockedItems = new ArrayList<>();
        blockedItems.add(Items.AIR);

        if(!listBlocks.isEmpty()){
            block = listBlocks.get(randomBlockInt);
        }else if(blockedItems.contains(itemBlock)){
            block = Blocks.DIRT;
        }

        this.playSound(SoundEvents.ENTITY_CHICKEN_EGG, 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
        this.dropItem(itemBlock, 1);
        this.timeToDiamond = this.rand.nextInt(6000) + 6000;
    }

    if(!world.isRemote && timeToDiamond > 0){
        timeToDiamond--;
        //System.out.println("BACON Time set to:" + timeToDiamond);
        //System.out.println(itemBlock);
    }
}
 
开发者ID:OCDiary,项目名称:TheOink,代码行数:34,代码来源:OinkBacon.java

示例13: getGroundFromAbove

private int getGroundFromAbove(World world, int x, int z)
{
    int y = 255;
    boolean foundGround = false;
    while(!foundGround && y-- >= 63)
    {
        Block blockAt = world.getBlockState(new BlockPos(x,y,z)).getBlock();
        foundGround = blockAt == Blocks.DIRT || blockAt == Blocks.GRASS || blockAt == Blocks.SAND || blockAt == Blocks.SNOW || blockAt == Blocks.SNOW_LAYER || blockAt == Blocks.STONE;
    }

    return y;
}
 
开发者ID:OCDiary,项目名称:TheOink,代码行数:12,代码来源:OinkWorldGenerator.java

示例14: canSustainBush

/**
 * Return true if the block can sustain a Bush
 */
protected boolean canSustainBush(IBlockState state)
{
    return state.getBlock() == Blocks.GRASS || state.getBlock() == Blocks.DIRT || state.getBlock() == Blocks.FARMLAND;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:7,代码来源:BlockBush.java

示例15: getFaceQuadsDirt

private static List getFaceQuadsDirt(IBlockAccess p_getFaceQuadsDirt_0_, IBlockState p_getFaceQuadsDirt_1_, BlockPos p_getFaceQuadsDirt_2_, EnumFacing p_getFaceQuadsDirt_3_, List p_getFaceQuadsDirt_4_)
{
    Block block = getBlockAt(p_getFaceQuadsDirt_2_, EnumFacing.UP, p_getFaceQuadsDirt_0_);

    if (p_getFaceQuadsDirt_1_.getValue(BlockDirt.VARIANT) != BlockDirt.DirtType.PODZOL)
    {
        return block == Blocks.GRASS_PATH ? (betterGrassPath && getBlockAt(p_getFaceQuadsDirt_2_, p_getFaceQuadsDirt_3_, p_getFaceQuadsDirt_0_) == Blocks.GRASS_PATH ? modelCubeGrassPath.getQuads(p_getFaceQuadsDirt_1_, p_getFaceQuadsDirt_3_, 0L) : p_getFaceQuadsDirt_4_) : p_getFaceQuadsDirt_4_;
    }
    else
    {
        boolean flag = block == Blocks.SNOW || block == Blocks.SNOW_LAYER;

        if (Config.isBetterGrassFancy())
        {
            if (flag)
            {
                if (betterPodzolSnow && getBlockAt(p_getFaceQuadsDirt_2_, p_getFaceQuadsDirt_3_, p_getFaceQuadsDirt_0_) == Blocks.SNOW_LAYER)
                {
                    return modelCubeSnow.getQuads(p_getFaceQuadsDirt_1_, p_getFaceQuadsDirt_3_, 0L);
                }
            }
            else if (betterPodzol)
            {
                BlockPos blockpos = p_getFaceQuadsDirt_2_.down().offset(p_getFaceQuadsDirt_3_);
                IBlockState iblockstate = p_getFaceQuadsDirt_0_.getBlockState(blockpos);

                if (iblockstate.getBlock() == Blocks.DIRT && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.PODZOL)
                {
                    return modelCubePodzol.getQuads(p_getFaceQuadsDirt_1_, p_getFaceQuadsDirt_3_, 0L);
                }
            }
        }
        else if (flag)
        {
            if (betterPodzolSnow)
            {
                return modelCubeSnow.getQuads(p_getFaceQuadsDirt_1_, p_getFaceQuadsDirt_3_, 0L);
            }
        }
        else if (betterPodzol)
        {
            return modelCubePodzol.getQuads(p_getFaceQuadsDirt_1_, p_getFaceQuadsDirt_3_, 0L);
        }

        return p_getFaceQuadsDirt_4_;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:47,代码来源:BetterGrass.java


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