Jump to content

Items aren't correctly registered


Anagkai

Recommended Posts

I updated my 1.10 code to 1.12 and basically just modified everything until it compiled, implementing the new method of item registration and whatnot. But there seems to be something profoundly wrong.

 

1) Items don't show up in the creative tab.

2) The block and item models aren't loaded.

 

I'll just post the code that I think, is relevant, if it's something else please tell me. Any input on what to modify is greatly appreciated.

 

ModItems class

 

	package anagkai.biodiversity.items;
	import java.util.ArrayList;
import java.util.List;
	import anagkai.biodiversity.Biodiversity;
import anagkai.biodiversity.blocks.BlocksBiodiversity;
import anagkai.biodiversity.items.ItemBiodiversityBow;
import anagkai.biodiversity.potion.PotionRegistry;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.potion.Potion;
import net.minecraft.util.ResourceLocation;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.common.EnumPlantType;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.fml.common.registry.GameRegistry;
	public class ItemsBiodiversity {
    
    public static final List<Item> ITEMS=new ArrayList<Item>();
    
    public static Item fluorite;
    public static Item fireOpal;
    public static Item amber;
    public static Item platinumPiece;
    
    public static void preInit(){
        fluorite = new ItemBiodiversity("fluorite");
        fireOpal = new ItemBiodiversity("fireOpal");
        amber = new ItemBiodiversity("amber");
        platinumPiece = new ItemBiodiversity("platinumPiece");
        
        setItems();
    }
}
	 
	

 

Basic Item class

 

	package anagkai.biodiversity.items;
	import java.util.List;
	import javax.annotation.Nullable;
	import anagkai.biodiversity.Biodiversity;
import anagkai.biodiversity.util.IHasModel;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
	public class ItemBiodiversity extends Item implements IHasModel{
    
    private String info;
    
    public ItemBiodiversity(String name){
        setUnlocalizedName(name);
        setRegistryName(name);
        setCreativeTab(Biodiversity.cTab);
        ItemsBiodiversity.ITEMS.add(this);
    }
    
    public void setInfo(String info){
        this.info = info;
    }
    
    @SideOnly(Side.CLIENT)
    public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn)
    {
        if(info!=null){
        tooltip.add(I18n.format(info));}
        super.addInformation(stack, worldIn, tooltip, flagIn);
    }
	    @Override
    public void registerModels() {
        
        Biodiversity.proxy.registerItemRenderer(this, 0, "inventory");
        
    }
}
	

Link to comment
Share on other sites

1) setItems is a not so well named method doing some stuff (such as apply addInformation to multiple items) which I'm most certain is not relevant for the problem at hand. I promise to rename it, though.

2) & 3)  I added the override and I will look into adding the modid to my things.

3) That is probably the issue. How would the event be called?

 

EDIT: Just found this, do all the items need to go here?

	package anagkai.biodiversity.util;
	import anagkai.biodiversity.blocks.BlocksBiodiversity;
import anagkai.biodiversity.items.ItemsBiodiversity;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
	@EventBusSubscriber
public class RegistryHandler {
    
    @SubscribeEvent
    public static void onItemRegister(RegistryEvent.Register<Item> event){
        
        event.getRegistry().registerAll(ItemsBiodiversity.ITEMS.toArray(new Item[0]));
    }
    
    @SubscribeEvent
    public static void onBlockRegister(RegistryEvent.Register<Block> event){
        
        event.getRegistry().registerAll(BlocksBiodiversity.BLOCKS.toArray(new Block[0]));
    }
    
    @SubscribeEvent
    public static void onModelRegister(ModelRegistryEvent event){
        
        for(Item item : ItemsBiodiversity.ITEMS){
            
            if(item instanceof IHasModel){
                
                ((IHasModel)item).registerModels();
            }
        }
        for(Block block : BlocksBiodiversity.BLOCKS){
            
            if(block instanceof IHasModel){
                
                ((IHasModel)block).registerModels();
            }
        }
    }
	}
	 
	

