Jump to content

World cannot be resolved to a type


Recommended Posts

I've been able to add a CustomBlock and texture it so far; just simple stuff.

Upping the game and I want to start getting that block to interact with other items in the world, so I've gone through the docs and found onBlockPlacedBy, and I have this class.

 

package com.example.examplemod;

import net.minecraft.core.BlockPos;
import net.minecraft.world.*;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;

public class CustomBlock extends Block
{
	public CustomBlock()
	{
		super(BlockBehaviour.Properties.of());
	}

	@Override
    public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack)
	{
        super.onBlockPlacedBy(world, pos, state, placer, stack);
    }
}

 

All the other imports work correctly, and can find BlockPos, BlockState, LivingEntity, ItemStack but I can't find World.

I've tried letting Eclipse find it, but it can't. I've searched the docs, and I can see it, but not for anything past 1.16.x

This is on 1.20.1, I don't believe it to be an import issue as other Types can be found and the super.onBlockPlacedBy() knows it needs a World type as its first parameter, yet I can't find where onBlockPlacedBy() is implemented in the inheritance tree either...

 

Any help would be great, I can't seem to find any docs for 1.20.1 that are up to date either.

Link to comment
Share on other sites

If you are posting compiler errors then you are in the wrong forum.

This is a support forum. It is not a place to learn minecraft modding or java.

We help people that have already implemented something but it doesn't work as they expected.

To receive such help, you need to provide a working example (preferably on github) that reproduces your problem.

Code snippets out of context in the forums do not qualify.

 

For your specific observations.

Forge changed to the Mojang deobfuscation mappings for minecraft 1.17

https://gist.github.com/50ap5ud5/beebcf056cbdd3c922cc8993689428f4#full-migration-to-mojang-mappings

Trying to use the old Forge mappings from 1.16 and before, whether examples, tutorials or docs  isn't going to work unless you understand how to translate them.

 

Forge only documents the things it changes and maybe other bits that are relevant to those changes.

It does not try to document the whole of Mojang's Minecraft source code.

Efforts to do such things can be found in for example in the parchment project: https://parchmentmc.org/

 

The translations you are looking for in your particular example are:

Old Forge => Mojang official

World => Level

onBlockPlacedBy => setPlacedBy

Do not expect to be able to ask for other such mappings. You need to do your own research.

Edited by warjort
  • Thanks 1

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

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