Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Sound Registry object returning as null


skip999
 Share

Recommended Posts

Hello,

I have been attempting to make a custom armor equip sound for a set of custom armor that I have made. I have registered the sound properly, but I have run into a problem: even though the sound is registered before the armor items are, the sound is returning as null for some reason. I know the sound works and is set up properly, so it must be something with registration. I have attached the crash report as well as linked the relevant classes from my github:

Armor Type: https://github.com/skiprocks999/Electrodynamics-Fork/blob/01b65b032b3cce7c5b5e71485af1c2f24e7874a3/src/main/java/electrodynamics/common/item/gear/armor/types/composite/CompositeArmor.java#L10

Sound Registry: https://github.com/skiprocks999/Electrodynamics-Fork/blob/01b65b032b3cce7c5b5e71485af1c2f24e7874a3/src/main/java/electrodynamics/SoundRegister.java#L13

Item Registration: https://github.com/skiprocks999/Electrodynamics-Fork/blob/01b65b032b3cce7c5b5e71485af1c2f24e7874a3/src/main/java/electrodynamics/DeferredRegisters.java#L300

Registry Registration in Mod Class: https://github.com/skiprocks999/Electrodynamics-Fork/blob/01b65b032b3cce7c5b5e71485af1c2f24e7874a3/src/main/java/electrodynamics/Electrodynamics.java#L59

 

I imagine I'll kick myself when the problem is found. Any help would be appreciated!

crash-2021-08-01_09.58.28-fml.txt

Link to comment
Share on other sites

3 minutes ago, skip999 said:

