Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

(SOLVED)[1.16.4] Block entity invalid


Recommended Posts

I have a block that has four different tiers (SMALL, MEDIUM, LARGE, CREATIVE), I had everything working but then I wanted to send the tier of block down the pipeline to the container where it can be used, so I'm sending the tile down.

The Tile accepts the Tier as a value to pass to its constructor, but for some reason I get an error in the console when I place any of this block that is not the CreativeTier. So if I place a Small/Medium/Large block then I get this error:

Quote

[14:50:14] [Render thread/WARN] [minecraft/TileEntity]: Block entity invalid: experienced:experience_block_creative @ BlockPos{x=-227, y=4, z=-218}
[14:50:14] [Server thread/WARN] [minecraft/TileEntity]: Block entity invalid: experienced:experience_block_creative @ BlockPos{x=-227, y=4, z=-218}

 

I've searched on here and I get not much to go on. And when I step through with the debugger, all the Tiles seem to be registered just like my Items and Blocks.

 

Code here:

My Registration Class:

public class Registration {

    public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, Constants.MOD_ID);
    public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, Constants.MOD_ID);
    public static final DeferredRegister<IRecipeSerializer<?>> RECIPES = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, Constants.MOD_ID);
    public static final DeferredRegister<TileEntityType<?>> TILES = DeferredRegister.create(ForgeRegistries.TILE_ENTITIES, Constants.MOD_ID);
    public static final DeferredRegister<ContainerType<?>> CONTAINERS = DeferredRegister.create(ForgeRegistries.CONTAINERS, Constants.MOD_ID);

    public static void register(){

        IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();

        // The deferred registries
        BLOCKS.register(modEventBus);
        ITEMS.register(modEventBus);
        RECIPES.register(modEventBus);
        TILES.register(modEventBus);
        CONTAINERS.register(modEventBus);

        // Registry objects are registered
        ModItems.register();
        ModBlocks.register();
        ModRecipes.register();
        ModTiles.register();
        ModContainers.register();

    }
}

 

My ModTiles code:

