当前位置: 首页>>代码示例>>Java>>正文


Java Result.ALLOW属性代码示例

本文整理汇总了Java中net.minecraftforge.event.Event.Result.ALLOW属性的典型用法代码示例。如果您正苦于以下问题:Java Result.ALLOW属性的具体用法?Java Result.ALLOW怎么用?Java Result.ALLOW使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在net.minecraftforge.event.Event.Result的用法示例。


在下文中一共展示了Result.ALLOW属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: hoeGround

public static boolean hoeGround (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, Random random)
{
    if (!player.canPlayerEdit(x, y, z, side, stack))
    {
        return false;
    }
    else
    {
        UseHoeEvent event = new UseHoeEvent(player, stack, world, x, y, z);
        if (MinecraftForge.EVENT_BUS.post(event))
        {
            return false;
        }

        if (event.getResult() == Result.ALLOW)
        {
            onBlockChanged(stack, world, 0, x, y, z, player, random);
            return true;
        }

        int bID = world.getBlockId(x, y, z);
        int bIDabove = world.getBlockId(x, y + 1, z);

        if ((side == 0 || bIDabove != 0 || bID != Block.grass.blockID) && bID != Block.dirt.blockID)
        {
            return false;
        }
        else
        {
            Block block = Block.tilledField;
            world.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), block.stepSound.getStepSound(),
                    (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);

            if (world.isRemote)
            {
                return true;
            }
            else
            {
                world.setBlock(x, y, z, block.blockID);
                onBlockChanged(stack, world, 0, x, y, z, player, random);
                return true;
            }
        }
    }
}
 
开发者ID:austinv11,项目名称:PeripheralsPlusPlus,代码行数:46,代码来源:AbilityHelper.java

示例2: onItemUse

/**
 * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
 * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
 */
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
    if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack))
    {
        return false;
    }
    else
    {
        UseHoeEvent event = new UseHoeEvent(par2EntityPlayer, par1ItemStack, par3World, par4, par5, par6);
        if (MinecraftForge.EVENT_BUS.post(event))
        {
            return false;
        }

        if (event.getResult() == Result.ALLOW)
        {
            par1ItemStack.damageItem(1, par2EntityPlayer);
            return true;
        }

        int i1 = par3World.getBlockId(par4, par5, par6);
        boolean air = par3World.isAirBlock(par4, par5 + 1, par6);

        if (par7 != 0 && air && (i1 == Block.grass.blockID || i1 == Block.dirt.blockID))
        {
            Block block = Block.tilledField;
            par3World.playSoundEffect((double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), block.stepSound.getStepSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);

            if (par3World.isRemote)
            {
                return true;
            }
            else
            {
                par3World.setBlock(par4, par5, par6, block.blockID);
                par1ItemStack.damageItem(1, par2EntityPlayer);
                return true;
            }
        }
        else
        {
            return false;
        }
    }
}
 
开发者ID:NovaViper,项目名称:ZeroQuest,代码行数:49,代码来源:ItemNileHoe.java

示例3: getMaxSpawnPackSize

