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


Java Result.ALLOW屬性代碼示例

本文整理匯總了Java中cpw.mods.fml.common.eventhandler.Event.Result.ALLOW屬性的典型用法代碼示例。如果您正苦於以下問題:Java Result.ALLOW屬性的具體用法?Java Result.ALLOW怎麽用?Java Result.ALLOW使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在cpw.mods.fml.common.eventhandler.Event.Result的用法示例。


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

示例1: onWorldDecoration

@SubscribeEvent(priority = EventPriority.LOWEST)
public void onWorldDecoration(DecorateBiomeEvent.Decorate event) 
{
	if ((event.getResult() == Result.ALLOW || event.getResult() == Result.DEFAULT) && event.type == EventType.FLOWERS) 
	{
		for(int i = 0; i < 2; i++) 
		{
			int x = event.chunkX + event.rand.nextInt(16) + 8;
			int z = event.chunkZ + event.rand.nextInt(16) + 8;
			int y = event.world.getTopSolidOrLiquidBlock(x, z);

			if(event.world.isAirBlock(x, y, z) && Blocks.flower_pot.canBlockStay(event.world, x, y, z) && ConfigPrimitiveCraft.genrocks)
			{
				event.world.setBlock(x, y, z, ModBlocks.rock);
			}
			else if(event.world.getBlock(x, y, z) == Blocks.water && ConfigPrimitiveCraft.genshale)
			{
				event.world.setBlock(x, y-1, z, ModBlocks.shale);
			}
		}
	}
}
 
開發者ID:gigabit101,項目名稱:PrimitiveCraft,代碼行數:22,代碼來源:WorldGenStones.java

示例2: onItemUse

public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
    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) {
            stack.damageItem(1, player);
            return true;
        }

        Block block = world.getBlock(x, y, z);

        if (side != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.grass || block == Blocks.dirt)) {
            Block block1 = Blocks.farmland;
            world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);

            if (world.isRemote) {
                return true;
            } else {
                world.setBlock(x, y, z, block1);
                stack.damageItem(1, player);
                return true;
            }
        } else {
            return false;
        }
    }
}
 
開發者ID:jtrent238,項目名稱:PopularMMOS-EpicProportions-Mod,代碼行數:32,代碼來源:itemJenMultiTool.java

示例3: onItemUse

@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int posX, int posY, int posZ, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) {
	if (!player.canPlayerEdit(posX, posY, posZ, p_77648_7_, stack)) {
		return false;
	} else {
		UseHoeEvent event = new UseHoeEvent(player, stack, world, posX, posY, posZ);
		if (MinecraftForge.EVENT_BUS.post(event)) {
			return false;
		}
		if (event.getResult() == Result.ALLOW) {
			if (stack.getItemDamage() >= this.getMaxDamage()) {
				player.setCurrentItemOrArmor(0, new ItemStack(Items.iron_hoe, 1, 0));
				return true;
			}
			stack.damageItem(1, player);
			return true;
		}
		Block block = world.getBlock(posX, posY, posZ);
		if (p_77648_7_ != 0 && world.getBlock(posX, posY + 1, posZ).isAir(world, posX, posY + 1, posZ) && (block == Blocks.grass || block == Blocks.dirt)) {
			Block block1 = Blocks.farmland;
			world.playSoundEffect((double)((float)posX + 0.5F), (double)((float)posZ + 0.5F), (double)((float)posZ + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);
			if (world.isRemote) {
				return true;
			} else {
				world.setBlock(posX, posY, posZ, block1);
				if (stack.getItemDamage() >= this.getMaxDamage()) {
					player.setCurrentItemOrArmor(0, new ItemStack(Items.iron_hoe, 1, 0));
					return true;
				}
				stack.damageItem(1, player);
				return true;
			}
		} else {
			return false;
		}
	}
}
 
開發者ID:NullaDev,項目名稱:KeyCraft,代碼行數:37,代碼來源:ItemAuroraIronHoe.java

示例4: applyBonemeal

public static boolean applyBonemeal(ItemStack itemstack, World world, int x, int y, int z, EntityPlayer player) {
	Block block = world.getBlock(x, y, z);

	BonemealEvent event = new BonemealEvent(player, world, block, x, y, z);
	if (MinecraftForge.EVENT_BUS.post(event)) {
		return false;
	}

	if (event.getResult() == Result.ALLOW) {
		if (!world.isRemote) {
			itemstack.stackSize--;
		}
		return true;
	}

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

		if (igrowable.func_149851_a(world, x, y, z, world.isRemote)) {
			if (!world.isRemote) {
				if (igrowable.func_149852_a(world, world.rand, x, y, z)) {
					igrowable.func_149853_b(world, world.rand, x, y, z);
				}

			}

			return true;
		}
	}

	return false;
}
 
