Error:  register(K) has private access in GameRegistry

Status
Works as designed
Product/platform
MCreator/Windows
Priority
Normal
Issue description

I'm trying to make my custom model rotatable. Everything is working, but every time I recompile the mod, it gives me this error saying that "register (K) has private access in GameRegistry. I don't understand why it keeps doing this. Please help!


Error Report:

 

Executing gradle command: clean build
Microsoft Windows [Version 10.0.16299.431]
(c) 2017 Microsoft Corporation. All rights reserved.
C:\Pylo\MCreator179>cd forge
C:\Pylo\MCreator179\forge>SET "JAVA_HOME=C:\Pylo\MCreator179\jdk\"
C:\Pylo\MCreator179\forge>SET JAVA_EXE=%JAVA_HOME%\bin\java.exe
C:\Pylo\MCreator179\forge>SET PATH=%JAVA_HOME%\bin\;%PATH%
C:\Pylo\MCreator179\forge>SET "GRADLE_USER_HOME=C:\Users\mrans\.mcreator\gradle"
C:\Pylo\MCreator179\forge>gradlew -Dorg.gradle.daemon=false -Dorg.gradle.parallel=false -Dorg.gradle.jvmargs="-Xms625m -Xmx2048m" clean build 
This mapping 'snapshot_20171003' was designed for MC 1.12! Use at your own peril.
#################################################
         ForgeGradle 2.3-SNAPSHOT-4a7d623        
  https://github.com/MinecraftForge/ForgeGradle  
#################################################
                 Powered by MCP                  
             http://modcoderpack.com             
     by: Searge, ProfMobius, R4wk, ZeuX          
     Fesh0r, IngisKahn, bspkrs, LexManos         
#################################################
:clean
:deobfCompileDummyTask
:deobfProvidedDummyTask
:sourceApiJava
:compileApiJava UP-TO-DATE
:processApiResources UP-TO-DATE
:apiClasses UP-TO-DATE
:sourceMainJava
C:\Pylo\MCreator179\forge\build\sources\main\java\mod\mcreator\mcreator_bBCSinkEast.java:51: error: register(K) has private access in GameRegistry
      GameRegistry.register(block);
                  ^
  where K is a type-variable:
    K extends IForgeRegistryEntry declared in method register(K)
C:\Pylo\MCreator179\forge\build\sources\main\java\mod\mcreator\mcreator_bBCSinkEast.java:53: error: register(K) has private access in GameRegistry
      GameRegistry.register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
                  ^
  where K is a type-variable:
    K extends IForgeRegistryEntry declared in method register(K)
2 errors
:compileJava FAILED
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.
BUILD FAILED
Total time: 25.843 secs
C:\Pylo\MCreator179\forge>
Task completed with return code 0 in 26994 milliseconds

 

 

 

 

 

 

Code:

package mod.mcreator;

import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;

import net.minecraft.world.World;
import net.minecraft.world.IBlockAccess;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.Item;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.Minecraft;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.material.Material;
import net.minecraft.block.SoundType;
import net.minecraft.block.Block;

import java.util.Random;

import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.entity.EntityLivingBase;

public class mcreator_bBCSinkEast {

	public mcreator_bBCSinkEast() {
	}

	public static BlockBBCSinkEast block;
	public static Item item;
	public static Object instance;

	public int addFuel(ItemStack fuel) {
		return 0;
	}

	public void serverLoad(FMLServerStartingEvent event) {
	}

	public void preInit(FMLPreInitializationEvent event) {
		block.setRegistryName("bbcsinkeast");
		GameRegistry.register(block);

		GameRegistry.register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
	}

	public void registerRenderers() {
	}

	public void load(FMLInitializationEvent event) {
		if (event.getSide() == Side.CLIENT) {
			Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
					.register(item, 0, new ModelResourceLocation("testenvironmentmod:bbcsinkeast", "inventory"));
		}
	}

	static {
		block = (BlockBBCSinkEast) (new BlockBBCSinkEast().setHardness(2.0F).setResistance(10.0F).setLightLevel(0.0F)
				.setUnlocalizedName("bbcsinkeast").setLightOpacity(0).setCreativeTab(mcreator_east.tab));
		block.setHarvestLevel("pickaxe", 4);
	}

	public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
	}

	public void generateNether(World world, Random random, int chunkX, int chunkZ) {
	}

	static class BlockBBCSinkEast extends Block {

		int a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0;
		boolean red = false;
	public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);

		protected BlockBBCSinkEast() {
			super(Material.GROUND);
			setSoundType(SoundType.WOOD);
		this.setDefaultState(blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
		}

		@Override
		public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
			int i = pos.getX();
			int j = pos.getY();
			int k = pos.getZ();
			world.scheduleUpdate(new BlockPos(i, j, k), this, this.tickRate(world));
		}

		@Override
		public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
			return red ? 15 : 0;
		}

		@Override
		public int getStrongPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
			return red ? 15 : 0;
		}

		@Override
		public boolean isOpaqueCube(IBlockState state) {
			return false;
		}

		@SideOnly(Side.CLIENT)
		@Override
		public BlockRenderLayer getBlockLayer() {
			return BlockRenderLayer.SOLID;
		}

		@Override
		public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
			return new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
		}

		@Override
		public int tickRate(World world) {
			return 10;
		}

		@Override
          public int quantityDropped(Random par1Random) {
               return 1;
          }
          
          @Override
          public IBlockState getStateFromMeta(int meta) {
               EnumFacing facing = EnumFacing.getFront(meta);
 
          if(facing.getAxis()==EnumFacing.Axis.Y) {
               facing=EnumFacing.NORTH;
          }
 
          return getDefaultState().withProperty(FACING, facing);
          }
 
          @Override
          public int getMetaFromState(IBlockState state) {
          return ((EnumFacing) state.getValue(FACING)).getIndex();
          }
 
          @Override
          protected BlockStateContainer createBlockState() {
          return new BlockStateContainer(this, new IProperty[]{FACING});
          }
 
          @Override
          public IBlockState getStateForPlacement(World worldIn, BlockPos pos,
               EnumFacing facing, float hitX, float hitY, float hitZ, int meta,
               EntityLivingBase placer) {
                    return getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
               }
 
    }
}

 

Issue comments

You have most likely copied the code for a different version of Minecraft. We don't offer support for custom codes here, so please ask for the help on the Advanced forums where other modders will help you out.



Donate to MCreator

By donating to developers you can speed up development, as with more resources, we can dedicate more time to MCreator. It is a free project made by developers working on it in their free time.