Java Code Examples for net.minecraft.init.Blocks#DIRT
The following examples show how to use
net.minecraft.init.Blocks#DIRT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DamageableShapelessOreRecipeTest.java From customstuff4 with GNU General Public License v3.0 | 6 votes |
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()); } }
Example 2
Source File: DamageableShapedOreRecipeTest.java From customstuff4 with GNU General Public License v3.0 | 6 votes |
@Test public void test_useUpItem() { ShapedOreRecipe recipe = new DamageableShapedOreRecipe(new ResourceLocation("group"), new int[] {60}, new ItemStack(Blocks.DIRT), "A", 'A', new ItemStack(Items.WOODEN_SWORD)); InventoryCrafting inv = new InventoryCrafting(new Container() { @Override public boolean canInteractWith(EntityPlayer playerIn) { return false; } }, 3, 3); inv.setInventorySlotContents(0, new ItemStack(Items.WOODEN_SWORD)); assertTrue(recipe.matches(inv, null)); NonNullList<ItemStack> remaining = recipe.getRemainingItems(inv); assertTrue(remaining.get(0).isEmpty()); }
Example 3
Source File: CropHandler.java From BetterChests with GNU Lesser General Public License v3.0 | 6 votes |
static boolean makeFarmland(World world, BlockPos pos, IBetterChest chest, boolean simulate) { BlockPos below = pos.down(); IBlockState blockBelow = world.getBlockState(below); boolean farmland = false; if (blockBelow.getBlock() == Blocks.DIRT || blockBelow.getBlock() == Blocks.GRASS) { int hoe = InvUtil.findInInvInternal(chest, null, test -> test.getItem() instanceof ItemHoe); if (hoe != -1) { farmland = true; if (!simulate) { ItemStack tool = chest.getStackInSlot(hoe); tool.attemptDamageItem(1, world.rand, null); if (tool.getItemDamage() > tool.getMaxDamage()) { tool.setItemDamage(0); tool.setCount(tool.getCount() - 1); } world.setBlockState(below, Blocks.FARMLAND.getDefaultState()); } } } return farmland; }
Example 4
Source File: MapGenTofuCaves.java From TofuCraftReload with MIT License | 6 votes |
protected boolean canReplaceBlock(IBlockState p_175793_1_, IBlockState p_175793_2_) { if (p_175793_1_.getBlock() == Blocks.STONE) { return true; } else if (p_175793_1_.getBlock() == Blocks.DIRT) { return true; } else if (p_175793_1_.getBlock() == Blocks.GRASS) { return true; } else if (p_175793_1_.getBlock() == Blocks.HARDENED_CLAY) { return true; } else if (p_175793_1_.getBlock() == Blocks.STAINED_HARDENED_CLAY) { return true; } else if (p_175793_1_.getBlock() == Blocks.SANDSTONE) { return true; } else if (p_175793_1_.getBlock() == Blocks.RED_SANDSTONE) { return true; } else if (p_175793_1_.getBlock() == Blocks.MYCELIUM) { return true; } else if (p_175793_1_.getBlock() == Blocks.SNOW_LAYER) { return true; } else { return (/*p_175793_1_.getBlock() == TcBlocks.tofuMinced || */p_175793_1_.getBlock() == Blocks.GRAVEL) && p_175793_2_.getMaterial() != Material.WATER; } }
Example 5
Source File: StatTreasureFinder.java From GokiStats with MIT License | 5 votes |
public List<ItemStack> getApplicableItemStackList(Block block, int blockMD, int level) { List<ItemStack> items = new ArrayList<>(); for (TreasureFinderEntry tfe : entries) { if (tfe.minimumLevel <= level) { if (((tfe.getBlock() == null) && ((block == Blocks.DIRT) || (block == Blocks.GRASS))) || ((tfe.getBlock() == block) && (tfe.blockMetadata == blockMD))) { items.add(new ItemStack(tfe.getItem(), 1, tfe.itemMetadata)); } } } return items; }
Example 6
Source File: TileEntityGnomeCache.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
protected void processBlueprintLoc(BlockPosAndBlock loc, Block oldblock) { Block normalblock = oldblock; // normalize blocks if (normalblock == Blocks.GRASS) { normalblock = Blocks.DIRT; } if (normalblock != loc.block) { // block mismatch if (isBlockUnsafe(normalblock)) { // avoid conflicts with nearby hovels by selfdestructing this.selfDestruct(); } else if (MobbableBlock.isSoftBlock(oldblock, this.world)) { if (loc.block == Blocks.AIR) // if old block is diggable and new block is air, destroy { this.assignmentQueue.add(new GnomeAssignment(loc, oldblock, EnumAssignType.DESTROY)); } else // if old block is diggable and new block is solid, alter { this.assignmentQueue.add(new GnomeAssignment(loc, oldblock, EnumAssignType.ALTER)); } } else if (WorldHelper.isAirLikeBlock(this.world, loc.pos)) { // if old block is air-like, create this.assignmentQueue.add(new GnomeAssignment(loc, oldblock, EnumAssignType.CREATE)); } } else { // no mismatch this.blueprint.add(loc); } }
Example 7
Source File: EntityGnomeWood.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void onLivingUpdate() { if (this.world.getBlockState(new BlockPos((int)this.posX, (int)this.posY, (int)this.posZ)).getBlock() == Blocks.DIRT) { this.heal(0.1F); } super.onLivingUpdate(); }
Example 8
Source File: WorldGenPatch.java From CommunityMod with GNU Lesser General Public License v2.1 | 4 votes |
public WorldGenPatch(IBlockState state, int size) { this(state, size, Blocks.DIRT, Blocks.GRASS, Blocks.STONE); }
Example 9
Source File: WorldGenSurfacePatch.java From Traverse-Legacy-1-12-2 with MIT License | 4 votes |
public WorldGenSurfacePatch(IBlockState state, int size) { this(state, size, Blocks.DIRT, Blocks.GRASS, Blocks.STONE); }
Example 10
Source File: MetaBlockTest.java From minecraft-roguelike with GNU General Public License v3.0 | 4 votes |
@Test public void testEquals(){ MetaBlock dirt = new MetaBlock(Blocks.DIRT); MetaBlock dirt2 = new MetaBlock(Blocks.DIRT); assert(dirt.equals(dirt2)); }
Example 11
Source File: MaterialCache.java From litematica with GNU Lesser General Public License v3.0 | 4 votes |
@Nullable protected ItemStack getStateToItemOverride(IBlockState state) { Block block = state.getBlock(); if (block == Blocks.PISTON_HEAD || block == Blocks.PISTON_EXTENSION || block == Blocks.PORTAL || block == Blocks.END_PORTAL || block == Blocks.END_GATEWAY) { return ItemStack.EMPTY; } else if (block == Blocks.FARMLAND) { return new ItemStack(Blocks.DIRT); } else if (block == Blocks.GRASS_PATH) { return new ItemStack(Blocks.GRASS); } else if (block == Blocks.BROWN_MUSHROOM_BLOCK) { return new ItemStack(Blocks.BROWN_MUSHROOM_BLOCK); } else if (block == Blocks.RED_MUSHROOM_BLOCK) { return new ItemStack(Blocks.RED_MUSHROOM_BLOCK); } else if (block == Blocks.LAVA) { if (state.getValue(BlockLiquid.LEVEL) == 0) { return new ItemStack(Items.LAVA_BUCKET); } else { return ItemStack.EMPTY; } } else if (block == Blocks.WATER) { if (state.getValue(BlockLiquid.LEVEL) == 0) { return new ItemStack(Items.WATER_BUCKET); } else { return ItemStack.EMPTY; } } else if (block instanceof BlockDoor && state.getValue(BlockDoor.HALF) == BlockDoor.EnumDoorHalf.UPPER) { return ItemStack.EMPTY; } else if (block instanceof BlockBed && state.getValue(BlockBed.PART) == BlockBed.EnumPartType.HEAD) { return ItemStack.EMPTY; } else if (block instanceof BlockDoublePlant && state.getValue(BlockDoublePlant.HALF) == BlockDoublePlant.EnumBlockHalf.UPPER) { return ItemStack.EMPTY; } return null; }
Example 12
Source File: WorldGenSurfacePatch.java From CommunityMod with GNU Lesser General Public License v2.1 | 4 votes |
public WorldGenSurfacePatch(IBlockState state, int size) { this(state, size, Blocks.DIRT, Blocks.GRASS, Blocks.STONE); }
Example 13
Source File: BlockMapleSaplingOrange.java From Sakura_mod with MIT License | 4 votes |
@Override protected boolean canSustainBush(IBlockState state) { Block block = state.getBlock(); return block == Blocks.GRASS || block == Blocks.DIRT || block.getMaterial(state) == Material.GROUND; }
Example 14
Source File: BlockMapleSaplingRed.java From Sakura_mod with MIT License | 4 votes |
@Override protected boolean canSustainBush(IBlockState state) { Block block = state.getBlock(); return block == Blocks.GRASS || block == Blocks.DIRT || block.getMaterial(state) == Material.GROUND; }
Example 15
Source File: BlockMapleSaplingYellow.java From Sakura_mod with MIT License | 4 votes |
@Override protected boolean canSustainBush(IBlockState state) { Block block = state.getBlock(); return block == Blocks.GRASS || block == Blocks.DIRT || block.getMaterial(state) == Material.GROUND; }
Example 16
Source File: BlockSakuraSapling.java From Sakura_mod with MIT License | 4 votes |
@Override protected boolean canSustainBush(IBlockState state) { Block block = state.getBlock(); return block == Blocks.GRASS || block == Blocks.DIRT || block.getMaterial(state) == Material.GROUND; }
Example 17
Source File: BlockMapleSaplingGreen.java From Sakura_mod with MIT License | 4 votes |
@Override protected boolean canSustainBush(IBlockState state) { Block block = state.getBlock(); return block == Blocks.GRASS || block == Blocks.DIRT || block.getMaterial(state) == Material.GROUND; }
Example 18
Source File: ItemEnderTool.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
public boolean useHoe(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side) { if (player.canPlayerEdit(pos, side, stack) == false) { return false; } int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(stack, player, world, pos); if (hook != 0) { return hook > 0; } IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); if (side != EnumFacing.DOWN && world.isAirBlock(pos.up())) { IBlockState newBlockState = null; if (block == Blocks.GRASS) { newBlockState = Blocks.FARMLAND.getDefaultState(); } else if (block == Blocks.DIRT) { if (state.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT || state.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.COARSE_DIRT) { newBlockState = Blocks.FARMLAND.getDefaultState(); } else { return false; } } else { return false; } if (newBlockState != null) { world.setBlockState(pos, newBlockState, 3); this.addToolDamage(stack, 1, player, player); world.playSound(null, pos.getX() + 0.5d, pos.getY() + 0.5d, pos.getZ() + 0.5d, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0f, 1.0f); return true; } } return false; }
Example 19
Source File: BlockApricotSapling.java From TofuCraftReload with MIT License | 4 votes |
@Override protected boolean canSustainBush(IBlockState state) { Block block = state.getBlock(); return block == Blocks.GRASS || block == Blocks.DIRT; }
Example 20
Source File: BlockTofuYuba.java From TofuCraftReload with MIT License | 4 votes |
/** * 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() == BlockLoader.tofuTerrain|| state.getBlock() == BlockLoader.yubaGrass; }