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


Java HarvestDropsEvent类代码示例

本文整理汇总了Java中net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent的典型用法代码示例。如果您正苦于以下问题:Java HarvestDropsEvent类的具体用法?Java HarvestDropsEvent怎么用?Java HarvestDropsEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: harvestDrops

import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
@SubscribeEvent
public void harvestDrops(HarvestDropsEvent event) {
	if (!ToroQuestConfiguration.cropsAffectRep) {
		return;
	}
	if (isCrop(event.getState().getBlock())) {
		BlockPos pos = event.getPos();
		AxisAlignedBB bb = new AxisAlignedBB(pos);
		List<EntityPlayer> players = event.getWorld().getEntitiesWithinAABB(EntityPlayer.class, bb);
		if (players != null && players.size() > 0) {
			for (EntityPlayer player : players) {
				adjustPlayerRep(player, pos.getX() / 16, pos.getZ() / 16, -getFarmRepAmount(event.getWorld().rand));
			}
		}
	}
}
 
开发者ID:ToroCraft,项目名称:ToroQuest,代码行数:17,代码来源:CivilizationHandlers.java

示例2: limitEnderBlockDropsInTheTeletory

import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
@SubscribeEvent
public void limitEnderBlockDropsInTheTeletory(HarvestDropsEvent event) {

	if (!isEnderBlock(event)) {
		return;
	}

	EntityPlayer player = event.getHarvester();

	if (player == null || player.dimension != Teletory.DIMID) {
		return;
	}

	List<ItemStack> drops = event.getDrops();
	List<ItemStack> dropsToRemove = new ArrayList<ItemStack>(drops.size());

	Random rand = event.getWorld().rand;

	for (ItemStack drop : drops) {
		if (rand.nextInt(10) > 2) {
			dropsToRemove.add(drop);
		}
	}

	drops.removeAll(dropsToRemove);
}
 
开发者ID:ToroCraft,项目名称:TeleToro,代码行数:27,代码来源:Teletory.java

示例3: mysticFortuneIncrease

import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
/** Apply a fortune increase to mystic tools */
private void mysticFortuneIncrease(HarvestDropsEvent e) {
	if(tool != null && tool.getItem() instanceof IMysticGear) {
		
		// override vanilla fortune handling here
           int i = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, tool) + mysticBonus;
           Block block = e.getState().getBlock();
           if(!e.getWorld().restoringBlockSnapshots) {
               for (ItemStack item : block.getDrops(e.getWorld(), e.getPos(), e.getState(), i)) {
                   if (e.getWorld().rand.nextFloat() <= e.getDropChance()) {
                       Block.spawnAsEntity(e.getWorld(), e.getPos(), item.copy());
                   }
               }
           }
		
		// cancel the default drops
		e.setDropChance(0);
	}
}
 
开发者ID:sblectric,项目名称:LightningCraft,代码行数:20,代码来源:ToolEvents.java

示例4: onDrop

import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
@SubscribeEvent
public void onDrop(HarvestDropsEvent event){
	if(Config.IsToolsEnabled&&!event.getWorld().isRemote&&event.getHarvester()!=null&&isBlazonium(event.getHarvester())){
		for(int i=0;i<event.getDrops().size();i++){
			if(event.getDrops().get(i)!=null){
				if(FurnaceRecipes.instance().getSmeltingResult(event.getDrops().get(i))!=null){
					event.getDrops().set(i, FurnaceRecipes.instance().getSmeltingResult(event.getDrops().get(i)).copy());
				}
			}
		}
	}
	if(Config.IsToolsEnabled&&!event.getWorld().isRemote&&event.getHarvester()!=null&&isEmerald(event.getHarvester())){
		if(event.isSilkTouching()==false&&event.getFortuneLevel()<=Config.MaxGreed){
			List<ItemStack> list=event.getDrops();
			list.clear();
			List<ItemStack> newlist=event.getState().getBlock().getDrops(event.getWorld(), event.getPos(), event.getState(), event.getFortuneLevel()+1);
			for(int i=0;i<newlist.size();i++){
				list.add(newlist.get(i).copy());
			}
		}
	}
}
 
