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


Java EntityList.getEntityString方法代码示例

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


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

示例1: determineDifficultyForSpawnEvent

import net.minecraft.entity.EntityList; //导入方法依赖的package包/类
public int determineDifficultyForSpawnEvent(SpawnEventDetails details){
    int difficulty = baseDifficulty;
    difficulty+=getMobBaseSpawnCost(details.entity);
    String mobId = EntityList.getEntityString(details.entity);
    RegionMobConfig mobConfig = getConfigForMob(mobId);
    for(DifficultyControl control : mobConfig.controls){
        try {
            difficulty += control.getChangeForSpawn(details);
        }catch (Exception e){
            if(DifficultyManager.debugLogSpawns){
                LOG.warn("A control misbehaved: "+control.getIdentifier());
                LOG.warn("  Issue was: "+e.getMessage());
            }
        }
    }
    return difficulty;
}
 
开发者ID:talandar,项目名称:ProgressiveDifficulty,代码行数:18,代码来源:Region.java

示例2: determineDifficultyForFakedSpawnEvent

import net.minecraft.entity.EntityList; //导入方法依赖的package包/类
public Map<String, Integer> determineDifficultyForFakedSpawnEvent(SpawnEventDetails spawnDetails){
    Map<String,Integer> details = Maps.newHashMap();
    details.put("MOB_BASE",getMobBaseSpawnCost(spawnDetails.entity));
    details.put("REGION_BASE",baseDifficulty);
    String mobId = EntityList.getEntityString(spawnDetails.entity);
    RegionMobConfig mobConfig = getConfigForMob(mobId);
    for(DifficultyControl control : mobConfig.controls){
        int difficulty = 0;
        try {
            difficulty += control.getChangeForSpawn(spawnDetails);
        }catch (Exception e){
            if(DifficultyManager.debugLogSpawns){
                LOG.warn("A control misbehaved: "+control.getIdentifier());
                LOG.warn("  Issue was: "+e.getMessage());
            }
        }
        details.put(control.getIdentifier(),difficulty);
    }
    return details;
}
 
开发者ID:talandar,项目名称:ProgressiveDifficulty,代码行数:21,代码来源:Region.java

示例3: doUpkeep

import net.minecraft.entity.EntityList; //导入方法依赖的package包/类
private static void doUpkeep(World world){
    List<EntityLiving> modifiedEntities = MobNBTHandler.getModifiedEntities(world);

    for(EntityLiving entity : modifiedEntities){
        String regionName = MobNBTHandler.getEntityRegion(entity);
        Map<String,Integer> changes = MobNBTHandler.getChangeMap(entity);
        Region region = DifficultyManager.getRegionByName(regionName);
        String mobId = EntityList.getEntityString(entity);
        for(String change : changes.keySet()){
            try {
                DifficultyModifier modifier = region.getModifierForMobById(mobId,change);
                if (modifier != null) {
                    modifier.handleUpkeepEvent(changes.get(change), entity);
                }
            }catch(Exception e){
                LOG.warn("Error applying modifier at upkeep.  Mob was "+entity.getName()+", Modifier was "+change+".  Please report to Progressive Difficulty Developer!");
                LOG.warn("\tCaught Exception had message "+e.getMessage());
            }
        }
    }
}
 
开发者ID:talandar,项目名称:ProgressiveDifficulty,代码行数:22,代码来源:MobUpkeepController.java

示例4: songEnded

import net.minecraft.entity.EntityList; //导入方法依赖的package包/类
@Override
public void songEnded(EntityPlayer player, ItemStack instrument, int interval) {
	World world = player.world;
	int radius = 15;
	AxisAlignedBB area = new AxisAlignedBB(player.posX - radius, player.posY - radius, player.posZ - radius,
			player.posX + radius, player.posY + radius, player.posZ + radius);
	List<Entity> mobs = world.getEntitiesWithinAABBExcludingEntity(player, area);
	for (Entity e : mobs) {
		if (e instanceof EntityLivingBase) {
			String key = EntityList.getEntityString(e);

			if (effects.containsKey(key)) {
				Potion p = effects.get(key);
				PotionEffect effect = new PotionEffect(p, (interval) * 20 * 6000);
				player.addPotionEffect(effect);
				return;
			}
		}
	}
}
 
开发者ID:TeamMelodium,项目名称:Melodium,代码行数:21,代码来源:SongHunt.java

示例5: onSpawn

import net.minecraft.entity.EntityList; //导入方法依赖的package包/类
/**
 * Checks spawning
 */
@SubscribeEvent
public void onSpawn(CheckSpawn event) {
	//If the entity is not a mob or above the forced-spawn-y-level, stop
	if (!(event.getEntity() instanceof EntityMob && event.getY() < underground))
		return;

	EntityMob mob = (EntityMob) event.getEntity();
	String name = EntityList.getEntityString(mob);

	//If whitelist and list contains mob, or blacklist and list does not contain mob
	if ((spawnWhitelist && mobsToSpawn.contains(name)) || (!(spawnWhitelist && mobsToSpawn.contains(name)))){
		//If the chance is within allowed mob-spawn-under-y-level range, and the game is not on Peaceful
		if (rand.nextFloat() < undergroundChance && event.getWorld().getDifficulty() != EnumDifficulty.PEACEFUL){
			//If there are no other entities in this area, and there are no collisions, and there is not a liquid
			if (event.getWorld().checkNoEntityCollision(mob.getEntityBoundingBox())
					&& event.getWorld().getCollisionBoxes(mob, mob.getEntityBoundingBox()).isEmpty()
					&& !event.getWorld().containsAnyLiquid(mob.getEntityBoundingBox())){
				//Allow the spawn
				event.setResult(Result.ALLOW);
			}
		}
	}

}
 
