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


Java EntityStruckByLightningEvent类代码示例

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


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

示例1: onLightning

import net.minecraftforge.event.entity.EntityStruckByLightningEvent; //导入依赖的package包/类
@SubscribeEvent
public void onLightning(EntityStruckByLightningEvent e) {
	if (e.entity.worldObj.isRemote) return;
	if (!config.getBoolean("fondue.cyberCider.craftable")) return;
	if (e.entity instanceof EntityPlayer) {
		EntityPlayer player = (EntityPlayer) e.entity;
		boolean sting = false;
		for (ItemStack is : player.inventory.mainInventory) {
			if (is == null) continue;
			if (is.getItem() == FONDUE) {
				if (is.getItemDamage() == 3) {
					is.setItemDamage(4);
					sting = true;
				}
			}
		}
		if (sting) {
			player.worldObj.playSoundAtEntity(player, "farrago:cyber_sting", 0.5f, 1.0f);
		}
	}
}
 
开发者ID:unascribed,项目名称:Farrago,代码行数:22,代码来源:FarragoMod.java

示例2: onLightningStrike

import net.minecraftforge.event.entity.EntityStruckByLightningEvent; //导入依赖的package包/类
@SubscribeEvent
public void onLightningStrike(EntityStruckByLightningEvent event) {
	Entity entityLiving = event.entity;

	if (hasEquippedSet(entityLiving, ModArmor.stormHelmet,
			ModArmor.stormChest, ModArmor.stormLeggings,
			ModArmor.stormBoots)
			|| hasEquippedSet(entityLiving, ModArmor.chaosHelmet,
					ModArmor.chaosChest, ModArmor.chaosLeggings,
					ModArmor.chaosBoots)
			|| hasEquippedSet(entityLiving, ModArmor.orderHelmet,
					ModArmor.orderChest, ModArmor.orderLeggings,
					ModArmor.orderBoots)) {
		event.setCanceled(true);
	}
}
 
开发者ID:testmad,项目名称:GaiaMod,代码行数:17,代码来源:GaiaModEventHandler.java

示例3: lightningStrike

import net.minecraftforge.event.entity.EntityStruckByLightningEvent; //导入依赖的package包/类
@SuppressWarnings("UnusedDeclaration")
@SubscribeEvent
public void lightningStrike(EntityStruckByLightningEvent event) {
    final int HOTBAR_SIZE = 9;
    Entity entity = event.entity;
    HashSet<String> easterEggUsers = new HashSet<String>();
    easterEggUsers.add("98513389c42a4c9d81fa16c247673e61"); // Portablejim
    easterEggUsers.add("9000e6350e3e422594214a2ce2a92227"); // Straymaverick

    String uuidFull = entity.getUniqueID().toString();
    String uuidStripped = uuidFull.replace("-", "");

    if(easterEggUsers.contains(uuidStripped) || this.configValues.EASTER_EGG_SHARE) {
        EntityPlayer player = (EntityPlayer) entity;
        for(int i = 0; i < HOTBAR_SIZE; i++) {
            ItemStack item = player.inventory.getStackInSlot(i);
            if(item != null && item.getItem() instanceof VeinSeedPlanter && item.getItemDamage() == 0) {
                item.setItemDamage(1);
            }
        }
    }
}
 
开发者ID:portablejim,项目名称:PlanterHelper,代码行数:23,代码来源:PlanterHelper.java

示例4: entityStruckByLightning