@Mod.EventBusSubscriber(modid = Constants.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class ModTiles {

    public static final DeferredRegister<TileEntityType<?>> TILES = DeferredRegister.create(ForgeRegistries.TILE_ENTITIES, Constants.MOD_ID);

    public static final RegistryObject<TileEntityType<ExperienceBlockTile>> EXPERIENCE_BLOCK_SMALL;
    public static final RegistryObject<TileEntityType<ExperienceBlockTile>> EXPERIENCE_BLOCK_MEDIUM;
    public static final RegistryObject<TileEntityType<ExperienceBlockTile>> EXPERIENCE_BLOCK_LARGE;
    public static final RegistryObject<TileEntityType<ExperienceBlockTile>> EXPERIENCE_BLOCK_CREATIVE;

    static {

        EXPERIENCE_BLOCK_SMALL = TILES.register("experience_block_small", ()-> TileEntityType.Builder.create(
                ()-> new ExperienceBlockTile(ExperienceBlock.Tier.SMALL), ModBlocks.EXPERIENCE_BLOCKS.get(ExperienceBlock.Tier.SMALL).get()
        ).build(null));
        EXPERIENCE_BLOCK_MEDIUM = TILES.register("experience_block_medium", ()-> TileEntityType.Builder.create(
                ()-> new ExperienceBlockTile(ExperienceBlock.Tier.MEDIUM), ModBlocks.EXPERIENCE_BLOCKS.get(ExperienceBlock.Tier.MEDIUM).get()
        ).build(null));
        EXPERIENCE_BLOCK_LARGE = TILES.register("experience_block_large", ()-> TileEntityType.Builder.create(
                ()-> new ExperienceBlockTile(ExperienceBlock.Tier.LARGE), ModBlocks.EXPERIENCE_BLOCKS.get(ExperienceBlock.Tier.LARGE).get()
        ).build(null));
        EXPERIENCE_BLOCK_CREATIVE = TILES.register("experience_block_creative", ()-> TileEntityType.Builder.create(
                ()-> new ExperienceBlockTile(ExperienceBlock.Tier.CREATIVE), ModBlocks.EXPERIENCE_BLOCKS.get(ExperienceBlock.Tier.CREATIVE).get()
        ).build(null));
    }

    public static void register() {
        TILES.register(FMLJavaModLoadingContext.get().getModEventBus());
    }
}

 

My ExperienceBlock Class just in  case:

public class ExperienceBlock extends Block {

    // The tiers of the experience block, this makes it easy to register the blocks and all that sort of stuff
    public static Tier BLOCK_TIER;

    public enum Tier {
        SMALL("small"),
        MEDIUM("medium"),
        LARGE("large"),
        CREATIVE("creative");

        final String name;

        Tier(String name){
            this.name = name;
        }

        public String getName(){
            return name;
        }
    }

    public ExperienceBlock(Tier tier) {
        super(AbstractBlock
                .Properties
                .create(Material.ROCK)
                .harvestLevel(2));
        BLOCK_TIER = tier;
    }

    //region Gui Functions

    //region Tile Entity

    @Override
    public boolean hasTileEntity(BlockState state) {
        return true;
    }

    @Nullable
    @Override
    public TileEntity createTileEntity(BlockState state, IBlockReader world) {
        return new ExperienceBlockTile(BLOCK_TIER);
    }

    //endregion

    @Nullable
    @Override
    public INamedContainerProvider getContainer(BlockState state, World worldIn, BlockPos pos) {
        TileEntity tile = worldIn.getTileEntity(pos);
        return tile instanceof INamedContainerProvider ? (INamedContainerProvider) tile : null;
    }

    //endregion

    @Override
    public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {

        if(worldIn.isRemote){
            return ActionResultType.SUCCESS;
        }

        // If the selected block has no container then one will be made for it
        INamedContainerProvider nmContainer = this.getContainer(state, worldIn, pos);
        if(nmContainer != null){

            TileEntity tile = worldIn.getTileEntity(pos);
            NetworkHooks.openGui((ServerPlayerEntity) player, nmContainer, (packetBuffer -> {}));
        }
        return ActionResultType.SUCCESS;
    }

    @Override
    public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {

        if(state.getBlock() != newState.getBlock()){
            TileEntity tile = worldIn.getTileEntity(pos);

            if(tile instanceof ExperienceBlockTile){
                ExperienceBlockTile tileEntity = (ExperienceBlockTile) tile;
                tileEntity.dropContents(worldIn, pos);
            }
            super.onReplaced(state, worldIn, pos, newState, isMoving);
        }
    }

    //region Helper Methods for Block

    // Method used to initialize the max amount of exp a certain block can hold
    // For now; Small = 30, Medium = 60, Large = 100, Creative = MAX_VALUE, and default is 0 cause that might not happen
    public static int getMaxExpFromTier(Tier tier){
        switch(tier){
            case SMALL:
                return 1395;
            case MEDIUM:
                return 8670;
            case LARGE:
                return 30970;
            case CREATIVE:
                return Integer.MAX_VALUE;
            default:
                return 0;
        }
    }

    //endregion
}

 

 

I also don't like how the registry objects are so verbose in my code tbh. I have the blocks in an EnumMap and just foreach through them all and that seems to work.

Please help me here cause I've been stuck on this for a while.

Edited by IntentScarab
Link to post
Share on other sites

First of all, do not put the DeferredRegister and its registry object in separate classes. You will break things.

 

Then, I'm guessing the issue is that you do not use the correct TileEntityType in your tile entity when calling the super constructor.

Link to post
Share on other sites
7 minutes ago, diesieben07 said:

First of all, do not put the DeferredRegister and its registry object in separate classes. You will break things.

So I should delete the DeferredRegisters in the Registration class and just keep them separate in their respective classes? So ModItems gets the DeferrefRegister and so on?

I did notice that when I changed in ModTiles from the DeferredRegister in Registration to the specific class DefReg it actually registered, so that explains something to me.

 

10 minutes ago, diesieben07 said:

Then, I'm guessing the issue is that you do not use the correct TileEntityType in your tile entity when calling the super constructor.

This is my ExperienceBlockTile constructor and the getTier method that returns the Tile:

 

public ExperienceBlockTile(ExperienceBlock.Tier tier) {
        super(getTier(tier));

        inputContents = ExperienceBlockContents.createForTileEntity(INPUT_SLOTS,
                this::canPlayerAccessInventory,
                this::markDirty);

        outputContents = ExperienceBlockContents.createForTileEntity(OUTPUT_SLOTS,
                this::canPlayerAccessInventory,
                this::markDirty);

        expBarContents = ExperienceBlockContents.createForTileEntity(EXP_BAR_SLOT,
                this::canPlayerAccessInventory,
                this::markDirty);
    }

    public static TileEntityType<ExperienceBlockTile> getTier(ExperienceBlock.Tier tier){
        switch (tier){
            case SMALL:
                return ModTiles.EXPERIENCE_BLOCK_SMALL.get();
            case MEDIUM:
                return ModTiles.EXPERIENCE_BLOCK_MEDIUM.get();
            case LARGE:
                return ModTiles.EXPERIENCE_BLOCK_LARGE.get();
            case CREATIVE:
                return ModTiles.EXPERIENCE_BLOCK_CREATIVE.get();
            default:
                throw new IllegalArgumentException("Unkown tier: " + tier);
        }
    }

 

Link to post
Share on other sites
1 minute ago, IntentScarab said:

So I should delete the DeferredRegisters in the Registration class and just keep them separate in their respective classes? So ModItems gets the DeferrefRegister and so on?

Yes. A good reminder is to make DeferredReigster fields private.

 

2 minutes ago, IntentScarab said:

This is my ExperienceBlockTile constructor and the getTier method that returns the Tile:

Hm, looks alright on first glance. Please post a Git repo of your mod.

Link to post
Share on other sites
8 minutes ago, diesieben07 said:

Yes. A good reminder is to make DeferredReigster fields private.

Sweet, made those changes now, thank you

 

8 minutes ago, diesieben07 said:

Hm, looks alright on first glance. Please post a Git repo of your mod.

https://github.com/RhysGrabany/Experienced

Here you go, the changes I've made rn are under the tile_passing branch

Link to post
Share on other sites
4 minutes ago, diesieben07 said:

Please learn what static means and why it is not appropriate here.

I've been coding for like four years and it seems like I still don't know what it means. I'm gonna research what it means now cause it's been too long 😅

 

I've took off the static property and commented out all the code that was complaining for the meantime.

That has cleared up the problem about the error showing.

 

Thank you for the help!!

Link to post
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.

Guest
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

    • I'm reworking vanilla enchanting mechanics for my mod, and need to completely replace the functionality of vanilla enchanting tables and anvils. I have 2 new tile entity blocks set up, and I'm working on their functionality at the moment. When they're done, how would I replace the vanilla blocks with them? Alternatively, how would I replace the tile entity of the vanilla blocks with my own tile entities?
    • This is the crash report  Description: Initializing game java.lang.NoClassDefFoundError: slimeknights/tconstruct/library/client/MaterialRenderInfo     at lucraft.mods.lucraftcore.LCConfig$Materials.<init>(LCConfig.java:108)     at lucraft.mods.lucraftcore.LCConfig.<clinit>(LCConfig.java:36)     at lucraft.mods.lucraftcore.addonpacks.AddonPackHandler.getAddonPacksDir(AddonPackHandler.java:61)     at lucraft.mods.lucraftcore.core.LCClientHooks.insertAddonPackResourcePacks(LCClientHooks.java:37)     at net.minecraft.client.Minecraft.func_110436_a(Minecraft.java:789)     at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:247)     at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:467)     at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:378)     at net.minecraft.client.main.Main.main(SourceFile:123)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     at java.lang.reflect.Method.invoke(Method.java:497)     at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)     at net.minecraft.launchwrapper.Launch.main(Launch.java:28) Caused by: java.lang.ClassNotFoundException: slimeknights.tconstruct.library.client.MaterialRenderInfo     at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191)     at java.lang.ClassLoader.loadClass(ClassLoader.java:424)     at java.lang.ClassLoader.loadClass(ClassLoader.java:357)     ... 15 more Caused by: java.lang.NullPointerException A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Client thread Stacktrace:     at lucraft.mods.lucraftcore.LCConfig$Materials.<init>(LCConfig.java:108)     at lucraft.mods.lucraftcore.LCConfig.<clinit>(LCConfig.java:36)     at lucraft.mods.lucraftcore.addonpacks.AddonPackHandler.getAddonPacksDir(AddonPackHandler.java:61)     at lucraft.mods.lucraftcore.core.LCClientHooks.insertAddonPackResourcePacks(LCClientHooks.java:37)     at net.minecraft.client.Minecraft.func_110436_a(Minecraft.java:789)     at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:247)     at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:467) -- Initialization -- Details: Stacktrace:     at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:378)     at net.minecraft.client.main.Main.main(SourceFile:123)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     at java.lang.reflect.Method.invoke(Method.java:497)     at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)     at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    • So I started my mods and this error popped up  The game crashed whilst initializing game Error: java.lang.NoClassDefFoundError: slimeknights/tconstruct/library/client/MaterialRenderInfo Exit Code: -1 which is weird since I don't have tinkers construct installed or is that something else and how do I fix this.
    • I want to use an old mod for some reason, but the forge-1.12.2-14.23.4.2764 installer does not work with the following error. java.net.preferIPv4Stack=true Exception in thread "main" java.lang.reflect.InvocationTargetException     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.installer.Java6Gate.main(Java6Gate.java:48) Caused by: java.lang.ExceptionInInitializerError     at net.minecraftforge.installer.ClientInstall.getSponsorMessage(ClientInstall.java:401)     at net.minecraftforge.installer.InstallerAction.getSponsorMessage(InstallerAction.java:60)     at net.minecraftforge.installer.InstallerPanel.updateFilePath(InstallerPanel.java:334)     at net.minecraftforge.installer.InstallerPanel.<init>(InstallerPanel.java:315)     at net.minecraftforge.installer.SimpleInstaller.launchGui(SimpleInstaller.java:167)     at net.minecraftforge.installer.SimpleInstaller.main(SimpleInstaller.java:54)     ... 5 more Caused by: java.lang.ArrayIndexOutOfBoundsException: 1     at net.minecraftforge.installer.MirrorData.buildMirrorList(MirrorData.java:84)     at net.minecraftforge.installer.MirrorData.<init>(MirrorData.java:63)     at net.minecraftforge.installer.MirrorData.<clinit>(MirrorData.java:17)     ... 11 more Is there a way to install this version other than the installer? The method of copying and overwriting the version of the .minecraft folder according to the explanation site on the net did not work. I don't want such an answer [1.12 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.]
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.