本文整理汇总了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);
}
}
}
示例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);
}
}
示例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);
}
}
}
}
示例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();
}
}
}
示例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);
}
}
示例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);
}
}
示例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));
}
示例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));
}
示例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);
}
}
}
}
}