winnetrie Posted April 27, 2019 Posted April 27, 2019 I have made a custom fluid, but for some reason the blockstate is not working. blockstate file: Spoiler { "forge_marker": 1, "variants": { "fluids": { "model": "forge:fluid", "custom": { "fluid": "molten_invar" } } } } fluidclass: Spoiler public class FluidLiquid extends Fluid{ public FluidLiquid(String registryname, ResourceLocation still, ResourceLocation flowing) { super(registryname, still, flowing); setUnlocalizedName(registryname); } } fluidblock class: Spoiler public class FluidSolid extends BlockFluidClassic{ public FluidSolid(String registryname, Fluid fluid, Material material) { super(fluid, material); setUnlocalizedName(registryname); setRegistryName(registryname); setCreativeTab(Utilities.WINNETRIETERRACOTTAEXPANSION); } @Override public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } } i made a renderHandler class: Spoiler public class RenderHandler { public static void registerCustomMeshesAndStates(ResourceLocation registryname, Block blockreference) { ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(blockreference), new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { return new ModelResourceLocation(registryname, "fluid"); } }); ModelLoader.setCustomStateMapper(blockreference, new StateMapperBase() { @Override protected ModelResourceLocation getModelResourceLocation(IBlockState state) { return new ModelResourceLocation(registryname, "fluid"); } }); } } a fluidinit class: Spoiler public class FluidInit { public static void registerFluids() { if (Loader.isModLoaded("immersiveengineering")) { registerFluid(ModFluidReference.invar_fluid = new FluidLiquid("molten_invar", new ResourceLocation(References.PREFIX + "blocks/liquid_invar_still"), new ResourceLocation(References.PREFIX + "blocks/liquid_invar_flow"))); } } public static void registerFluid(Fluid fluid) { FluidRegistry.registerFluid(fluid); FluidRegistry.addBucketForFluid(fluid); } } inside the blockregistry event: Spoiler if (Loader.isModLoaded("immersiveengineering")) { event.getRegistry().registerAll( ModBlockReference.invar_block = new BlockInvar(new ResourceLocation(References.PREFIX + "block_invar")), ModBlockReference.bronze_block = new BlockBronze(new ResourceLocation(References.PREFIX + "block_bronze")), ModBlockReference.tin_block = new BlockTin(new ResourceLocation(References.PREFIX + "block_tin")), ModBlockReference.solder_block = new BlockSolder(new ResourceLocation(References.PREFIX + "block_solder")), ModBlockReference.molten_invar = new FluidSolid("winnetriesexpansionmod:molten_invar", ModFluidReference.invar_fluid, Material.LAVA) ); } Btw it is registering just the blockstate isn't loading, so i have purple/black squared textures here the client class: Spoiler @EventBusSubscriber public class ClientProxy implements IProxy{ private static final String DEFAULT_VARIANT = "default"; private static final String NORMAL_VARIANT = "normal"; @SubscribeEvent public static void onModelRegister(ModelRegistryEvent event) { RenderHandler.registerCustomMeshesAndStates(new ResourceLocation(References.PREFIX + "molten_invar"), ModBlockReference.molten_invar); for (Item item : ForgeRegistries.ITEMS.getValuesCollection()) { if (item.getRegistryName().getResourceDomain().equals(References.MOD_ID)) { registerItemModel(item); } } for (Block block : ForgeRegistries.BLOCKS.getValuesCollection()) { if (block.getRegistryName().getResourceDomain().equals(References.MOD_ID) && !(block instanceof BlockWinnetrieSlab.Double)) { registerBlockModel(block); } } } @Override public void PreInit(FMLPreInitializationEvent event) { // TODO Auto-generated method stub //RenderHandler.registerCustomMeshesAndStates(new ResourceLocation(References.PREFIX + "molten_invar"), ModBlockReference.molten_invar); } @Override public void Init(FMLInitializationEvent event) { // TODO Auto-generated method stub } @Override public void PostInit(FMLPostInitializationEvent event) { // TODO Auto-generated method stub } @Override public void ServerStarting(FMLServerStartingEvent event) { // TODO Auto-generated method stub } public static void registerItemModel(Item item) { ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), NORMAL_VARIANT)); } public static void registerItemSlab(Item item) { ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), DEFAULT_VARIANT)); } public static void registerBlockModel(Block block) { ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), NORMAL_VARIANT)); } } and at last the main mod class: Spoiler @Mod(modid = References.MOD_ID, name = References.NAME, version = References.VERSION, dependencies=References.DEPENDENCIES) public class Wtemod { @Instance public static Wtemod instance; private static File configDir; public static File getConfigDir() { return configDir; } static { FluidRegistry.enableUniversalBucket(); } @SidedProxy(clientSide = References.CLIENT_PROXY_CLASS, serverSide = References.SERVER_PROXY_CLASS) public static IProxy proxy; @EventHandler public void PreInit(FMLPreInitializationEvent event) { //entities & networking configDir = new File(event.getModConfigurationDirectory() + "/" + References.MOD_ID); configDir.mkdirs(); ConfigHandler.init(new File(configDir.getPath(), References.MOD_ID + ".cfg")); FluidInit.registerFluids(); } @EventHandler public void Init(FMLInitializationEvent event) { //registry events ModRecipes.init(); GameRegistry.registerWorldGenerator(new WinnetrieWorldGenerator(), 10); if (Loader.isModLoaded("immersiveengineering")) { ModIEAddon.init(); } } @EventHandler public void PostInit(FMLPostInitializationEvent event) { //inter-mod stuff } @EventHandler public void serverStarting(FMLServerStartingEvent event) { //server commands registering } } I have searched this forum for similar problems but none apply to me (as far as i know). I don't why is doesn' tload the blockstate Btw the blockstate file is inside assets/winnetriesexpansionmod/blockstates package the textures with the mcmeta files are at assets/winnetriesexpansionmod/textures/blocks the texture files are called : liquid_invar_flow.png, liquid_invar_flow.png.mcmeta, liquid_invar_still.png, liquid_invar_still.png.mcmeta Quote Try out my new Modpack for MC 1.15.2 https://www.curseforge.com/minecraft/modpacks/terran-civilization
winnetrie Posted April 27, 2019 Author Posted April 27, 2019 (edited) Well, found out that i misspelled something in the blockstate. I had "fluids" instead of "fluid" The fluid has now a texture in game. 1 more weird thing is when the fluid is flowing, his texture looks like it is zoomed in by a x2 factor Edit: I've added a screenshot Edited April 27, 2019 by winnetrie Quote Try out my new Modpack for MC 1.15.2 https://www.curseforge.com/minecraft/modpacks/terran-civilization
winnetrie Posted April 28, 2019 Author Posted April 28, 2019 (edited) Can anyone help me with this? I only need to know why the flowing liquid texture is zoomed in. the texture is 16 x 512 EDIT: I just tried to make the texture 32 x 512, because i have to try something. This seems to fix the texture problem, now the flowing texture has the appropriate texture format 16 x 16 and not 8 x 8. I'm not sure this is the right way to do it nor do i know why this happens. Edited April 28, 2019 by winnetrie Quote Try out my new Modpack for MC 1.15.2 https://www.curseforge.com/minecraft/modpacks/terran-civilization
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.