本文整理汇总了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);
}
}
}
示例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;
}
示例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();
}
示例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;
}
}
}
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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;
}
}
}
}
示例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);
}