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


Java HarvestDropsEvent.getHarvester方法代码示例

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


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

示例3: onHarvestDrop

import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHarvestDrop(HarvestDropsEvent event) {
    EntityPlayer player = event.getHarvester();
    if (player != null) {
        Iterator<ItemStack> it = event.getDrops().iterator();
        while (it.hasNext()) {
            ItemStack stack = it.next();
            if (ProgressionEvents.isEventCancelled(player, ActionType.HARVESTDROPWITH, player.getHeldItemMainhand(), ActionType.HARVESTDROP, stack)) {
                it.remove();
            }
        }
    }
}
 
开发者ID:joshiejack,项目名称:Progression,代码行数:14,代码来源:ActionHarvestDrop.java

示例4: onHarvestDropsEvent

import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHarvestDropsEvent(HarvestDropsEvent event)
{
    if (event.getHarvester() != null)
    {
        ItemStack stack = event.getHarvester().getHeldItemMainhand();

        if (stack.isEmpty() == false && stack.getItem() instanceof ItemEnderTool)
        {
            ((ItemEnderTool) stack.getItem()).handleHarvestDropsEvent(stack, event);
        }
    }
}
 
开发者ID:maruohon,项目名称:enderutilities,代码行数:14,代码来源:BlockEventHandler.java

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

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

示例7: onMine

import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onMine(HarvestDropsEvent event) {
	if (event.getHarvester() == null) {
		return;
	}

	EntityPlayer player = event.getHarvester();
	Province inProvince = loadProvince(event.getHarvester().world, event.getPos());

	if (inProvince == null || inProvince.civilization == null) {
		return;
	}

	ItemStack tool = player.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND);

	if (!tool.hasTagCompound()) {
		return;
	}

	String questId = tool.getTagCompound().getString("mine_quest");
	String provinceId = tool.getTagCompound().getString("province");

	if (questId == null || provinceId == null || !provinceId.equals(inProvince.id.toString())) {
		return;
	}

	QuestData data = getQuestById(player, questId);

	if (data == null) {
		return;
	}

	if (notCurrentDepth(event, data)) {
		return;
	}

	if (event.getState().getBlock() != BLOCK_TYPES[getBlockType(data)]) {
		return;
	}

	event.setDropChance(1f);
	for (ItemStack drop : event.getDrops()) {
		drop.setTagInfo("mine_quest", new NBTTagString(questId));
		drop.setTagInfo("province", new NBTTagString(provinceId));
		drop.setStackDisplayName(drop.getDisplayName() + " for " + inProvince.name);
	}
}
 
开发者ID:ToroCraft,项目名称:ToroQuest,代码行数:48,代码来源:QuestMine.java

示例8: 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.getHarvester方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。