net.minecraft.entity.EntityList Java Examples

The following examples show how to use net.minecraft.entity.EntityList. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EmptySyringe.java    From EmergingTechnology with MIT License 6 votes vote down vote up
@Override
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer playerIn, EntityLivingBase target,
        EnumHand hand) {

    if (playerIn.world.isRemote) {
        return false;
    }

    String entityId = EntityList.getKey(target).toString();

    ItemStack itemStack = ModTissueProvider.getSyringeItemStackByEntityId(entityId);

    if (!StackHelper.isItemStackEmpty(itemStack)) {
        ItemStack newItemStack = stack.copy();
        newItemStack.shrink(1);
        playerIn.setHeldItem(hand, newItemStack);
        playerIn.addItemStackToInventory(itemStack);
        return true;
    }

    return false;
}
 
Example #2
Source File: ItemPetContract.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void signContract(ItemStack stack, EntityPlayer oldOwner, EntityLivingBase target)
{
    NBTTagCompound nbt = NBTUtils.getCompoundTag(stack, null, true);
    UUID uuidOwner = oldOwner.getUniqueID();
    nbt.setLong("OwnerM", uuidOwner.getMostSignificantBits());
    nbt.setLong("OwnerL", uuidOwner.getLeastSignificantBits());

    UUID uuidTarget = target.getUniqueID();
    nbt.setLong("OwnableM", uuidTarget.getMostSignificantBits());
    nbt.setLong("OwnableL", uuidTarget.getLeastSignificantBits());

    nbt.setFloat("Health", target.getHealth());
    String str = EntityList.getEntityString(target);

    if (str != null)
    {
        nbt.setString("EntityString", str);
    }

    if (target.hasCustomName())
    {
        nbt.setString("CustomName", target.getCustomNameTag());
    }

    oldOwner.getEntityWorld().playSound(null, oldOwner.getPosition(), SoundEvents.BLOCK_ENCHANTMENT_TABLE_USE, SoundCategory.PLAYERS, 0.5f, 1f);
}
 
Example #3
Source File: MinecraftTypeHelper.java    From malmo with MIT License 6 votes vote down vote up
/** Does essentially the same as entity.getName(), but without pushing the result
 * through the translation layer. This ensures the result matches what we use in Types.XSD,
 * and prevents things like "entity.ShulkerBullet.name" being returned, where there is no
 * translation provided in the .lang file.
 * @param e The entity
 * @return The entity's name.
 */
public static String getUnlocalisedEntityName(Entity e)
{
    String name;
    if (e.hasCustomName())
    {
        name = e.getCustomNameTag();
    }
    else if (e instanceof EntityPlayer)
    {
        name = e.getName(); // Just returns the user name
    }
    else
    {
        name = EntityList.getEntityString(e);
        if (name == null)
            name = "unknown";
    }
    return name;
}
 
Example #4
Source File: MobSpawnEventHandler.java    From EnderZoo with Creative Commons Zero v1.0 Universal 6 votes vote down vote up
@SubscribeEvent
public void onCheckSpawn(CheckSpawn evt) {
  if (evt.getEntityLiving() == null) {
    return;
  }
  String name = EntityList.getEntityString(evt.getEntityLiving());
  if (name == null) {
    return;
  }
  for (ISpawnEntry ent : MobSpawns.instance.getEntries()) {
    if (name.equals(ent.getMobName())) {
      if (!ent.canSpawnInDimension(evt.getWorld())) {
        evt.setResult(Result.DENY);
      }
    }
  }

}
 