public static int getMaxSpawnPackSize(EntityLiving entity)
{
    LivingPackSizeEvent maxCanSpawnEvent = new LivingPackSizeEvent(entity);
    MinecraftForge.EVENT_BUS.post(maxCanSpawnEvent);
    return maxCanSpawnEvent.getResult() == Result.ALLOW ? maxCanSpawnEvent.maxPackSize : entity.getMaxSpawnedInChunk();
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:6,代码来源:ForgeEventFactory.java

示例4: onCollideWithPlayer

/**
 * Called by a player entity when they collide with an entity
 */
public void onCollideWithPlayer(EntityPlayer par1EntityPlayer)
{
    if (!this.worldObj.isRemote)
    {
        if (this.delayBeforeCanPickup > 0)
        {
            return;
        }

        EntityItemPickupEvent event = new EntityItemPickupEvent(par1EntityPlayer, this);

        if (MinecraftForge.EVENT_BUS.post(event))
        {
            return;
        }

        ItemStack itemstack = this.getEntityItem();
        int i = itemstack.stackSize;

        if (this.delayBeforeCanPickup <= 0 && (event.getResult() == Result.ALLOW || i <= 0 || par1EntityPlayer.inventory.addItemStackToInventory(itemstack)))
        {
            if (itemstack.itemID == Block.wood.blockID)
            {
                par1EntityPlayer.triggerAchievement(AchievementList.mineWood);
            }

            if (itemstack.itemID == Item.leather.itemID)
            {
                par1EntityPlayer.triggerAchievement(AchievementList.killCow);
            }

            if (itemstack.itemID == Item.diamond.itemID)
            {
                par1EntityPlayer.triggerAchievement(AchievementList.diamonds);
            }

            if (itemstack.itemID == Item.blazeRod.itemID)
            {
                par1EntityPlayer.triggerAchievement(AchievementList.blazeRod);
            }

            GameRegistry.onPickupNotification(par1EntityPlayer, this);

            this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
            par1EntityPlayer.onItemPickup(this, i);

            if (itemstack.stackSize <= 0)
            {
                this.setDead();
            }
        }
    }
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:56,代码来源:EntityItem.java

示例5: attackEntityFrom

/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
    if (!super.attackEntityFrom(par1DamageSource, par2))
    {
        return false;
    }
    else
    {
        EntityLivingBase entitylivingbase = this.getAttackTarget();

        if (entitylivingbase == null && this.getEntityToAttack() instanceof EntityLivingBase)
        {
            entitylivingbase = (EntityLivingBase)this.getEntityToAttack();
        }

        if (entitylivingbase == null && par1DamageSource.getEntity() instanceof EntityLivingBase)
        {
            entitylivingbase = (EntityLivingBase)par1DamageSource.getEntity();
        }

        int i = MathHelper.floor_double(this.posX);
        int j = MathHelper.floor_double(this.posY);
        int k = MathHelper.floor_double(this.posZ);

        SummonAidEvent summonAid = ForgeEventFactory.fireZombieSummonAid(this, worldObj, i, j, k, entitylivingbase, this.getEntityAttribute(field_110186_bp).getAttributeValue());
        
        if (summonAid.getResult() == Result.DENY)
        {
            return true;
        }
        else if (summonAid.getResult() == Result.ALLOW || entitylivingbase != null && this.worldObj.difficultySetting >= 3 && (double)this.rand.nextFloat() < this.getEntityAttribute(field_110186_bp).getAttributeValue())
        {
            EntityZombie entityzombie;
            if (summonAid.customSummonedAid != null && summonAid.getResult() == Result.ALLOW)
            {
                entityzombie = summonAid.customSummonedAid;
            }
            else
            {
                entityzombie = new EntityZombie(this.worldObj);
            }
            
            for (int l = 0; l < 50; ++l)
            {
                int i1 = i + MathHelper.getRandomIntegerInRange(this.rand, 7, 40) * MathHelper.getRandomIntegerInRange(this.rand, -1, 1);
                int j1 = j + MathHelper.getRandomIntegerInRange(this.rand, 7, 40) * MathHelper.getRandomIntegerInRange(this.rand, -1, 1);
                int k1 = k + MathHelper.getRandomIntegerInRange(this.rand, 7, 40) * MathHelper.getRandomIntegerInRange(this.rand, -1, 1);

                if (this.worldObj.doesBlockHaveSolidTopSurface(i1, j1 - 1, k1) && this.worldObj.getBlockLightValue(i1, j1, k1) < 10)
                {
                    entityzombie.setPosition((double)i1, (double)j1, (double)k1);

                    if (this.worldObj.checkNoEntityCollision(entityzombie.boundingBox) && this.worldObj.getCollidingBoundingBoxes(entityzombie, entityzombie.boundingBox).isEmpty() && !this.worldObj.isAnyLiquid(entityzombie.boundingBox))
                    {
                        this.worldObj.spawnEntityInWorld(entityzombie);
                        if (entitylivingbase != null) entityzombie.setAttackTarget(entitylivingbase);
                        entityzombie.onSpawnWithEgg((EntityLivingData)null);
                        this.getEntityAttribute(field_110186_bp).applyModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, 0));
                        entityzombie.getEntityAttribute(field_110186_bp).applyModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, 0));
                        break;
                    }
                }
            }
        }

        return true;
    }
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:71,代码来源:EntityZombie.java


注:本文中的net.minecraftforge.event.Event.Result.ALLOW属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。