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