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


Java LivingSpawnEvent类代码示例

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


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

示例1: onEntitySpawnEvent

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //导入依赖的package包/类
@SubscribeEvent
public void onEntitySpawnEvent(LivingSpawnEvent.CheckSpawn event) {
    int i = 0;
    for (SpawnRule rule : RulesManager.rules) {
        if (rule.match(event)) {
            Event.Result result = rule.getResult();
            if (debug) {
                InControl.logger.log(Level.INFO, "Rule " + i + ": "+ result
                        + " entity: " + event.getEntity().getName()
                        + " y: " + event.getY()
                        + " biome: " + event.getWorld().getBiome(new BlockPos(event.getX(), event.getY(), event.getZ())).getBiomeName());
            }
            event.setResult(result);
            if (result != Event.Result.DENY) {
                rule.action(event);
            }
            return;
        }
        i++;
    }
}
 
开发者ID:McJty,项目名称:InControl,代码行数:22,代码来源:ForgeEventHandlers.java

示例2: 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

示例3: updateSoulDrain

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void updateSoulDrain(final LivingSpawnEvent event) {
    if (event.world.isRemote) {
        return;
    }
    if (!EntityPlayerMP.class.equals(event.getClass())) {
        return;
    }
    final IAttributeInstance a = event.entityLiving.getAttributeMap().getAttributeInstanceByName(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName());
    final AttributeModifier attr = a.getModifier(ItemSoul.uuid);
    if (attr == null || attr.getOperation() == 2) {
        return;
    }
    final double l = attr.getAmount() / 20.0;
    a.removeModifier(attr);
    a.applyModifier(new AttributeModifier(ItemSoul.uuid, "Missing Soul", l, 0));
}
 
开发者ID:sameer,项目名称:ExtraUtilities,代码行数:18,代码来源:EventHandlerServer.java

示例4: SiegeCheckSpawn

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //导入依赖的package包/类
@SubscribeEvent
public void SiegeCheckSpawn(final LivingSpawnEvent.CheckSpawn event) {
    if (EventHandlerSiege.SiegeParticipants.isEmpty()) {
        return;
    }
    if (event.entity.worldObj.isRemote) {
        return;
    }
    if (event.world.provider.dimensionId != 1) {
        return;
    }
    if (event.entityLiving instanceof EntityMob && event.entityLiving.worldObj.checkNoEntityCollision(event.entityLiving.boundingBox) && event.entityLiving.worldObj.getCollidingBoundingBoxes((Entity)event.entityLiving, event.entityLiving.boundingBox).isEmpty() && !event.entityLiving.worldObj.isAnyLiquid(event.entityLiving.boundingBox)) {
        event.entityLiving.getEntityData().setBoolean("Siege", true);
        event.entityLiving.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 7200, 2));
        event.setResult(Event.Result.ALLOW);
    }
}
 
开发者ID:sameer,项目名称:ExtraUtilities,代码行数:18,代码来源:EventHandlerSiege.java

示例5: noMobs

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //导入依赖的package包/类
@SubscribeEvent
public void noMobs(final LivingSpawnEvent.CheckSpawn event) {
    if (event.getResult() == Event.Result.DEFAULT && event.world.provider.dimensionId == ExtraUtils.underdarkDimID && event.entity instanceof EntityMob) {
        if (EventHandlerUnderdark.rand.nextDouble() < Math.min(0.95, event.entity.posY / 80.0)) {
            event.setResult(Event.Result.DENY);
        }
        else {
            IAttributeInstance t = ((EntityMob)event.entity).getEntityAttribute(SharedMonsterAttributes.maxHealth);
            t.setBaseValue(t.getBaseValue() * 2.0);
            ((EntityMob)event.entity).heal((float)t.getAttributeValue());
            t = ((EntityMob)event.entity).getEntityAttribute(SharedMonsterAttributes.attackDamage);
            t.setBaseValue(t.getBaseValue() * 2.0);
            if (!EventHandlerServer.isInRangeOfTorch(event.entity) && event.entityLiving.worldObj.checkNoEntityCollision(event.entityLiving.boundingBox) && event.entityLiving.worldObj.getCollidingBoundingBoxes((Entity)event.entityLiving, event.entityLiving.boundingBox).isEmpty() && !event.entityLiving.worldObj.isAnyLiquid(event.entityLiving.boundingBox)) {
                event.setResult(Event.Result.ALLOW);
            }
        }
    }
}
 
开发者ID:sameer,项目名称:ExtraUtilities,代码行数:19,代码来源:EventHandlerUnderdark.java

