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


Java ForgeEventFactory.fireBlockHarvesting方法代碼示例

本文整理匯總了Java中net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting方法的典型用法代碼示例。如果您正苦於以下問題:Java ForgeEventFactory.fireBlockHarvesting方法的具體用法?Java ForgeEventFactory.fireBlockHarvesting怎麽用?Java ForgeEventFactory.fireBlockHarvesting使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraftforge.event.ForgeEventFactory的用法示例。


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

示例1: update

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
@Override
public void update() {
	if(!worldObj.isRemote && !worldObj.isBlockPowered(pos) && worldObj.getTotalWorldTime() % breakModTime == 0 && 
			this.hasLPCell() && this.canDrawCellPower(breakLE)) {
		BlockPos check = this.pos.offset(EnumFacing.getFront(this.getBlockMetadata()));
		
		// make sure the block is valid and isn't unbreakable
		IBlockState checkState = worldObj.getBlockState(check);
		Block checkBlock = checkState.getBlock();
		if(checkBlock != null && !checkBlock.isAir(checkState, worldObj, check) && checkState.getBlockHardness(worldObj, check) >= 0) {
			List<ItemStack> drops = checkBlock.getDrops(this.worldObj, check, checkState, 0);
            float chance = ForgeEventFactory.fireBlockHarvesting(drops, this.worldObj, check, 
            		this.worldObj.getBlockState(check), 0, 1, false, null);
            if(random.nextFloat() <= chance) {
            	this.drawCellPower(breakLE);
            	worldObj.destroyBlock(check, true);
            }
		}
	}
}
 
開發者ID:sblectric,項目名稱:LightningCraft,代碼行數:21,代碼來源:TileEntityLightningBreaker.java

示例2: dropBlockAsItemWithChance

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
@Override
public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_)
{
    if (!p_149690_1_.isRemote)
    {
        ArrayList<ItemStack> items = getDrops(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_7_);
        p_149690_6_ = ForgeEventFactory.fireBlockHarvesting(items, p_149690_1_, this, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_7_, p_149690_6_, false, harvesters.get());

        for (ItemStack item : items)
        {
            if (p_149690_1_.rand.nextFloat() <= p_149690_6_)
            {
                this.dropBlockAsItem(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, item);
            }
        }
    }
}
 
開發者ID:NovaViper,項目名稱:ZeroQuest,代碼行數:18,代碼來源:BlockNileGrainOre.java

示例3: removedByPlayer

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
@Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) {
	ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
	TileEntityMetadata tile = (TileEntityMetadata) getTileEntity(world, x, y, z);
	if(tile != null && !tile.hasDroppped) {
		drops = world.getBlock(x, y, z).getDrops(world, x, y, z, tile.getTileMetadata(), EnchantmentHelper.getFortuneModifier(player));
	}
	boolean hasBeenBroken = world.setBlockToAir(x, y, z);
	if(hasBeenBroken && !world.isRemote) {
		if(drops.size() > 0 && (player == null || !player.capabilities.isCreativeMode) && shouldDropItems(world, x, y, z, tile.getTileMetadata(), player, player.getCurrentEquippedItem())) {
			float chance = ForgeEventFactory.fireBlockHarvesting(drops, world, this, x, y, z, tile.getTileMetadata(), EnchantmentHelper.getFortuneModifier(player), 1.0F, false, player);
			for(ItemStack drop : drops) {
				if(world.rand.nextFloat() <= chance) {
					dropBlockAsItem(world, x, y, z, drop);
				}
			}
		}
		tile.hasDroppped = true;
	}
	return hasBeenBroken;
}
 
開發者ID:ElConquistador,項目名稱:ElConQore,代碼行數:22,代碼來源:BlockExtendedMetadata.java

