• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ExplosionEvent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: onDetonate

import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@SubscribeEvent
public void onDetonate(ExplosionEvent.Detonate event) {
    World world = event.world;
    if (world.isRemote) {
        return;
    }
    ProtectedBlocks protectedBlocks = ProtectedBlocks.getProtectedBlocks(world);
    if (!protectedBlocks.hasProtections()) {
        return;
    }


    List<BlockPos> affectedBlocks = event.getAffectedBlocks();

    int i = 0;
    while (i < affectedBlocks.size()) {
        BlockPos block = affectedBlocks.get(i);
        if (protectedBlocks.isProtected(world, block)) {
            affectedBlocks.remove(i);
        } else {
            i++;
        }
    }
}
 
开发者ID:romelo333,项目名称:notenoughwands1.8.8,代码行数:25,代码来源:ForgeEventHandlers.java


示例2: onBlockChange

import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@Listener
public void onBlockChange(ChangeBlockEvent event) {
  // Depends on SpongeForge#550
  if (event instanceof ExplosionEvent.Detonate) {
    return;
  }

  Optional<PluginContainer> optPluginContainer = event.getCause().first(PluginContainer.class);
  if (optPluginContainer.isPresent()) {
    return;
  }

  for (Transaction<BlockSnapshot> transaction : event.getTransactions()) {
    if (manager.getApplicableZone(transaction.getOriginal().getLocation().get()).isPresent()) {
      event.setCancelled(true);
      break;
    }
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:20,代码来源:PatientXListener.java


示例3: onDetonate

import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@SubscribeEvent
public void onDetonate(ExplosionEvent.Detonate event) {
    World world = event.world;
    if (world.isRemote) {
        return;
    }
    ProtectedBlocks protectedBlocks = ProtectedBlocks.getProtectedBlocks(world);
    if (!protectedBlocks.hasProtections()) {
        return;
    }


    List<ChunkPosition> affectedBlocks = event.getAffectedBlocks();

    int i = 0;
    while (i < affectedBlocks.size()) {
        ChunkPosition block = affectedBlocks.get(i);
        if (protectedBlocks.isProtected(world, block.chunkPosX, block.chunkPosY, block.chunkPosZ)) {
            affectedBlocks.remove(i);
        } else {
            i++;
        }
    }
}
 
开发者ID:romelo333,项目名称:notenoughwands,代码行数:25,代码来源:ForgeEventHandlers.java


示例4: onExplode

import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@SubscribeEvent
public void onExplode(ExplosionEvent.Detonate event) {
    List<Block> affectedBlocks = Arrays.asList(Blocks.GRASS, Blocks.SANDSTONE, Blocks.STONE, Blocks.SAND, Blocks.DIRT, Blocks.COBBLESTONE, Blocks.GRAVEL);
    if (!event.getWorld().isRemote) {
        Explosion explosion = event.getExplosion();
        AxisAlignedBB axisAlignedBB = new AxisAlignedBB(explosion.getPosition().xCoord - 3, explosion.getPosition().yCoord - 3, explosion.getPosition().zCoord - 3, explosion.getPosition().xCoord + 3, explosion.getPosition().yCoord + 3, explosion.getPosition().zCoord + 3);
        List<EntityPlayer> players = event.getWorld().getEntitiesWithinAABB(EntityPlayer.class, axisAlignedBB);
        for (EntityPlayer player : players) {
            if (getBaubleFromInv(ItemExplosionRing.class, player) != null) {
                Iterator<BlockPos> iterator = explosion.getAffectedBlockPositions().iterator();
                while (iterator.hasNext()) {
                    BlockPos position = iterator.next();
                    Block block = event.getWorld().getBlockState(position).getBlock();
                    if (!affectedBlocks.contains(block) && block != Blocks.AIR) {
                        iterator.remove();
                    }
                }
            }
        }
    }
}
 
开发者ID:AdlyTempleton,项目名称:Aura-Cascade,代码行数:22,代码来源:EventHandler.java


示例5: explosionEventStart

import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@SubscribeEvent
public void explosionEventStart(ExplosionEvent.Start event) {
    World world = event.getWorld();
    Random random = new Random();
    BlockPos explosionPosition = new BlockPos(event.getExplosion().getPosition());

    for (int dz = -detectionRadius; dz <= detectionRadius; dz++) {
        for (int dx = -detectionRadius; dx <= detectionRadius; dx++) {
            for (int dy = -detectionRadius; dy <= detectionRadius; dy++) {
                BlockPos pos = explosionPosition.add(dx, dy, dz);
                if (world.getBlockState(pos).getBlock() == Blocks.BEDROCK && random.nextDouble() < 0.2d) {
                    EnumFacing face = EnumFacing.getFacingFromVector(-dx, -dy, -dz);

                    if (world.getBlockState(pos.add(face.getDirectionVec())).getMaterial() == Material.AIR) {
                        PlayerInteractEventHandler.SendPacket(pos, face, event.getWorld().provider.getDimension());
                    }
                }
            }
        }
    }
}
 
开发者ID:danny50610,项目名称:ImmortalObjectTip,代码行数:22,代码来源:ExplosionEventHandler.java


示例6: onExplosion

import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
/**
 * Forge 1254 is needed for this
 */
@SubscribeEvent
public void onExplosion(ExplosionEvent.Start ev) {
    if(ev.world.isRemote)
        return;
    if (ev.isCanceled())
        return;
    List<ChunkPos> chunks = WorldUtils.getChunksInBox(ev.world.provider.dimensionId, (int) (ev.explosion.explosionX - ev.explosion.explosionSize - 2), (int) (ev.explosion.explosionZ - ev.explosion.explosionSize - 2), (int) (ev.explosion.explosionX + ev.explosion.explosionSize + 2), (int) (ev.explosion.explosionZ + ev.explosion.explosionSize + 2));
    for(ChunkPos chunk : chunks) {
        TownBlock block = MyTownUniverse.instance.blocks.get(ev.world.provider.dimensionId, chunk.getX(), chunk.getZ());
        if(block == null) {
            if(!(Boolean)Wild.instance.flagsContainer.getValue(FlagType.EXPLOSIONS)) {
                ev.setCanceled(true);
                return;
            }
        } else {
            if (!(Boolean) block.getTown().flagsContainer.getValue(FlagType.EXPLOSIONS)) {
                ev.setCanceled(true);
                block.getTown().notifyEveryone(MyTown.instance.LOCAL.getLocalization(FlagType.EXPLOSIONS.getTownNotificationKey()));
                return;
            }
        }
    }
}
 
开发者ID:MyEssentials,项目名称:MyTown2,代码行数:27,代码来源:ExtraEventsHandler.java


示例7: handleIronExplosions

import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@SubscribeEvent
public void handleIronExplosions(ExplosionEvent.Detonate event){
    Iterator<Entity> iterator = event.getAffectedEntities().iterator();
    while(iterator.hasNext()) {
        Entity entity = iterator.next();
        if(entity instanceof EntityItem) {
            ItemStack stack = ((EntityItem)entity).getEntityItem();
            if(stack != null && !entity.isDead && PneumaticCraftUtils.isSameOreDictStack(stack, IRON_INGOT) || PneumaticCraftUtils.isSameOreDictStack(stack, IRON_BLOCK)) {
                Random rand = new Random();
                if(stack.stackSize >= 3 || rand.nextDouble() >= Config.configCompressedIngotLossRate / 100D) {
                    Item newItem = PneumaticCraftUtils.isSameOreDictStack(stack, IRON_INGOT) ? Itemss.ingotIronCompressed : Item.getItemFromBlock(Blockss.compressedIron);
                    ItemStack newStack = new ItemStack(newItem, stack.stackSize, stack.getItemDamage());
                    if(stack.stackSize >= 3) {
                        newStack.stackSize = (int)(stack.stackSize * (rand.nextDouble() * Math.min(Config.configCompressedIngotLossRate * 0.02D, 0.2D) + (Math.max(0.9D, 1D - Config.configCompressedIngotLossRate * 0.01D) - Config.configCompressedIngotLossRate * 0.01D)));
                    }
                    ((EntityItem)entity).setEntityItemStack(newStack);
                    iterator.remove();
                    for(EntityPlayer player : (List<EntityPlayer>)event.world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(event.explosion.explosionX - 32, event.explosion.explosionY - 32, event.explosion.explosionZ - 32, event.explosion.explosionX + 32, event.explosion.explosionY + 32, event.explosion.explosionZ + 32))) {
                        AchievementHandler.giveAchievement(player, newStack);
                    }
                }
            }
        }
    }
}
 
开发者ID:MineMaarten,项目名称:PneumaticCraft,代码行数:26,代码来源:EventHandlerPneumaticCraft.java


示例8: onExplosionStart

import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@SubscribeEvent
   public void onExplosionStart(ExplosionEvent.Detonate event){
// Make the explosions by the Ice Queen slow the player.
Explosion explosion = event.explosion;
if(explosion.exploder instanceof EntityIceQueen){
    EntityIceQueen queen = (EntityIceQueen)explosion.exploder;
    List<Entity> entitiesHit = event.getAffectedEntities();
    for(Entity entity : entitiesHit){
	if(entity instanceof EntityPlayer){
	    EntityPlayer player = (EntityPlayer)entity;
	    player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.getId(), 300, 2));
	    player.attackEntityFrom(DamageSource.setExplosionSource(explosion), (float)queen.getEntityAttribute(SharedMonsterAttributes.attackDamage).getBaseValue() / 2);
	}
    }
}
   }
 
