當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。