示例4: removedByPlayer

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
@Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) {
	ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
	TileEntityExtended tile = (TileEntityExtended) getTileEntity(world, x, y, z);
	if(tile != null && !tile.hasDroppped) {
		drops = world.getBlock(x, y, z).getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), EnchantmentHelper.getFortuneModifier(player));
	}
	boolean hasBeenBroken = world.setBlockToAir(x, y, z);
	if(hasBeenBroken && !world.isRemote && drops.size() > 0 && (player == null || !player.capabilities.isCreativeMode)) {
		float chance = ForgeEventFactory.fireBlockHarvesting(drops, world, this, x, y, z, world.getBlockMetadata(x, y, z), EnchantmentHelper.getFortuneModifier(player), 1.0F, false, player);
		for(ItemStack drop : drops) {
			if(world.rand.nextFloat() <= chance) {
				dropBlockAsItem(world, x, y, z, drop);
			}
		}
		tile.hasDroppped = true;
	}
	return hasBeenBroken;
}
 
開發者ID:ElConquistador,項目名稱:ElConQore,代碼行數:20,代碼來源:BlockExtendedContainer.java

示例5: dropBlockAsItemWithChance

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_)
{
    if (!p_149690_1_.isRemote && !p_149690_1_.restoringBlockStates) // Cauldron do not drop items while restoring blockstates, prevents item dupe
    {
        ArrayList<ItemStack> items = getDrops(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_7_);
        p_149690_6_ = ForgeEventFactory.fireBlockHarvesting(items, p_149690_1_, this, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_7_, p_149690_6_, false, harvesters.get());

        for (ItemStack item : items)
        {
            if (p_149690_1_.rand.nextFloat() <= p_149690_6_)
            {
                this.dropBlockAsItem(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, item);
            }
        }
    }
}
 
開發者ID:xtrafrancyz,項目名稱:Cauldron,代碼行數:17,代碼來源:Block.java

示例6: dropBlockAsItemWithChance

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_)
{
    if (!p_149690_1_.isRemote)
    {
        ArrayList<ItemStack> items = getDrops(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_7_);
        p_149690_6_ = ForgeEventFactory.fireBlockHarvesting(items, p_149690_1_, this, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_7_, p_149690_6_, false, harvesters.get());

        for (ItemStack item : items)
        {
            if (p_149690_1_.rand.nextFloat() <= p_149690_6_)
            {
                this.dropBlockAsItem(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, item);
            }
        }
    }
}
 
開發者ID:xtrafrancyz,項目名稱:Cauldron,代碼行數:17,代碼來源:Block.java

示例7: dropBlockAsItemWithChance

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
/**
 * Drops the block items with a specified chance of dropping the specified items
 */
public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7)
{
    if (!par1World.isRemote)
    {
        ArrayList<ItemStack> items = getBlockDropped(par1World, par2, par3, par4, par5, par7);
        par6 = ForgeEventFactory.fireBlockHarvesting(items, par1World, this, par2, par3, par4, par5, par7, par6, false, harvesters.get());
        
        for (ItemStack item : items)
        {
            if (par1World.rand.nextFloat() <= par6)
            {
                this.dropBlockAsItem_do(par1World, par2, par3, par4, item);
            }
        }
    }
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:20,代碼來源:Block.java

示例8: handleNormalDrops

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
protected void handleNormalDrops(World world, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te, @Nonnull ItemStack stack) {
	harvesters.set(player);
	final int fortune = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack);

	boolean addNormalDrops = true;

	if (te instanceof ICustomHarvestDrops) {
		final ICustomHarvestDrops dropper = (ICustomHarvestDrops)te;
		final List<ItemStack> drops = Lists.newArrayList();
		dropper.addHarvestDrops(player, drops, state, fortune, false);

		ForgeEventFactory.fireBlockHarvesting(drops, world, pos, state, fortune, 1.0f, false, player);
		for (ItemStack drop : drops)
			spawnAsEntity(world, pos, drop);

		addNormalDrops = !dropper.suppressBlockHarvestDrops();
	}

	if (addNormalDrops)
		dropBlockAsItem(world, pos, state, fortune);

	harvesters.set(null);
}
 
開發者ID:OpenMods,項目名稱:OpenModsLib,代碼行數:24,代碼來源:OpenBlock.java