开发者ID:EnderiumSmith,项目名称:Nuclear-Foundation,代码行数:23,代码来源:EventHandler.java

示例5: doBonusDrops

import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
/**
 * Gives a chance for bonus drops to happen depending on dropChance
 * 
 * @param event
 * @param dropChance
 */
public void doBonusDrops(HarvestDropsEvent event, float dropChance)
{
	
	List<ItemStack> dropList = new ArrayList();
	System.out.println("DropListB:"+ event.drops.size());
	
	Iterator<ItemStack> it = event.drops.iterator();
	Random rand = new Random();
	ItemStack item;
	while(it.hasNext())
	{
		item = it.next();
		System.out.println("increase items:"+ item.getDisplayName());
		if(rand.nextFloat() < dropChance)
		{
			dropList.add(item.copy());
		}
	}
	event.drops.addAll(dropList);
	System.out.println("DropListA:"+ event.drops.size());

}
 
开发者ID:GenDeathrow,项目名称:Skills,代码行数:29,代码来源:ResourceGatheringBase.java

示例6: onBlockHarvest

import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
@SubscribeEvent
public void onBlockHarvest(HarvestDropsEvent event) {
	if (event.harvester != null) {
		Block block = event.state.getBlock();
		if (block == Blocks.dirt || block == Blocks.grass) {
			if (event.harvester.getCurrentArmor(ArmorIndex.WORN_HELM) != null && event.harvester.getCurrentArmor(ArmorIndex.WORN_HELM).getItem() == ZSSItems.maskScents && event.world.rand.nextInt(32) == 0) {
				event.drops.add(event.world.rand.nextInt(4) == 0 ? new ItemStack(Blocks.red_mushroom) : new ItemStack(Blocks.brown_mushroom));
			}
		} else if (block == Blocks.tallgrass) {
			if (PlayerUtils.isSword(event.harvester.getHeldItem()) && event.world.rand.nextFloat() < Config.getGrassDropChance()) {
				event.drops.add(ZSSItems.getRandomGrassDrop(event.world.rand));
			}
		} else if (block == Blocks.iron_ore) {
			if (event.world.rand.nextFloat() < (0.005F * event.fortuneLevel)) {
				event.drops.add(new ItemStack(ZSSItems.masterOre));
				event.harvester.worldObj.playSoundEffect(event.harvester.posX, event.harvester.posY, event.harvester.posZ, Sounds.SPECIAL_DROP, 1.0F, 1.0F);
			}
		}
	}
}
 
开发者ID:coolAlias,项目名称:ZeldaSwordSkills,代码行数:21,代码来源:ZSSItemEvents.java

示例7: onBlockDrop

import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
@SubscribeEvent
public void onBlockDrop(HarvestDropsEvent event) {
	if (event.block == GameRegistry.findBlock("derpyshiz", "log")) {
		if (event.harvester == null)
			return;
		event.drops.removeAll(event.drops);
		ItemStack is = event.harvester.getHeldItem();
		if (is == null) {
			event.drops.add(this.dropsHand[event.blockMetadata % 2].get());
		} else {
			int hl = is.getItem().getHarvestLevel(is, "axe");
			if (hl < 0) {
				event.drops.add(this.dropsHand[event.blockMetadata % 2].get());
				return;
			}
			if (hl > 3)
				hl = 3;
			event.drops.add(this.dropsPerLevel[hl][event.blockMetadata % 2].get());
		}
	} else if (event.block == GameRegistry.findBlock("derpyshiz", "ore") && event.blockMetadata == DerpyOres.darknessIndex) {
		if (event.world.getBlockLightValue(event.x, event.y, event.z) != 0) {
			event.drops.clear();
		}
	}
}
 
开发者ID:Wuerfel21,项目名称:The-Derpy-Shiz-Mod,代码行数:26,代码来源:DerpyEvents.java

示例8: OnBlockBreak

