Packages not found

Started by Sammy_HD on Sat, 06/26/2021 - 07:26

Topic category: Help with modding (Java Edition)

Last seen on 09:31, 16. Aug 2021
Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Packages not found
Sat, 06/26/2021 - 07:26

I got the following errors: 

 

Executing Gradle task: runClient 
Build info: MCreator 2021.1.18117, forge-1.16.5, 64-bit, 32699 MB, Windows 10, JVM 1.8.0_275, JAVA_HOME: C:\Program Files\Pylo\MCreator\jdk 
> Task :compileJava FAILED 
C:\Users\Sammy_HD\MCreatorWorkspaces\tests\src\main\java\net\mcreator\tests\block\PerfectstonestairBlock.java:26: error: package net.minecraft.block.state does not exist 
import net.minecraft.block.state.*; 
^ 
C:\Users\Sammy_HD\MCreatorWorkspaces\tests\src\main\java\net\mcreator\tests\block\PerfectstonestairBlock.java:29: error: package net.minecraft.block.properties does not exist 
import net.minecraft.block.properties.PropertyDirection; 
                                     ^ 
C:\Users\Sammy_HD\MCreatorWorkspaces\tests\src\main\java\net\mcreator\tests\block\PerfectstonestairBlock.java:62: error: cannot find symbol 
      public static final PropertyDirection FACING = PropertyDirection.create("facing"); 
                          ^ 
  symbol:   class PropertyDirection 
  location: class CustomBlock 
C:\Users\Sammy_HD\MCreatorWorkspaces\tests\src\main\java\net\mcreator\tests\block\PerfectstonestairBlock.java:62: error: cannot find symbol 
      public static final PropertyDirection FACING = PropertyDirection.create("facing"); 
                                                     ^ 
  symbol:   variable PropertyDirection 
  location: class CustomBlock 
C:\Users\Sammy_HD\MCreatorWorkspaces\tests\src\main\java\net\mcreator\tests\block\PerfectstonestairBlock.java:68: error: cannot find symbol 
         setDefaultState(getDefaultState().withProperty(FACING, EnumFacing.NORTH)); 
                                                                ^ 
  symbol:   variable EnumFacing 
  location: class CustomBlock 
5 errors 
FAILURE: Build failed with an exception. 
* What went wrong: 
Execution failed for task ':compileJava'. 
> Compilation failed; see the compiler error output for details. 
* Try: 
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. 
* Get more help at https://help.gradle.org 
BUILD FAILED in 1s 
1 actionable task: 1 executed 
BUILD FAILED 
Task completed in 3 seconds 

With the following code:


package net.mcreator.tests.block;

import net.minecraftforge.registries.ObjectHolder;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.api.distmarker.Dist;

import net.minecraft.world.IBlockReader;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.Direction;
import net.minecraft.loot.LootContext;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.Item;
import net.minecraft.item.BlockItem;
import net.minecraft.client.renderer.RenderTypeLookup;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.block.material.Material;
import net.minecraft.block.SoundType;
import net.minecraft.block.BlockState;
import net.minecraft.block.Block;
import net.minecraft.block.state.*;
import net.minecraft.block.*;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.*;
import net.minecraftforge.fml.common.registry.GameRegistry;

import net.mcreator.tests.TestsModElements;

import java.util.List;
import java.util.Collections;

@TestsModElements.ModElement.Tag
public class PerfectstonestairBlock extends TestsModElements.ModElement {
	@ObjectHolder("tests:perfectstonestair")
	public static final Block block = null;
	public PerfectstonestairBlock(TestsModElements instance) {
		super(instance, 1);
	}

	@Override
	public void initElements() {
		elements.blocks.add(() -> new CustomBlock());
		elements.items
				.add(() -> new BlockItem(block, new Item.Properties().group(ItemGroup.BUILDING_BLOCKS)).setRegistryName(block.getRegistryName()));
	}