示例9: handleSilkTouchDrops

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
protected void handleSilkTouchDrops(World world, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te) {
	List<ItemStack> items = Lists.newArrayList();

	boolean addNormalDrops = true;

	if (te instanceof ICustomHarvestDrops) {
		final ICustomHarvestDrops dropper = (ICustomHarvestDrops)te;

		dropper.addHarvestDrops(player, items, state, 0, true);
		addNormalDrops = !dropper.suppressBlockHarvestDrops();
	}

	if (addNormalDrops) {
		final ItemStack drop = new ItemStack(Item.getItemFromBlock(this), 1, damageDropped(state));
		items.add(drop);
	}

	ForgeEventFactory.fireBlockHarvesting(items, world, pos, state, 0, 1.0f, true, player);
	for (ItemStack stack : items)
		spawnAsEntity(world, pos, stack);
}
 
開發者ID:OpenMods,項目名稱:OpenModsLib,代碼行數:22,代碼來源:OpenBlock.java

示例10: doMultiHarvest

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
private boolean doMultiHarvest(@Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos bc, @Nonnull Block refBlock) {

    IBlockState bs = world.getBlockState(bc);
    Block block = bs.getBlock();
    bs = bs.getActualState(world, bc);
    ItemStack held = player.getHeldItemMainhand();

    List<ItemStack> itemDrops = block.getDrops(world, bc, bs, 0);
    float chance = ForgeEventFactory.fireBlockHarvesting(itemDrops, world, bc, bs, EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, held), 1,
        EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, held) != 0, player);

    world.setBlockToAir(bc);
    boolean usedPower = false;
    for (ItemStack stack : itemDrops) {
      if (world.rand.nextFloat() <= chance) {
        world.spawnEntity(new EntityItem(world, bc.getX() + 0.5, bc.getY() + 0.5, bc.getZ() + 0.5, stack.copy()));
        if (block == refBlock) { // other wise leaves
          EnergyUpgradeManager.extractEnergy(player.getHeldItemMainhand(), Config.darkSteelAxePowerUsePerDamagePointMultiHarvest, false);
          usedPower = true;
        }
      }
    }
    return usedPower;
  }
 
開發者ID:SleepyTrousers,項目名稱:EnderIO,代碼行數:25,代碼來源:ItemDarkSteelAxe.java

示例11: harvestBlock

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
@Override
public void harvestBlock(@Nonnull final World worldIn, @Nonnull EntityPlayer player, @Nonnull final BlockPos pos, @Nonnull IBlockState state,
    @Nullable TileEntity te, @Nonnull ItemStack stack) {

  if (Config.paintedGlowstoneRequireSilkTouch && EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, stack) <= 0) {
    super.harvestBlock(worldIn, player, pos, state, te, stack);
    return;
  }

  // need special code so we can get the paint source from the te
  supressed(player);
  player.addExhaustion(0.025F);

  NNList<ItemStack> items = new NNList<ItemStack>(createPaintedDrop(te));
  ForgeEventFactory.fireBlockHarvesting(items, worldIn, pos, state, 0, 1.0f, true, player);
  items.apply(new NNList.Callback<ItemStack>() {
    @Override
    public void apply(@Nonnull ItemStack itemStack) {
      spawnAsEntity(worldIn, pos, itemStack);
    }
  });
}
 
開發者ID:SleepyTrousers,項目名稱:EnderIO,代碼行數:23,代碼來源:BlockPaintedGlowstone.java

示例12: onBlockHarvested

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
@Override
public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityPlayer player) {
	if (!player.capabilities.isCreativeMode) {
		ArrayList<ItemStack> drops = getDrops(world, x, y, z, meta, 0);
		if (ForgeEventFactory.fireBlockHarvesting(drops, world, this, x, y, z, meta, 0, 1.0F, false, player) > 0.0F)
			for (ItemStack stack : drops)
				dropBlockAsItem(world, x, y, z, stack);
	}
}
 
開發者ID:jm-organization,項目名稱:connor41-etfuturum2,代碼行數:10,代碼來源:BlockBanner.java