開發者ID:mookie1097,項目名稱:NausicaaMod,代碼行數:32,代碼來源:VoluciteNecklace.java

示例5: 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 doesn't. This is for ITEMS, not BLOCKS
 */
public boolean onItemUse(ItemStack itemStack, EntityPlayer entityPlayer, World world, int blockX, int blockY,
		int blockZ, int blockSide, float pointX, float pointY, float pointZ) {
	if (!entityPlayer.canPlayerEdit(blockX, blockY, blockZ, blockSide, itemStack)) {
		return false;
	} else {
		UseSandRakeEvent event = new UseSandRakeEvent(entityPlayer, itemStack, world, blockX, blockY, blockZ);
		if (MinecraftForge.EVENT_BUS.post(event)) {
			return false;
		}

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

		Block block = world.getBlock(blockX, blockY, blockZ);
		if (blockSide != 0 && world.getBlock(blockX, blockY + 1, blockZ).isAir(world, blockX, blockY + 1, blockZ)
				&& (block == ModBlocks.blockBlackSand)) {
			Block sand = Blocks.sand;
			Block farmSand = ModBlocks.blockFarmsand;
			world.playSoundEffect((double) ((float) blockX + 0.5F), (double) ((float) blockY + 0.5F),
					(double) ((float) blockZ + 0.5F), sand.stepSound.getStepResourcePath(),
					(sand.stepSound.getVolume() + 1.0F) / 2.0F, sand.stepSound.getPitch() * 0.8F);

			if (world.isRemote) {
				return true;
			} else {
				world.setBlock(blockX, blockY, blockZ, farmSand);
				itemStack.damageItem(1, entityPlayer);
				return true;
			}
		} else {
			return false;
		}
	}
}
 
開發者ID:GilliganCraft,項目名稱:GilliganCraft,代碼行數:40,代碼來源:ItemSandRake.java

示例6: applyBonemeal

public static boolean applyBonemeal(World world, int x, int y, int z, EntityPlayer player)
{
	Block block = world.getBlock(x, y, z);

	BonemealEvent event = new BonemealEvent(player, world, block, x, y, z);
	if (MinecraftForge.EVENT_BUS.post(event))
	{
		return false;
	}

	if (event.getResult() == Result.ALLOW)
	{
		return true;
	}

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

		if (igrowable.func_149851_a(world, x, y, z, world.isRemote))
		{
			if (!world.isRemote)
			{
				if (igrowable.func_149852_a(world, world.rand, x, y, z))
				{
					igrowable.func_149853_b(world, world.rand, x, y, z);
				}
			}

			return true;
		}
	}

	return false;
}
 
開發者ID:wuppy29,項目名稱:WuppyMods,代碼行數:35,代碼來源:EntityBonemealBottle.java

示例7: 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.func_70641_bl();
}
 
開發者ID:SchrodingersSpy,項目名稱:TRHS_Club_Mod_2016,代碼行數:6,代碼來源:ForgeEventFactory.java

示例8: 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:alexandrage,項目名稱:CauldronGit,代碼行數:6,代碼來源:ForgeEventFactory.java