Edited by Anagkai
Link to comment
Share on other sites

There's obviously something I didn't do right, because I get a NullPointerException:

 

Here's the report, although I'm not sure, if someone get info out of it:

Spoiler

---- Minecraft Crash Report ----
// I blame Dinnerbone.

Time: 8/4/19 8:13 PM
Description: There was a severe problem during mod loading that has caused the game to fail

net.minecraftforge.fml.common.LoaderException: java.lang.ClassNotFoundException: anagkai.biodiversity.ProxyClient
    at net.minecraftforge.fml.common.ProxyInjector.inject(ProxyInjector.java:102)
    at net.minecraftforge.fml.common.FMLModContainer.constructMod(FMLModContainer.java:600)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
    at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
    at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
    at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
    at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
    at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
    at com.google.common.eventbus.EventBus.post(EventBus.java:217)
    at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:218)
    at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:196)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
    at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
    at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
    at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
    at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
    at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
    at com.google.common.eventbus.EventBus.post(EventBus.java:217)
    at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:135)
    at net.minecraftforge.fml.common.Loader.loadMods(Loader.java:593)
    at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:232)
    at net.minecraft.client.Minecraft.init(Minecraft.java:513)
    at net.minecraft.client.Minecraft.run(Minecraft.java:421)
    at net.minecraft.client.main.Main.main(Main.java:118)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    at GradleStart.main(GradleStart.java:25)
Caused by: java.lang.ClassNotFoundException: anagkai.biodiversity.ProxyClient
    at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at net.minecraftforge.fml.common.ModClassLoader.loadClass(ModClassLoader.java:75)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at net.minecraftforge.fml.common.ProxyInjector.inject(ProxyInjector.java:85)
    ... 43 more