import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
@SubscribeEvent
public void OnBlockBreak(HarvestDropsEvent event) {
	if(event.harvester != null && event.harvester.getHeldItem() != null && event.harvester.getHeldItem().getItem() != null) {
		if(event.harvester.getHeldItem().getItem() instanceof ItemTool && ((ItemTool) event.harvester.getHeldItem().getItem()).func_150913_i() == ModTools.FYRESTONE && !event.isSilkTouching) {
			if(FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(event.block.getItemDropped(event.blockMetadata, event.world.rand, event.fortuneLevel))) != null) {
				event.drops.clear();
				event.world.playSoundAtEntity(event.harvester, "random.fizz", 0.7f, 1.6f);
				event.drops.add(new ItemStack(FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(event.block.getItemDropped(event.blockMetadata, event.world.rand, event.fortuneLevel))).getItem(), 1, FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(event.block.getItemDropped(event.blockMetadata, event.world.rand, event.fortuneLevel))).getItemDamage()));
			} else if(event.block.isFlammable(event.world, event.x, event.y, event.z, ForgeDirection.WEST)) {
				event.drops.clear();
				event.world.playSoundAtEntity(event.harvester, "random.fizz", 0.7f, 1.6f);
			}
		} else if(event.harvester.getHeldItem().getItem() instanceof ItemTool && ((ItemTool) event.harvester.getHeldItem().getItem()).func_150913_i() == ModTools.VOIDIUM) {
			event.drops.clear();
			event.world.playSoundAtEntity(event.harvester, "mob.endermen.portal", 1.0f, 1.6f);
		}
	}
}
 
开发者ID:OmgImAlexis,项目名称:TheStuffMod,代码行数:19,代码来源:BlockBreakHandler.java

示例9: onHarvestDrops

import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
@SubscribeEvent
public void onHarvestDrops(HarvestDropsEvent event) {
	if ((event.block != Blocks.gravel) || event.isSilkTouching)
		return;
	
	double chance = 0;
	ItemStack holding = ((event.harvester != null) ? event.harvester.getCurrentEquippedItem() : null);
	ItemTool tool = (((holding != null) && (holding.getItem() instanceof ItemTool)) ? (ItemTool)holding.getItem() : null);
	
	if ((tool != null) && tool.getToolClasses(holding).contains("shovel")) {
		chance = 0.35 - tool.getHarvestLevel(holding, "shovel") * 0.15;
		if (event.fortuneLevel > 0)
			chance += event.fortuneLevel * 0.15;
	}
	
	event.drops.clear();
	event.drops.add(RandomUtils.getBoolean(chance)
			? new ItemStack(Items.flint) : new ItemStack(Blocks.gravel));
}
 
开发者ID:copygirl,项目名称:copyVanillaTweaks,代码行数:20,代码来源:GravelFlintDropHandler.java

示例10: onDrop

import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
@SubscribeEvent
public void onDrop(HarvestDropsEvent event)
{
	if(event.harvester == null)
		return ;
	ArrayList<EnchantmentModifier> modifiers = CraftMaterial.getModifiers(event.harvester.getHeldItem());
   	for (int i = 0; i < modifiers.size(); i++) {
   		modifiers.get(i).onHarvestBlockPre(event.harvester, event.world, event.x, event.y, event.z, event.blockMetadata, event.block, event.drops);
   	}
   	
   	for (int i = 0; i < modifiers.size(); i++) {
   		modifiers.get(i).onHarvestBlock(event.harvester, event.world, event.x, event.y, event.z, event.blockMetadata, event.block, event.drops);
   	}
   	
   	for (int i = 0; i < modifiers.size(); i++) {
   		modifiers.get(i).onHarvestBlockPost(event.harvester, event.world, event.x, event.y, event.z, event.blockMetadata, event.block, event.drops);
   	}
   	
}
 
开发者ID:CreativeMD,项目名称:RandomAdditions,代码行数:20,代码来源:EventHandlerRandom.java

示例11: blockHarvestDrops

