Java 类net.minecraft.client.audio.SoundRegistry 实例源码

项目:CrystalMod    文件:GuiSoundMuffler.java   
public List<ResourceLocation> getSounds(String filter){
    if(soundCache == null){
        soundCache = Lists.newArrayList();

        SoundRegistry reg = null;
        try{
            reg = ObfuscationReflectionHelper.getPrivateValue(SoundHandler.class, Minecraft.getMinecraft().getSoundHandler(), 4);
        } catch(Exception e){}

        if(reg == null)return soundCache;

        for(ResourceLocation loc : reg.getKeys()){
            if(loc.toString().toLowerCase().contains(filter)){
                soundCache.add(loc);
            }
        }
    }
    return soundCache;
}
项目:projectzulu1.7.10-pre-1.3a    文件:GuiLimitedMobSpawner.java   
public void openList(ListType listType) {
    currentListType = listType;
    switch (currentListType) {
    case Creature:
        /* Create List if Empty */
        if (rootCreatureNode.numberOfChildren() == 0) {
            Iterator stringToClassIterator = EntityList.stringToClassMapping.keySet().iterator();
            while (stringToClassIterator.hasNext()) {
                String stringKey = (String) stringToClassIterator.next();
                if (EntityLiving.class.isAssignableFrom(((Class) EntityList.stringToClassMapping.get(stringKey)))) {
                    if (stringKey.equals("Mob")) {
                        continue;
                    }
                    rootCreatureNode.addChild("root." + stringKey);
                }
            }
            rootCreatureNode.sortNodeTree();
        }
        scrollingList = new GUISelectionList(this, rootCreatureNode, currentListType, 85, new Point(this.width,
                this.height), backgroundSize);
        scrollingList.registerScrollButtons(this.buttonList, 7, 8);
        break;
    case Sound:
        if (rootSoundNode.numberOfChildren() == 0) {
            /*
             * Grab "nameToSoundPoolEntriesMapping" : OBFSC: "m" : nameToSoundPoolEntriesMapping --> fields.csv -->
             * joined.srg --> d
             */
            SoundRegistry registry = ObfuscationHelper.getFieldFromReflection("field_147697_e", "sndRegistry",
                    mc.getSoundHandler(), SoundRegistry.class);
            HashMap soundHash = ObfuscationHelper.getFieldFromReflection("field_148764_a", "field_148764_a",
                    registry, HashMap.class);

            if (soundHash != null) {
                Iterator stringSoundIterator = soundHash.keySet().iterator();
                while (stringSoundIterator.hasNext()) {
                    ResourceLocation key = (ResourceLocation) stringSoundIterator.next();
                     rootSoundNode.addChild("root." + key.getResourceDomain() + "." + key.getResourcePath());
                }
                rootSoundNode.sortNodeTree();
            }
        }
        scrollingList = new GUISelectionList(this, rootSoundNode, currentListType, 85, new Point(this.width,
                this.height), backgroundSize);
        scrollingList.registerScrollButtons(this.buttonList, 7, 8);
        break;
    default:
        throw new IllegalStateException("Trying to Open invalid List type " + listType.toString());
    }
}
项目:projectzulu1.7.10    文件:GuiLimitedMobSpawner.java   
public void openList(ListType listType) {
    currentListType = listType;
    switch (currentListType) {
    case Creature:
        /* Create List if Empty */
        if (rootCreatureNode.numberOfChildren() == 0) {
            Iterator stringToClassIterator = EntityList.stringToClassMapping.keySet().iterator();
            while (stringToClassIterator.hasNext()) {
                String stringKey = (String) stringToClassIterator.next();
                if (EntityLiving.class.isAssignableFrom(((Class) EntityList.stringToClassMapping.get(stringKey)))) {
                    if (stringKey.equals("Mob")) {
                        continue;
                    }
                    rootCreatureNode.addChild("root." + stringKey);
                }
            }
            rootCreatureNode.sortNodeTree();
        }
        scrollingList = new GUISelectionList(this, rootCreatureNode, currentListType, 85, new Point(this.width,
                this.height), backgroundSize);
        scrollingList.registerScrollButtons(this.buttonList, 7, 8);
        break;
    case Sound:
        if (rootSoundNode.numberOfChildren() == 0) {
            /*
             * Grab "nameToSoundPoolEntriesMapping" : OBFSC: "m" : nameToSoundPoolEntriesMapping --> fields.csv -->
             * joined.srg --> d
             */
            SoundRegistry registry = ObfuscationHelper.getFieldFromReflection("field_147697_e", "sndRegistry",
                    mc.getSoundHandler(), SoundRegistry.class);
            HashMap soundHash = ObfuscationHelper.getFieldFromReflection("field_148764_a", "field_148764_a",
                    registry, HashMap.class);

            if (soundHash != null) {
                Iterator stringSoundIterator = soundHash.keySet().iterator();
                while (stringSoundIterator.hasNext()) {
                    ResourceLocation key = (ResourceLocation) stringSoundIterator.next();
                     rootSoundNode.addChild("root." + key.getResourceDomain() + "." + key.getResourcePath());
                }
                rootSoundNode.sortNodeTree();
            }
        }
        scrollingList = new GUISelectionList(this, rootSoundNode, currentListType, 85, new Point(this.width,
                this.height), backgroundSize);
        scrollingList.registerScrollButtons(this.buttonList, 7, 8);
        break;
    default:
        throw new IllegalStateException("Trying to Open invalid List type " + listType.toString());
    }
}