Caused by: java.lang.NullPointerException
    at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:182)
    ... 49 more


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- System Details --
Details:
    Minecraft Version: 1.12.2
    Operating System: Windows 7 (amd64) version 6.1
    Java Version: 1.8.0_161, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 794257456 bytes (757 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
    JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
    IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
    FML: MCP 9.42 Powered by Forge 14.23.5.2768 5 mods loaded, 5 mods active
    States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

    | State | ID           | Version      | Source                           | Signature |
    |:----- |:------------ |:------------ |:-------------------------------- |:--------- |
    | UC    | minecraft    | 1.12.2       | minecraft.jar                    | None      |
    | UC    | mcp          | 9.42         | minecraft.jar                    | None      |
    | UC    | FML          | 8.0.99.99    | forgeSrc-1.12.2-14.23.5.2768.jar | None      |
    | UC    | forge        | 14.23.5.2768 | forgeSrc-1.12.2-14.23.5.2768.jar | None      |
    | UE    | biodiversity | 3.0          | bin                              | None      |

    Loaded coremods (and transformers):
    GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.6.0 NVIDIA 398.36' Renderer: 'GeForce GTX 960/PCIe/SSE2'

 

 

Some other interesting questions would be how to call the #setItems which is now called #setAdditionalItemData now, because it needs to access the items:

Spoiler

	public static void setAdditionalItemData(){
		((ItemBiodiversityBow) cherryBow).setBowAndArrow(cherryBow, cherryArrow);
		((ItemBiodiversityBow) antBow).setBowAndArrow(antBow, antArrow);
		((ItemBiodiversityBow) poisonBow).setBowAndArrow(poisonBow, poisonArrow);
		((ItemBiodiversityBow) devastator).setBowAndArrow(devastator, devasArrow);
		((ItemBiodiversityBow) shockBow).setBowAndArrow(shockBow, shockArrow);
		
		((ItemBiodiversityThrowableDye) whiteTDye).setColor(EnumDyeColor.WHITE);
		((ItemBiodiversityThrowableDye) orangeTDye).setColor(EnumDyeColor.ORANGE);
		((ItemBiodiversityThrowableDye) magentaTDye).setColor(EnumDyeColor.MAGENTA);
		((ItemBiodiversityThrowableDye) lightBlueTDye).setColor(EnumDyeColor.LIGHT_BLUE);
		((ItemBiodiversityThrowableDye) yellowTDye).setColor(EnumDyeColor.YELLOW);
		((ItemBiodiversityThrowableDye) limeTDye).setColor(EnumDyeColor.LIME);
		((ItemBiodiversityThrowableDye) pinkTDye).setColor(EnumDyeColor.PINK);
		((ItemBiodiversityThrowableDye) grayTDye).setColor(EnumDyeColor.GRAY);
		((ItemBiodiversityThrowableDye) silverTDye).setColor(EnumDyeColor.SILVER);
		((ItemBiodiversityThrowableDye) cyanTDye).setColor(EnumDyeColor.CYAN);
		((ItemBiodiversityThrowableDye) purpleTDye).setColor(EnumDyeColor.PURPLE);
		((ItemBiodiversityThrowableDye) blueTDye).setColor(EnumDyeColor.BLUE);
		((ItemBiodiversityThrowableDye) brownTDye).setColor(EnumDyeColor.BROWN);
		((ItemBiodiversityThrowableDye) greenTDye).setColor(EnumDyeColor.GREEN);
		((ItemBiodiversityThrowableDye) redTDye).setColor(EnumDyeColor.RED);
		((ItemBiodiversityThrowableDye) blackTDye).setColor(EnumDyeColor.BLACK);
		
		((ItemBiodiversityWeapon) unbreaker).setInfo("unbreaker_tooltip");
		((ItemBiodiversityWeapon) esmeralda).setInfo("esmeralda_tooltip");
		((ItemBiodiversityAxe) woodpecker).setInfo("woodpecker_tooltip");
		((ItemBiodiversityChestfinder) chestfinder).setInfo("chestfinder_tooltip");
		((ItemBiodiversityGuano) guanoPiece).setInfo("gunao_tooltip");
		((ItemBiodiversity) salt).setInfo("salt_tooltip");
		((ItemBiodiversityGinkgo) ginkgoLeaf).setInfo("ginkgo_tooltip");
		((ItemBiodiversityDrug) dolphinBerry).setInfo("dolphin_tooltip");	
		((ItemBiodiversityFoodcrop) chili).setInfo("chili_tooltip");	
		((ItemBiodiversityBow) devastator).setInfo("devastator_tooltip");	
		((ItemBiodiversityDrug) crystalPetal).setInfo("crystal_tooltip");	
		((ItemBiodiversity) electricRay).setInfo("ray_tooltip");
		((ItemBiodiversityBow) antBow).setInfo("antbow_tooltip");	
		((ItemBiodiversitySuperChili) superChili).setInfo("superchili_tooltip");	
	}

 

 

Also I think I need to change the model registering:

Spoiler

	@SubscribeEvent
	public static void onModelRegister(ModelRegistryEvent event){
		
		for(Item item : ItemsBiodiversity.ITEMS){
			
			if(item instanceof IHasModel){
				
				((IHasModel)item).registerModels();
			}
		}
		for(Block block : BlocksBiodiversity.BLOCKS){
			
			if(block instanceof IHasModel){
				
				((IHasModel)block).registerModels();
			}
		}
	}

 

I admit I don't understand all of this very well.

Link to comment
Share on other sites

1) Just noticed myself (I looked on the bottom because I normally do python). I just messed something up while refactoring.

 

2) I have no idea, why this was separate, probably something with readability. The way you wrote it, I don't define variables for the items. I mean I can just append that stuff to the new ItemWhatever, but what would I do if I want my gems falling out of blocks? Has this changed, too? I need the drop item for the constructor of my ore block...

3) Changed my mind.

4) I know basic Java, but I mostly I do Python.

 

Link to comment
Share on other sites

Okay, so that is not basic enough for me. :D

 

