本文整理匯總了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());
}
}
示例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);
}
}
示例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;
}
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
}
示例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));
}
}
}
示例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());
}
}
}
}
}
}
示例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());
}
}
示例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;
}
}
示例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());
}
}
}
}
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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_;
}
}