示例9: isGenerationAllowed

private static boolean isGenerationAllowed(final DecorateBiomeEvent.Decorate event) {
	return (event.getResult() == Result.ALLOW || event.getResult() == Result.DEFAULT)
			&& event.type == EventType.FLOWERS && isGenAllowedInDimension(event.world.provider.dimensionId);
}
 
開發者ID:OreCruncher,項目名稱:ThermalRecycling,代碼行數:4,代碼來源:BiomeDecorationHandler.java

示例10: 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
 */
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
{
    if(this.hasEnoughEnergyAndMode(stack, energyCostUseSmall, Mode.HOE)) {
        //if(this.getMode(stack) == Mode.HOE) {
        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)
            {
                this.consumePower(stack, player, energyCostUseSmall);
                //stack.damageItem(1, player);
                return true;
            }

            Block block = world.getBlock(x, y, z);

            if (side != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.grass || block == Blocks.dirt))
            {
                Block block1 = Blocks.farmland;
                world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);

                if (world.isRemote)
                {
                    return true;
                }
                else
                {
                    world.setBlock(x, y, z, block1);
                    //stack.damageItem(1, player);
                    this.consumePower(stack, player, energyCostUseSmall);
                    return true;
                }
            }
            else
            {
                return false;
            }
        }
    }
    return super.onItemUse(stack, player, world, x, y, z, side, hitX, hitY, hitZ);
}
 
開發者ID:katzenpapst,項目名稱:amunra,代碼行數:55,代碼來源:ItemNanotool.java

示例11: onItemUse

@Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int side, float entityX, float entityY, float entityZ)
{
	if(!entityplayer.canPlayerEdit(x, y, z, side, itemstack))
	{
		return false;
	}
	else {
		UseHoeEvent event = new UseHoeEvent(entityplayer, itemstack, world, x, y, z);

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

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

		Block blockID = world.getBlock(x, y, z);
		Block aboveBlock = world.getBlock(x, y + 1, z);

		if((side == 0 || !aboveBlock.isAir(world, x, y, z+1) || blockID != Blocks.grass) && blockID != Blocks.dirt)
		{
			return false;
		}
		else {
			Block block = Blocks.farmland;
			world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.getStepResourcePath(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);

			if(world.isRemote)
			{
				return true;
			}
			else {
				world.setBlock(x, y, z, block);
				itemstack.damageItem(1, entityplayer);
				return true;
			}
		}
	}
}
 
開發者ID:Microsoft,項目名稱:vsminecraft,代碼行數:44,代碼來源:ItemMekanismHoe.java

示例12: useHoe

private boolean useHoe(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side)
{
	if(!player.canPlayerEdit(x, y, z, side, stack) || (!player.capabilities.isCreativeMode && getEnergy(stack) < HOE_USAGE))
	{
		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)
		{
			setEnergy(stack, getEnergy(stack)-HOE_USAGE);
			return true;
		}

		Block block1 = world.getBlock(x, y, z);
		boolean air = world.isAirBlock(x, y + 1, z);

		if(side != 0 && air && (block1 == Blocks.grass || block1 == Blocks.dirt))
		{
			Block farm = Blocks.farmland;
			world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, farm.stepSound.getStepResourcePath(), (farm.stepSound.getVolume() + 1.0F) / 2.0F, farm.stepSound.getPitch() * 0.8F);

			if(world.isRemote)
			{
				return true;
			}
			else {
				world.setBlock(x, y, z, farm);
				
				if(!player.capabilities.isCreativeMode)
				{
					setEnergy(stack, getEnergy(stack)-HOE_USAGE);
				}
				
				return true;
			}
		}
		else {
			return false;
		}
	}
}
 
開發者ID:Microsoft,項目名稱:vsminecraft,代碼行數:48,代碼來源:ItemAtomicDisassembler.java

示例13: onItemUse