I use the method with the constructor, because I have multiple ore blocks and I didn't wanna create a class for each. How could I do that with the annotation? I admit, I don't even get where I need to put the annotation.

Link to comment
Share on other sites

First of all I have like 300 instances where things reference my items and I'm wondering how I would fix that with @ObjectHolder.

 

For example, the following class references ItemsBiodiversity.beeQueen. What would I here?

Spoiler

package anagkai.biodiversity.blocks;

import java.util.Random;

import javax.annotation.Nullable;

import anagkai.biodiversity.Biodiversity;
import anagkai.biodiversity.registry.ItemsBiodiversity;
import net.minecraft.block.Block;
import net.minecraft.block.BlockHorizontal;
import net.minecraft.block.BlockPlanks;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class BlockBiodiversityBeeNest extends Block
{
    public static final PropertyDirection FACING = BlockHorizontal.FACING;

    public BlockBiodiversityBeeNest(String name)
    {
        super(Material.WOOD);
        setUnlocalizedName(name);
        setHardness(2F);
        setSoundType(SoundType.WOOD);
        setCreativeTab(Biodiversity.cTab);
        this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
    }
    
    /**
     * Get the Item that this Block should drop when harvested.
     */
    @Nullable
    public Item getItemDropped(IBlockState state, Random rand, int fortune)
    {
        return null;
    }
    
    public void onBlockDestroyedByPlayer(World worldIn, BlockPos pos, IBlockState state)
    {
    	dropBee(worldIn, pos);
    }
    
    public void dropBee(World world, BlockPos pos){
    	
        world.setBlockToAir(pos);
        if(!world.isRemote){
        
        int num = 1;
        ItemStack item1 = new ItemStack(ItemsBiodiversity.beeQueen, num);
        EntityItem entityitem1 = new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), item1);            
        world.spawnEntity(entityitem1);
        
        int num2 = 1;
        ItemStack item2 = new ItemStack(Blocks.LOG, num2, BlockPlanks.EnumType.OAK.getMetadata());
        EntityItem entityitem2 = new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), item2);            
        world.spawnEntity(entityitem2);
        
        int num3 = world.rand.nextInt(5);
        ItemStack item3 = new ItemStack(Items.PAPER, num3);
        EntityItem entityitem3 = new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), item3);            
        world.spawnEntity(entityitem3);
        
        }
    	
    }    	
    
    /**
     * Called after the block is set in the Chunk data, but before the Tile Entity is set
     */
    public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
    {
        this.setDefaultFacing(worldIn, pos, state);
    }

    private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state)
    {
        if (!worldIn.isRemote)
        {
            IBlockState iblockstate = worldIn.getBlockState(pos.north());
            IBlockState iblockstate1 = worldIn.getBlockState(pos.south());
            IBlockState iblockstate2 = worldIn.getBlockState(pos.west());
            IBlockState iblockstate3 = worldIn.getBlockState(pos.east());
            EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);

            if (enumfacing == EnumFacing.NORTH && iblockstate.isFullBlock() && !iblockstate1.isFullBlock())
            {
                enumfacing = EnumFacing.SOUTH;
            }
            else if (enumfacing == EnumFacing.SOUTH && iblockstate1.isFullBlock() && !iblockstate.isFullBlock())
            {
                enumfacing = EnumFacing.NORTH;
            }
            else if (enumfacing == EnumFacing.WEST && iblockstate2.isFullBlock() && !iblockstate3.isFullBlock())
            {
                enumfacing = EnumFacing.EAST;
            }
            else if (enumfacing == EnumFacing.EAST && iblockstate3.isFullBlock() && !iblockstate2.isFullBlock())
            {
                enumfacing = EnumFacing.WEST;
            }

            worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
        }
    }
    
    /**
     * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
     * IBlockstate
     */
    public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
    {
        return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
    }

    /**
     * Called by ItemBlocks after a block is set in the world, to allow post-place logic
     */
    public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
    {
        worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);
    }
    
    /**
     * Convert the given metadata into a BlockState for this Block
     */
    public IBlockState getStateFromMeta(int meta)
    {
        EnumFacing enumfacing = EnumFacing.getFront(meta);

        if (enumfacing.getAxis() == EnumFacing.Axis.Y)
        {
            enumfacing = EnumFacing.NORTH;
        }

        return this.getDefaultState().withProperty(FACING, enumfacing);
    }

    /**
     * Convert the BlockState into the correct metadata value
     */
    public int getMetaFromState(IBlockState state)
    {
        return ((EnumFacing)state.getValue(FACING)).getIndex();
    }

    /**
     * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed
     * blockstate.
     */
    public IBlockState withRotation(IBlockState state, Rotation rot)
    {
        return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING)));
    }

    /**
     * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed
     * blockstate.
     */
    public IBlockState withMirror(IBlockState state, Mirror mirrorIn)
    {
        return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING)));
    }

    protected BlockStateContainer createBlockState()
    {
        return new BlockStateContainer(this, new IProperty[] {FACING});
    }
    
    /**
     * Chance that fire will spread and consume this block.
     * 300 being a 100% chance, 0, being a 0% chance.
     *
     * @param world The current world
     * @param pos Block position in world
     * @param face The face that the fire is coming from
     * @return A number ranging from 0 to 300 relating used to determine if the block will be consumed by fire
     */
    public int getFlammability(IBlockAccess world, BlockPos pos, EnumFacing face)
    {
        return 5;
    }
    
    /**
     * Called when fire is updating on a neighbor block.
     * The higher the number returned, the faster fire will spread around this block.
     *
     * @param world The current world
     * @param pos Block position in world
     * @param face The face that the fire is coming from
     * @return A number that is used to determine the speed of fire growth around the block
     */
    public int getFireSpreadSpeed(IBlockAccess world, BlockPos pos, EnumFacing face)
    {
        return 20;
    }
    
}

 

