public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int p_180622_4_, int p_180622_5_, double p_180622_6_) { this.topBlock = Blocks.grass.getDefaultState(); this.fillerBlock = Blocks.dirt.getDefaultState(); if (p_180622_6_ > 1.75D) { this.topBlock = Blocks.stone.getDefaultState(); this.fillerBlock = Blocks.stone.getDefaultState(); } else if (p_180622_6_ > -0.5D) { this.topBlock = Blocks.dirt.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT); } this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, p_180622_4_, p_180622_5_, p_180622_6_); }
public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int p_180622_4_, int p_180622_5_, double p_180622_6_) { if (this.field_150644_aH == 1 || this.field_150644_aH == 2) { this.topBlock = Blocks.grass.getDefaultState(); this.fillerBlock = Blocks.dirt.getDefaultState(); if (p_180622_6_ > 1.75D) { this.topBlock = Blocks.dirt.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT); } else if (p_180622_6_ > -0.95D) { this.topBlock = Blocks.dirt.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.PODZOL); } } this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, p_180622_4_, p_180622_5_, p_180622_6_); }
@Override public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) { this.topBlock = Blocks.GRASS.getDefaultState(); this.fillerBlock = Blocks.DIRT.getDefaultState(); if (noiseVal > 1.8D) { this.topBlock = Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT); } else if (noiseVal <= -1.85D) { this.topBlock = Blocks.GRAVEL.getDefaultState(); } this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal); }
@Override public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) { this.topBlock = Blocks.GRASS.getDefaultState(); this.fillerBlock = Blocks.DIRT.getDefaultState(); double fuzz = MathUtil.getFuzz(x,z, 342453747); if (noiseVal + fuzz * 2 > 1.85) { this.topBlock = Blocks.SAND.getDefaultState(); this.fillerBlock = Blocks.SAND.getDefaultState(); } else if( noiseVal + fuzz * 2 < -1.85) { this.topBlock = Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT); this.fillerBlock = Blocks.DIRT.getDefaultState(); } this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal); }
public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) { this.topBlock = Blocks.GRASS.getDefaultState(); this.fillerBlock = Blocks.DIRT.getDefaultState(); if (noiseVal > 1.75D) { this.topBlock = Blocks.STONE.getDefaultState(); this.fillerBlock = Blocks.STONE.getDefaultState(); } else if (noiseVal > -0.5D) { this.topBlock = Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT); } this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal); }
public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) { if (this.type == BiomeTaiga.Type.MEGA || this.type == BiomeTaiga.Type.MEGA_SPRUCE) { this.topBlock = Blocks.GRASS.getDefaultState(); this.fillerBlock = Blocks.DIRT.getDefaultState(); if (noiseVal > 1.75D) { this.topBlock = Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT); } else if (noiseVal > -0.95D) { this.topBlock = Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.PODZOL); } } this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal); }
@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().withProperty(BlockDirt.VARIANT, DirtType.DIRT)); } else { if (worldIn.getLightFromNeighbors(pos.up()) >= 9) { for (int i = 0; i < 4; ++i) { BlockPos posAt = pos.add(rand.nextInt(3) - 1, rand.nextInt(5) - 3, rand.nextInt(3) - 1); IBlockState stateAt = worldIn.getBlockState(posAt); IBlockState stateAbove = worldIn.getBlockState(posAt.up()); if (Blocks.DIRT.equals(stateAt.getBlock()) && DirtType.DIRT.equals(stateAt.getValue(BlockDirt.VARIANT)) && worldIn.getLightFromNeighbors(posAt.up()) >= 4 && stateAbove.getLightOpacity(worldIn, posAt.up()) <= 2) { worldIn.setBlockState(posAt, this.getDefaultState()); } } } } } }
@Override public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer primer, int p_180622_4_, int p_180622_5_, double noise) { this.fillerBlock = Blocks.dirt.getDefaultState(); this.topBlock = Blocks.grass.getDefaultState(); if (noise > 2.5D) { this.topBlock = Blocks.sand.getDefaultState(); this.fillerBlock = Blocks.sand.getDefaultState(); } else if (noise > -0.95D) { this.topBlock = Blocks.dirt.getStateFromMeta(BlockDirt.DirtType.PODZOL.getMetadata()); } this.generateBiomeTerrain(worldIn, rand, primer, p_180622_4_, p_180622_5_, noise); }
public static void inventoryRender() { Item item = GameRegistry.findItem(MReference.MODID, "virtian_soil"); ModelBakery.addVariantName(item, "ministrapp:virtian_soil_dirt"); ModelBakery.addVariantName(item, "ministrapp:virtian_soil_coarse_dirt"); ModelBakery.addVariantName(item, "ministrapp:virtian_soil_podzol"); Item itemBlockVariants = GameRegistry.findItem(MReference.MODID, "virtian_soil"); DirtType[] aenumtype = BlockDirt.DirtType.values(); int i = aenumtype.length; for (int j = 0; j < i; ++j) { BlockDirt.DirtType enumtype = aenumtype[j]; ModelResourceLocation itemModelResourceLocation = new ModelResourceLocation(MReference.MODID + ":" + "virtian_soil_" + enumtype .getName(), "inventory"); Minecraft.getMinecraft().getRenderItem().getItemModelMesher() .register(itemBlockVariants, enumtype.getMetadata(), itemModelResourceLocation); } }
public void genTerrainBlocks(World worldIn, Random p_180622_2_, ChunkPrimer p_180622_3_, int p_180622_4_, int p_180622_5_, double p_180622_6_) { if (this.field_150644_aH == 1 || this.field_150644_aH == 2) { this.topBlock = Blocks.grass.getDefaultState(); this.fillerBlock = Blocks.dirt.getDefaultState(); if (p_180622_6_ > 1.75D) { this.topBlock = Blocks.dirt.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT); } else if (p_180622_6_ > -0.95D) { this.topBlock = Blocks.dirt.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.PODZOL); } } this.generateBiomeTerrain(worldIn, p_180622_2_, p_180622_3_, p_180622_4_, p_180622_5_, p_180622_6_); }
public void genTerrainBlocks(World worldIn, Random p_180622_2_, ChunkPrimer p_180622_3_, int p_180622_4_, int p_180622_5_, double p_180622_6_) { this.topBlock = Blocks.grass.getDefaultState(); this.fillerBlock = Blocks.dirt.getDefaultState(); if (p_180622_6_ > 1.75D) { this.topBlock = Blocks.stone.getDefaultState(); this.fillerBlock = Blocks.stone.getDefaultState(); } else if (p_180622_6_ > -0.5D) { this.topBlock = Blocks.dirt.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT); } this.generateBiomeTerrain(worldIn, p_180622_2_, p_180622_3_, p_180622_4_, p_180622_5_, p_180622_6_); }
/** * Called frequently so the entity can update its state every tick as * required. For example, zombies and skeletons use this to react to * sunlight and start to burn. */ @Override public void onLivingUpdate() { super.onLivingUpdate(); if (isClient()) { ClientProxy.spawnForisParticle(this); } for (int l = 0; l <= 4; ++l) { if (Constants.DEF_GRASSSTEP == true) { int x = MathHelper.floor_double(this.posX + (l % 2 * 2 - 1) * 0.25F); int y = MathHelper.floor_double(this.posY) - 1; int z = MathHelper.floor_double(this.posZ + (l / 2 % 2 * 2 - 1) * 0.25F); BlockPos pos = new BlockPos(x, y, z); IBlockState state = this.worldObj.getBlockState(pos); boolean isAnyDirt = state.getBlock() == Blocks.dirt; boolean isRegularDirt = isAnyDirt && state.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT; if (isAnyDirt && isRegularDirt) { this.worldObj.setBlockState(pos, footprint.getDefaultState()); } } } }
@SubscribeEvent public void onUseHoe(UseHoeEvent event) { Block oblock = event.world.getBlock(event.x, event.y, event.z); if (LongHoe.AOEEnabled && event.current.getItem() instanceof LongHoe && (oblock instanceof BlockDirt || oblock instanceof BlockGrass)) { LongHoe.AOEEnabled = false; for (int x = event.x - 3; x < event.x + 3; x++) { for (int z = event.z - 3; z < event.z + 3; z++) { Block block = event.world.getBlock(x, event.y, z); if ((!(x == event.x && z == event.z)) && (block instanceof BlockDirt || block instanceof BlockGrass) && (!MinecraftForge.EVENT_BUS.post(new UseHoeEvent(event.entityPlayer, event.current, event.world, x, event.y, z)))) { event.world.setBlock(x, event.y, z, Blocks.farmland); if (event.world.getBlock(x, event.y + 1, z).isReplaceable(event.world, x, event.y + 1, z)) { event.world.setBlockToAir(x, event.y + 1, z); } DerpyItems.damageItem(event.current, 1, event.entityPlayer); } } } LongHoe.AOEEnabled = true; } }
@Test public void jsonArgs() throws Exception { MetaBlock dirt = new MetaBlock(Blocks.DIRT); MetaBlock stone = new MetaBlock(Blocks.STONE); JsonObject json = new JsonObject(); json.addProperty("name", "minecraft:dirt"); MetaBlock test = new MetaBlock(json); assert(test.equals(dirt)); MetaBlock podzol = new MetaBlock(Blocks.DIRT); podzol.withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.PODZOL); json = new JsonObject(); json.addProperty("name", "minecraft:dirt"); json.addProperty("meta", 2); test = new MetaBlock(json); assertTrue(!test.equals(stone)); assertTrue(!test.equals(dirt)); assertTrue(test.equals(podzol)); }
/** * Adds the crafting recipes to the CraftingManager. */ public void addRecipes(CraftingManager p_77589_1_) { p_77589_1_.addRecipe(new ItemStack(Blocks.chest), new Object[] {"###", "# #", "###", '#', Blocks.planks}); p_77589_1_.addRecipe(new ItemStack(Blocks.trapped_chest), new Object[] {"#-", '#', Blocks.chest, '-', Blocks.tripwire_hook}); p_77589_1_.addRecipe(new ItemStack(Blocks.ender_chest), new Object[] {"###", "#E#", "###", '#', Blocks.obsidian, 'E', Items.ender_eye}); p_77589_1_.addRecipe(new ItemStack(Blocks.furnace), new Object[] {"###", "# #", "###", '#', Blocks.cobblestone}); p_77589_1_.addRecipe(new ItemStack(Blocks.crafting_table), new Object[] {"##", "##", '#', Blocks.planks}); p_77589_1_.addRecipe(new ItemStack(Blocks.sandstone), new Object[] {"##", "##", '#', new ItemStack(Blocks.sand, 1, BlockSand.EnumType.SAND.getMetadata())}); p_77589_1_.addRecipe(new ItemStack(Blocks.red_sandstone), new Object[] {"##", "##", '#', new ItemStack(Blocks.sand, 1, BlockSand.EnumType.RED_SAND.getMetadata())}); p_77589_1_.addRecipe(new ItemStack(Blocks.sandstone, 4, BlockSandStone.EnumType.SMOOTH.getMetadata()), new Object[] {"##", "##", '#', new ItemStack(Blocks.sandstone, 1, BlockSandStone.EnumType.DEFAULT.getMetadata())}); p_77589_1_.addRecipe(new ItemStack(Blocks.red_sandstone, 4, BlockRedSandstone.EnumType.SMOOTH.getMetadata()), new Object[] {"##", "##", '#', new ItemStack(Blocks.red_sandstone, 1, BlockRedSandstone.EnumType.DEFAULT.getMetadata())}); p_77589_1_.addRecipe(new ItemStack(Blocks.sandstone, 1, BlockSandStone.EnumType.CHISELED.getMetadata()), new Object[] {"#", "#", '#', new ItemStack(Blocks.stone_slab, 1, BlockStoneSlab.EnumType.SAND.getMetadata())}); p_77589_1_.addRecipe(new ItemStack(Blocks.red_sandstone, 1, BlockRedSandstone.EnumType.CHISELED.getMetadata()), new Object[] {"#", "#", '#', new ItemStack(Blocks.stone_slab2, 1, BlockStoneSlabNew.EnumType.RED_SANDSTONE.getMetadata())}); p_77589_1_.addRecipe(new ItemStack(Blocks.quartz_block, 1, BlockQuartz.EnumType.CHISELED.getMetadata()), new Object[] {"#", "#", '#', new ItemStack(Blocks.stone_slab, 1, BlockStoneSlab.EnumType.QUARTZ.getMetadata())}); p_77589_1_.addRecipe(new ItemStack(Blocks.quartz_block, 2, BlockQuartz.EnumType.LINES_Y.getMetadata()), new Object[] {"#", "#", '#', new ItemStack(Blocks.quartz_block, 1, BlockQuartz.EnumType.DEFAULT.getMetadata())}); p_77589_1_.addRecipe(new ItemStack(Blocks.stonebrick, 4), new Object[] {"##", "##", '#', new ItemStack(Blocks.stone, 1, BlockStone.EnumType.STONE.getMetadata())}); p_77589_1_.addRecipe(new ItemStack(Blocks.stonebrick, 1, BlockStoneBrick.CHISELED_META), new Object[] {"#", "#", '#', new ItemStack(Blocks.stone_slab, 1, BlockStoneSlab.EnumType.SMOOTHBRICK.getMetadata())}); p_77589_1_.addShapelessRecipe(new ItemStack(Blocks.stonebrick, 1, BlockStoneBrick.MOSSY_META), new Object[] {Blocks.stonebrick, Blocks.vine}); p_77589_1_.addShapelessRecipe(new ItemStack(Blocks.mossy_cobblestone, 1), new Object[] {Blocks.cobblestone, Blocks.vine}); p_77589_1_.addRecipe(new ItemStack(Blocks.iron_bars, 16), new Object[] {"###", "###", '#', Items.iron_ingot}); p_77589_1_.addRecipe(new ItemStack(Blocks.glass_pane, 16), new Object[] {"###", "###", '#', Blocks.glass}); p_77589_1_.addRecipe(new ItemStack(Blocks.redstone_lamp, 1), new Object[] {" R ", "RGR", " R ", 'R', Items.redstone, 'G', Blocks.glowstone}); p_77589_1_.addRecipe(new ItemStack(Blocks.beacon, 1), new Object[] {"GGG", "GSG", "OOO", 'G', Blocks.glass, 'S', Items.nether_star, 'O', Blocks.obsidian}); p_77589_1_.addRecipe(new ItemStack(Blocks.nether_brick, 1), new Object[] {"NN", "NN", 'N', Items.netherbrick}); p_77589_1_.addRecipe(new ItemStack(Blocks.stone, 2, BlockStone.EnumType.DIORITE.getMetadata()), new Object[] {"CQ", "QC", 'C', Blocks.cobblestone, 'Q', Items.quartz}); p_77589_1_.addShapelessRecipe(new ItemStack(Blocks.stone, 1, BlockStone.EnumType.GRANITE.getMetadata()), new Object[] {new ItemStack(Blocks.stone, 1, BlockStone.EnumType.DIORITE.getMetadata()), Items.quartz}); p_77589_1_.addShapelessRecipe(new ItemStack(Blocks.stone, 2, BlockStone.EnumType.ANDESITE.getMetadata()), new Object[] {new ItemStack(Blocks.stone, 1, BlockStone.EnumType.DIORITE.getMetadata()), Blocks.cobblestone}); p_77589_1_.addRecipe(new ItemStack(Blocks.dirt, 4, BlockDirt.DirtType.COARSE_DIRT.getMetadata()), new Object[] {"DG", "GD", 'D', new ItemStack(Blocks.dirt, 1, BlockDirt.DirtType.DIRT.getMetadata()), 'G', Blocks.gravel}); p_77589_1_.addRecipe(new ItemStack(Blocks.stone, 4, BlockStone.EnumType.DIORITE_SMOOTH.getMetadata()), new Object[] {"SS", "SS", 'S', new ItemStack(Blocks.stone, 1, BlockStone.EnumType.DIORITE.getMetadata())}); p_77589_1_.addRecipe(new ItemStack(Blocks.stone, 4, BlockStone.EnumType.GRANITE_SMOOTH.getMetadata()), new Object[] {"SS", "SS", 'S', new ItemStack(Blocks.stone, 1, BlockStone.EnumType.GRANITE.getMetadata())}); p_77589_1_.addRecipe(new ItemStack(Blocks.stone, 4, BlockStone.EnumType.ANDESITE_SMOOTH.getMetadata()), new Object[] {"SS", "SS", 'S', new ItemStack(Blocks.stone, 1, BlockStone.EnumType.ANDESITE.getMetadata())}); p_77589_1_.addRecipe(new ItemStack(Blocks.prismarine, 1, BlockPrismarine.ROUGH_META), new Object[] {"SS", "SS", 'S', Items.prismarine_shard}); p_77589_1_.addRecipe(new ItemStack(Blocks.prismarine, 1, BlockPrismarine.BRICKS_META), new Object[] {"SSS", "SSS", "SSS", 'S', Items.prismarine_shard}); p_77589_1_.addRecipe(new ItemStack(Blocks.prismarine, 1, BlockPrismarine.DARK_META), new Object[] {"SSS", "SIS", "SSS", 'S', Items.prismarine_shard, 'I', new ItemStack(Items.dye, 1, EnumDyeColor.BLACK.getDyeDamage())}); p_77589_1_.addRecipe(new ItemStack(Blocks.sea_lantern, 1, 0), new Object[] {"SCS", "CCC", "SCS", 'S', Items.prismarine_shard, 'C', Items.prismarine_crystals}); }
@SuppressWarnings("incomplete-switch") /** * Called when a Block is right-clicked with this Item */ public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { if (!playerIn.canPlayerEdit(pos.offset(side), side, stack)) { return false; } else { IBlockState iblockstate = worldIn.getBlockState(pos); Block block = iblockstate.getBlock(); if (side != EnumFacing.DOWN && worldIn.getBlockState(pos.up()).getBlock().getMaterial() == Material.air) { if (block == Blocks.grass) { return this.useHoe(stack, playerIn, worldIn, pos, Blocks.farmland.getDefaultState()); } if (block == Blocks.dirt) { switch ((BlockDirt.DirtType)iblockstate.getValue(BlockDirt.VARIANT)) { case DIRT: return this.useHoe(stack, playerIn, worldIn, pos, Blocks.farmland.getDefaultState()); case COARSE_DIRT: return this.useHoe(stack, playerIn, worldIn, pos, Blocks.dirt.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT)); } } } return false; } }
@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()); } } } } } }
public static List getFaceQuads(IBlockAccess p_getFaceQuads_0_, IBlockState p_getFaceQuads_1_, BlockPos p_getFaceQuads_2_, EnumFacing p_getFaceQuads_3_, List p_getFaceQuads_4_) { if (p_getFaceQuads_3_ != EnumFacing.UP && p_getFaceQuads_3_ != EnumFacing.DOWN) { Block block = p_getFaceQuads_1_.getBlock(); return block instanceof BlockMycelium ? getFaceQuadsMycelium(p_getFaceQuads_0_, p_getFaceQuads_1_, p_getFaceQuads_2_, p_getFaceQuads_3_, p_getFaceQuads_4_) : (block instanceof BlockGrassPath ? getFaceQuadsGrassPath(p_getFaceQuads_0_, p_getFaceQuads_1_, p_getFaceQuads_2_, p_getFaceQuads_3_, p_getFaceQuads_4_) : (block instanceof BlockDirt ? getFaceQuadsDirt(p_getFaceQuads_0_, p_getFaceQuads_1_, p_getFaceQuads_2_, p_getFaceQuads_3_, p_getFaceQuads_4_) : (block instanceof BlockGrass ? getFaceQuadsGrass(p_getFaceQuads_0_, p_getFaceQuads_1_, p_getFaceQuads_2_, p_getFaceQuads_3_, p_getFaceQuads_4_) : p_getFaceQuads_4_))); } else { return p_getFaceQuads_4_; } }
/** * Called when a Block is right-clicked with this Item */ @Override @SuppressWarnings("incomplete-switch") public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (!playerIn.canPlayerEdit(pos.offset(facing), facing, stack)) { return EnumActionResult.FAIL; } else { int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(stack, playerIn, worldIn, pos); if (hook != 0) return hook > 0 ? EnumActionResult.SUCCESS : EnumActionResult.FAIL; IBlockState iblockstate = worldIn.getBlockState(pos); Block block = iblockstate.getBlock(); if (facing != EnumFacing.DOWN && worldIn.isAirBlock(pos.up())) { if (block == Blocks.grass || block == Blocks.grass_path) { this.func_185071_a(stack, playerIn, worldIn, pos, Blocks.farmland.getDefaultState()); return EnumActionResult.SUCCESS; } if (block == Blocks.dirt) { switch (iblockstate.getValue(BlockDirt.VARIANT)) { case DIRT: this.func_185071_a(stack, playerIn, worldIn, pos, Blocks.farmland.getDefaultState()); return EnumActionResult.SUCCESS; case COARSE_DIRT: this.func_185071_a(stack, playerIn, worldIn, pos, Blocks.dirt.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT)); return EnumActionResult.SUCCESS; } } } return EnumActionResult.PASS; } }
public TeletoryChunkProvider(World worldIn, long seed) { world = worldIn; random = new Random(seed); noise1 = new NoiseGeneratorOctaves(random, 8); base = Blocks.END_STONE.getDefaultState(); dirt = Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT); ore = BlockEnderOre.INSTANCE.getDefaultState(); bush = Blocks.DEADBUSH.getDefaultState(); }
@Override public void updateTick(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, Random rand) { if (canGrow(world, pos, state, true)) grow(world, world.rand, pos, state); else if (!canGrow(world, pos, state, true) && world.getBlockState(pos.down()).getBlock() instanceof BlockDirt && state.getValue(AGE) > 0) { world.setBlockState(pos, state.withProperty(AGE, state.getValue(AGE) - 1)); } }
@SubscribeEvent public void onUseHoeEvent(UseHoeEvent event) { if (ModBlocks.customFarmLand == null) { return; } World world = event.getWorld(); BlockPos pos = event.getPos(); EntityPlayer player = event.getEntityPlayer(); ItemStack stack = event.getCurrent(); IBlockState iblockstate = world.getBlockState(pos); Block block = iblockstate.getBlock(); if (world.isAirBlock(pos.up())) { if (block == Blocks.GRASS) { event.setCanceled(true); useHoe(stack, player, world, pos, ModBlocks.customFarmLand.getDefaultState()); } else if (block == Blocks.DIRT) { switch (iblockstate.getValue(BlockDirt.VARIANT)) { case DIRT: event.setCanceled(true); useHoe(stack, player, world, pos, ModBlocks.customFarmLand.getDefaultState()); break; case COARSE_DIRT: event.setCanceled(true); useHoe(stack, player, world, pos, Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT)); break; } } } }
protected boolean caveableBlock(IBlockState blockstate, IBlockState aboveblockstate) { if (aboveblockstate.getBlock().getMaterial() == Material.water) return false; return blockstate.getBlock() instanceof BlockStone || blockstate.getBlock() instanceof BlockDirt || blockstate.getBlock() instanceof BlockGrass ; }
private EntityVillager.ITradeList[][] buildDruidTrades() { return new EntityVillager.ITradeList[][] { { new EmeraldForItems(Items.COOKED_FISH, new PriceInfo(9, 12)), // GROUP 1 new EmeraldForItems(Items.APPLE, new PriceInfo(3, 6)), new EmeraldForItems(Items.BEETROOT, new PriceInfo(8, 12)) }, { new EmeraldForItems(Items.FEATHER, new PriceInfo(12, 13)), //GROUP 2 new EmeraldForItems(Items.WHEAT_SEEDS, new PriceInfo(50, 64)), new EmeraldForItems(Items.POISONOUS_POTATO, new PriceInfo(1, 3)) }, { new EmeraldForItems(Item.getItemFromBlock(Blocks.BROWN_MUSHROOM), new PriceInfo(8, 12)), //GROUP 3 new EmeraldForItems(Item.getItemFromBlock(Blocks.RED_MUSHROOM), new PriceInfo(8, 12)) }, { new EmeraldForItems(Items.BEEF, new PriceInfo(14, 17)), //GROUP 4 new EmeraldForItems(Items.RABBIT, new PriceInfo(14, 17)), new EmeraldForItems(Items.CHICKEN, new PriceInfo(14, 17)) }, { new EmeraldForItems(Items.WRITTEN_BOOK, new PriceInfo(1, 1)), //GROUP 5 new EmeraldForItems(Items.FISH, new PriceInfo(9, 12)), new EmeraldForItems(Items.SPIDER_EYE, new PriceInfo(3, 6)) }, { new ListItemForEmeraldsFixed(new ItemStack(Blocks.GRASS, 32), new PriceInfo(1, 2)), //GROUP 6 new ListItemForEmeraldsFixed(new ItemStack(Blocks.FARMLAND, 32), new PriceInfo(1, 2)), new ListItemForEmeraldsFixed(new ItemStack(Blocks.DIRT, 32, BlockDirt.DirtType.PODZOL.getMetadata()), new PriceInfo(1, 2)), new ListItemForEmeraldsFixed(new ItemStack(Blocks.GRASS_PATH, 32), new PriceInfo(1, 2)) }, { new ListItemForEmeraldsFixed(new ItemStack(Blocks.MYCELIUM, 1), new PriceInfo(12, 16)), //GROUP 7 new ListItemForEmeraldsFixed(new ItemStack(Blocks.WATERLILY, 32), new PriceInfo(1, 2)), new ListItemForEmeraldsFixed(new ItemStack(Blocks.SAND, 32, BlockSand.EnumType.RED_SAND.ordinal()), new PriceInfo(1, 3)), new ListItemForEmeraldsFixed(new ItemStack(Items.DYE, 16, EnumDyeColor.BLACK.getDyeDamage()), new PriceInfo(1, 3)) } }; }
default EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (!playerIn.canPlayerEdit(pos.offset(facing), facing, stack)) { return EnumActionResult.FAIL; } else { int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(stack, playerIn, worldIn, pos); if (hook != 0) { return hook > 0 ? EnumActionResult.SUCCESS : EnumActionResult.FAIL; } IBlockState iblockstate = worldIn.getBlockState(pos); Block block = iblockstate.getBlock(); if (facing != EnumFacing.DOWN && worldIn.isAirBlock(pos.up())) { if (block == Blocks.GRASS || block == Blocks.GRASS_PATH) { this.setBlock(stack, playerIn, worldIn, pos, Blocks.FARMLAND.getDefaultState()); return EnumActionResult.SUCCESS; } if (block == Blocks.DIRT) { switch (iblockstate.getValue(BlockDirt.VARIANT)) { case DIRT: this.setBlock(stack, playerIn, worldIn, pos, Blocks.FARMLAND.getDefaultState()); return EnumActionResult.SUCCESS; case COARSE_DIRT: this.setBlock(stack, playerIn, worldIn, pos, Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT)); return EnumActionResult.SUCCESS; } } } return EnumActionResult.PASS; } }
@Override public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state) { if (pos.getY() >= 0 && pos.getY() < 256) { IBlockState iblockstate1 = worldIn.getBlockState(pos.down()); return iblockstate1.getBlock() == Blocks.mycelium || (iblockstate1.getBlock() == Blocks.dirt && iblockstate1.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.PODZOL || (iblockstate1.getBlock() == MBlocks.lichen_permafrost || (iblockstate1.getBlock() == MBlocks.dirt_permafrost || (iblockstate1.getBlock() == MBlocks.mud || worldIn.getLight(pos) < 13 && iblockstate1 .getBlock() .canSustainPlant( worldIn, pos.down(), EnumFacing.UP, this))))); } else { return false; } }