Here you are trying to access the sound event from the class initialization. But that sound event is only available after the sound registry event has fired. From a static initializer you cannot guarantee this is the case. Your CompositeArmor should store the RegistryObject, not the SoundEvent. Then just call get in getSoundEvent.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Nevermind, I was able to wrap my mind around https://forge.gemwire.uk/wiki/Capabilities#Accessing_a_Capability , and currently have it working!
    • So I'm nearly finished with a version of my mod and, although I haven't done mapping changes in awhile, I'm confident that I have the correct method name so that an instance of reflection runs properly. However, the new method name isn't recognized during load in the real environment (I'm aware it needs to be changed back to run in dev). I cross-referenced both the output.srg as well as a Discord bot and they tell me that: func_221052_a    in     PointOfInterestType.class       should be       registerBlockStates Attached is the relevant class and log file. Any help is appreciated. Loading Output Log Villager Util class:  
    • Hey, I have an issue where I can't run the Minecraft client on a fresh project. The steps I took to set it up are as follows: - Downloaded the Forge 1.12.2 MDK (version 14.23.5.2855) - Extracted the .zip file to a folder - With a command prompt console within that directory, I ran "gradlew genEclipseRuns" then once that successfully completed, "gradlew eclipse". - Opened that root folder as a Gradle project in Eclipse - Under Gradle Tasks I ran "runClient" then received the following error specifically for ":runClient":   org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk-11.0.11\bin\java.exe'' finished with non-zero exit value 1 at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:395) at org.gradle.process.internal.DefaultJavaExecAction.execute(DefaultJavaExecAction.java:37) at org.gradle.api.tasks.JavaExec.exec(JavaExec.java:79) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73) at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:46) at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39) at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26) at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:786) at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:753) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:131) at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300) at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292) at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174) at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90) at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:120) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:99) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:77) at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51) at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59) at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54) at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59) at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101) at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44) at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91) at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59) at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54) at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.run(EventFiringTaskExecuter.java:51) at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300) at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292) at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174) at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90) at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:46) at org.gradle.execution.taskgraph.LocalTaskInfoExecutor.execute(LocalTaskInfoExecutor.java:42) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:273) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:258) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:135) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:130) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.execute(DefaultTaskPlanExecutor.java:200) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.executeWithWork(DefaultTaskPlanExecutor.java:191) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.run(DefaultTaskPlanExecutor.java:130) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) at java.base/java.lang.Thread.run(Thread.java:834) I'd appreciate any help, and please don't think I'm lazy by asking this, I've honestly been looking for a solution for the past ~6 hours haha. Thanks!
    • Hello! I'm trying to create a capability that reads a player's CompoundTag, and extracts some custom mod data from it to assemble an object, along with being given one of those mod objects and writing it to a Player's nbt. I've hopefully created the capability correctly, but I'm not sure how to go about having a `Player` read/write this data during a world save, and how I can go about retrieving the data from a given `Player` object on world join (I know I'd need to subscribe to the event, but I have no idea what I'd do from there). Additionally, this code results in "Invalid player data" whenever I join a world, and I don't know what's in here causes that (EDIT: Figured out this was due to my own bad serialization code. Does this mean that the NBT is automatically loaded on world join and saved on world leave?). My full repository can be found here: https://github.com/hammy3502/elementalism , and the relevant code snippets are below:   Object with Custom Mod Data (PlayerProgressionData.java): public class PlayerProgressionData implements INBTSerializable<CompoundTag> { public static final String outerTag = "elementalism_data"; public ProgressionInfo.ElementType type; public ProgressionInfo.ElementType type2; public List<ProgressionInfo> powersUnlocked; public PlayerProgressionData() { this.type = ProgressionInfo.ElementType.NONE; this.type2 = ProgressionInfo.ElementType.NONE; this.powersUnlocked = new ArrayList<>(); } @Override public CompoundTag serializeNBT() { CompoundTag toRet = new CompoundTag(); CompoundTag data = new CompoundTag(); StringBuilder powersList = new StringBuilder(); for (int i = 0; i < powersUnlocked.size(); i++) { powersList.append(powersUnlocked.get(i).id); if (i != powersUnlocked.size() - 1) { powersList.append(","); } } data.putString("unlockedPowers", powersList.toString()); data.putString("element1", this.type.id); data.putString("element2", this.type2.id); toRet.put(outerTag, data); return toRet; } @Override public void deserializeNBT(CompoundTag nbt) { if (!nbt.contains(outerTag)) return; this.powersUnlocked.clear(); CompoundTag data = nbt.getCompound(outerTag); this.type = ProgressionInfo.ElementType.getElementById(data.getString("element1")); this.type2 = ProgressionInfo.ElementType.getElementById(data.getString("element2")); String[] powerIds = data.getString("unlockedPowers").split(","); for (String id : powerIds) { ProgressionInfo info = Objects.requireNonNull(ProgressionInfoInit.ALL_PROGRESSION_INFOS.get(id)); this.powersUnlocked.add(info); } } } Capability Registration (Elementalism.java): public void registerCapabilities(RegisterCapabilitiesEvent event) { event.register(PlayerProgressionData.class); }   Capability Attaching (CommonSubscriber.java): @SubscribeEvent public void attachCapabilities(AttachCapabilitiesEvent<Entity> event) { if (!(event.getObject() instanceof Player)) return; PlayerProgressionData progressionData = new PlayerProgressionData(); LazyOptional<PlayerProgressionData> optionalProgressionData = LazyOptional.of(() -> progressionData); ICapabilityProvider provider = new ICapabilitySerializable<CompoundTag>() { @Override public CompoundTag serializeNBT() { return progressionData.serializeNBT(); } @Override public void deserializeNBT(CompoundTag nbt) { progressionData.deserializeNBT(nbt); } @Nonnull @Override public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) { if (cap == DATA_STORAGE_CAPABILITY) { return optionalProgressionData.cast(); } return LazyOptional.empty(); } }; event.addCapability(new ResourceLocation(Elementalism.MOD_ID, "data_storage"), provider); event.addListener(optionalProgressionData::invalidate); }   Thank you so much for any help!
    • 1.12 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.