Jump to content

Mksn

Members
  • Posts

    4
  • Joined

  • Last visited

Mksn's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I know basic Java coding from arithmetics to polymorphism. I will be aware the next time I post the codes. But can someone give me some ideas on what went wrong in the code? or some constructive advice?
  2. Emmm, I kinda got busy in school recently, so I havent gotten much progress. checked the code again and compared it with many tutorials, not many differences. But still encountering issues with the registry. I guess its some of the nuance that caused errors, tried many changes but didnt work. can someone check it for me plez?
  3. Thanks fellows.
  4. Hi guys, I am pretty new on Minecraft Modding. I am trying to create custom fluid using forge recently, but it just couldn't work. I suspect there's something wrong with the registry. Emmm, so, please help me Orz. Down here are my codes. public class FluidBase extends Fluid implements IHasModel { static { FluidRegistry.enableUniversalBucket(); } public FluidBase(String name, Material material) { this(name, material, new ResourceLocation("fluid/"+ name + "_still"), new ResourceLocation("fluid/" + name + "_flowing")); } public FluidBase(String name, Material material, ResourceLocation still, ResourceLocation flowing) { super(name, still, flowing); block = new BlockFluidClassic(this, material); block.setUnlocalizedName(name); block.setRegistryName("fluid " + name); Item item = new ItemBlock(block); item.setRegistryName(name); ModFluid.FLUID.add(this); ModBlocks.BLOCKS.add(block); ModItems.ITEMS.add(item); } @Override public void registerModel() { Main.proxy.registerFluidModel(Item.getItemFromBlock(this.getBlock()), this.getBlock(), this.getName()); } } I created a class FluidBase, which extends fluid from net.minecraft. As most tutorials suggested, I also created a corresponding block using BlockFluidClass. ModFluid.FLUID, ModBlocks.BLOCKS, and ModItems.ITEMS are just three arraylists for registering the objects. (IHasModel only contains the method registerModel(), which is overridden here.) @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])); } public static void onFluidRegister() { for(Fluid object : ModFluid.FLUID) { FluidRegistry.registerFluid(object); FluidRegistry.addBucketForFluid(object); } } @SubscribeEvent public static void onModelRegister(ModelRegistryEvent event) { for(Item item : ModItems.ITEMS) { if(item instanceof IHasModel) { ((IHasModel)item).registerModel(); } } for(Block block : ModBlocks.BLOCKS) { if(block instanceof IHasModel) { ((IHasModel)block).registerModel(); } } } } After I declared an instance of FluidBase, I created several subscribe event methods. I did not put the annotation @SubscribeEvent before onFluidRegister(), since i saw there is an event bus method built into the FluidRegistry.registerFluid() method. public class ClientProxy extends CommonProxy{ @Override public void registerItemRenderer(Item item, int meta, String id){ ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(item.getRegistryName(), id)); } @Override public void registerFluidModel(Item item, Block block, String name) { ModelBakery.registerItemVariants(item); ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { return new ModelResourceLocation(Reference.MOD_ID + ":" + name , name); } }); ModelLoader.setCustomStateMapper(block, new StateMapperBase() { @Override protected ModelResourceLocation getModelResourceLocation(IBlockState state) { return new ModelResourceLocation(Reference.MOD_ID + ":" + name , name); } }); } } Here is my client proxy, model registry basically, about which I have no idea Lol. I copied most of the code from MCreator here. @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; @EventHandler public static void PreInit(FMLPreInitializationEvent event) { RegistryHandler.onFluidRegister(); } @EventHandler public static void Init(FMLInitializationEvent event){} @EventHandler public static void PostInit(FMLPostInitializationEvent event){] } Lastly, here is my Main method. As a website instructed, I put the fluidregistry inside preinit. (I didn't mess with the item and block registries since forge docs state they are between preinit and init.) Well.. Somehow, as a result of these terrible codes the game wouldn't load and would crash every time. Here's the console: error.txt There's like other texture problems as well, but please just ignore these for now... I know there's probably some really dumb problems here in the code. I have just started codding, so please offer some help Orz. I would be very grateful~~~
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.