OJarrisonn Posted February 22, 2022 Posted February 22, 2022 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? Quote
Luis_ST Posted February 22, 2022 Posted February 22, 2022 you need to set the RenderType of your Block to RenderType.cutout via ItemBlockRenderTypes.setRenderLayer in FMLClientSetupEvent Quote
OJarrisonn Posted February 22, 2022 Author Posted February 22, 2022 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 } Quote
CoddingDirtMC Posted June 1, 2022 Posted June 1, 2022 I did that solution and it didn't work for me. (i was in 1.18.2) Quote
CoddingDirtMC Posted June 2, 2022 Posted June 2, 2022 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 Quote
Luis_ST Posted June 2, 2022 Posted June 2, 2022 On 6/2/2022 at 1:18 AM, CoddingDirtMC said: private void clientSetup (final FMLClientSetupEvent event) { ItemBlockRenderTypes.setRenderLayer(BlockInit.TELEPORTER_A.get(), RenderType.cutout()); Expand 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 Quote
CoddingDirtMC Posted June 2, 2022 Posted June 2, 2022 i already fixed the bracket and made sure I only called the function once but it still didnt work Quote
CoddingDirtMC Posted June 3, 2022 Posted June 3, 2022 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"); } } } Quote
Draco18s Posted June 3, 2022 Posted June 3, 2022 Quote private void clientSetup (final FMLClientSetupEvent event) { ItemBlockRenderTypes.setRenderLayer(BlockInit.TELEPORTER_A.get(), RenderType.cutout()); } Expand You never set your block's render type, just the item. Quote 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.
Luis_ST Posted June 3, 2022 Posted June 3, 2022 (edited) On 6/3/2022 at 2:24 AM, Draco18s said: You never set your block's render type, just the item. Expand wrong ItemBlockRenderTypes is used to set the RenderType of the Block, not sure why the class is called ItemBlockRenderTypes On 6/3/2022 at 1:42 AM, CoddingDirtMC said: private void clientSetup (final FMLClientSetupEvent event) { ItemBlockRenderTypes.setRenderLayer(BlockInit.TELEPORTER_A.get(), RenderType.cutout()); } Expand is this EventHandler called? use debugger to check Edited June 3, 2022 by Luis_ST Quote
CoddingDirtMC Posted June 3, 2022 Posted June 3, 2022 (edited) 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, 2022 by CoddingDirtMC Quote
CoddingDirtMC Posted June 3, 2022 Posted June 3, 2022 i changed the render type parameter and it still didnt work Quote
CoddingDirtMC Posted June 4, 2022 Posted June 4, 2022 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()); } Quote
Draco18s Posted June 4, 2022 Posted June 4, 2022 On 6/4/2022 at 1:48 AM, 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()); } Expand By the way, why do you have this? It does nothing useful. Quote 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.
CoddingDirtMC Posted June 4, 2022 Posted June 4, 2022 alr so I have that cause I was testing something with strs and chars. I know it does nothing Quote
CoddingDirtMC Posted June 4, 2022 Posted June 4, 2022 I also already tried removing setup and keeping client setup. The method "clientSetup" runs but the render type still does not change Quote
Luis_ST Posted June 4, 2022 Posted June 4, 2022 try to move the FMLClientSetupEvent into a client event class Quote
CoddingDirtMC Posted June 4, 2022 Posted June 4, 2022 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()); } } Quote
CoddingDirtMC Posted June 4, 2022 Posted June 4, 2022 alr here it is https://github.com/pixelwastaken/javamods Quote
CoddingDirtMC Posted June 5, 2022 Posted June 5, 2022 wait nvm I fixed the entire thing I was just being an idiot XD Quote
Recommended Posts
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.