本文整理匯總了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);
}
}
示例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;
}
示例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);
}
示例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;
}
}
}
示例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));
}
}
}
示例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);
}