	@Override
	@OnlyIn(Dist.CLIENT)
	public void clientLoad(FMLClientSetupEvent event) {
		RenderTypeLookup.setRenderLayer(block, RenderType.getCutout());
	}
	public static class CustomBlock extends Block {
		public static final PropertyDirection FACING = PropertyDirection.create("facing");
	
		public CustomBlock() {
			super(Block.Properties.create(Material.ROCK).sound(SoundType.STONE).hardnessAndResistance(1f, 10f).setLightLevel(s -> 0).notSolid()
					.setOpaque((bs, br, bp) -> false));
			setRegistryName("perfectstonestair");
			setDefaultState(getDefaultState().withProperty(FACING, EnumFacing.NORTH));
		}

		@Override
		public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
			return true;
		}

		@Override
		public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) {
			switch ((Direction) state.get(FACING)) {
			default:
				return VoxelShapes.or(makeCuboidShape(0, 0, 0, 16, 1, 16), makeCuboidShape(0, 1, 0, 16, 2, 15), makeCuboidShape(0, 2, 0, 16, 3, 14), makeCuboidShape(0, 3, 0, 16, 4, 13), makeCuboidShape(0, 4, 0, 16, 5, 12), makeCuboidShape(0, 5, 0, 16, 6, 11), makeCuboidShape(0, 6, 0, 16, 7, 10), makeCuboidShape(0, 7, 0, 16, 8, 9), makeCuboidShape(0, 8, 0, 16, 9, 8), makeCuboidShape(0, 9, 0, 16, 10, 7), makeCuboidShape(0, 10, 0, 16, 11, 6), makeCuboidShape(0, 11, 0, 16, 12, 5), makeCuboidShape(0, 12, 0, 16, 13, 4), makeCuboidShape(0, 13, 0, 16, 14, 3), makeCuboidShape(0, 14, 0, 16, 15, 2), makeCuboidShape(0, 15, 0, 16, 16, 1));
		    case SOUTH :
		    	return VoxelShapes.or(makeCuboidShape(0, 0, 0, 16, 1, 16), makeCuboidShape(0, 1, 0, 16, 2, 15), makeCuboidShape(0, 2, 0, 16, 3, 14), makeCuboidShape(0, 3, 0, 16, 4, 13), makeCuboidShape(0, 4, 0, 16, 5, 12), makeCuboidShape(0, 5, 0, 16, 6, 11), makeCuboidShape(0, 6, 0, 16, 7, 10), makeCuboidShape(0, 7, 0, 16, 8, 9), makeCuboidShape(0, 8, 0, 16, 9, 8), makeCuboidShape(0, 9, 0, 16, 10, 7), makeCuboidShape(0, 10, 0, 16, 11, 6), makeCuboidShape(0, 11, 0, 16, 12, 5), makeCuboidShape(0, 12, 0, 16, 13, 4), makeCuboidShape(0, 13, 0, 16, 14, 3), makeCuboidShape(0, 14, 0, 16, 15, 2), makeCuboidShape(0, 15, 0, 16, 16, 1));
		    case NORTH :
		        return VoxelShapes.or(makeCuboidShape(0, 0, 0, 16, 1, 1), makeCuboidShape(0, 1, 0, 16, 2, 2), makeCuboidShape(0, 2, 0, 16, 3, 3), makeCuboidShape(0, 3, 0, 16, 4, 4), makeCuboidShape(0, 4, 0, 16, 5, 5), makeCuboidShape(0, 5, 0, 16, 6, 6), makeCuboidShape(0, 6, 0, 16, 7, 7), makeCuboidShape(0, 7, 0, 16, 8, 8), makeCuboidShape(0, 8, 0, 16, 9, 9), makeCuboidShape(0, 9, 0, 16, 10, 10), makeCuboidShape(0, 10, 0, 16, 11, 11), makeCuboidShape(0, 11, 0, 16, 12, 12), makeCuboidShape(0, 12, 0, 16, 13, 13), makeCuboidShape(0, 13, 0, 16, 14, 14), makeCuboidShape(0, 14, 0, 16, 15, 15), makeCuboidShape(0, 15, 0, 16, 16, 16));
		    case WEST :
		        return VoxelShapes.or(makeCuboidShape(0, 0, 0, 1, 1, 16), makeCuboidShape(0, 1, 0, 2, 2, 16), makeCuboidShape(0, 2, 0, 3, 3, 16), makeCuboidShape(0, 3, 0, 4, 4, 16), makeCuboidShape(0, 4, 0, 5, 5, 16), makeCuboidShape(0, 5, 0, 6, 6, 16), makeCuboidShape(0, 6, 0, 7, 7, 16), makeCuboidShape(0, 7, 0, 8, 8, 16), makeCuboidShape(0, 8, 0, 9, 9, 16), makeCuboidShape(0, 9, 0, 10, 10, 16), makeCuboidShape(0, 10, 0, 11, 11, 16), makeCuboidShape(0, 11, 0, 12, 12, 16), makeCuboidShape(0, 12, 0, 13, 13, 16), makeCuboidShape(0, 13, 0, 14, 14, 16), makeCuboidShape(0, 14, 0, 15, 15, 16), makeCuboidShape(0, 15, 0, 16, 16, 16));
		    case EAST :
		        return VoxelShapes.or(makeCuboidShape(0, 0, 0, 16, 1, 16), makeCuboidShape(0, 1, 0, 15, 2, 16), makeCuboidShape(0, 2, 0, 14, 3, 16), makeCuboidShape(0, 3, 0, 13, 4, 16), makeCuboidShape(0, 4, 0, 12, 5, 16), makeCuboidShape(0, 5, 0, 11, 6, 16), makeCuboidShape(0, 6, 0, 10, 7, 16), makeCuboidShape(0, 7, 0, 9, 8, 16), makeCuboidShape(0, 8, 0, 8, 9, 16), makeCuboidShape(0, 9, 0, 7, 10, 16), makeCuboidShape(0, 10, 0, 6, 11, 16), makeCuboidShape(0, 11, 0, 5, 12, 16), makeCuboidShape(0, 12, 0, 4, 13, 16), makeCuboidShape(0, 13, 0, 3, 14, 16), makeCuboidShape(0, 14, 0, 2, 15, 16), makeCuboidShape(0, 15, 0, 1, 16, 16));
			}
		}

		@Override
		public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
			List<ItemStack> dropsOriginal = super.getDrops(state, builder);
			if (!dropsOriginal.isEmpty())
				return dropsOriginal;
			return Collections.singletonList(new ItemStack(this, 1));
		}
	}
}

It seems as if the Gradle wasn't installed correctly or something, but I have no Idea. I only changed one or two files in MCreator.

Please help!

PS: If you need any more resources, please just write what file name is unclear.

In some cases, Gradle caches…
Sat, 06/26/2021 - 09:45

In some cases, Gradle caches that make sure the build process does not take too long can get corrupted. In such a case, go to:

<your user home folder>/.mcreator/gradle

In this folder, there is a folder called caches. Delete this folder and open MCreator again. Next build will take a bit longer as caches need to be rebuilt. If you can not delete all files in this folder (which is necessary), reboot the computer first to remove any potential file locks.

If this is not enough to make things work, delete the entire gradle folder, not just caches, and try again.

If even this fails, try to delete the entire <your user home folder>/.mcreator/gradle folder, create a new workspace with the same generator version as the version of the workspace failing, after the setup of this new workspace is done, open your current workspace, and click Build & run -> Build workspace, then Build & run -> Reload gradle project and then Build & run -> Regenerate code and build.

The solution to this problem and many other problems can be found in our knowledge base: https://mcreator.net/support/knowledgebase Please check the knowledge base before opening a new topic on the issue which has a known fix.