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


Java HarvestDropsEvent.getWorld方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: onHarvestDrops

import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入方法依赖的package包/类
/** Harvest the drops and call sub-events */
@SubscribeEvent
public void onHarvestDrops(HarvestDropsEvent e) {
	tool = null; // always reset this
	if(!e.getWorld().isRemote) {
		if(!onBlockDropSmelt(e)) {
			mysticFortuneIncrease(e);
		}
	}
}
 
开发者ID:sblectric,项目名称:LightningCraft,代码行数:11,代码来源:ToolEvents.java

示例6: onHarvestDropsEvent

import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHarvestDropsEvent(HarvestDropsEvent event) {
  if (event.getState() != null && event.getState().getBlock() instanceof BlockDimensionOre) {
    //then try spawning mob
    //EntityPlayer player = event.getPlayer();
    BlockPos pos = event.getPos();
    World world = event.getWorld();
    BlockDimensionOre block = (BlockDimensionOre) event.getState().getBlock();
    block.trySpawnTriggeredEntity(world, pos);
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:12,代码来源:WorldModule.java

示例7: onBlockHarvest

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

  if (!Config.direSlimeEnabled || event.isCanceled() || event.getWorld() == null || event.getWorld().isRemote) {
    return;
  }
  if (event.getHarvester() == null || event.getHarvester().capabilities.isCreativeMode) {
    return;
  }

  if (!(event.getState().getBlock() instanceof BlockDirt || event.getState().getBlock() instanceof BlockGrass)) {
    return;
  }

  if (!isToolEffective(event.getState(), event.getHarvester().getHeldItemMainhand())) {

    if (Config.direSlimeChance < event.getWorld().rand.nextFloat()) {
      return;
    }

    EntityDireSlime direSlime = new EntityDireSlime(event.getWorld());
    direSlime.setPosition(event.getPos().getX() + 0.5, event.getPos().getY() + 0.0, event.getPos().getZ() + 0.5);
    event.getWorld().spawnEntity(direSlime);
    direSlime.playLivingSound();
    for (ItemStack drop : event.getDrops()) {
      if (drop != null && drop.getItem() != null && drop.getItem() == Item.getItemFromBlock(Blocks.DIRT)) {
        if (drop.getCount() > 1) {
          drop.shrink(1);
        } else if (event.getDrops().size() == 1) {
          event.getDrops().clear();
        } else {
          event.getDrops().remove(drop);
        }
        return;
      }
    }
  }
}
 
开发者ID:SleepyTrousers,项目名称:EnderZoo,代码行数:39,代码来源:MobSpawnEventHandler.java

示例8: thisToolWasUsed

import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入方法依赖的package包/类
private boolean thisToolWasUsed(HarvestDropsEvent event) {
	return event.getHarvester() != null && event.getHarvester().getHeldItemMainhand() != null
			&& event.getHarvester().getHeldItemMainhand().getItem() == INSTANCE && !event.getWorld().isRemote;
}
 
开发者ID:ToroCraft,项目名称:ToroQuest,代码行数:5,代码来源:ItemPickaxeOfGreed.java

示例9: onBlockDropSmelt

import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入方法依赖的package包/类
/** Auto-smelt blocks when using a skyfather tool */
private boolean onBlockDropSmelt(HarvestDropsEvent e) {
	if(e.getHarvester() != null && LCConfig.autoSmelt) {
		int fortuneLevel = e.getFortuneLevel() + defBonus;
		
		// get the held item and make sure it isn't null!
		// 1.1.2 fix
		tool = e.getHarvester().inventory.getCurrentItem();
		if(e.getHarvester().inventory.getCurrentItem() == null) {
			return false;
		}
		
		Item itool = tool.getItem();
		
		// auto smelt with the pick, axe, and shovel
		// but not when sneaking! Also, not with silk touch
		if((itool instanceof ItemSkyAxe || itool instanceof ItemSkyPick || itool instanceof ItemSkySpade) 
				&& !e.isSilkTouching() && !e.getHarvester().isSneaking()) {
			ItemStack result = FurnaceRecipes.instance().getSmeltingResult(
					new ItemStack(e.getState().getBlock(), 1, e.getState().getBlock().getMetaFromState(e.getState())));
			if (result != null) {
				// depending on fortune, release smelted ores
				// 1.4.1 fix: no fortune on block items!
				int nItems;
				int nParticles = 2;
				if(fortuneLevel > 0 && !(result.getItem() instanceof ItemBlock)) {
					nItems = 1 + random.nextInt(fortuneLevel + (itool instanceof IMysticGear ? 1 : 0)); // only Mystic has Luck
				} else {
					nItems = 1;
				}
				for(int i = 0; i < nItems; i++) {
					float f = random.nextFloat() * 0.6F + 0.1F;
					float f1 = random.nextFloat() * 0.6F + 0.1F;
					float f2 = random.nextFloat() * 0.6F + 0.1F;
					float f3 = 0.025F;
					EntityItem eitem = new EntityItem(e.getWorld(), 
							e.getPos().getX() + f, e.getPos().getY() + f1, e.getPos().getZ() + f2, result.copy());
					eitem.motionX = random.nextGaussian() * f3;
					eitem.motionY = random.nextGaussian() * f3 + 0.2F;
					eitem.motionZ = random.nextGaussian() * f3;
					e.getWorld().spawnEntityInWorld(eitem);
					tool.damageItem(1, e.getHarvester()); // +1 damage per ore obtained
					// spawn particles at this position
					for(int j = 0; j < nParticles; j++) {
						double rx = eitem.posX + random.nextFloat() - 0.5;
						double ry = eitem.posY + (random.nextFloat() + 0.5) * 0.15;
						double rz = eitem.posZ + random.nextFloat() - 0.5;							
						LCNetwork.net.sendToAll(new MessageSpawnParticle("flame", rx, ry, rz, 0, 0, 0));
					}
				}
				
				// cancel the default drops
				e.setDropChance(0);
				return true;
			}
			
		}
		
	}
	return false;
}
 
开发者ID:sblectric,项目名称:LightningCraft,代码行数:62,代码来源:ToolEvents.java


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