开发者ID:bookerthegeek,项目名称:Mob-Option-Redux,代码行数:28,代码来源:MobOptionsEventHandler.java

示例6: makeDifficultyChanges

import net.minecraft.entity.EntityList; //导入方法依赖的package包/类
public void makeDifficultyChanges(EntityLiving entity, int determinedDifficulty, Random rand) {
    Map<String, Integer> thisSpawnModifiers = Maps.newHashMap();
    int initialDifficulty = determinedDifficulty;
    int failCount = 0;
    String mobId = EntityList.getEntityString(entity);
    RegionMobConfig mobConfig = getConfigForMob(mobId);
    while (determinedDifficulty > allowedMargin && failCount < maxFailCount) {
        DifficultyModifier pickedModifier = mobConfig.pickModifierFromList(rand);
        boolean failed = true;
        if (pickedModifier.costPerChange() <= (determinedDifficulty + allowedMargin) && pickedModifier.validForEntity(entity)) {
            //add mod to list, IFF not past max
            int numAlreadyInList = thisSpawnModifiers.computeIfAbsent(pickedModifier.getIdentifier(), result -> 0);
            if (numAlreadyInList < pickedModifier.getMaxInstances()) {
                thisSpawnModifiers.put(pickedModifier.getIdentifier(), 1 + thisSpawnModifiers.get(pickedModifier.getIdentifier()));
                //reduce remainder of difficulty
                determinedDifficulty -= pickedModifier.costPerChange();
                failed = false;
                failCount = 0;
            }
        }
        if (failed) {
            failCount++;
        }
    }

    String log = "For spawn of " + EntityList.getEntityString(entity)
            + " in region "+ getName()
            + " with difficulty " + initialDifficulty + ", ("+determinedDifficulty+" remaining) decided to use: ";
    for (String modId : thisSpawnModifiers.keySet()) {
        int numToApply = thisSpawnModifiers.get(modId);
        mobConfig.modifiers.get(modId).handleSpawnEvent(numToApply, entity);
        log = log + modId + " " + numToApply + " times, ";
    }
    if(DifficultyManager.debugLogSpawns) {
        LOG.info(log);
    }
    MobNBTHandler.setChangeMap(entity,getName(),thisSpawnModifiers);
}
 
开发者ID:talandar,项目名称:ProgressiveDifficulty,代码行数:39,代码来源:Region.java

示例7: onLivingAttack

import net.minecraft.entity.EntityList; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingAttack(LivingAttackEvent event){
    if(DifficultyManager.enabled) {
        Entity causeMob = event.getSource().getTrueSource();
        if (causeMob instanceof EntityLiving
                && event.getEntity() instanceof EntityPlayer
                && MobNBTHandler.isModifiedMob((EntityLiving) causeMob)) {
            Map<String, Integer> changes = MobNBTHandler.getChangeMap((EntityLiving) causeMob);
            String regionName = MobNBTHandler.getEntityRegion((EntityLiving) causeMob);
            Region mobRegion = DifficultyManager.getRegionByName(regionName);
            String mobId = EntityList.getEntityString(causeMob);
            for (String change : changes.keySet()) {
                try {
                    DifficultyModifier modifier = mobRegion.getModifierForMobById(mobId, change);
                    if (modifier != null) {
                        modifier.handleDamageEvent(event);
                    }
                } catch (Exception e) {
                    LOG.warn("Error applying modifier at onLivingAttack.  Mob was " + causeMob.getName() + ", Modifier was " + change + ".  Please report to Progressive Difficulty Developer!");
                    LOG.warn("\tCaught Exception had message " + e.getMessage());
                }
            }
        } else if (event.getSource().getImmediateSource() instanceof PotionCloudModifier.PlayerEffectingOnlyEntityAreaEffectCloud
                && !(event.getEntity() instanceof EntityPlayer)) {
            event.setCanceled(true);
        }
    }
}
 
开发者ID:talandar,项目名称:ProgressiveDifficulty,代码行数:29,代码来源:EventHandler.java

示例8: getType

import net.minecraft.entity.EntityList; //导入方法依赖的package包/类
public static String getType(Entity ent) {
    if (ent instanceof EntityPlayer) return "Player";
    String type = EntityList.getEntityString(ent);
    return (type == null) ? "???" : type;
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:6,代码来源:ZWrapper.java

示例9: getName

import net.minecraft.entity.EntityList; //导入方法依赖的package包/类
public static String getName(Entity ent) {
    if (ent instanceof EntityPlayer) return getPlayerName((EntityPlayer)ent);
    String type = EntityList.getEntityString(ent);
    return (type == null) ? "???" : type;
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:6,代码来源:ZWrapper.java


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