My other problem is, that my registerAll suddenly doesn't like it's arguments any more:

Spoiler

		event.getRegistry().registerAll(
				new ItemBiodiversity("fluorite"),
				new ItemBiodiversity("fireOpal"),
				new ItemBiodiversity("amber"),
				new ItemBiodiversity("platinumPiece"),
				new ItemBiodiversity("platinumIngot"),
				new ItemBiodiversity("manganesePiece"),
				new ItemBiodiversity("manganeseIngot"),
				new ItemBiodiversity("thalassiumIngot"),
				new ItemBiodiversity("refinedQuartz"),
				new ItemBiodiversity("carborundumPowder"),
				new ItemBiodiversity("carborundumIngot"),
				new ItemBiodiversitySalt("salt").setInfo("salt_tooltip"),
				new ItemBiodiversity("graphitePiece"),
				new ItemBiodiversityGuano("guanoPiece").setInfo("gunao_tooltip"),
				new ItemBiodiversity("hematitePiece"),
				new ItemBiodiversity("obsidianPiece"),
				new ItemBiodiversity("flowerCrystal"),
				new ItemBiodiversity("anttreeStick"),
				new ItemBiodiversity("cherryStick"),
				new ItemBiodiversity("antFlask"),
				new ItemBiodiversity("formicAcid").setContainerItem(Items.GLASS_BOTTLE),
				new ItemBiodiversityEffect("lightningPlasma"),
				new ItemBiodiversityEffect("lifeEssence"),
				new ItemBiodiversity("reaperBlade"),
				new ItemBiodiversity("exterminatorBlade"),
				new ItemBiodiversity("exterminatorHandle"),
				new ItemBiodiversity("moonbladeBlade"),
				new ItemBiodiversity("moonbladeHandle"),
				new ItemBiodiversity("unbreakerBlade"),
				new ItemBiodiversity("unbreakerHandle"),
				new ItemBiodiversity("woodpeckerBlade"),
				new ItemBiodiversity("woodpeckerHandle"),
				new ItemBiodiversity("esmeraldaBlade"),
				new ItemBiodiversity("esmeraldaHandle"),
);

 

