Posted February 22, 20223 yr Hello guys, how are you? I'm working on a block that I've designed it using BlockBench, the block have a transparent chamber with 2 electrodes inside. But in-game the block doesn't render properly, how can I fix it?
February 22, 20223 yr you need to set the RenderType of your Block to RenderType.cutout via ItemBlockRenderTypes.setRenderLayer in FMLClientSetupEvent
February 22, 20223 yr Author Oh thanks it worked For anyone who wants to know the solution: Add the following to the constructor of your main class: FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup); // clientSetup is the name of a method that i've created Add the following method (the name need to be the same of the name that you passed inside .addListener()): private void clientSetup (final FMLClientSetupEvent event) { ItemBlockRenderTypes.setRenderLayer(ModBlocks.INFUSER_BLOCK.get(), RenderType.cutout()); // Replace ModBlocks.INFUSER_BLOCK.get() with your block }
June 2, 20223 yr My main is: package com.example.eitem; import com.mojang.logging.LogUtils; import init.BlockInit; import init.ItemInit; import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.client.renderer.RenderType; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.InterModComms; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent; import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; import net.minecraftforge.event.server.ServerStartingEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.slf4j.Logger; import java.util.stream.Collectors; // The value here should match an entry in the META-INF/mods.toml file @Mod("eitem") public class ElliotItems { public static final String MOD_ID = "eitem"; public static final String VERSION = "1.6.2"; public static final String NAME = "Elliot's Item"; // Directly reference a slf4j logger private static final Logger LOGGER = LogUtils.getLogger(); public ElliotItems() { // Register the setup method for modloading final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); modEventBus.addListener(this::setup); // Register the enqueueIMC method for modloading modEventBus.addListener(this::enqueueIMC); // Register the processIMC method for modloading modEventBus.addListener(this::processIMC); BlockInit.BLOCKS.register(modEventBus); ItemInit.ITEMS.register(modEventBus); modEventBus.addListener(this::clientSetup); // Register ourselves for server and other game events we are interested in MinecraftForge.EVENT_BUS.register(this); } private void setup(final FMLCommonSetupEvent event) { // some preinit code LOGGER.info("HELLO FROM PREINIT"); char[] ca = {'g', 'o', ' ', 'm', 'y'}; String c = Character.toString(ca[0]).toUpperCase(); System.out.println(c + " is c"); char[] newc = c.toCharArray(); ca[0] = newc[0]; System.out.println(new String(ca)); ItemBlockRenderTypes.setRenderLayer(BlockInit.TELEPORTER_A.get(), RenderType.cutout()); LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName()); } private void clientSetup (final FMLClientSetupEvent event) { ItemBlockRenderTypes.setRenderLayer(BlockInit.TELEPORTER_A.get(), RenderType.cutout()); private void enqueueIMC(final InterModEnqueueEvent event) { // Some example code to dispatch IMC to another mod InterModComms.sendTo("eitem", "helloworld", () -> { LOGGER.info("Hello world from the MDK"); return "Hello world";}); } private void processIMC(final InterModProcessEvent event) { // Some example code to receive and process InterModComms from other mods LOGGER.info("Got IMC {}", event.getIMCStream(). map(m->m.messageSupplier().get()). collect(Collectors.toList())); } // You can use SubscribeEvent and let the Event Bus discover methods to call @SubscribeEvent public void onServerStarting(ServerStartingEvent event) { // Do something when the server starts LOGGER.info("HELLO from server starting"); } // You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD // Event bus for receiving Registry Events) @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) public static class RegistryEvents { @SubscribeEvent public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) { // Register a new block here LOGGER.info("HELLO from Register Block"); } } } there was stuff i was experimenting with so don't worry about it lol
June 2, 20223 yr 5 hours ago, CoddingDirtMC said: private void clientSetup (final FMLClientSetupEvent event) { ItemBlockRenderTypes.setRenderLayer(BlockInit.TELEPORTER_A.get(), RenderType.cutout()); the code will not compile, because there is a bracket missing you call ItemBlockRenderTypes twice, in FMLCommonSetupEvent and the in FMLClientSetupEvent but you should call int onyl in FMLClientSetupEvent
June 2, 20223 yr i already fixed the bracket and made sure I only called the function once but it still didnt work
June 3, 20223 yr alr heres my code: package com.example.eitem; import com.mojang.logging.LogUtils; import init.BlockInit; import init.ItemInit; import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.client.renderer.RenderType; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.InterModComms; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent; import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; import net.minecraftforge.event.server.ServerStartingEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.slf4j.Logger; import java.util.stream.Collectors; // The value here should match an entry in the META-INF/mods.toml file @Mod("eitem") public class ElliotItems { public static final String MOD_ID = "eitem"; public static final String VERSION = "1.6.2"; public static final String NAME = "Elliot's Item"; // Directly reference a slf4j logger private static final Logger LOGGER = LogUtils.getLogger(); public ElliotItems() { // Register the setup method for modloading final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); modEventBus.addListener(this::setup); // Register the enqueueIMC method for modloading modEventBus.addListener(this::enqueueIMC); // Register the processIMC method for modloading modEventBus.addListener(this::processIMC); BlockInit.BLOCKS.register(modEventBus); ItemInit.ITEMS.register(modEventBus); modEventBus.addListener(this::clientSetup); // Register ourselves for server and other game events we are interested in MinecraftForge.EVENT_BUS.register(this); } private void setup(final FMLCommonSetupEvent event) { // some preinit code LOGGER.info("HELLO FROM PREINIT"); char[] ca = {'g', 'o', ' ', 'm', 'y'}; String c = Character.toString(ca[0]).toUpperCase(); System.out.println(c + " is c"); char[] newc = c.toCharArray(); ca[0] = newc[0]; System.out.println(new String(ca)); LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName()); } private void clientSetup (final FMLClientSetupEvent event) { ItemBlockRenderTypes.setRenderLayer(BlockInit.TELEPORTER_A.get(), RenderType.cutout()); } private void enqueueIMC(final InterModEnqueueEvent event) { // Some example code to dispatch IMC to another mod InterModComms.sendTo("eitem", "helloworld", () -> { LOGGER.info("Hello world from the MDK"); return "Hello world";}); } private void processIMC(final InterModProcessEvent event) { // Some example code to receive and process InterModComms from other mods LOGGER.info("Got IMC {}", event.getIMCStream(). map(m->m.messageSupplier().get()). collect(Collectors.toList())); } // You can use SubscribeEvent and let the Event Bus discover methods to call @SubscribeEvent public void onServerStarting(ServerStartingEvent event) { // Do something when the server starts LOGGER.info("HELLO from server starting"); } // You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD // Event bus for receiving Registry Events) @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) public static class RegistryEvents { @SubscribeEvent public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) { // Register a new block here LOGGER.info("HELLO from Register Block"); } } }
June 3, 20223 yr Quote private void clientSetup (final FMLClientSetupEvent event) { ItemBlockRenderTypes.setRenderLayer(BlockInit.TELEPORTER_A.get(), RenderType.cutout()); } You never set your block's render type, just the item. 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.
June 3, 20223 yr 5 hours ago, Draco18s said: You never set your block's render type, just the item. wrong ItemBlockRenderTypes is used to set the RenderType of the Block, not sure why the class is called ItemBlockRenderTypes 6 hours ago, CoddingDirtMC said: private void clientSetup (final FMLClientSetupEvent event) { ItemBlockRenderTypes.setRenderLayer(BlockInit.TELEPORTER_A.get(), RenderType.cutout()); } is this EventHandler called? use debugger to check Edited June 3, 20223 yr by Luis_ST
June 3, 20223 yr In my constructor, Im doing modEventBus.addListener(this::clientSetup); So I think it is. (I'm new to mc modding btw so idk if I'm even in the right spot lol) If you need my debug here. Edited June 3, 20223 yr by CoddingDirtMC
June 4, 20223 yr wait my code has a setup method. And my clientSetup seems to be not running. Is the setup method overriding clientSetup? Setup method and Constructor: public ElliotItems() { // Register the setup method for modloading final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); modEventBus.addListener(this::setup); // Register the enqueueIMC method for modloading modEventBus.addListener(this::enqueueIMC); // Register the processIMC method for modloading modEventBus.addListener(this::processIMC); modEventBus.addListener(this::clientSetup); BlockInit.BLOCKS.register(modEventBus); ItemInit.ITEMS.register(modEventBus); // Register ourselves for server and other game events we are interested in MinecraftForge.EVENT_BUS.register(this); } private void setup(final FMLCommonSetupEvent event) { // some preinit code LOGGER.info("HELLO FROM PREINIT"); char[] ca = {'g', 'o', ' ', 'm', 'y'}; String c = Character.toString(ca[0]).toUpperCase(); System.out.println(c + " is c"); char[] newc = c.toCharArray(); ca[0] = newc[0]; System.out.println(new String(ca)); LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName()); }
June 4, 20223 yr 3 hours ago, CoddingDirtMC said: private void setup(final FMLCommonSetupEvent event) { // some preinit code LOGGER.info("HELLO FROM PREINIT"); char[] ca = {'g', 'o', ' ', 'm', 'y'}; String c = Character.toString(ca[0]).toUpperCase(); System.out.println(c + " is c"); char[] newc = c.toCharArray(); ca[0] = newc[0]; System.out.println(new String(ca)); LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName()); } By the way, why do you have this? It does nothing useful. 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.
June 4, 20223 yr alr so I have that cause I was testing something with strs and chars. I know it does nothing
June 4, 20223 yr I also already tried removing setup and keeping client setup. The method "clientSetup" runs but the render type still does not change
June 4, 20223 yr you're reading my mind I just did that now and it STILL didnt work package util; import init.BlockInit; import com.example.eitem.ElliotItems; import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.client.renderer.RenderType; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; @Mod.EventBusSubscriber(modid = ElliotItems.MOD_ID, bus = Bus.MOD, value = Dist.CLIENT) public class ClientEventBusSubscriber { @SubscribeEvent public static void clientSetup(FMLClientSetupEvent event) { ItemBlockRenderTypes.setRenderLayer(BlockInit.TELEPORTER.get(), RenderType.cutout()); } }
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.