示例6: onCheckSpawn

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //导入依赖的package包/类
@SubscribeEvent
public void onCheckSpawn(LivingSpawnEvent.CheckSpawn event) {
    double distanceMin = Double.MAX_VALUE;

    for (int i = -31; i <= 32; ++i) {
        for (int j = -31; j <= 32; ++j) {
            for (int k = -31; k <= 32; ++k) {
                BlockPos pos = new BlockPos(event.getX() + i, event.getY() + j, event.getZ() + k);
                IBlockState state = event.getWorld().getBlockState(pos);
                if (state.getBlock() instanceof BlockSourceLight && state.getValue(IWTechBlocks.WORKING)) {
                    distanceMin = Math.min(distanceMin, MathHelper.sqrt_double(i * i + j * j + k * k));
                }
            }
        }
    }

    if (event.getWorld().rand.nextDouble() * 32.0D > distanceMin) {
        event.setResult(Event.Result.DENY);
    }
}
 
开发者ID:InfinityStudio,项目名称:InspiringWorld,代码行数:21,代码来源:BlockSourceLight.java

示例7: onEntityCheckSpawn

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //导入依赖的package包/类
@SubscribeEvent
public void onEntityCheckSpawn(LivingSpawnEvent.CheckSpawn event)
{
	if(event.getResult() == Event.Result.ALLOW) return;
	if(TorchmasterConfig.MegaTorchAllowVanillaSpawners && event.isSpawner()) return;

	if(TorchMasterMod.MegaTorchFilterRegistry.containsEntity(event.getEntity()))
	{
		if(TorchRegistry.getMegaTorchRegistry().isInRangeOfTorch(event.getWorld(), event.getEntity().getPosition()))
		{
			event.setResult(Event.Result.DENY);
		}
	}
	else if(TorchMasterMod.DreadLampFilterRegistry.containsEntity(event.getEntity()))
	{
		if(TorchRegistry.getDreadLampRegistry().isInRangeOfTorch(event.getWorld(), event.getEntity().getPosition()))
		{
			event.setResult(Event.Result.DENY);
		}
	}
}
 
开发者ID:Xalcon,项目名称:TorchMaster,代码行数:22,代码来源:EventHandlerServer.java

示例8: onZombieSpawn

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //导入依赖的package包/类
@SubscribeEvent
@SuppressWarnings({"unused", "unchecked"})
public void onZombieSpawn(LivingSpawnEvent event) {
    if(!(event.getEntity() instanceof EntityCreature)) {
        return;
    }
    EntityCreature entity = (EntityCreature) event.getEntity();
    //if i replace this with a stream it stops working for some reason >>
    for(Map.Entry<Class<? extends EntityCreature>, List<Class<? extends Entity>>> entry : this.targetMap.entrySet()) {
        if (entry.getKey().isAssignableFrom(entity.getClass())) {
            for (Class<? extends Entity> entityClass : entry.getValue()) {
                entity.targetTasks.addTask(2, new EntityAINearestAttackableTarget(entity, entityClass, true));
            }
        }
    }
}
 
开发者ID:InfinityRaider,项目名称:InfinityLib,代码行数:17,代码来源:EntityTargetingHandler.java

示例9: 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

示例10: spawnHandler

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //导入依赖的package包/类
@SubscribeEvent
public void spawnHandler(LivingSpawnEvent.CheckSpawn event)
{
	if((!(event.getEntity() instanceof EntityPlayer))&&(!(event.getWorld().isRemote)))
	{
		if(ScarecrowTracking.get(event.getWorld()).inRange(event.getEntity()))
		{
			if(event.getWorld().getBlockState(event.getEntity().getPosition()).getBlock()==Blocks.FARMLAND)
			{
				event.setResult(Result.DENY);
			}
			if(event.getEntity() instanceof EntityBat)
			{
				event.setResult(Result.DENY);
				// I hate bats
			}
		}
	}
}
 
开发者ID:theishiopian,项目名称:ForageCraft,代码行数:20,代码来源:SpawnHandler.java