(I removed most of the items for better readability)

Link to comment
Share on other sites

I read the documentation but I'm not sure if I understood.

 

From what I understood, I what define static fields for the items I need. And if I add the annotation I can just use the field?

 

That's strange. I tried commenting out part of it but it seems none of them are okay. Maybe it's because of all the other errors.

Link to comment
Share on other sites

	@ObjectHolder("fluorite")
	public static Item fluorite;

 What I did looks like this. But the game crashes and the crash report says "PM Description: Initializing game java.lang.IllegalStateException: Unqualified reference to ObjectHolder"

 

I don't see any reference to my code directly in the crash report, so I'm not sure where to look.

 

Spoiler

---- Minecraft Crash Report ----
// I'm sorry, Dave.

Time: 8/4/19 11:09 PM
Description: Initializing game

java.lang.IllegalStateException: Unqualified reference to ObjectHolder
    at net.minecraftforge.registries.ObjectHolderRegistry.scanTarget(ObjectHolderRegistry.java:125)
    at net.minecraftforge.registries.ObjectHolderRegistry.findObjectHolders(ObjectHolderRegistry.java:80)
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:624)
    at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252)
    at net.minecraft.client.Minecraft.init(Minecraft.java:513)
    at net.minecraft.client.Minecraft.run(Minecraft.java:421)
    at net.minecraft.client.main.Main.main(Main.java:118)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    at GradleStart.main(GradleStart.java:25)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Client thread
Stacktrace:
    at net.minecraftforge.registries.ObjectHolderRegistry.scanTarget(ObjectHolderRegistry.java:125)
    at net.minecraftforge.registries.ObjectHolderRegistry.findObjectHolders(ObjectHolderRegistry.java:80)
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:624)
    at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252)
    at net.minecraft.client.Minecraft.init(Minecraft.java:513)

-- Initialization --
Details:
Stacktrace:
    at net.minecraft.client.Minecraft.run(Minecraft.java:421)
    at net.minecraft.client.main.Main.main(Main.java:118)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    at GradleStart.main(GradleStart.java:25)

-- System Details --
Details:
    Minecraft Version: 1.12.2
    Operating System: Windows 7 (amd64) version 6.1
    Java Version: 1.8.0_161, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 716698352 bytes (683 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
    JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
    IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
    FML: MCP 9.42 Powered by Forge 14.23.5.2768 5 mods loaded, 5 mods active
    States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

    | State | ID           | Version      | Source                           | Signature |
    |:----- |:------------ |:------------ |:-------------------------------- |:--------- |
    | UC    | minecraft    | 1.12.2       | minecraft.jar                    | None      |
    | UC    | mcp          | 9.42         | minecraft.jar                    | None      |
    | UC    | FML          | 8.0.99.99    | forgeSrc-1.12.2-14.23.5.2768.jar | None      |
    | UC    | forge        | 14.23.5.2768 | forgeSrc-1.12.2-14.23.5.2768.jar | None      |
    | UC    | biodiversity | 3.0          | bin                              | None      |

    Loaded coremods (and transformers):
    GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.6.0 NVIDIA 398.36' Renderer: 'GeForce GTX 960/PCIe/SSE2'
    Launched Version: 1.12.2
    LWJGL: 2.9.4
    OpenGL: GeForce GTX 960/PCIe/SSE2 GL version 4.6.0 NVIDIA 398.36, NVIDIA Corporation
    GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.

    Using VBOs: Yes
    Is Modded: Definitely; Client brand changed to 'fml,forge'
    Type: Client (map_client.txt)
    Resource Packs:
    Current Language: English (US)
    Profiler Position: N/A (disabled)
    CPU: 6x AMD FX(tm)-6300 Six-Core Processor

 

Does this mean, I forgot an annotation or didn't I get one right, or ... ?

Link to comment
Share on other sites

I added a class level annotation but there's still something missing, it seems. I thought this meant, that I needed to register the event, but I'm not sure if it shouldn't be registered automatically...

 

Anyway, this is the crash:

Spoiler

---- Minecraft Crash Report ----
// Quite honestly, I wouldn't worry myself about that.

Time: 8/5/19 5:44 PM
Description: Initializing game

java.lang.IllegalStateException: The ObjectHolder annotation cannot apply to a field that does not map to a registry. Ensure the registry was created during the RegistryEvent.NewRegistry event. (found : java.util.List at java.lang.reflect.Field.ITEMS)
    at net.minecraftforge.registries.ObjectHolderRef.<init>(ObjectHolderRef.java:85)
    at net.minecraftforge.registries.ObjectHolderRegistry.scanClassForFields(ObjectHolderRegistry.java:153)
    at net.minecraftforge.registries.ObjectHolderRegistry.scanTarget(ObjectHolderRegistry.java:115)
    at net.minecraftforge.registries.ObjectHolderRegistry.findObjectHolders(ObjectHolderRegistry.java:68)
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:624)
    at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252)
    at net.minecraft.client.Minecraft.init(Minecraft.java:513)
    at net.minecraft.client.Minecraft.run(Minecraft.java:421)
    at net.minecraft.client.main.Main.main(Main.java:118)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    at GradleStart.main(GradleStart.java:25)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Client thread
