當前位置: 首頁>>代碼示例>>Java>>正文


Java IGrowable類代碼示例

本文整理匯總了Java中net.minecraft.block.IGrowable的典型用法代碼示例。如果您正苦於以下問題:Java IGrowable類的具體用法?Java IGrowable怎麽用?Java IGrowable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IGrowable類屬於net.minecraft.block包,在下文中一共展示了IGrowable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: safeImpact

import net.minecraft.block.IGrowable; //導入依賴的package包/類
@Override
public void safeImpact(BlockPos pos, @Nullable EnumFacing side, World world, int amplifier) {
	int box = 1 + (int) ((float) amplifier / 2F);

	BlockPos posI = pos.add(box, box, box);
	BlockPos posF = pos.add(-box, -box, -box);

	Iterable<BlockPos> spots = BlockPos.getAllInBox(posI, posF);
	for (BlockPos spot : spots) {
		IBlockState state = world.getBlockState(spot);
		boolean place = amplifier > 2 || world.rand.nextBoolean();
		if (place && state.getBlock() instanceof IGrowable) {
			IGrowable crop = (IGrowable) state.getBlock();
			if (crop.canGrow(world, spot, state, false))
				crop.grow(world, world.rand, spot, state);
		}
	}
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:19,代碼來源:FertilizeBrew.java

示例2: applyBonemeal

import net.minecraft.block.IGrowable; //導入依賴的package包/類
public static boolean applyBonemeal(ItemStack stack, World worldIn, BlockPos target)
{
    IBlockState iblockstate = worldIn.getBlockState(target);

    if (iblockstate.getBlock() instanceof IGrowable)
    {
        IGrowable igrowable = (IGrowable)iblockstate.getBlock();

        if (igrowable.canGrow(worldIn, target, iblockstate, worldIn.isRemote))
        {
            if (!worldIn.isRemote)
            {
                if (igrowable.canUseBonemeal(worldIn, worldIn.rand, target, iblockstate))
                {
                    igrowable.grow(worldIn, worldIn.rand, target, iblockstate);
                }

                --stack.stackSize;
            }

            return true;
        }
    }

    return false;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:27,代碼來源:ItemDye.java

示例3: isCorrectBlock

import net.minecraft.block.IGrowable; //導入依賴的package包/類
private boolean isCorrectBlock(BlockPos pos)
{
	Block block = WBlock.getBlock(pos);
	
	if(!(block instanceof IGrowable) || block instanceof BlockGrass
		|| !((IGrowable)block).canGrow(WMinecraft.getWorld(), pos,
			WBlock.getState(pos), false))
		return false;
	
	if(block instanceof BlockSapling)
		return saplings.isChecked();
	else if(block instanceof BlockCrops)
		return crops.isChecked();
	else if(block instanceof BlockStem)
		return stems.isChecked();
	else if(block instanceof BlockCocoa)
		return cocoa.isChecked();
	else
		return other.isChecked();
}
 
開發者ID:Wurst-Imperium,項目名稱:Wurst-MC-1.12,代碼行數:21,代碼來源:BonemealAuraMod.java

示例4: enderlilyTele

import net.minecraft.block.IGrowable; //導入依賴的package包/類
private void enderlilyTele(World world, BlockPos pos, IBlockState state, int age) {
	
	if (world.getLightFromNeighbors(pos.up()) >= 9) {
		if (age < ((BlockCrops)state.getBlock()).getMaxAge()) {
			Iterable<BlockPos> getBox = BlockPos.getAllInBox(pos.add(-4, 0, -4), pos.add(4, 0, 4));
			Iterator it = getBox.iterator();
			while (it.hasNext()) {
				BlockPos looppos = (BlockPos)it.next();
				Block loopblock = world.getBlockState(looppos).getBlock();
				if (loopblock != null && (world.isAirBlock(looppos) || (loopblock instanceof IGrowable && loopblock != this))) {
					IBlockState savestate = world.getBlockState(looppos);
					if (world.getBlockState(looppos.add(0, -1, 0)).getBlock() == Blocks.FARMLAND && world.rand.nextInt(7) == 0)
					{
						world.setBlockState(looppos, ((BlockCrops)state.getBlock()).withAge(age + 1), 2);
						world.setBlockState(pos, savestate);
						UCPacketHandler.sendToNearbyPlayers(world, looppos, new PacketUCEffect(EnumParticleTypes.PORTAL, looppos.getX(), looppos.getY(), looppos.getZ(), 6));
						UCPacketHandler.sendToNearbyPlayers(world, pos, new PacketUCEffect(EnumParticleTypes.PORTAL, pos.getX(), pos.getY(), pos.getZ(), 6));
						return;
					}
				}
			}
		}
	}
}
 
開發者ID:bafomdad,項目名稱:uniquecrops,代碼行數:25,代碼來源:Enderlily.java

示例5: applyBonemeal

import net.minecraft.block.IGrowable; //導入依賴的package包/類
public static boolean applyBonemeal(ItemStack stack, World worldIn, BlockPos target)
{
    IBlockState iblockstate = worldIn.getBlockState(target);

    if (iblockstate.getBlock() instanceof IGrowable)
    {
        IGrowable igrowable = (IGrowable)iblockstate.getBlock();

        if (igrowable.canGrow(worldIn, target, iblockstate, worldIn.isRemote))
        {
            if (!worldIn.isRemote)
            {
                if (igrowable.canUseBonemeal(worldIn, worldIn.rand, target, iblockstate))
                {
                    igrowable.grow(worldIn, worldIn.rand, target, iblockstate);
                }

                stack.func_190918_g(1);
            }

            return true;
        }
    }

    return false;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:27,代碼來源:ItemDye.java

示例6: isNormalCrop

import net.minecraft.block.IGrowable; //導入依賴的package包/類
public static boolean isNormalCrop(World world, BlockPos pos)
{
	if (world.isAirBlock(pos)) {
      return false;
    }
    boolean found = false;
    IBlockState state = world.getBlockState(pos);
    Block bi = state.getBlock();
    for (int a = 0; a < 16; a++) {
      if ((getCrops(CropType.NORMAL).contains(bi.getUnlocalizedName() + a)))
      {
        found = true;
        break;
      }
    }
    int md = bi.getMetaFromState(state);
    if ((((bi instanceof IGrowable)) && (!(bi instanceof BlockStem))) || (((bi instanceof BlockCrops)) && (!found)) || ((bi == Blocks.NETHER_WART)) || ((bi == Blocks.COCOA)) || (getCrops(CropType.NORMAL).contains(bi.getUnlocalizedName() + md))) {
      return true;
    }
    return false;
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:22,代碼來源:FarmUtil.java

示例7: run

import net.minecraft.block.IGrowable; //導入依賴的package包/類
@Override
public boolean run(@Nonnull SpellData spell) {
	World world = spell.world;
	BlockPos targetPos = spell.getData(BLOCK_HIT);
	Entity targetEntity = spell.getData(ENTITY_HIT);
	Entity caster = spell.getData(CASTER);
	Vec3d pos = spell.getData(TARGET_HIT);

	if (pos != null)
		spell.world.playSound(null, new BlockPos(pos), ModSounds.HEAL, SoundCategory.NEUTRAL, 1, 1);
	if (targetEntity instanceof EntityLivingBase) {
		double strength = getModifier(spell, Attributes.POTENCY, 3, 20) / 10.0;

		if (!tax(this, spell)) return false;

		((EntityLivingBase) targetEntity).heal((float) strength);
	}

	if (targetPos != null) {
		if (world.getBlockState(targetPos).getBlock() instanceof IGrowable) {
			if (!tax(this, spell)) return false;
			if (caster == null || (caster instanceof EntityPlayer && BlockUtils.hasEditPermission(targetPos, (EntityPlayerMP) caster)))
				ItemDye.applyBonemeal(new ItemStack(Items.DYE), world, targetPos);
		} else if (world.getBlockState(targetPos).getBlock() instanceof IPlantable) {
			IBlockState state = world.getBlockState(targetPos);
			Block block = state.getBlock();
			if (!tax(this, spell)) return false;
			if (caster == null || (caster instanceof EntityPlayer && BlockUtils.hasEditPermission(targetPos, (EntityPlayerMP) caster))) {
				while (world.getBlockState(targetPos.up()).getBlock() == block) {
					targetPos = targetPos.up();
					state = world.getBlockState(targetPos);
					block = state.getBlock();
				}
				world.immediateBlockTick(targetPos, state, RandUtil.random);
			}
		}
	}
	return true;
}
 
開發者ID:TeamWizardry,項目名稱:Wizardry,代碼行數:40,代碼來源:ModuleEffectThrive.java

示例8: onItemUse

import net.minecraft.block.IGrowable; //導入依賴的package包/類
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    ItemStack stack = player.getHeldItem(hand);
    IBlockState state = world.getBlockState(pos);
    if (state.getBlock() instanceof IGrowable) {
        NBTTagList nbtList = stack.getEnchantmentTagList();
        for (NBTBase nbt : nbtList) {
            if (((NBTTagCompound) nbt).getInteger("id") == Enchantment.getEnchantmentID(GSEnchantment.BONE_RAIN)) {
                if (applyBonemeal(stack, world, pos, state, player, hand)) {
                    if (!world.isRemote) {
                        world.playEvent(2005, pos, 0);
                    }
                    return EnumActionResult.SUCCESS;
                }
                break;
            }
        }
    }

    return super.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ);
}
 
開發者ID:NightKosh,項目名稱:Gravestone-mod-Extended,代碼行數:22,代碼來源:ItemBoneHoe.java

示例9: applyBonemeal

import net.minecraft.block.IGrowable; //導入依賴的package包/類
public static boolean applyBonemeal(ItemStack stack, World worldIn, BlockPos pos, IBlockState state, EntityPlayer player, @javax.annotation.Nullable EnumHand hand) {
    if (!(state.getBlock() instanceof BlockGrass) || player.isSneaking()) {

        int hook = net.minecraftforge.event.ForgeEventFactory.onApplyBonemeal(player, worldIn, pos, state, stack, hand);
        if (hook != 0) return hook > 0;

        IGrowable igrowable = (IGrowable) state.getBlock();
        if (igrowable.canGrow(worldIn, pos, state, worldIn.isRemote)) {
            if (!worldIn.isRemote) {
                if (igrowable.canUseBonemeal(worldIn, worldIn.rand, pos, state)) {
                    igrowable.grow(worldIn, worldIn.rand, pos, state);
                }
                stack.damageItem(1, player);
            }
            return true;
        }
    }
    return false;
}
 
開發者ID:NightKosh,項目名稱:Gravestone-mod-Extended,代碼行數:20,代碼來源:ItemBoneHoe.java

示例10: applyUnko

import net.minecraft.block.IGrowable; //導入依賴的package包/類
private boolean applyUnko(ItemStack stack, World worldIn, BlockPos pos, EntityPlayer player) {
       IBlockState iblockstate = worldIn.getBlockState(pos);
       Block block = iblockstate.getBlock();

       if (block instanceof IGrowable)
       {
           IGrowable igrowable = (IGrowable)block;

           if (igrowable.isStillGrowing(worldIn, pos, iblockstate, worldIn.isRemote))
           {
               if (!worldIn.isRemote)
               {
                   if (igrowable.canUseBonemeal(worldIn, worldIn.rand, pos, iblockstate))
                   {
                       igrowable.grow(worldIn, worldIn.rand, pos, iblockstate);
                   }

                   --stack.stackSize;
               }

               return true;
           }
       }

       return false;
}
 
開發者ID:shu3,項目名稱:FatCatMOD,代碼行數:27,代碼來源:ItemFatCatUnko.java

示例11: onItemExpire

import net.minecraft.block.IGrowable; //導入依賴的package包/類
@SuppressWarnings({ "NumericCastThatLosesPrecision", "MethodMayBeStatic" })
@SubscribeEvent
public void onItemExpire(ItemExpireEvent event)
{
    if (Settings.INSTANCE.doPlantGrowable())
    {
        final Item item = event.entityItem.getEntityItem().getItem();
        final Block block = Block.getBlockFromItem(item);

        if (block instanceof IGrowable)
        {
            final World world = event.entityItem.worldObj;
            final int x = (int) event.entityItem.posX;
            final int y = (int) event.entityItem.posY;
            final int z = (int) event.entityItem.posZ;
            final int metadata = event.entityItem.getEntityItem().getItemDamage();

            plantGrowable(world, x, y, z, block, metadata);
        }
    }
}
 
開發者ID:MinecraftModArchive,項目名稱:ScottsTweaks,代碼行數:22,代碼來源:Planter.java

示例12: growPlantAtBlock

import net.minecraft.block.IGrowable; //導入依賴的package包/類
/**
	 * Gives a bonemeal growth effect to the plant in question. Does not work on BlockBush because they appear to pop off on tall pushes.
	 * @param world
	 * @param pos
	 * @return
	 */
	public static boolean growPlantAtBlock(World world, BlockPos pos)
	{
		IBlockState state = world.getBlockState(pos);
		Block block = state.getBlock();
		
		if(block instanceof IGrowable && !(block instanceof BlockBush))
		{
			((IGrowable)block).grow(world, rand, pos, state);
			
//			block.updateTick(world, pos, state, world.rand);
			
			return true;
		}
		
		return false;
	}
 
開發者ID:WayofTime,項目名稱:Hemomancy,代碼行數:23,代碼來源:Utils.java

示例13: func_150919_a

import net.minecraft.block.IGrowable; //導入依賴的package包/類
public static boolean func_150919_a(ItemStack p_150919_0_, World p_150919_1_, int p_150919_2_, int p_150919_3_, int p_150919_4_)
{
    Block var5 = p_150919_1_.getBlock(p_150919_2_, p_150919_3_, p_150919_4_);

    if (var5 instanceof IGrowable)
    {
        IGrowable var6 = (IGrowable)var5;

        if (var6.func_149851_a(p_150919_1_, p_150919_2_, p_150919_3_, p_150919_4_, p_150919_1_.isClient))
        {
            if (!p_150919_1_.isClient)
            {
                if (var6.func_149852_a(p_150919_1_, p_150919_1_.rand, p_150919_2_, p_150919_3_, p_150919_4_))
                {
                    var6.func_149853_b(p_150919_1_, p_150919_1_.rand, p_150919_2_, p_150919_3_, p_150919_4_);
                }

                --p_150919_0_.stackSize;
            }

            return true;
        }
    }

    return false;
}
 
開發者ID:MinecraftModdedClients,項目名稱:Resilience-Client-Source,代碼行數:27,代碼來源:ItemDye.java

示例14: onUpdateTick

import net.minecraft.block.IGrowable; //導入依賴的package包/類
@Override
public void onUpdateTick(ItemStack stack, World world, Entity entity, IPlayerSession session, int par4, boolean par5, int boost, int cost, boolean bool) {
    if (entity != null && entity instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) entity;
        if (++tick >= 140) {
            tick = 0;
            for (int x = -(1 + boost); x < (2 + boost); x++)
                for (int z = -(1 + boost); z < (2 + boost); z++) {
                    if (session.hasEnoughMana(cost())) {
                        int blkX = (int) player.posX + x, blkY = (int) player.posY, blkZ = (int) player.posZ + z;
                        Block blk = world.getBlock(blkX, blkY, blkZ);
                        if (blk != null && !world.isAirBlock(blkX, blkY, blkZ)) {
                            if (blk instanceof IGrowable) {
                                if (((IGrowable) blk).func_149851_a(world, blkX, blkY, blkZ, world.isRemote)) {
                                    if (!world.isRemote)
                                        blk.updateTick(world, blkX, blkY, blkZ, world.rand);
                                    session.adjustMana(-cost(), false);
                                }
                            }
                        }
                    } else
                        break;
                }
        }
    }
}
 
開發者ID:Lomeli12,項目名稱:MagicalRings,代碼行數:27,代碼來源:Harvest.java

示例15: init

import net.minecraft.block.IGrowable; //導入依賴的package包/類
private void init () {
    registerCompostMaterial(new ItemStack(Blocks.melon_block), defaultMaterial);
    registerCompostMaterial(new ItemStack(Blocks.pumpkin), defaultMaterial);
    registerCompostMaterial(new ItemStack(Blocks.hay_block), defaultMaterial);
    registerCompostMaterial(new ItemStack(Items.string), new StandardCompostMaterial(100, 0.0625f));
    registerCompostMaterial(new ItemStack(Items.wheat), new StandardCompostMaterial(100, 0.125f));
    registerCompostMaterial(new ItemStack(Items.reeds), new StandardCompostMaterial(150, 0.125f));
    registerCompostMaterial(new ItemStack(Items.feather), new StandardCompostMaterial(50, 0.0625f));
    registerCompostMaterial(new ItemStack(Items.rotten_flesh), new StandardCompostMaterial(150, 0.125f));
    registerCompostMaterial(new ItemStack(Items.leather), new StandardCompostMaterial(150, 0.125f));

    registerCompostMaterial("treeWood", new StandardCompostMaterial(300, 0.25f));
    registerCompostMaterial("logWood", new StandardCompostMaterial(300, 0.25f));
    registerCompostMaterial("treeLeaves", defaultMaterial);
    registerCompostMaterial("treeSapling", defaultMaterial);
    registerCompostMaterial("stickWood", defaultMaterial);

    registerCompostMaterial(IPlantable.class, defaultMaterial);
    registerCompostMaterial(IGrowable.class, defaultMaterial);
    registerCompostMaterial(BlockLeavesBase.class, defaultMaterial);
    registerCompostMaterial(BlockVine.class, defaultMaterial);
    registerCompostMaterial(ItemFood.class, defaultMaterial);
}
 
開發者ID:jaquadro,項目名稱:GardenCollection,代碼行數:24,代碼來源:CompostRegistry.java


注:本文中的net.minecraft.block.IGrowable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。