import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
@Override
public void blockHarvestDrops(ItemStack tool, HarvestDropsEvent event) {
  if (ToolHelper.isToolEffective2(tool, event.getState())) {
    ModifierNBT data = new ModifierNBT(TinkerUtil.getModifierTag(tool, name));
    BlockPos pos = event.getPos();
    final World world = event.getWorld();
    for (Iterator<ItemStack> iterator = event.getDrops().iterator(); iterator.hasNext();) {
      ItemStack next = iterator.next().copy();
      if (world != null && random.nextFloat() <= event.getDropChance()) {
        if (random.nextFloat() < (data.level * .21f)) {
          RandomTeleportUtil.teleportSpawnItem(world, pos, next);
          iterator.remove();
        }
      } else {
        iterator.remove();
      }
    }
    event.setDropChance(1); // we already implemented the drop chance
  }
}
 
开发者ID:SleepyTrousers,项目名称:EnderIO,代码行数:21,代码来源:TraitTeleport.java

示例12: blockHarvestDrops

import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
@Override
public void blockHarvestDrops(ItemStack tool, HarvestDropsEvent event) {
  if (ToolHelper.isToolEffective2(tool, event.getState())) {
    for (Iterator<ItemStack> iterator = event.getDrops().iterator(); iterator.hasNext();) {
      ItemStack next = iterator.next().copy();
      if (random.nextFloat() <= event.getDropChance()) {
        if (event.getHarvester().inventory.addItemStackToInventory(next)) {
          iterator.remove();
        }
      } else {
        iterator.remove();
      }
    }
    event.setDropChance(1); // we already implemented the drop chance
  }
}
 
开发者ID:SleepyTrousers,项目名称:EnderIO,代码行数:17,代码来源:TraitPickup.java

示例13: onHarvestDropsEvent

import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.NORMAL)
public void onHarvestDropsEvent(HarvestDropsEvent event){
    // System.out.println("Block: " + event.getState().getBlock().getUnlocalizedName());
    if (event.getState().getBlock() == Blocks.DIAMOND_ORE){
        int random_number = (int) (Math.random() * 5);
        System.out.println(random_number);
        if (random_number == 4) {
            event.getDrops().clear();
            event.getDrops().add(new ItemStack(ModItems.crackeddiamond));
        }
    }
}
 
开发者ID:DeflatedPickles-Old-Repositories,项目名称:JustJunk,代码行数:13,代码来源:EventHandlerCommon.java

示例14: notCurrentDepth

import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
protected boolean notCurrentDepth(HarvestDropsEvent event, QuestData data) {
	int max = getMaxDepth(data);
	int min = getMinDepth(data);
	int y = event.getPos().getY();

	if (min > 0 && y < min) {
		return true;
	}

	if (max > 0 && y > max) {
		return true;
	}

	return false;
}
 
开发者ID:ToroCraft,项目名称:ToroQuest,代码行数:16,代码来源:QuestMine.java

示例15: onBlockBreak

import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onBlockBreak(HarvestDropsEvent event)
{
	if (!event.isSilkTouching())
	{
		BlockPos pos = event.getPos();
		int fortuneBonus = 0;
		for (int x = -16; x <= 16; x++)
			for (int z = -16; z <= 16; z++)
				for (int y = -8; y <= 8; y++)
					if (event.getWorld().getBlockState(pos.add(x, y, z)).getBlock() == Blocks.BEACON)
					{
						Block block = event.getWorld().getBlockState(pos.add(x, y, z).down()).getBlock();
						if (block == Blocks.IRON_BLOCK)
							fortuneBonus = Math.max(fortuneBonus, 1);
						else if (block == Blocks.GOLD_BLOCK)
							fortuneBonus = Math.max(fortuneBonus, 2);
						else if (block == Blocks.DIAMOND_BLOCK)
							fortuneBonus = Math.max(fortuneBonus, 3);
						else if (block == Blocks.EMERALD_BLOCK)
							fortuneBonus = Math.max(fortuneBonus, 4);
					}
		List<ItemStack> drops = event.getDrops();
		drops.clear();
		drops.addAll(event.getState().getBlock().getDrops(event.getWorld(), event.getPos(), event.getState(), event.getFortuneLevel() + fortuneBonus));
	}
}
 
开发者ID:murapix,项目名称:Inhuman-Resources,代码行数:29,代码来源:EventHandler.java


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