RustyGearGames Posted June 24, 2019 Posted June 24, 2019 (edited) Issue: Currently I am having an issue where I can't get two fluid blocks in my mod to render. Using 'ModelLoader.setCustomMeshDefinition' and 'ModelLoader.setCustomStateMapper' as i was told to do in one of a few available tutorials, The first fluid "registered" using these methods get the texture from the last fluid "registered" and all the others fail to have textures completely. I Have spent many hours trying to find documentation on these methods or my issue but was only able to find scraps, uninformative tutorials or outdated information. If someone could please tell me what I'm doing wrong or missing that would be greatly appreciated. ModBlocks.java public static final List<Block> BLOCKS = new ArrayList<Block>(); public static final Block Copper_Ore = new BlockBase("copper_ore", Material.IRON); public static final Block Silver_Ore = new BlockBase("silver_ore", Material.IRON); //FLUIDS public static final Block Molten_Copper = new BlockFluid("molten_copper",ModFluid.MOLTEN_COPPER_FLUID,Material.LAVA); public static final Block Molten_Silver = new BlockFluid("molten_silver",ModFluid.MOLTEN_SILVER_FLUID,Material.LAVA); public static void registerBlock(Block block) { ForgeRegistries.BLOCKS.register(block); ForgeRegistries.ITEMS.register(new ItemBlock(block).setRegistryName(block.getRegistryName())); } RenderHandler.java package com.xjacobx24.simplemod.util.handlers; import com.xjacobx24.simplemod.init.ModBlocks; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.statemap.StateMapperBase; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.client.model.ModelLoader; public class RenderHandler { public static void CallMe() { new RenderHandler().registerCustomMeshesAndStates(); } public void registerCustomMeshesAndStates() { ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(ModBlocks.Molten_Copper), new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { return new ModelResourceLocation("sm:molten_copper", "fluid"); } }); ModelLoader.setCustomStateMapper(ModBlocks.Molten_Copper, new StateMapperBase() { @Override protected ModelResourceLocation getModelResourceLocation(IBlockState state) { return new ModelResourceLocation("sm:molten_copper", "fluid"); } }); ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(ModBlocks.Molten_Silver), new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { return new ModelResourceLocation("sm:molten_silver", "fluid"); } }); ModelLoader.setCustomStateMapper(ModBlocks.Molten_Silver, new StateMapperBase() { @Override protected ModelResourceLocation getModelResourceLocation(IBlockState state) { return new ModelResourceLocation("sm:molten_silver", "fluid"); } }); } } Main.java package com.xjacobx24.simplemod; import com.xjacobx24.simplemod.generation.ModWorldGen; import com.xjacobx24.simplemod.init.ModBlocks; import com.xjacobx24.simplemod.proxy.ClientProxy; import com.xjacobx24.simplemod.proxy.CommonProxy; import com.xjacobx24.simplemod.util.Reference; import com.xjacobx24.simplemod.util.handlers.RegistryHandler; import com.xjacobx24.simplemod.util.handlers.RenderHandler; import net.minecraft.block.Block; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.Mod.Instance; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.registries.IForgeRegistry; import slimeknights.mantle.pulsar.control.PulseManager; import slimeknights.tconstruct.TinkerIntegration; import slimeknights.tconstruct.common.TinkerOredict; import slimeknights.tconstruct.common.config.Config; import slimeknights.tconstruct.debug.TinkerDebug; import slimeknights.tconstruct.gadgets.TinkerGadgets; import slimeknights.tconstruct.library.book.TinkerBook; import slimeknights.tconstruct.plugin.Chisel; import slimeknights.tconstruct.plugin.ChiselAndBits; import slimeknights.tconstruct.plugin.CraftingTweaks; import slimeknights.tconstruct.plugin.theoneprobe.TheOneProbe; import slimeknights.tconstruct.plugin.waila.Waila; import slimeknights.tconstruct.shared.TinkerCommons; import slimeknights.tconstruct.shared.TinkerFluids; import slimeknights.tconstruct.smeltery.TinkerSmeltery; import slimeknights.tconstruct.tools.AggregateModelRegistrar; import slimeknights.tconstruct.tools.TinkerMaterials; import slimeknights.tconstruct.tools.TinkerModifiers; import slimeknights.tconstruct.tools.TinkerTools; import slimeknights.tconstruct.tools.harvest.TinkerHarvestTools; import slimeknights.tconstruct.tools.melee.TinkerMeleeWeapons; import slimeknights.tconstruct.tools.ranged.TinkerRangedWeapons; import slimeknights.tconstruct.world.TinkerWorld; @Mod(modid = Reference.MOD_ID, name = Reference.NAME, version = Reference.VERSION) public class Main { @Instance public static Main instance; @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.COMMON_PROXY_CLASS) public static CommonProxy proxy; public static PulseManager pulseManager = new PulseManager(Config.pulseConfig); static { FluidRegistry.enableUniversalBucket(); } @EventHandler public static void PreInit(FMLPreInitializationEvent event) { RegistryHandler.preInitReg(event); } @EventHandler public static void init(FMLInitializationEvent event) { GameRegistry.registerWorldGenerator(new ModWorldGen(), 0); } @EventHandler public static void Postinit(FMLPostInitializationEvent event) { } } RegistryHandler.java package com.xjacobx24.simplemod.util.handlers; import com.xjacobx24.simplemod.init.ModBlocks; import com.xjacobx24.simplemod.init.ModFluid; import com.xjacobx24.simplemod.init.ModItems; import com.xjacobx24.simplemod.util.IHasModel; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.statemap.StateMapperBase; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fluids.BlockFluidClassic; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @EventBusSubscriber public class RegistryHandler { @SubscribeEvent public static void onItemRegister(RegistryEvent.Register<Item> event) { event.getRegistry().registerAll(ModItems.ITEMS.toArray(new Item[0])); } @SubscribeEvent public static void onBlockRegister(RegistryEvent.Register<Block> event) { event.getRegistry().registerAll(ModBlocks.BLOCKS.toArray(new Block[0])); } /* @SubscribeEvent public static void onFluidRegister(FluidRegistry.FluidRegisterEvent event) { FluidRegistry.registerFluid(ModFluid.CORUNDUM); System.out.println("FluidRegisterd"); } */ @SubscribeEvent public static void onModelRegister(ModelRegistryEvent event) { for(Item item : ModItems.ITEMS) { if(item instanceof IHasModel) { ((IHasModel)item).registerModels(); } } for(Block block : ModBlocks.BLOCKS) { if(block instanceof IHasModel) { ((IHasModel)block).registerModels(); } } } public static void preInitReg(FMLPreInitializationEvent event) { ModFluid.registerFluids(); //MUST BE CALLED FIRST!!!!!!!! RenderHandler.CallMe();//Calls registerCustomMeshesAndStates } } Edited June 26, 2019 by RustyGearGames Quote
RustyGearGames Posted June 25, 2019 Author Posted June 25, 2019 5 hours ago, diesieben07 said: Problematic code, issue 1, 14. "sm" is a terrible mod ID, it is way too short. Make it longer. Please post the complete file. "sm" isnt my modid its a shortened version of my modid, it wasnt my choice to do this. and i have edited the post for the full files inclusion. Quote
Cadiboo Posted June 25, 2019 Posted June 25, 2019 9 hours ago, RustyGearGames said: "sm" isnt my modid its a shortened version of my modid, it wasnt my choice to do this. You’re using it as your modid though... so it is your modid. Everything in programming is “your choice”, you can do literally whatever you want. Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
RustyGearGames Posted June 25, 2019 Author Posted June 25, 2019 (edited) 6 hours ago, diesieben07 said: registerCustomMeshesAndStates where is this called from? its called client side from my main class Edited June 25, 2019 by RustyGearGames Quote
RustyGearGames Posted June 26, 2019 Author Posted June 26, 2019 2 hours ago, diesieben07 said: That does not answer my question. What exactly do you want then? Quote Your main class also cannot reference client-only code. I was taught you can use an If statement checking for isClientSide to be true, then you can. correct me if im wrong. Quote
RustyGearGames Posted June 26, 2019 Author Posted June 26, 2019 9 minutes ago, diesieben07 said: You are wrong. In certain circumstances the JVM will still load classes that are only referenced inside an if statement. You must use @SidedProxy or side-only event subscribers (using @EventBusSubscriber) to interact with side-only code. My apologies. I will fix this Quote Which event are you calling it from? "My main mod class" can be anything from "in the mod class constructor" to "inside an event handler for PlayerInteractEvent". I have edited the original post to include my Main mod class file. Quote
RustyGearGames Posted June 26, 2019 Author Posted June 26, 2019 1 minute ago, diesieben07 said: The posted main mod file does not include a call to registerCustomMeshesAndStates. you are correct, Sorry, My main used to contain that and i moved it. give me a sec ill post the class containing it. Quote
RustyGearGames Posted June 26, 2019 Author Posted June 26, 2019 8 minutes ago, diesieben07 said: The posted main mod file does not include a call to registerCustomMeshesAndStates. I have posted the proper file. Quote
RustyGearGames Posted June 26, 2019 Author Posted June 26, 2019 (edited) 5 minutes ago, diesieben07 said: Where is this called from then? Its being called from the preInitReg method in the RegistryHandler class. Quote Also why are you calling the static method registerCustomMeshesAndStates as an instance method? Your IDE should be yelling at you for this, too. My bad I failed to edit the entirety of the class so it was still a static method. However, it should be updated properly now. Edited June 26, 2019 by RustyGearGames Quote
RustyGearGames Posted June 26, 2019 Author Posted June 26, 2019 11 minutes ago, diesieben07 said: ModelLoader registration methods must be called during ModelRegistryEvent, not preInit. Oh. My. God. That fixed it, thank you so much. I Have spent way to much on this for such a simple mistake. Once again, thanks for helping me. Side note how do I state a topic as solved (if Possible) 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.