开发者ID:OwnAgePau,项目名称:Soul-Forest,代码行数:17,代码来源:ForgeHookEventHelper.java


示例9: handleIronExplosions

import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@SubscribeEvent
public void handleIronExplosions(ExplosionEvent.Detonate event) {
    Iterator<Entity> iterator = event.getAffectedEntities().iterator();
    while (iterator.hasNext()) {
        Entity entity = iterator.next();
        if (entity instanceof EntityItem) {
            ItemStack stack = ((EntityItem) entity).getItem();
            if (!stack.isEmpty() && !entity.isDead && (PneumaticCraftUtils.isSameOreDictStack(stack, IRON_INGOT) || PneumaticCraftUtils.isSameOreDictStack(stack, IRON_BLOCK))) {
                Random rand = new Random();
                int lossRate = ConfigHandler.general.configCompressedIngotLossRate;
                if (stack.getCount() >= 3 || rand.nextDouble() >= lossRate / 100D) {
                    Item newItem = PneumaticCraftUtils.isSameOreDictStack(stack, IRON_INGOT) ? Itemss.INGOT_IRON_COMPRESSED : Item.getItemFromBlock(Blockss.COMPRESSED_IRON);
                    ItemStack newStack = new ItemStack(newItem, stack.getCount(), stack.getItemDamage());
                    if (stack.getCount() >= 3) {
                        newStack.setCount((int) (stack.getCount() * (rand.nextDouble() * Math.min(lossRate * 0.02D, 0.2D) + (Math.max(0.9D, 1D - lossRate * 0.01D) - lossRate * 0.01D))));
                    }
                    ((EntityItem) entity).setItem(newStack);
                    iterator.remove();
                    if (!event.getWorld().isRemote) {
                        Vec3d exp = event.getExplosion().getPosition();
                        for (EntityPlayer player : event.getWorld().getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(exp.x - 32, exp.y - 32, exp.z - 32, exp.x + 32, exp.y + 32, exp.z + 32))) {
                            AdvancementTriggers.EXPLODE_IRON.trigger((EntityPlayerMP) player);
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:30,代码来源:EventHandlerPneumaticCraft.java


示例10: onExplosionDetonate

import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
public static void onExplosionDetonate(World world, Explosion explosion, List<Entity> list, double diameter)
{
    //Filter entities to only those who are effected, to prevent modders from seeing more then will be hurt.
    /* Enable this if we get issues with modders looping to much.
    Iterator<Entity> itr = list.iterator();
    Vec3 p = explosion.getPosition();
    while (itr.hasNext())
    {
        Entity e = itr.next();
        double dist = e.getDistance(p.xCoord, p.yCoord, p.zCoord) / diameter;
        if (e.isImmuneToExplosions() || dist > 1.0F) itr.remove();
    }
    */
    MinecraftForge.EVENT_BUS.post(new ExplosionEvent.Detonate(world, explosion, list));
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:16,代码来源:ForgeEventFactory.java


示例11: explosionDetonate

import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@SubscribeEvent
public void explosionDetonate(ExplosionEvent.Detonate event)
{
	Iterator<BlockPos> iterator = event.getAffectedBlocks().iterator();

	while (iterator.hasNext())
	{
		BlockPos pos = iterator.next();

		if (event.getWorld().getBlockState(pos).getBlock() instanceof IExplosionImmune)
		{
			iterator.remove();
		}
	}
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:16,代码来源:EventHandler.java


示例12: onExplosionDetonate

import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
public static void onExplosionDetonate(World world, Explosion explosion, List<Entity> list, double diameter)
{
    //Filter entities to only those who are effected, to prevent modders from seeing more then will be hurt.
    /* Enable this if we get issues with modders looping to much.
    Iterator<Entity> itr = list.iterator();
    while (itr.hasNext())
    {
        Entity e = itr.next();
        double dist = e.getDistance(explosion.explosionX, explosion.explosionY, explosion.explosionZ) / diameter;
        if (dist > 1.0F) itr.remove();
    }
    */
    MinecraftForge.EVENT_BUS.post(new ExplosionEvent.Detonate(world, explosion, list));
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:15,代码来源:ForgeEventFactory.java


示例13: onImpact

import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@Override
protected void onImpact(RayTraceResult result) {
    if (!this.worldObj.isRemote) {
        SourceBombExplosion explosion =
            new SourceBombExplosion(this.worldObj, this, this.posX, this.posY, this.posZ, 5.0F);
        if (!MinecraftForge.EVENT_BUS.post(new ExplosionEvent.Start(this.worldObj, explosion))) {
            explosion.doExplosionA();
            explosion.doExplosionB(true);
        }
        this.setDead();
    }
}
 
开发者ID:InfinityStudio,项目名称:InspiringWorld,代码行数:13,代码来源:EntitySourceBomb.java


示例14: onExplosion

import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onExplosion(ExplosionEvent.Detonate evt) {
    if(evt.isCanceled()) return;

    try {
        BlockDropRegistry.registerExplodedBlocks(evt.getAffectedBlocks());
    } catch (Exception ex) {
        LogHelper.error("Error handling explosion detonation event; please report this along with your config file.", ex);
    }
}
 
开发者ID:legendblade,项目名称:CraftingHarmonics,代码行数:11,代码来源:EventHandler.java


示例15: onExplosion

import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@SubscribeEvent
public void onExplosion(final ExplosionEvent.Detonate event) {
	if (!BLOCK_CREEPER_BLOCK_DAMAGE)
		return;
	if (event.explosion.getExplosivePlacedBy() instanceof EntityCreeper)
		// Reset the affected block list
		event.explosion.func_180342_d();
}
 
开发者ID:OreCruncher,项目名称:Restructured,代码行数:9,代码来源:MobControl.java


示例16: onEvent

import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@Override
public void onEvent(ExplosionEvent event) {
	if (event instanceof ExplosionEvent.Start && event.getExplosion().getExplosivePlacedBy() instanceof EntityCreeper) {
		if (!this.creeperExplosion) {event.setCanceled(true); return;}
		
		EntityCreeper creeper = (EntityCreeper) event.getExplosion().getExplosivePlacedBy();
		
		if (creeper.getAttackTarget() instanceof EntityPlayerMP) {
			EntityPlayerMP player = (EntityPlayerMP) creeper.getAttackTarget();
			if (!getPlayerSettings(player).creeperExplosion) event.setCanceled(true);
		}
	}
}
 
开发者ID:MrNobody98,项目名称:morecommands,代码行数:14,代码来源:CommandCreeper.java


示例17: onExplosionDetonateEvent

import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
/**
 * Intended to remove entities that are not supposed to get influenced by an explosion from the list of entities that are.
 * 
 * @param event The explosion event that is taking place.
 */
@SubscribeEvent
public void onExplosionDetonateEvent(ExplosionEvent.Detonate event)
{
	Iterator<Entity> itr = event.getAffectedEntities().iterator();
	
	while (itr.hasNext())
	{
		Entity ent = itr.next();
		if (!(ent instanceof EntityScience)) continue;
		
		EntityScience entSci = (EntityScience) ent;
		if (!entSci.isPushedByExplosion()) itr.remove();
	}
}
 
开发者ID:JasonYe4273,项目名称:Minecraft-Modding,代码行数:20,代码来源:ScienceEventHandler.java


示例18: on

import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGH)
public void on(ExplosionEvent.Start e) {
    Explosion expl = e.explosion;
    if(expl.isSmoking
            && (expl.exploder != null ? TileBlockProtector.isSpotProtected(e.world, expl.exploder) :
                TileBlockProtector.isSpotProtected(e.world, expl.explosionX, expl.explosionY, expl.explosionZ))) {
        //why?
        //expl.isSmoking = false;
        e.setCanceled(true);
        e.world.newExplosion(expl.exploder, expl.explosionX, expl.explosionY, expl.explosionZ, expl.explosionSize, expl.isFlaming, false);
    }
}
 
开发者ID:makeoo,项目名称:Gadomancy,代码行数:13,代码来源:EventHandlerWorld.java


示例19: onExplosionDetonate

import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@SubscribeEvent
public void onExplosionDetonate(ExplosionEvent.Detonate event)
{
    if (!SprinklesForVanilla.isOnServer)
    {
        return;
    }
    Explosion explosion = event.explosion;
    Entity exploder = explosion.getExplosivePlacedBy();
    for (String explosionDatum : Settings.explosionData[1])
    {
        String[] data = explosionDatum.replace(", ", ",").split(",");
        String exploderName = data[0];
        boolean doesDamage = Boolean.parseBoolean(data[3]);
        boolean isSmoking = Boolean.parseBoolean(data[5]);

        if (isNotCorrectConfig(exploderName, exploder, event.explosion.getPosition().xCoord, event.explosion.getPosition().yCoord, event.explosion.getPosition().zCoord, event.world))
        {
            continue;
        }

        if (!doesDamage)
        {
            event.getAffectedEntities().clear();
        }

        if (!isSmoking)
        {
            explosion.getAffectedBlockPositions().clear();
        }

        return;
    }
}
 
开发者ID:VikeStep,项目名称:sprinkles_for_vanilla,代码行数:35,代码来源:WorldHandlers.java


示例20: onExplosion

import net.minecraftforge.event.world.ExplosionEvent; //导入依赖的package包/类
@SubscribeEvent
public void onExplosion(ExplosionEvent.Detonate event) {
	List<ChunkPosition> poslist = event.getAffectedBlocks();
	for (int i=poslist.size()-1; i > 0; i--) {
		ChunkPosition pos = poslist.get(i);
		if (this.shouldProtectStructure(event.world, pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ)) {
			poslist.remove(pos);
		}
	}
}
 
开发者ID:TTFTCUTS,项目名称:ShadowsOfPhysis,代码行数:11,代码来源:StructureHandler.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java KeyStoreLoginModule类代码示例发布时间:2022-05-21
下一篇:
Java TransactionMode类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap