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


Java BlockEvent.HarvestDropsEvent方法代码示例

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


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

示例1: onWitherBoneHarvestEvent

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

	EntityPlayer player = event.getHarvester();
	ItemStack stack = player.getHeldItemMainhand();

	boolean flag = false;

	if (stack.getItem() instanceof IHaftTool) {
		if (IHaftTool.getHaftMat(stack) == ModMaterials.HAFT_WITHER_BONE) {
			flag = true;
		}
	}

	if (flag) {
		if (player.dimension != DimensionType.NETHER.getId()) {
			stack.damageItem(7, player);
		}
	}
}
 
开发者ID:the-realest-stu,项目名称:Adventurers-Toolbox,代码行数:24,代码来源:SpecialToolAbilityHandler.java

示例2: HarvestDropsEvent

import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void HarvestDropsEvent(BlockEvent.HarvestDropsEvent e){
    try {
        if (e != null && e.getHarvester() == null && !e.getDrops().isEmpty() && ((e.getState().getBlock().equals(Blocks.LEAVES))
                || e.getState().getBlock().equals(Blocks.LEAVES2)) && !e.getWorld().isRemote) {
            Block block = Block.getBlockFromItem(e.getDrops().get(0).getItem());
            int meta = e.getDrops().get(0).getMetadata();
            BlockPos pos = findGround(e.getWorld(), e.getPos());
            if (pos != null && e.getWorld() != null) {
                e.getWorld().setBlockState(pos, block.getStateFromMeta(meta));
                deleteCopySapling(e.getWorld(), pos, Item.getItemFromBlock(block));
            }
        }
    }catch(Throwable throwable){
        System.out.println("    EXCEPTION FOUND IN EVENT TWEAKS FOREST REPLANTING: PLEASE REPORT LOGS TO EVENT TWEAKS WITH INFORMATION ON REPRODUCING");
        throwable.printStackTrace();
    }
}
 
开发者ID:baileyholl,项目名称:Event-Tweaks,代码行数:19,代码来源:ForestEventHandlers.java

示例3: blockHarvestDrops

import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@Override
public void blockHarvestDrops(ItemStack tool, BlockEvent.HarvestDropsEvent event) {
    if (!event.getWorld().isRemote && random.nextFloat() < 0.05) {
        List<IBlockState> blockstates = Lists.newArrayList(Blocks.STONE.getDefaultState(), Blocks.NETHERRACK.getDefaultState(), Blocks.END_STONE.getDefaultState(), Blocks.AIR.getDefaultState(), Blocks.DIRT.getDefaultState());
        IBlockState mainstate = event.getState();
        if (blockstates.contains(mainstate)) return;
        for (int i = 0; i < chance; i++) {
            int x = event.getPos().getX() + Utils.nextInt(random, -distance, distance);
            int y = event.getPos().getY() + Utils.nextInt(random, -distance, distance);
            int z = event.getPos().getZ() + Utils.nextInt(random, -distance, distance);
            BlockPos cPos = new BlockPos(x, y, z);
            IBlockState state = event.getWorld().getBlockState(cPos);
            if (blockstates.contains(state)) {
                event.getDrops().clear();
                event.getWorld().setBlockState(cPos, mainstate);
                event.getHarvester().playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0F);
                event.getHarvester().sendStatusMessage(new TextComponentString("Teleported to: " + x + " " + y + " " + z), false);
                return;
            }
        }
    }
}
 
开发者ID:TeamFRM,项目名称:TAIGA,代码行数:23,代码来源:TraitCurvature.java

示例4: suppressClayDrops

import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void suppressClayDrops(BlockEvent.HarvestDropsEvent event) {
    List<ItemStack> drops = event.getDrops();
    if (drops.stream().noneMatch(this::isClay)) {
        return;
    }
    EntityPlayer harvester = event.getHarvester();
    if (harvester != null && ModItems.getInstance().isValidClayHarvester(harvester.getHeldItemMainhand())) {
        return;
    }
    drops.clear();
}
 
开发者ID:elifoster,项目名称:MakeClayValuableAgain,代码行数:13,代码来源:ClayProgressionImprovements.java

示例5: harvestDrops

import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
public void harvestDrops(BlockEvent.HarvestDropsEvent event) {
    for (ItemStack stack : event.getDrops()) {
        ItemHandlerHelper.insertItem(outItems, stack, false);
        sludge.fill(new FluidStack(FluidsRegistry.SLUDGE, 10 * stack.getCount()), true);
    }
    event.getDrops().clear();
    hasWorked = true;
}
 
开发者ID:Buuz135,项目名称:Industrial-Foregoing,代码行数:9,代码来源:PlantInteractorTile.java

示例6: onHarvest

import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHarvest(BlockEvent.HarvestDropsEvent event) {
    for (PlantInteractorTile tile : PlantInteractorTile.WORKING_TILES) {
        if (tile.getWorld().equals(event.getWorld()) && BlockUtils.getBlockPosInAABB(tile.getWorkingArea()).contains(event.getPos())) {
            tile.harvestDrops(event);
            return;
        }
    }
}
 
开发者ID:Buuz135,项目名称:Industrial-Foregoing,代码行数:10,代码来源:PlantInteractorHarvestDropsHandler.java

示例7: onHarvestAllium

import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHarvestAllium(BlockEvent.HarvestDropsEvent harvest) {
	if (harvest.getState().getBlock() == Blocks.RED_FLOWER && harvest.getState().getBlock().getMetaFromState(harvest.getState()) == 2 && harvest.getWorld().rand.nextInt(5) == 0) {
		harvest.getDrops().clear();
		harvest.getDrops().add(new ItemStack(ModItems.seed_garlic, 1));
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:8,代码来源:HarvestEvent.java

示例8: onHarvestDeadBush

import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHarvestDeadBush(BlockEvent.HarvestDropsEvent harvest) {
	if ((harvest.getState().getBlock() == Blocks.DEADBUSH && harvest.getWorld().rand.nextInt(150) < 25)) {
		harvest.getDrops().clear();
		harvest.getDrops().add(new ItemStack(ModItems.seed_white_sage, 1));
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:8,代码来源:HarvestEvent.java

示例9: onHarvestOakLeaves

import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHarvestOakLeaves(BlockEvent.HarvestDropsEvent event) {
	if ((event.getState().getBlock() == Blocks.LEAVES && event.getWorld().rand.nextInt(150) < 25)) {
		event.getDrops().clear();
		event.getDrops().add(new ItemStack(ModItems.oak_apple_gall, 1));
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:8,代码来源:HarvestEvent.java

示例10: onScoopGravel

import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onScoopGravel(BlockEvent.HarvestDropsEvent event) {
	if ((event.getState().getBlock() == Blocks.GRAVEL && event.getWorld().rand.nextInt(400) < 25)) {
		event.getDrops().clear();
		event.getDrops().add(new ItemStack(ModItems.gem, 1, 1));
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:8,代码来源:HarvestEvent.java

示例11: onMineCoquina

import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onMineCoquina(BlockEvent.HarvestDropsEvent event) {
	if ((event.getState().getBlock() == ModBlocks.coquina && event.getWorld().rand.nextInt(345) < 25)) {
		event.getDrops().clear();
		event.getDrops().add(new ItemStack(Blocks.GRAVEL, 1));
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:8,代码来源:HarvestEvent.java

示例12: onHarvestWormwood

import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHarvestWormwood(BlockEvent.HarvestDropsEvent event) {
	if ((event.getState().getBlock() == ModBlocks.crop_wormwood && event.getWorld().rand.nextInt(450) < 25)) {
		event.getDrops().clear();
		event.getDrops().add(new ItemStack(ModItems.absinthe_green, 1));
		event.getDrops().add(new ItemStack(ModItems.wormwood, 3));
		event.getDrops().add(new ItemStack(ModItems.seed_wormwood, 2));
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:10,代码来源:HarvestEvent.java

示例13: modifyHarvestDrops

import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public static void modifyHarvestDrops(BlockEvent.HarvestDropsEvent event)
{
	if (event.getState().getBlock() == Blocks.GRAVEL)
	{
		Random rand = event.getWorld().rand;

		if (rand.nextInt(100) < Config.shiny_stone_drop_rate)
		{
			event.getDrops().add(new ItemStack(ModItems.shiny_stone));
		}
	}
}
 
开发者ID:DarkMorford,项目名称:BetterThanWeagles,代码行数:14,代码来源:EventHandlerBlockDrops.java

示例14: onHarvestDropsEvent

import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHarvestDropsEvent(BlockEvent.HarvestDropsEvent event) {
    BlockPos pos = event.getPos();
    if (harvestableBlocksToCollect.containsKey(pos)) {
        Integer actionId = harvestableBlocksToCollect.get(pos);
        ActionOptions options = ServerActionManager.getManager().getOptions(actionId);
        if (options != null) {
            options.registerDrops(pos, event.getDrops());
            event.getDrops().clear();
            ServerActionManager.getManager().save();
        } else {
            harvestableBlocksToCollect.remove(pos);
        }
    }
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:16,代码来源:ForgeEventHandlers.java

示例15: registerEvent

import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void registerEvent(BlockEvent.HarvestDropsEvent event)
{
    if (!Config.getInstance().boringSamples || event.getHarvester() == null || event.getState() == null || event.getState().getBlock() != this)
    {
        return;
    }
    String resource = Types.Modded.byMetadata(event.getState().getBlock().getMetaFromState(event.getState())).getResource();
    event.getHarvester().sendStatusMessage(new TextComponentString("You break the sample to find " + resource), true);
    event.getDrops().clear();
}
 
开发者ID:oitsjustjose,项目名称:Geolosys,代码行数:12,代码来源:BlockSample.java


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