示例11: BlockSpawnEvent

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //导入依赖的package包/类
@SubscribeEvent
public void BlockSpawnEvent(LivingSpawnEvent.CheckSpawn event){
    List<MobInhibitorReference> RefList;
    if (event.getResult() != Event.Result.DEFAULT){ return;} // If the event is already forced Allow or Deny, let it through
    if (event.entity.isCreatureType(EnumCreatureType.monster,false)){ //decide which list to use.
        RefList = MobInhibitor.HostileInhibitors;
    } else if (event.entity.isCreatureType(EnumCreatureType.waterCreature,false)){
        RefList = MobInhibitor.AquaInhibitors;
    } else { // this will also catch ambient creatures like bats.
        if (!ConfigurationHandler.InhibitAmbient && event.entity.isCreatureType(EnumCreatureType.ambient,false)){
            return; //If the InhibitAmbient config is not set, and the creature type is ambient, don't do anything.
            //If the config is set, fall through. The remaining category is Creature, which includes passives.
        }
        RefList = MobInhibitor.PassiveInhibitors;
    }
    for (MobInhibitorReference Ref : RefList){
        if (TestRange(Ref, event.entity.posX, event.entity.posY, event.entity.posZ, event.world.provider.dimensionId)) {
            event.setResult(Event.Result.DENY);
            LogHelper.debug("Blocked a spawn based on inhibitor at:"+Ref.i+", "+Ref.j+", "+Ref.k);
            return;
        }
    }
}
 
开发者ID:yarrim,项目名称:MobInhibitor,代码行数:24,代码来源:ServerEventHandler.java

示例12: entitySpawn

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //导入依赖的package包/类
public static void entitySpawn(LivingSpawnEvent evt) {
	if (! (evt.entity.worldObj instanceof WorldServer)) return;

	if (evt.entity instanceof EntityMob) {
		int spawncap = VintageCraftMobTweaker.spawnCapByDay(evt.world.getTotalWorldTime() / 24000L, evt.world.getDifficulty());
		if (spawncap == 0) {
			evt.setCanceled(true);
			return;
		}
	}

	if (evt.entity instanceof EntityZombie) {
		gearUpMob((EntityZombie)evt.entity);
	}

	if (evt.entity instanceof EntitySkeleton) {
		gearUpMob((EntitySkeleton)evt.entity); 
	}
	

}
 
开发者ID:tyronx,项目名称:vintagecraft,代码行数:22,代码来源:VintageCraftMobTweaker.java

示例13: batSpawnEvent

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //导入依赖的package包/类
@SubscribeEvent
public void batSpawnEvent(LivingSpawnEvent event)
{
	EntityLivingBase entity = event.entityLiving;
	int rand = new Random().nextInt(5);
	switch (rand){
		case 0:
			if (entity instanceof EntityBat)
			{
				event.setCanceled(true);
			}
			break;
		default:
			break;
	}
}
 
开发者ID:hanetzer,项目名称:CreepyPastaCraft,代码行数:17,代码来源:CPCBatHandler.java

示例14: onEntitySpawnEvent

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //导入依赖的package包/类
@ForgeSubscribe
public void onEntitySpawnEvent(LivingSpawnEvent e)
{
    World world = e.world;
    EntityLivingBase ent = e.entityLiving;
    int difficulty = 0;
    List<EntityPlayerMP> playerList = world.playerEntities;
    
    for (EntityPlayerMP player : playerList)
        if (player != null)
            if (GroupManager.groups().getGroupFromPlayer(player.username) != null)
                if (GroupManager.groups().getGroupFromPlayer(player.username).getSize() >= difficulty && ent.getDistanceToEntity(player) <= 128)
                    difficulty = GroupManager.groups().getGroupFromPlayer(player.username).getSize();
    
    
}
 
开发者ID:Hologuardian,项目名称:Sojourn,代码行数:17,代码来源:DifficultyScaler.java

示例15: onEntityLivingSpawn

import net.minecraftforge.event.entity.living.LivingSpawnEvent; //导入依赖的package包/类
@ForgeSubscribe
public void onEntityLivingSpawn(LivingSpawnEvent event) {
	 
	if (!event.world.isRemote)
     {
	     	 
	 if (event.entityLiving instanceof EntityCreeper)
	 {
		 EntityCreeper b = (EntityCreeper) event.entityLiving;  
		 if (b.getCanSpawnHere()){
			 CreeperBurnModCreeper newCreeper = new CreeperBurnModCreeper(event.world);
    		 newCreeper.setLocationAndAngles(b.posX, b.posY, b.posZ, b.rotationYaw, b.rotationPitch);
    		 event.world.spawnEntityInWorld(newCreeper);
    		 b.setDead();
    		 //event.setCanceled(true);
		 }
		
	 }
     }
}
 
开发者ID:culegooner,项目名称:CreeperBurnMod,代码行数:21,代码来源:EntityLivingHandler.java


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