Jump to content

Recommended Posts

Posted

Hello! I'm right now trying to see how you use tile entities.

But then, I got this error.

 

error: method create in class Builder<T#2> cannot be applied to given types;
    public static final RegistryObject<TileEntityType<BlockMinerTile>> BLOCK_MINER_TILE = TILE_ENTITY_TYPES.register("quarry", TileEntityType.Builder.create(BlockMinerTile::new, RegistryHandler.BlOCK_MINER).build());
                                                                                                                                                     ^
  required: Supplier<? extends T#1>,Block[]
  found: BlockMinerTile::new,RegistryObject<Block>
  reason: cannot infer type-variable(s) T#1
    (varargs mismatch; RegistryObject<Block> cannot be converted to Block)
  where T#1,T#2 are type-variables:
    T#1 extends TileEntity declared in method <T#1>create(Supplier<? extends T#1>,Block...)
    T#2 extends TileEntity declared in class Builder

 

Here is the code where the error is.

 

package com.example.examplemod.tile;

import com.example.examplemod.ExampleMod;
import com.example.examplemod.util.RegistryHandler;
import net.minecraft.tileentity.TileEntityType;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;

public class ModTileEntityTypes {

    public static final DeferredRegister<TileEntityType<?>> TILE_ENTITY_TYPES = new DeferredRegister<>(ForgeRegistries.TILE_ENTITIES, ExampleMod.MOD_ID);

    public static final RegistryObject<TileEntityType<BlockMinerTile>> BLOCK_MINER_TILE = TILE_ENTITY_TYPES.register("quarry", TileEntityType.Builder.create(BlockMinerTile::new, RegistryHandler.BlOCK_MINER).build(null));

}

 

Also, here's the code of the BlockMinerTile.

 

import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.fluid.IFluidState;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.math.BlockPos;

public class BlockMinerTile extends TileEntity implements ITickableTileEntity {


    public BlockMinerTile(final TileEntityType<?> tileEntityTypeIn) {
        super(tileEntityTypeIn);
    }

    public BlockMinerTile() {
        super(ModTileEntityTypes.BLOCK_MINER_TILE.get());
    }


    @Override
    public void tick() {
    }

}

 

That's All. Ask me if you need more information.

Posted
Quote

You are passing in BLOCK_MINER, which is a RegistryObject<Block>, thats not what the tileEntity factory requires. You need to get the actual block from that RegistryObject

What do you mean by the actual block?

Posted (edited)

You know how when you buy a pair of headphones, they come in a box?

You have a box labeled "headphones" right now and you're trying to plug it into your computer, but it doesn't have an audio jack.

Edited by Draco18s
  • Haha 2

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

I think I fixed it, but I still get a error.

 

    public static final RegistryObject<TileEntityType<BlockMinerTile>> BLOCK_MINER_TILE = TILE_ENTITY_TYPES.register("quarry", TileEntityType.Builder.create(BlockMinerTile::new, RegistryHandler.BlOCK_MINER.get()).build(null));
                                                                                                           ^
  required: String,Supplier<? extends I>
  found: String,TileEntityType<BlockMinerTile>
  reason: cannot infer type-variable(s) I
    (argument mismatch; TileEntityType<BlockMinerTile> cannot be converted to Supplier<? extends I>)
  where I,T are type-variables:
    I extends TileEntityType<?> declared in method <I>register(String,Supplier<? extends I>)
    T extends IForgeRegistryEntry<T> declared in class DeferredRegister

 

I know I have to change the null because when I remove it, it says this.

 

    public static final RegistryObject<TileEntityType<BlockMinerTile>> BLOCK_MINER_TILE = TILE_ENTITY_TYPES.register("quarry", TileEntityType.Builder.create(BlockMinerTile::new, RegistryHandler.BlOCK_MINER.get()).build());
                                                                                                                                                                                                                    ^
  required: Type<?>
  found: no arguments
  reason: actual and formal argument lists differ in length
  where T is a type-variable:
    T extends TileEntity declared in class Builder

 

I'm guessing I have to put a type in there

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.