示例13: handleDrops

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
private void handleDrops(IBlockState state, BlockPos pos, boolean silk, int fortune) {
	List<ItemStack> drops = new ArrayList<>();
	if (silk) {
		drops.add(Utils.getSilkTouchDrop(pos, getWorld()));
	} else {
		drops.addAll(Utils.getBlockDrops(pos, getWorld(), fortune));
	}
	ForgeEventFactory.fireBlockHarvesting(drops, getWorld(), pos, state, fortune, 1.0f, silk, FakePlayerHandler.getFakePlayer());
	
	AxisAlignedBB bb = getAABBForExtension();
	List<EntityItem> ents = getWorld().getEntitiesWithinAABB(EntityItem.class, bb);
	for (EntityItem ent : ents) {
		drops.add(ent.getItem());
		getWorld().removeEntity(ent);
	}
	ents.clear();
	
	for (ItemStack stack : drops) {
		if (stack.isEmpty()) {
			continue;
		}
		if (!addToAdjacentInventory(stack)) {
			dropStack(stack);
		}
	}
	drops.clear();
}
 
開發者ID:cjburkey01,項目名稱:MiningWells,代碼行數:28,代碼來源:TileEntityMiningWell.java

示例14: doMultiHarvest

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
public static List<ItemStack> doMultiHarvest(ItemStack held, World worldObj, BlockPos bc, Block refBlock, int fortune) {  
    
	IBlockState bs = worldObj.getBlockState(bc);
    Block block = bs.getBlock();
    bs = bs.getActualState(worldObj, bc);
    
    //ItemStack held = minion.getHeldItemMainhand();
    EntityPlayer player = FakePlayerUtil.getPlayer((WorldServer)worldObj);
    player.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, held);
    List<ItemStack> itemDrops = block.getDrops(worldObj, bc, bs, 0);
    float chance = ForgeEventFactory.fireBlockHarvesting(itemDrops, worldObj, bc, bs,
    		fortune, 1, EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, held) != 0, player);
    worldObj.setBlockToAir(bc);
    List<ItemStack> realDrops = Lists.newArrayList();
    if (itemDrops != null) {
        for (ItemStack stack : itemDrops) {
          if (worldObj.rand.nextFloat() <= chance) {
        	  realDrops.add(stack);
            //worldObj.spawnEntityInWorld(new EntityItem(worldObj, bc.getX() + 0.5, bc.getY() + 0.5, bc.getZ() + 0.5, stack.copy()));
        	  if (block == refBlock) { // other wise leaves
        		  held.getItem().onBlockDestroyed(held, worldObj, bs, bc, player);
        		  //applyDamage(held, 1, true);
        	  }
          }
        }
    }
    held = player.getHeldItemMainhand();
    player.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ItemStackTools.getEmptyStack());
    return realDrops;
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:31,代碼來源:TreeUtil.java

示例15: harvestBlock

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
public boolean harvestBlock(BlockPos pos, int fortune, RelativeSide...relativeSides)
{
	if(getWorld().isRemote || !(getWorld() instanceof WorldServer)) {
        return false;
	}
	IBlockState state = getWorld().getBlockState(pos);
	if(getWorld().isAirBlock(pos)){
		return false;
	}
	EntityPlayer player = FakePlayerUtil.getPlayer((WorldServer)getWorld());
	float chance = 1.0f;
	List<ItemStack> drops = state.getBlock().getDrops(getWorld(), pos, state, fortune);
	chance = ForgeEventFactory.fireBlockHarvesting(drops, getWorld(), pos, state, fortune, chance, false, player);
	if(!ItemUtil.canInventoryHold(inventory, inventory.getRawIndicesCombined(relativeSides), drops))
	{
		return false;
	}
	getWorld().playEvent(player, 2001, pos, Block.getStateId(state));
	getWorld().setBlockToAir(pos);
	for(ItemStack stack : drops)
	{
		if(getWorld().rand.nextFloat() <= chance){
			addStackToInventory(stack, relativeSides);
		}
	}
	return true;
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:28,代碼來源:TileWorksiteBoundedInventory.java


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