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


Java LivingSpawnEvent.SpecialSpawn方法代码示例

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


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

示例1: medicSpawn

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void medicSpawn(LivingSpawnEvent.SpecialSpawn event) {
	float chance = 0;
	if (event.getEntity() instanceof EntityHeavy) {
		chance = 0.16f;
	} else if (event.getEntity() instanceof EntitySoldier) {
		chance = 0.08f;
	} else if (event.getEntity() instanceof EntityDemoman) {
		chance = 0.07f;
	} else if (event.getEntity() instanceof EntityPyro) {
		chance = 0.06f;
	} else
		return;
	chance *= TF2ConfigVars.medicChance;
	if (event.getWorld().rand.nextFloat() < event.getWorld().getDifficulty().getDifficultyId() * chance) {
		EntityMedic medic = new EntityMedic(event.getWorld());
		medic.setLocationAndAngles(event.getEntity().posX + event.getWorld().rand.nextDouble() * 0.5 - 0.25, event.getEntity().posY,
				event.getEntity().posZ + event.getWorld().rand.nextDouble() * 0.5 - 0.25, event.getWorld().rand.nextFloat() * 360.0F, 0.0F);
		medic.natural = true;
		// medic.setEntTeam(event.getWorld().rand.nextInt(2));
		medic.onInitialSpawn(event.getWorld().getDifficultyForLocation(new BlockPos(event.getX(), event.getY(), event.getZ())), null);
		EntityTF2Character.nextEntTeam = medic.getEntTeam();

		event.getWorld().spawnEntity(medic);
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:27,代码来源:TF2EventsCommon.java

示例2: pickNearPlayer

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //导入方法依赖的package包/类
private EntityPlayer pickNearPlayer(LivingSpawnEvent.SpecialSpawn event) {
    //See "Algorithm R (Reservoir sampling)" in "The Art of Computer Programming: Seminumerical Algorithms" by Donald Knuth, Chapter 3.4.2, page 144.
    double maxDistanceSq = Math.pow(16*8, 2);
    EntityPlayer secretary = null;
    int interviews = 0;
    for (EntityPlayer player : event.world.playerEntities) {
        if (player.capabilities.isCreativeMode) {
            continue;
        }
        if (event.entity.getDistanceSqToEntity(player) > maxDistanceSq) {
            continue;
        }
        interviews++;
        int M = event.world.rand.nextInt(interviews) + 1 /* converts from [0,i-1] to [1, i] */;
        if (M <= 1 /* we need only 1 sample */) {
            secretary = player;
        }
    }
    return secretary;
}
 
开发者ID:purpleposeidon,项目名称:Factorization,代码行数:21,代码来源:MobEqualizer.java

示例3: onSpecialSpawn

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onSpecialSpawn(LivingSpawnEvent.SpecialSpawn event)
{
    if ( isInsideBorder(event) )
        return;

    // SpecialSpawn uses event cancellation instead of result
    event.setCanceled(true);
}
 
开发者ID:abused,项目名称:World-Border,代码行数:10,代码来源:MobSpawnListener.java

示例4: japaneseSpawn

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST)
public void japaneseSpawn(LivingSpawnEvent.SpecialSpawn event)
{
    World world = event.getWorld();
    EntityLivingBase living = event.getEntityLiving();
    if(!event.isCanceled() && living.hasCapability(JAPANESE_MOB_CAP,null))
    {
        JapaneseMob japaneseMob = living.getCapability(JAPANESE_MOB_CAP,null);
        if(InteractionEriottoMod.JAPANESE_RANDOM_SPAWN && world.rand.nextDouble() < InteractionEriottoMod.JAPANESE_RANDOM_SPAWN_CHANCE)
        {
            japaneseMob.spirits = world.rand.nextInt(4)+3;
        }
    }
}
 
开发者ID:DaedalusGame,项目名称:BetterWithAddons,代码行数:15,代码来源:JapaneseMobHandler.java

示例5: onLivingSpawnSpecialSpawnEvent

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingSpawnSpecialSpawnEvent(LivingSpawnEvent.SpecialSpawn event) {
	if (zombieKnockbackResistance > 0) {
		if (event.getEntityLiving() instanceof EntityZombie) {
			EntityZombie zombie = (EntityZombie) event.getEntityLiving();
			zombie
					.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE)
					.applyModifier(new AttributeModifier("Base value",
							zombieKnockbackResistance, 0));
		}
	}
}
 
开发者ID:hea3ven,项目名称:HardModeTweaks,代码行数:13,代码来源:MobsTweaksManager.java

示例6: specialSpawn

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void specialSpawn(LivingSpawnEvent.SpecialSpawn ev) {
    if (ev.isCanceled()) return;

    ProtectionManager.checkExist(ev.entity, true);
}
 
开发者ID:MyEssentials,项目名称:MyTown2,代码行数:7,代码来源:ProtectionHandlers.java


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