Jump to content

frakier

Members
  • Posts

    65
  • Joined

  • Last visited

Posts posted by frakier

  1. in the...

    public class MyCrazyEntity extends CreatureEntity implements IMob

    for each of the soundEvents for ambient, hurt, death etc I call the method from the last post, making name changes as appropriate for each

    if(!ENTITY_TALK_STATUSCHECKED){
    	ENTITY_TALK_SOUNDMISSING=soundMissing(ModSound.entity_talk); //is the sound missing
    	ENTITY_TALK_STATUSCHECKED=true; //remeber we alred have made this check
    }
    if (!ENTITY_TALK_SOUNDMISSING) {
    	return ModSound.ENTITY_TALK; //use my sound
    } else {
    	return SoundEvents.ENTITY_SPIDER_AMBIENT; //use the minecraft sound
    }

    I'll make a demo mod.

  2. You did not read what i wrote that code was the last thing I tried. Did no document the other attempts.

    Put a chicken into the rotisserie to cook, ran the tiller in the garden for awhile getting it broke up...then came back to it....

     

    public static boolean ENTITY_TALK_STATUSCHECKED = false; //remember if we have alredy done this check
    public static boolean ENTITY_TALK_SOUNDMISSING = true; //assume missing and then prove otherwise
    
    public static boolean soundMissing(SoundEvent lookFor) {
    		/*
    		 * I create a couple of variables to hold some information...
    		 * 
    		 * 		after the first check this is set to false and never checked again
    		 * 		ENTITY_TALK_STATUSCHECKED = false
    		 * 
    		 * 		best to assume the sound is missing and then prove otherwise
    		 * 		ENTITY_TALK_SOUNDMISSING = true
    		 * 
    		 * 		in the Entity.java class that calls this, in the soundEvent for ambient, hurt, death etc..
    		 * 		I wrap this method call in a if statement...
    		 * 
    		 * 		if(!ENTITY_TALK_STATUSCHECKED){
    		 *			ENTITY_TALK_SOUNDMISSING=soundMissing(ModSound.entity_talk); //is the sound missing
    		 *			ENTITY_TALK_STATUSCHECKED=true; //remeber we alred have made this check
    		 *		}
    		 *		if (!ENTITY_TALK_SOUNDMISSING) {
    		 *			return ModSound.ENTITY_TALK; //use my sound
    		 *		} else {
    		 *			return SoundEvents.ENTITY_SPIDER_AMBIENT; //use the minecraft sound
    		 *		}
    		*/
    		
    		//get the soundHandler
    		SoundHandler s = Minecraft.getInstance().getSoundHandler();
    		
    		//get some information from the soundevent we are looking for
    		//so we do not have to do this a couple of hundred times
    		String lookfornamespace = lookFor.getRegistryName().getNamespace();
    		String lookforpath = lookFor.getRegistryName().getPath();
    
    		//loopover the registered sound
    		for(SoundEvent soundevent : Registry.SOUND_EVENT) {
    			//only go further is the looking and searched are in the same namespace
    			
    			//namespace match and the sound we are looking for is present
    			if (soundevent.getRegistryName().getNamespace().contains(lookfornamespace) &&
    					soundevent.getRegistryName().getPath().contains(lookforpath)) {
    				//you would think this be enough but no
    				
    				//get a resource location for the current sound event
    				ResourceLocation resourcelocation = soundevent.getName();
    				//create an accessor
    				SoundEventAccessor accessor = s.getAccessor(resourcelocation);
    				//this is where SoundHandler.MISSING_SOUND is returned if the sound is missing
    				//but it is not exposed outside the class so we have to do more.
    				Sound jki = accessor.cloneEntry();
    				
    				//here we go SoundHandler.MISSING_SOUND
    				String path = jki.getSoundLocation().toString();
    				//String lk4 = lookFor.getRegistryName().getPath().replace(".", ":");
    				
    					if (path.contains(SoundHandler.MISSING_SOUND.getSoundLocation().toString())) {
    						return true; //missing
    					} else {
    						return false; //not missing
    					}
    			}
    		}
    		//if you got to here the sound is really is missing
    		return true;
    	}
    }

    It works but I think it will fail if I add multiple sounds into the sounds.json file in resources.
    Think I would be better off only looking over the Registry.SOUND_EVENT once  [or see if I can get the sounds.json file and do the test] and look for any/all sounds with my namspace.

    then test each one at a time, then on the Entity page I would only have to check the ENTITY_TALK_SOUNDMISSING for each sound.
    I'm off to refine this more and trim it down some, will post finalized code once I get it done.

  3. Well two days is enough, going to rip the sounds out of minecraft and drop them into the mod for now and come back to this one later.
    ..
    Searching online was little help... Tried multiple angles and always ran into road blocks with code that was not accessible outside of the classes. Something as simple as a method that checked the UNABLE_TO_PLAY hash set in SoundEngine for the specified sound may have worked. Burned out at this point and moving on to something else. This could have been a simple one liner or a .isEmpty method.
    Oh well, I'll check back later to see if anyone else has a suggestion.

  4. Thanks, but...

    Quote

    "Playing sounds is completely client-side. Only the client knows this information."

    Yes... I was not asking about sides but does that matter or does the CreatureEntity blindly prompt a sound to play. And if that is so could I test during registration of sounds and make the decision.


    I have a entity class that extends a CreatureEntity, with methods getAmbientSound(), getHurtSound(), getDeathSound(), as in...
     

    	@Override
        protected SoundEvent getAmbientSound() {
        	return SpiderSounds.SPIDER_TALK;
        }


    I would like to be able to test the "SpiderSounds.SPIDER_TALK" to see if it is empty.

    Quote

    "PlaySoundEvent to substitute a fallback, if the sound happens to be empty."


    as you say ... "if the sound happens to be empty"... "if the sound happens to be empty"...
    All I was asking is how to "Check if soundEvent is empty".
     

    if (SpiderSounds.SPIDER_TALK != null) {}

    does not work because SpiderSounds.SPIDER_TALK is never null, even if empty.

    If I can see that  SpiderSounds.SPIDER_TALK is empty then I use a simple if statement and return SoundEvents.ENTITY_SPIDER_AMBIENT instead of returning the SpiderSounds.SPIDER_TALK  in the overridden getAmbientSound(), getHurtSound(), getDeathSound() methods.

  5. Is there a way to check if a soundEvent is empty so I can specify a fallback sound using a minecraft existing sounds.
    I'm working on a mod that has spiders, so I can use the minecraft spiders sounds but if someone wants
    to add a resource pack just for my mob, without changing the minecraft spider sounds, i would like to leave that
    option open.

    something like... in a getAmbientSound or getHurtSound method

    	if (SpiderSounds.SPIDER_TALK.isEmpty()) {
        		return SoundEvents.ENTITY_SPIDER_AMBIENT; //use minecrafts spider sounds
        	} else {
        		return SpiderSounds.SPIDER_TALK; //use the sound provided by the resource pack
        	}


    I could rip the spider sounds out of minecraft and include them in the mod with a different name but what would the legal impact be doing it that way.
    Or I could create the sounds from scratch but never have done that and doubt how it would come out.

  6. Well went back and tried the eclipse again and it worked, seems intellij is downloading/unpacking the needed dependencies [the snapshot stuff] into ".gradle\caches\forge_gradle" that eclipse is not doing correctly or at all.

    Before there was this error...
    ...missing required library: 'C:\Windows\System32\unresolved dependency - net.minecraftforge forge 1.14.4-28.1.87_mapped_snapshot_20190719-1.14.3''

    now completes with
    C:\Users\{username}\.gradle\caches\forge_gradle\minecraft_user_repo\net\minecraftforge\forge\1.14.4-28.1.87_mapped_snapshot_20190719-1.14.3

    Hope this helps someone else and if anyone knows where I should report this let me know.

  7. IntelliJ worked though and using the AdoptOpenJDK, got to be something on the eclipse gradle side having problems.
     

    1. Create WORKSPACE "test.forge.mod.intellij".
    2. Create the PROJECT_FOLDER "intellijtest" in the WORKSPACE folder.
    3. Copy in the contents of forge-1.14.4-28.1.87-mdk.zip into the PROJECT_FOLDER.
    4. Right click the PROJECT_FOLDER and in the contexzt menuslect "open folder as intellij idea community edition project". Let intellij do its thing.
    5. On the bottom left hand side of the window next to "build" and "TODO" find the Terminal and click it. Execute gradlew genIntellijRuns
    ...{had a problem had to set classpath} still a problem intellij using internal jdk {had to point to the AdoptOpenJDK folder}...
    6. "Run"->"Edit Configurations"->"Run Client"...
    ...set the "Use classpath of module:" to intellijtest.main .. [Apply]
    ...set the "JRE:"->"Browse"[using the folder icon] to your java jdk folder [for me it was "C:\Program Files\AdoptOpenJDK\jdk-8.0.232.09-hotspot"] .. [Apply]
    ...[OK].."Run"->"runClient"


    WORKED!!
     

    INTELLIJ:

    IntelliJ IDEA 2019.2.4 (Community Edition)
    Build #IC-192.7142.36, built on October 29, 2019
    Runtime version: 11.0.4+10-b304.77 amd64
    VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
    Windows 10 10.0
    GC: ParNew, ConcurrentMarkSweep
    Memory: 725M
    Cores: 4
    Registry:
    Non-Bundled Plugins:
     

    JAVA:
    (due to the recent changes by oracle using the recommended openJDK, tried "Eclipse OpenJ9" but it did not work with [drum-roll please] eclipse had to switch to Hotspot  version)
    (would not be surprised if this is the whole problem)
    openjdk version "1.8.0_232"
    OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_232-b09)
    OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.232-b09, mixed mode)

     

  8. From what I have gathered this is the process...(the process was different last time I played with any mods)
    Now I know I have to make changes to make a mod this is just a straight up test to see if I can narrow down what was going on and was [sort of] surprised to get the same error on the forge example mod.
    1. Create WORKSPACE "test.forge.mod".
    2. Create the PROJECT_FOLDER"test" in the WORKSPACE "test.forge.mod".
    3. Copy in the contents of forge-1.14.4-28.1.87-mdk.zip into the "test" PROJECT_FOLDER.
    4. Start eclipse and select the PROJECT_FOLDER then "import projects"->"Gradle"->"import existing gradle project" [NEXT] select the "test" PROJECT_FOLDER and [finish]. let eclipse do its thing.
    5. Run the Gradle task  "idle" -> "eclipse" then "fg_runs"->"genEclipseRuns".
    6. Be sure and refresh select the PROJECT_FOLDER "test" and refresh [f5] (some 40 errors or so will come down to two errors).
    6. When all is said and done the project has two problems...
    ..."Project 'test' is missing required library: 'C:\Windows\System32\unresolved dependency - net.minecraftforge forge 1.14.4-28.1.87_mapped_snapshot_20190719-1.14.3''
    and
    ..."The project cannot be built until build path errors are resolved".

    I have searched all over and even tried looking around in here, actually found a similar topic but it seemed to just die and there is another topic from today that was for intellij that could be similar but did not want to hijack their post by even explaining I was getting something similar in eclipse.
    Any help would be appreciated.

    EDIT: if there are any logs tell me where to find them and I will attach them.

    ALSO...

    ECLIPSE:

    Eclipse IDE for Java Developers

    Version: 2019-06 (4.12.0)
    Build id: 20190614-1200

    JAVA:
    (due to the recent changes by oracle using the recommended openJDK, tried "Eclipse OpenJ9" but it did not work with [drum-roll please] eclipse had to switch to Hotspot  version)
    (would not be surprised if this is the whole problem)
    openjdk version "1.8.0_232"
    OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_232-b09)
    OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.232-b09, mixed mode)

  9.  

    2 minutes ago, diesieben07 said:

    Here is your mistake. Overriding takes place whether the method comes from a direct superclass or a superclass "further up".

    I see that now.  Makes sense. Believe it or not I have programmed in other languages switching to Java has been a bit different, when I quit getting in my own way I'll have it. I've already setup forge and source for mods from off-line, made simple changes and compiled jar files. This is mostly just a weekend hobby I'm trying to learn and I learn better by example, matching examples from real world [and current forge] to tutorials on-line is interesting to say the least.
    Thanks for the help.

  10. Apparently some people use it when they are not overriding anything. Or maybe I'm just misunderstanding. Like I said still learning.

    In this case the author had a customTorch class that extends BlockTorch [a minecraft class] which of course extends Block [a minecraft class].

    @Override was used on the onBlockActivated method in customTorch and of course as you say BlockTorch does not have the onBlockActivated method but Block does.

    Most of what I have done has been fairly simple up to now and I have used @Override only when.. well overriding a method int a direct parent class.

    Figured I need to go learn more on the subject.

  11. Sorry, I had gotten into a brain loop and had started assuming based on experience from other work I'm doing that the code was there in 1.10. I had convinced myself that somewhere between 1.10 and 1.12 that the method was removed. If I had thought to look back at 1.10 source I would have realized my mistake. I even had the 1.10 source open in a window.

    Thanks for the jolt, knocked me out of that endless loop. I've been running around in for hours.

  12. I've run into a few methods that have been removed/missing like onBlockActivated
    From minecraft classes that extend the Block class such as...
    BlockTorch
    BlockBush
    Just for examples.

    I'm kind of new to this so I figured I would ask what I am missing
    before I drop back to the block class and reinvent the wheel.
    Should I wait for 1.12.2 to mature more?
    Thanks
     

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.