Posted April 2, 20205 yr Hey all, it's been a while since I've last modded this game and Im kinda struggling, Im trying to register a Tile Entity and then attach it to a block. Unsure if the way Im doing this is outdated, wrong or what, but enough babblin', here's the code. (Items and Blocks all work, its just when I try to meddle with the Tile Ent stuffs) Main File Quote // ... public static CookieJarMod instance; public CookieJarMod() { final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); modEventBus.addListener(this::setup); modEventBus.addListener(this::doClientStuff); instance = this; MinecraftForge.EVENT_BUS.register(this); } private void setup(final FMLCommonSetupEvent event) { } private void doClientStuff(final FMLClientSetupEvent event) { ClientRegistry.bindTileEntityRenderer(/*unsure what to do here... JAR_TILE_ENT is a ? while this needs a specific one*/, JarContainerTileEntityRenderer::new); } @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD) public static class RegistryEvents { @SubscribeEvent public static void registerItems(final RegistryEvent.Register<Item> event) { event.getRegistry().registerAll( ObjectList.DEBUG_STAR, //First Item Test, remove later ObjectList.COOKIE_JAR_ITEM ); } @SubscribeEvent public static void registerBlocks(final RegistryEvent.Register<Block> event) { event.getRegistry().registerAll( ObjectList.COOKIE_JAR ); } @SubscribeEvent public static void onTileEntitiesTypeRegistry(final RegistryEvent.Register<TileEntityType<?>> event) { event.getRegistry().registerAll( ObjectList.JAR_TILE_ENT ); } } ObjectList Quote // ... public class ObjectList { // ... private static final Block JAR_TILE_ENT_TILES[] = new Block[] { ObjectList.COOKIE_JAR }; public static TileEntityType<?> JAR_TILE_ENT = TileEntityType.Builder.create(JarContainerTileEntity::new, ObjectList.JAR_TILE_ENT_TILES).build(null); }
April 3, 20205 yr Hi This working example (tutorial) project will show you how you can register TileEntities - see mbe20, mbe21 https://github.com/TheGreyGhost/MinecraftByExample -TGG
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.