import net.minecraftforge.event.entity.EntityStruckByLightningEvent; //导入依赖的package包/类
@SubscribeEvent
public void entityStruckByLightning(EntityStruckByLightningEvent event) {
	if (EtFuturum.enableVillagerTurnsIntoWitch && event.entity instanceof EntityVillager) {
		EntityVillager villager = (EntityVillager) event.entity;
		if (!villager.worldObj.isRemote) {
			EntityWitch witch = new EntityWitch(villager.worldObj);
			witch.copyLocationAndAnglesFrom(villager);
			witch.onSpawnWithEgg(null);
			villager.worldObj.spawnEntityInWorld(witch);
			villager.setDead();
		}
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:14,代码来源:ServerEventHandler.java

示例5: onEntityItemStruckByLightning

import net.minecraftforge.event.entity.EntityStruckByLightningEvent; //导入依赖的package包/类
/** Special handler for when an EntityItem is struck by lightning */
@SubscribeEvent
public void onEntityItemStruckByLightning(EntityStruckByLightningEvent e) {
	World world = e.getEntity().worldObj;
	if(!world.isRemote && !e.getEntity().isDead && e.getEntity() instanceof EntityItem) {
		// get the EntityItem struck
		EntityItem item = (EntityItem)e.getEntity();
		JointList<ItemStack> input = new JointList().join(item.getEntityItem());
		JointList<EntityItem> activeItems = new JointList().join(item);

		// now get nearby items within a 2 block radius
		for(Entity t : world.loadedEntityList) {
			if(!!t.isDead && t instanceof EntityItem && t != item && t.getDistanceToEntity(item) <= 2) {
				EntityItem et = (EntityItem)t;
				input.add(et.getEntityItem());
				activeItems.add(et);
			}
		}

		// get the output of the transformation
		ItemStack out = LightningTransformRecipes.instance().getTransformResult(input);
		if(out == null) return; // abort processing here if there's no output

		// now remove the items
		for(EntityItem ent : activeItems) ent.setDead();

		// spawn an invincible resulting item at that position
		EntityItem entityitem = new EntityLCItem(world, item.posX, item.posY, item.posZ, out);
		world.spawnEntityInWorld(entityitem);
	}
}
 
开发者ID:sblectric,项目名称:LightningCraft,代码行数:32,代码来源:EntityItemEvents.java

示例6: detectLightning

import net.minecraftforge.event.entity.EntityStruckByLightningEvent; //导入依赖的package包/类
/**
 * @param event
 */
@SubscribeEvent
public void detectLightning(EntityStruckByLightningEvent event)
{
    if (event.entity != null && event.entity instanceof EntityPlayer)
    {
        ServerActions.electrify((EntityPlayer) event.entity);
    }
}
 
开发者ID:Darkona,项目名称:AdventureBackpack2,代码行数:12,代码来源:GeneralEventHandler.java

示例7: onEntityStruckByLightning

import net.minecraftforge.event.entity.EntityStruckByLightningEvent; //导入依赖的package包/类
public static boolean onEntityStruckByLightning(Entity entity, EntityLightningBolt bolt)
{
    return MinecraftForge.EVENT_BUS.post(new EntityStruckByLightningEvent(entity, bolt));
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:5,代码来源:ForgeEventFactory.java

示例8: onEntityStruckByLightning

import net.minecraftforge.event.entity.EntityStruckByLightningEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onEntityStruckByLightning(EntityStruckByLightningEvent event)
{
	EventFactory.fireEvent(new EventEntityStruckByLightning(event.lightning, event.entity));
}
 
开发者ID:Niadel,项目名称:N-API,代码行数:6,代码来源:EventHandlerForge.java

示例9: onUpdate

import net.minecraftforge.event.entity.EntityStruckByLightningEvent; //导入依赖的package包/类
/**
 * Called to update the entity's position/logic.
 */
public void onUpdate()
{
    super.onUpdate();

    if (this.lightningState == 2)
    {
        this.worldObj.playSoundEffect(this.posX, this.posY, this.posZ, "ambient.weather.thunder", 10000.0F, 0.8F + this.rand.nextFloat() * 0.2F);
        this.worldObj.playSoundEffect(this.posX, this.posY, this.posZ, "random.explode", 2.0F, 0.5F + this.rand.nextFloat() * 0.2F);
    }

    --this.lightningState;

    if (this.lightningState < 0)
    {
        if (this.boltLivingTime == 0)
        {
            this.setDead();
        }
        else if (this.lightningState < -this.rand.nextInt(10))
        {
            --this.boltLivingTime;
            this.lightningState = 1;
            this.boltVertex = this.rand.nextLong();

            if (!this.worldObj.isRemote && this.worldObj.getGameRules().getGameRuleBooleanValue("doFireTick") && this.worldObj.doChunksNearChunkExist(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ), 10))
            {
                int i = MathHelper.floor_double(this.posX);
                int j = MathHelper.floor_double(this.posY);
                int k = MathHelper.floor_double(this.posZ);

                if (this.worldObj.getBlockId(i, j, k) == 0 && Block.fire.canPlaceBlockAt(this.worldObj, i, j, k))
                {
                    this.worldObj.setBlock(i, j, k, Block.fire.blockID);
                }
            }
        }
    }

    if (this.lightningState >= 0)
    {
        if (this.worldObj.isRemote)
        {
            this.worldObj.lastLightningBolt = 2;
        }
        else
        {
            double d0 = 3.0D;
            List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, AxisAlignedBB.getAABBPool().getAABB(this.posX - d0, this.posY - d0, this.posZ - d0, this.posX + d0, this.posY + 6.0D + d0, this.posZ + d0));

            for (int l = 0; l < list.size(); ++l)
            {
                Entity entity = (Entity)list.get(l);
                if (!MinecraftForge.EVENT_BUS.post(new EntityStruckByLightningEvent(entity, this)))
                {
                    entity.onStruckByLightning(this);
                }
            }
        }
    }
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:64,代码来源:EntityLightningBolt.java


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