@Override
  public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10)
  {
// TODO: Make sure this works right.. They can break from this.
      if ( !player.canPlayerEdit( x, y, z, par7, stack ) )
      {
          return false;
      }
      
      UseHoeEvent event = new UseHoeEvent( player, stack, world, x, y, z );
      if ( MinecraftForge.EVENT_BUS.post( event ) )
      {
          return false;
      }

      if ( event.getResult() == Result.ALLOW )
      {
          damageItemStack( player, stack, 1 );
          return true;
      }

      Block i1 = world.getBlock(x, y, z);
      Block j1 = world.getBlock(x, y + 1, z);

      if ((par7 == 0 || j1 != air || i1 != grass) && i1 != dirt)
      {
          return false;
      }
      else
      {
          Block block = farmland;
          world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), block.stepSound.soundName, (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);

          if (world.isRemote)
          {
              return true;
          }
          else
          {
              world.setBlock(x, y, z, block);
              damageItemStack( player, stack, 1 );
              return true;
          }
      }
  }
 
開發者ID:spacechase0,項目名稱:ComponentEquipment,代碼行數:45,代碼來源:HoeItem.java

示例14: onItemUse

@Override
public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_)
   {
       if (!p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_))
       {
           return false;
       }
       else
       {
           UseHoeEvent event = new UseHoeEvent(p_77648_2_, p_77648_1_, p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_);
           if (MinecraftForge.EVENT_BUS.post(event))
           {
               return false;
           }

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

           Block block = p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_);

           if (p_77648_7_ != 0 && p_77648_3_.getBlock(p_77648_4_, p_77648_5_ + 1, p_77648_6_).isAir(p_77648_3_, p_77648_4_, p_77648_5_ + 1, p_77648_6_) && (block == Blocks.grass || block == Blocks.dirt))
           {
               Block block1 = IlluminatedBlocks.illuminatedFarmland;
               p_77648_3_.playSoundEffect((double)((float)p_77648_4_ + 0.5F), (double)((float)p_77648_5_ + 0.5F), (double)((float)p_77648_6_ + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);

               if (p_77648_3_.isRemote)
               {
                   return true;
               }
               else
               {
                   p_77648_3_.setBlock(p_77648_4_, p_77648_5_, p_77648_6_, block1);
                   p_77648_1_.damageItem(1, p_77648_2_);
                   return true;
               }
           }
           else
           {
               return false;
           }
       }
   }
 
開發者ID:MikeLydeamore,項目名稱:IlluminatedBows,代碼行數:45,代碼來源:ItemIlluminatedPotathoe.java

示例15: 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 p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_)
{
    if (!p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_))
    {
        return false;
    }
    else
    {
        UseHoeEvent event = new UseHoeEvent(p_77648_2_, p_77648_1_, p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_);
        if (MinecraftForge.EVENT_BUS.post(event))
        {
            return false;
        }

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

        Block block = p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_);

        if (p_77648_7_ != 0 && p_77648_3_.getBlock(p_77648_4_, p_77648_5_ + 1, p_77648_6_).isAir(p_77648_3_, p_77648_4_, p_77648_5_ + 1, p_77648_6_) && (block == Blocks.grass || block == Blocks.dirt))
        {
            Block block1 = Blocks.farmland;
            p_77648_3_.playSoundEffect((double)((float)p_77648_4_ + 0.5F), (double)((float)p_77648_5_ + 0.5F), (double)((float)p_77648_6_ + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);

            if (p_77648_3_.isRemote)
            {
                return true;
            }
            else
            {
                p_77648_3_.setBlock(p_77648_4_, p_77648_5_, p_77648_6_, block1);
                p_77648_1_.damageItem(1, p_77648_2_);
                return true;
            }
        }
        else
        {
            return false;
        }
    }
}
 
開發者ID:NovaViper,項目名稱:ZeroQuest,代碼行數:48,代碼來源:ItemNileHoe.java


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