Stacktrace:
    at net.minecraftforge.registries.ObjectHolderRef.<init>(ObjectHolderRef.java:85)
    at net.minecraftforge.registries.ObjectHolderRegistry.scanClassForFields(ObjectHolderRegistry.java:153)
    at net.minecraftforge.registries.ObjectHolderRegistry.scanTarget(ObjectHolderRegistry.java:115)
    at net.minecraftforge.registries.ObjectHolderRegistry.findObjectHolders(ObjectHolderRegistry.java:68)
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:624)
    at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252)
    at net.minecraft.client.Minecraft.init(Minecraft.java:513)

-- Initialization --
Details:
Stacktrace:
    at net.minecraft.client.Minecraft.run(Minecraft.java:421)
    at net.minecraft.client.main.Main.main(Main.java:118)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    at GradleStart.main(GradleStart.java:25)

-- System Details --
Details:
    Minecraft Version: 1.12.2
    Operating System: Windows 7 (amd64) version 6.1
    Java Version: 1.8.0_161, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 721608616 bytes (688 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
    JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
    IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
    FML: MCP 9.42 Powered by Forge 14.23.5.2768 5 mods loaded, 5 mods active
    States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

    | State | ID           | Version      | Source                           | Signature |
    |:----- |:------------ |:------------ |:-------------------------------- |:--------- |
    | UC    | minecraft    | 1.12.2       | minecraft.jar                    | None      |
    | UC    | mcp          | 9.42         | minecraft.jar                    | None      |
    | UC    | FML          | 8.0.99.99    | forgeSrc-1.12.2-14.23.5.2768.jar | None      |
    | UC    | forge        | 14.23.5.2768 | forgeSrc-1.12.2-14.23.5.2768.jar | None      |
    | UC    | biodiversity | 3.0          | bin                              | None      |

    Loaded coremods (and transformers):
    GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.6.0 NVIDIA 398.36' Renderer: 'GeForce GTX 960/PCIe/SSE2'
    Launched Version: 1.12.2
    LWJGL: 2.9.4
    OpenGL: GeForce GTX 960/PCIe/SSE2 GL version 4.6.0 NVIDIA 398.36, NVIDIA Corporation
    GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.

    Using VBOs: Yes
    Is Modded: Definitely; Client brand changed to 'fml,forge'
    Type: Client (map_client.txt)
    Resource Packs:
    Current Language: English (US)
    Profiler Position: N/A (disabled)
    CPU: 6x AMD FX(tm)-6300 Six-Core Processor

 

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.

Announcements



×
×
  • Create New...

Important Information

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