Jump to content

[1.20.2] The target type of this expression must be a functional interface


Adil Yilan

Recommended Posts

I have updated mod that has previously worked with Forge for 1.20.1 to latest version of Forge for 1.20.2, and then code that was previously compiling properly started to show unusual message:

PlayerManager.java:107: error: incompatible types: Factory is not a functional interface PlayersSeenSavedData savedData = storage.get(PlayersSeenSavedData::load, SEENS_KEY);

The code looks like this:

	private static PlayersSeenSavedData tryLoadPlayersSeenData(DimensionDataStorage storage) {

		// Load saved data based on the key.
		PlayersSeenSavedData savedData = storage.get(PlayersSeenSavedData::load, SEENS_KEY);
		
		// IF: Data was never saved before.
		if(savedData == null) {
			savedData = PlayersSeenSavedData.create();
		}
		
		return savedData;
	}

I have checked method signature for get method of DimensionDataStorage for 1.20.1 and 1.20.2 and I cannot find any difference.

Any hints on what exactly has changed and why is my load method now rejected?

Here is the code for load method:

	public static PlayersSeenSavedData load(CompoundTag compoundTag) {
		
		// Load list of NBTs from server data.
		ListTag listTag = compoundTag.getList(KEY, Tag.TAG_COMPOUND);
		
		// Create new empty list that will hold all data.
		ArrayList<PlayerSeenData> playersData = new ArrayList<PlayerSeenData>();
		
		// Iterate through all NBTs.
		for(Tag tag : listTag) {
			
			// Deserialize NBT back to regular object.
			PlayerSeenData playerData = PlayerSeenData.deserialize((CompoundTag)tag);
			
			// Add object to array of data.
			playersData.add(playerData);
		}
		
		// Create new instance of saved data class and provide data that was loaded to it.
		return new PlayersSeenSavedData(playersData);
	}

 

Link to comment
Share on other sites

Alright, so the key for this is to implement a factory method in the class that extends SavedData:

public static SavedData.Factory<PlayersSeenSavedData> factory() {
    return new SavedData.Factory<>(PlayersSeenSavedData::new, PlayersSeenSavedData::load, DataFixTypes.PLAYER);
}

Once the factory method is implemented, it should be provided to .get method of DimensionDataStorage:

PlayersSeenSavedData savedData = storage.get(PlayersSeenSavedData.factory(), SEENS_KEY);

The only thing I am not sure of is usage of DataFixTypes.PLAYER.

What is this used for?

How to select proper DataFixType?

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.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Also wondering how to create these manually.  First time creating a forge server.
    • Exception in thread "main" java.lang.IllegalStateException: Could not find forge-1.19-41.1.0 in classpath at MC-BOOTSTRAP/fmlloader@1.19.2-43.3.5/net.minecraftforge.fml.loading.targets.CommonDevLaunchHandler.lambda$findJarOnClasspath$3(CommonDevLaunchHandler.java:90) at java.base/java.util.Optional.orElseThrow(Optional.java:403) at MC-BOOTSTRAP/fmlloader@1.19.2-43.3.5/net.minecraftforge.fml.loading.targets.CommonDevLaunchHandler.findJarOnClasspath(CommonDevLaunchHandler.java:90) at MC-BOOTSTRAP/fmlloader@1.19.2-43.3.5/net.minecraftforge.fml.loading.targets.ForgeUserdevLaunchHandler.processStreams(ForgeUserdevLaunchHandler.java:17) at MC-BOOTSTRAP/fmlloader@1.19.2-43.3.5/net.minecraftforge.fml.loading.targets.CommonUserdevLaunchHandler.getMinecraftPaths(CommonUserdevLaunchHandler.java:32) at MC-BOOTSTRAP/fmlloader@1.19.2-43.3.5/net.minecraftforge.fml.loading.moddiscovery.MinecraftLocator.scanMods(MinecraftLocator.java:36) at MC-BOOTSTRAP/fmlloader@1.19.2-43.3.5/net.minecraftforge.fml.loading.moddiscovery.ModDiscoverer.discoverMods(ModDiscoverer.java:74) at MC-BOOTSTRAP/fmlloader@1.19.2-43.3.5/net.minecraftforge.fml.loading.FMLLoader.beginModScan(FMLLoader.java:166) at MC-BOOTSTRAP/fmlloader@1.19.2-43.3.5/net.minecraftforge.fml.loading.FMLServiceProvider.beginScanning(FMLServiceProvider.java:86) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.9/cpw.mods.modlauncher.TransformationServiceDecorator.runScan(TransformationServiceDecorator.java:112) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.9/cpw.mods.modlauncher.TransformationServicesHandler.lambda$runScanningTransformationServices$8(TransformationServicesHandler.java:100) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.base/java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1779) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575) at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260) at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616) at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:622) at java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:627) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.9/cpw.mods.modlauncher.TransformationServicesHandler.runScanningTransformationServices(TransformationServicesHandler.java:102) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.9/cpw.mods.modlauncher.TransformationServicesHandler.initializeTransformationServices(TransformationServicesHandler.java:55) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.9/cpw.mods.modlauncher.Launcher.run(Launcher.java:88) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.9/cpw.mods.modlauncher.Launcher.main(Launcher.java:78) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.9/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.9/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) at cpw.mods.bootstraplauncher@1.1.2/cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:141) I tried to make a minecraft mod but this error appears every time I click on the RunClient button and it won't start. Does anyone know how to get rid of this? (btw. I'm using version 1.19.2-43.3.5) https://pastebin.com/mQ3q4SwW
    • I've been following the discussion on automatically downloading mods from server to client, and I thought I'd share a helpful resource I stumbled upon. If you're looking for high-quality images for your mods or any other project, Depositphotos offers a fantastic collection for free download: free download images. In the spirit of collaboration, I believe that access to free, high-resolution visuals can greatly enhance the overall modding experience. Feel free to explore the link, and let me know what you think. Looking forward to hearing your thoughts and ideas on how we can collectively improve mod development efficiency.
    • Indian & Pakistani Girls (+971525382202{{ Dubai House Wife Indian Call 'Girl Deira Indian & Pakistani Girls (+971525382202{{ Dubai House Wife Indian Call 'Girl Deira Indian & Pakistani Girls (+971525382202{{ Dubai House Wife Indian Call 'Girl Deira Indian & Pakistani Girls (+971525382202{{ Dubai House Wife Indian Call 'Girl Deira Indian & Pakistani Girls (+971525382202{{ Dubai House Wife Indian Call 'Girl Deira Indian & Pakistani Girls (+971525382202{{ Dubai House Wife Indian Call 'Girl Deira
    • full-service 0506530048 pakistani call 'girls in deira by dubai full-service 0506530048 pakistani call 'girls in deira by dubai full-service 0506530048 pakistani call 'girls in deira by dubai full-service 0506530048 pakistani call 'girls in deira by dubai full-service 0506530048 pakistani call 'girls in deira by dubai full-service 0506530048 pakistani call 'girls in deira by dubai
  • Topics

×
×
  • Create New...

Important Information

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