Example #5
Source File: QuestKillMobs.java    From ToroQuest with GNU General Public License v3.0 6 votes vote down vote up
private void handleKillMobsQuest(EntityPlayer player, Province provinceHuntedIn, EntityLivingBase victim) {
	if (victim == null) {
		return;
	}
	Set<QuestData> quests = PlayerCivilizationCapabilityImpl.get(player).getCurrentQuests();

	DataWrapper quest = new DataWrapper();
	for (QuestData data : quests) {
		try {
			quest.setData(data);
			quest.huntedMob = EntityList.getKey(victim).getResourcePath();
			quest.provinceHuntedIn = provinceHuntedIn;
			if (perform(quest)) {
				return;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
 
Example #6
Source File: EntityUtils.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Nullable
private static Entity createEntityFromNBTSingle(NBTTagCompound nbt, World world)
{
    try
    {
        Entity entity = EntityList.createEntityFromNBT(nbt, world);

        if (entity != null)
        {
            entity.setUniqueId(UUID.randomUUID());
        }

        return entity;
    }
    catch (Exception e)
    {
        return null;
    }
}
 
Example #7
Source File: PlayerChunkViewer.java    From ChickenChunks with MIT License 6 votes vote down vote up
public void update()
{
    TicketInfo ticket = tickets.get(ticketComboBox.getSelectedIndex());
    String info = "<span style=\"font-family:Tahoma; font-size:10px\">";
    info += "Mod: " + ticket.modId;
    if(ticket.player != null)
        info += "<br>Player: " + ticket.player;
    info += "<br>Type: " + ticket.type.name();
    if(ticket.entity != null)
        info += "<br>Entity: " + EntityList.classToStringMapping.get(ticket.entity) + "#" + ticket.entity.getEntityId() + " (" + String.format("%.2f", ticket.entity.posX) + ", " + String.format("%.2f", ticket.entity.posY) + ", " + String.format("%.2f", ticket.entity.posZ) + ")";
    info+="</span><p style=\"text-align:center; font-family:Tahoma; font-size:10px\">ForcedChunks</p>";
    String chunks = "<span style=\"font-family:Tahoma; font-size:10px\">";
    for(ChunkCoordIntPair coord : ticket.chunkSet)
        chunks += coord.chunkXPos + ", " + coord.chunkZPos + "<br>";
    chunks += "</span>";
    infoPane.setText(info);
    chunkPane.setText(chunks);
    repaint();
}
 
Example #8
Source File: ClientProxy.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void init(FMLInitializationEvent event) {
	super.init(event);

	MinecraftForge.EVENT_BUS.register(CapeHandler.instance());

	Map<String, RenderPlayer> skinMap = Minecraft.getMinecraft().getRenderManager().getSkinMap();
	for (RenderPlayer render : skinMap.values()) {
		//	render.addLayer(new BloodRenderLayer(render));
		render.addLayer(new RenderHaloEntity(render.getMainModel().bipedHead));
	}

	Map<Class<? extends Entity>, Render<? extends Entity>> map = Minecraft.getMinecraft().getRenderManager().entityRenderMap;
	for (ResourceLocation entity : EntityList.getEntityNameList()) {
		Class<? extends Entity> clazz = EntityList.getClass(entity);
		Render<? extends Entity> entityRenderer = map.get(clazz);
		if (entityRenderer instanceof RenderLiving<?>) {
			ModelBase main = ((RenderLiving<?>) entityRenderer).getMainModel();
			ModelRenderer renderer = null;
			if (main instanceof ModelBiped) renderer = ((ModelBiped) main).bipedHead;

			((RenderLiving<?>) entityRenderer).addLayer(new RenderHaloEntity(renderer));
		}
	}
}
 
Example #9
Source File: EntityHandler.java    From wailanbt with MIT License 6 votes vote down vote up
@Override
public List<String> getWailaBody(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config) {
    Entity currentEntity = accessor.getEntity();
    Class currentEntityClass = currentEntity.getClass();
    if (EntityList.classToStringMapping.containsKey(currentEntityClass)) {
        NBTTagCompound n = accessor.getNBTData();
        //LogHelper.info(n.toString());
        EntityPlayer player = accessor.getPlayer();
        ItemStack holdItemReal = player.getHeldItem();
        String holdItemNameReal = "";
        if (holdItemReal != null) {
            holdItemNameReal = Item.itemRegistry.getNameForObject(holdItemReal.getItem());
        }
        NBTHandler.flag=1;
        NBTHandler.id= EntityList.getEntityString(currentEntity);
        //currenttip.add(NBTHandler.id);
        List<String> tips = NBTHandler.getTipsFromNBT(n, holdItemNameReal);
        currenttip.addAll(tips);
    }
    return currenttip;
}
 
Example #10
Source File: EntityHandler.java    From OmniOcular with Apache License 2.0 5 votes vote down vote up
@Override
public List<String> getWailaBody(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config) {
    NBTTagCompound n = accessor.getNBTData();
    if (n != null) {
        currenttip.addAll(JSHandler.getBody(ConfigHandler.entityPattern, n, EntityList.getEntityString(accessor.getEntity()), accessor.getPlayer()));
    }
    return currenttip;
}
 
Example #11
Source File: CraftStatistic.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
public static net.minecraft.stats.StatBase getEntityStatistic(org.bukkit.Statistic stat, EntityType entity) {
    EntityEggInfo entityEggInfo = (EntityEggInfo) EntityList.entityEggs.get(Integer.valueOf(entity.getTypeId()));

    if (entityEggInfo != null) {
        return entityEggInfo.field_151512_d;
    }
    return null;
}
 
Example #12
Source File: EntityBlock.java    From OpenModsLib with MIT License 5 votes vote down vote up
public static void registerFixes(DataFixer fixers, final Class<? extends EntityBlock> cls) {
	fixers.registerWalker(FixTypes.ENTITY, (fixer, compound, versionIn) -> {
		if (EntityList.getKey(cls).equals(new ResourceLocation(compound.getString("id")))) {
			if (compound.hasKey(TAG_TILE_ENTITY, Constants.NBT.TAG_COMPOUND)) {
				final NBTTagCompound teTag = compound.getCompoundTag(TAG_TILE_ENTITY);
				final NBTTagCompound fixedTeTag = fixer.process(FixTypes.BLOCK_ENTITY, teTag, versionIn);
				compound.setTag(TAG_TILE_ENTITY, fixedTeTag);
			}
		}

		return compound;
	});
}
 
Example #13
Source File: EntityRegistrator.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public static int getUniqueEntityId(){
    int startEntityId = 0;
    do {
        startEntityId++;
    } while(EntityList.getStringFromID(startEntityId) != null);

    return startEntityId;
}
 
Example #14
Source File: ItemMobSpawner.java    From NotEnoughItems with MIT License 5 votes vote down vote up
public static void loadSpawners(World world) {
    if (loaded) return;
    loaded = true;
    HashMap<Class<Entity>, String> classToStringMapping = (HashMap<Class<Entity>, String>) EntityList.classToStringMapping;
    HashMap<Class<Entity>, Integer> classToIDMapping = (HashMap<Class<Entity>, Integer>) EntityList.classToIDMapping;
    for (Class<Entity> eclass : classToStringMapping.keySet()) {
        if (!EntityLiving.class.isAssignableFrom(eclass))
            continue;
        try {
            EntityLiving entityliving = (EntityLiving) eclass.getConstructor(new Class[]{World.class}).newInstance(world);
            entityliving.isChild();

            int id = classToIDMapping.get(eclass);
            String name = classToStringMapping.get(eclass);

            if (name.equals("EnderDragon"))
                continue;

            IDtoNameMap.put(id, name);

            if (name.equals("Pig"))
                idPig = id;
        } catch (Throwable ignored) {
        }
    }

    for(Iterator<Entry<Integer, String>> it = IDtoNameMap.entrySet().iterator(); it.hasNext();) {
        Entry<Integer, String> e = it.next();
        if(getEntity(e.getKey()).getClass() == EntityPig.class && !e.getValue().equals("Pig"))
            it.remove();
    }
}
 
Example #15
Source File: CommandEntity.java    From wailanbt with MIT License 5 votes vote down vote up
@Override
public void processCommand(ICommandSender sender, String[] array) {
    EntityPlayer player = (EntityPlayer) sender;
    Minecraft minecraft = Minecraft.getMinecraft();
    MovingObjectPosition objectMouseOver = minecraft.objectMouseOver;
    if (objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY){
        Class pointEntityClass  = objectMouseOver.entityHit.getClass();
        if (EntityList.classToStringMapping.containsKey(pointEntityClass)){
         player.addChatComponentMessage(new ChatComponentText(EntityList.getEntityString(objectMouseOver.entityHit)));
        }
    }else{
        player.addChatComponentMessage(new ChatComponentTranslation("wailanbt.info.NotPointing"));
    }
}
 
Example #16
Source File: ServerStateMachine.java    From malmo with MIT License 5 votes vote down vote up
/** Called by Forge - return ALLOW, DENY or DEFAULT to control spawning in our world.*/
@SubscribeEvent
public void onCheckSpawn(CheckSpawn cs)
{
    // Decide whether or not to allow spawning.
    // We shouldn't allow spawning unless it has been specifically turned on - whether
    // a mission is running or not. (Otherwise spawning may happen in between missions.)
    boolean allowSpawning = false;
    if (currentMissionInit() != null && currentMissionInit().getMission() != null)
    {
        // There is a mission running - does it allow spawning?
        ServerSection ss = currentMissionInit().getMission().getServerSection();
        ServerInitialConditions sic = (ss != null) ? ss.getServerInitialConditions() : null;
        if (sic != null)
            allowSpawning = (sic.isAllowSpawning() == Boolean.TRUE);

        if (allowSpawning && sic.getAllowedMobs() != null && !sic.getAllowedMobs().isEmpty())
        {
            // Spawning is allowed, but restricted to our list.
            // Is this mob on our list?
            String mobName = EntityList.getEntityString(cs.getEntity());
            allowSpawning = false;
            for (EntityTypes mob : sic.getAllowedMobs())
            {
                if (mob.value().equals(mobName))
                {
                    allowSpawning = true;
                    break;
                }
            }
        }
    }
    if (allowSpawning)
        cs.setResult(Result.DEFAULT);
    else
        cs.setResult(Result.DENY);
}
 
Example #17
Source File: CommandEntityName.java    From OmniOcular with Apache License 2.0 5 votes vote down vote up
@Override
public void processCommand(ICommandSender sender, String[] array) {
    EntityPlayer player = (EntityPlayer) sender;
    Minecraft minecraft = Minecraft.getMinecraft();
    MovingObjectPosition objectMouseOver = minecraft.objectMouseOver;
    if (objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) {
        Class pointEntityClass = objectMouseOver.entityHit.getClass();
        if (EntityList.classToStringMapping.containsKey(pointEntityClass)) {
            player.addChatComponentMessage(new ChatComponentText(EntityList.getEntityString(objectMouseOver.entityHit)));
        }
    } else {
        player.addChatComponentMessage(new ChatComponentTranslation("omniocular.info.NotPointing"));
    }
}
 
Example #18
Source File: EntityDumper.java    From NEI-Integration with MIT License 5 votes vote down vote up
@Override
public Iterable<String[]> dump(int mode) {
    List<String[]> list = new LinkedList<String[]>();
    
    List<Integer> ids = new ArrayList<Integer>();
    ids.addAll(EntityList.IDtoClassMapping.keySet());
    Collections.sort(ids);
    
    for (int id : ids) {
        list.add(new String[] { GLOBAL, String.valueOf(id), EntityList.getStringFromID(id), EntityList.getClassFromID(id).getName() });
    }
    
    ListMultimap<ModContainer, EntityRegistration> modEntities = ReflectionHelper.getPrivateValue(EntityRegistry.class, EntityRegistry.instance(), "entityRegistrations");
    
    for (Entry<ModContainer, EntityRegistration> e : modEntities.entries()) {
        EntityRegistration er = e.getValue();
        list.add(new String[] { e.getKey().getModId(), String.valueOf(er.getModEntityId()), e.getKey().getModId() + "." + er.getEntityName(), er.getEntityClass().getName() });
    }
    
    Collections.sort(list, new Comparator<String[]>() {
        @Override
        public int compare(String[] s1, String[] s2) {
            if (s1[0].equals(GLOBAL) && !s1[0].equals(s2[0])) {
                return -1;
            }
            int i = s1[0].compareTo(s2[0]);
            if (i != 0) {
                return i;
            }
            return Integer.compare(Integer.valueOf(s1[1]), Integer.valueOf(s2[1]));
        }
    });
    
    return list;
}
 
Example #19
Source File: WrathSpawnerLogic.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
public Entity getEntityForRender() {
    if (this.renderEntity == null) {
        Entity entity = EntityList.createEntityByName(this.getEntityNameToSpawn(), (World) null);
        entity = this.spawnMob(entity);
        this.renderEntity = entity;
    }

    return this.renderEntity;
}
 
Example #20
Source File: BaseEntityRegistry.java    From Electro-Magic-Tools with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public static void registerEntityEgg(Class<? extends Entity> entity, int colPrim, int colSec) {
    int id = getUniqueEntityID();
    EntityList.IDtoClassMapping.put(id, entity);
    EntityList.entityEggs.put(id, new EntityEggInfo(id, colPrim, colSec));
    return;
}
 
Example #21
Source File: ItemLivingManipulator.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
private boolean canStoreEntity(Entity entity)
{
    if (Configs.lmmListIsWhitelist)
    {
        return Sets.newHashSet(Configs.lmmWhitelist).contains(EntityList.getEntityString(entity));
    }
    else
    {
        return Sets.newHashSet(Configs.lmmBlacklist).contains(EntityList.getEntityString(entity)) == false;
    }
}
 
Example #22
Source File: BaseEntityRegistry.java    From Electro-Magic-Tools with GNU General Public License v3.0 5 votes vote down vote up
private static int getUniqueEntityID() {

        do {
            startEID++;
        } while (EntityList.getStringFromID(startEID) != null);
        return startEID;
    }
 
Example #23
Source File: EntityUtils.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new, identical instance of the given entity, by writing it to NBT
 * and then constructing a new entity based on that NBT data.
 * @param entityOld the original entity
 * @return the new entity, or null if the operation failed
 */
@Nullable
public static Entity recreateEntityViaNBT(Entity entityOld)
{
    NBTTagCompound tag = new NBTTagCompound();
    Entity entityNew = null;

    if (entityOld.writeToNBTOptional(tag))
    {
        entityNew = EntityList.createEntityFromNBT(tag, entityOld.getEntityWorld());
    }

    return entityNew;
}
 
Example #24
Source File: MixinWorld.java    From VanillaFix with MIT License 5 votes vote down vote up
/**
 * @reason Adds subsections to the "root.tick.level.entities.regular.tick"
 * profiler, using the entity ID, or the class name if the ID is null.
 */
@Redirect(method = "updateEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;onUpdate()V"))
private void entityOnUpdate(Entity entity) {
    profiler.func_194340_a(() -> { // func_194340_a = startSection(Supplier<String>)
        final ResourceLocation entityID = EntityList.getKey(entity);
        return entityID == null ? entity.getClass().getSimpleName() : entityID.toString();
    });
    entity.onUpdate();
    profiler.endSection();
}
 
Example #25
Source File: SpawnEggCommand.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
private ResourceLocation findSimilar(String name) {
    ResourceLocation ret = null;
    double similarity = 0.0f;

    for (ResourceLocation res : EntityList.getEntityNameList()) {
        final double currentSimilarity = StringUtil.levenshteinDistance(name, res.getPath());

        if (currentSimilarity >= similarity) {
            similarity = currentSimilarity;
            ret = res;
        }
    }

    return ret;
}
 
Example #26
Source File: SpawnEggCommand.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
private ResourceLocation find(String name) {
    for (ResourceLocation res : EntityList.getEntityNameList()) {
        if (res.getPath().equalsIgnoreCase(name)) {
            return res;
        }
    }
    return null;
}
 
Example #27
Source File: EnchantmentEnderDamage.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onEntityDamaged(EntityLivingBase hurtEntity, Entity damagingEntity, int level) {
    String entityName = EntityList.getEntityString(hurtEntity);
    if (hurtEntity instanceof EntityEnderman || hurtEntity instanceof EntityDragon || (entityName != null && entityName.toLowerCase().contains("ender"))) {
        hurtEntity.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, level * 200, Math.max(1, (5 * level) / 7)));
        hurtEntity.addPotionEffect(new PotionEffect(MobEffects.POISON, level * 200, Math.max(1, (5 * level) / 7)));
    }
}
 
Example #28
Source File: CraftHumanEntity.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@Override
public org.bukkit.entity.Entity getShoulderEntityLeft() {
    if (!getHandle().getLeftShoulderEntity().hasNoTags()) {
        Entity shoulder = EntityList.createEntityFromNBT(getHandle().getLeftShoulderEntity(), getHandle().world);

        return (shoulder == null) ? null : shoulder.getBukkitEntity();
    }

    return null;
}
 
Example #29
Source File: CraftHumanEntity.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@Override
public org.bukkit.entity.Entity getShoulderEntityRight() {
    if (!getHandle().getRightShoulderEntity().hasNoTags()) {
        Entity shoulder = EntityList.createEntityFromNBT(getHandle().getRightShoulderEntity(), getHandle().world);

        return (shoulder == null) ? null : shoulder.getBukkitEntity();
    }

    return null;
}
 
Example #30
Source File: CraftStatistic.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public static StatBase getEntityStatistic(Statistic stat, EntityType entity) {
    EntityList.EntityEggInfo monsteregginfo = EntityList.ENTITY_EGGS.get(new ResourceLocation(entity.getName()));

    if (monsteregginfo != null) {
        if (stat == Statistic.KILL_ENTITY) {
            return monsteregginfo.killEntityStat;
        }
        if (stat == Statistic.ENTITY_KILLED_BY) {
            return monsteregginfo.entityKilledByStat;
        }
    }
    return null;
}