Jump to content

[Forge 1.8-11.14.4.1563] Obj compatibility - how?


Recommended Posts

Posted

Hello community!

 

I glaldy heard that it is now possible to use Obj's with forge again since Forge 1.8-11.14.4.1563

 

I'm a newbie in that case and heared there are differences between 1.7.10 and 1.8 Obj model implementation.

I hoped that eventually a tutorial for 1.7.10 would work in 1.8 either but yeah, I was wrong.

 

 

Can someone guide me trough this?

Posted

I don't know much about the system myself, but Forge has some examples here: code, assets

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

If you have any questions regarding with this, feel free to ask me, since i was able to get it working.

Its fairly simple AND laggy. DO not plan to use "HQ" models, because MC engine cannot handle it.

Posted

Well, here is an update of my status.

 

I took the code as it was and did change the structure a bit.

 

I placed all classes in the ModelLoaderRegistryDebug.java file in sepereta java files.

I placed the java files in an own package:

 

net.clash_of_nations.forge.confacilities.obj ->

 

CustomModelBlock.java

OBJCustomDataBlock.java

OBJDirectionBlock.java

OBJDirectionEye.java

OBJDynamicEye.java

OBJDynamicEyeTileEntity.java (temporarily placed here)

OBJTesseractBlock.java

OBJTesseractBlockTileEntity.java

OBJVertexColoring1.java

OBJVertexColoring2.java

OBJVertexColoring2TileEntity.java

 

(I didn't change any code and implemented all necessary packages)

 

So my ModelLoaderRegistryDebug.java file (renamed to ObjReg.java) only contains this code (It serves as a list for the initialization in my main java file called CoNFacilities.java):

 

 

package net.clash_of_nations.forge.confacilities;

import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.client.model.b3d.B3DLoader;
import net.minecraftforge.client.model.obj.OBJLoader;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.clash_of_nations.forge.confacilities.CoNFacilities;
import net.clash_of_nations.forge.confacilities.obj.CustomModelBlock;
import net.clash_of_nations.forge.confacilities.obj.OBJCustomDataBlock;
import net.clash_of_nations.forge.confacilities.obj.OBJDirectionBlock;
import net.clash_of_nations.forge.confacilities.obj.OBJTesseractBlock;
import net.clash_of_nations.forge.confacilities.obj.OBJTesseractTileEntity;
import net.clash_of_nations.forge.confacilities.obj.OBJVertexColoring1;
import net.clash_of_nations.forge.confacilities.obj.OBJVertexColoring2;
import net.clash_of_nations.forge.confacilities.obj.OBJVertexColoring2TileEntity;
import net.clash_of_nations.forge.confacilities.obj.OBJDirectionEye;
import net.clash_of_nations.forge.confacilities.obj.OBJDynamicEye;
import net.clash_of_nations.forge.confacilities.obj.OBJDynamicEyeTileEntity;

public class ObjReg{

static String MODID = CoNFacilities.MODID;

    public static void objLoaderInit(){
    	
        GameRegistry.registerBlock(CustomModelBlock.instance, CustomModelBlock.name);
        GameRegistry.registerBlock(OBJTesseractBlock.instance, OBJTesseractBlock.name);
        GameRegistry.registerBlock(OBJVertexColoring1.instance, OBJVertexColoring1.name);
        GameRegistry.registerBlock(OBJDirectionEye.instance, OBJDirectionEye.name);
        GameRegistry.registerBlock(OBJVertexColoring2.instance, OBJVertexColoring2.name);
        GameRegistry.registerBlock(OBJDirectionBlock.instance, OBJDirectionBlock.name);
        GameRegistry.registerBlock(OBJCustomDataBlock.instance, OBJCustomDataBlock.name);
        GameRegistry.registerBlock(OBJDynamicEye.instance, OBJDynamicEye.name);
        GameRegistry.registerTileEntity(OBJTesseractTileEntity.class, OBJTesseractBlock.name);
        GameRegistry.registerTileEntity(OBJVertexColoring2TileEntity.class, OBJVertexColoring2.name);
        GameRegistry.registerTileEntity(OBJDynamicEyeTileEntity.class, OBJDynamicEye.name);

    }

public static void objClientPreInit(){
    	
        B3DLoader.instance.addDomain(MODID.toLowerCase());
        Item item = Item.getItemFromBlock(CustomModelBlock.instance);
        ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + CustomModelBlock.name, "inventory"));
        
        OBJLoader.instance.addDomain(MODID.toLowerCase());
        Item item2 = Item.getItemFromBlock(OBJTesseractBlock.instance);
        ModelLoader.setCustomModelResourceLocation(item2, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + OBJTesseractBlock.name, "inventory"));
        
        Item item3 = Item.getItemFromBlock(OBJVertexColoring1.instance);
        ModelLoader.setCustomModelResourceLocation(item3, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + OBJVertexColoring1.name, "inventory"));
        
        Item item4 = Item.getItemFromBlock(OBJDirectionEye.instance);
        ModelLoader.setCustomModelResourceLocation(item4, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + OBJDirectionEye.name, "inventory"));
        
        Item item5 = Item.getItemFromBlock(OBJVertexColoring2.instance);
        ModelLoader.setCustomModelResourceLocation(item5, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + OBJVertexColoring2.name, "inventory"));
        
        Item item6 = Item.getItemFromBlock(OBJDirectionBlock.instance);
        ModelLoader.setCustomModelResourceLocation(item6, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + OBJDirectionBlock.name, "inventory"));
        
        Item item7 = Item.getItemFromBlock(OBJCustomDataBlock.instance);
        ModelLoader.setCustomModelResourceLocation(item7, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + OBJCustomDataBlock.name, "inventory"));
        
        Item item8 = Item.getItemFromBlock(OBJDynamicEye.instance);
        ModelLoader.setCustomModelResourceLocation(item8, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + OBJDynamicEye.name, "inventory"));
        
    }
}

 

 

 

They are like I said initialized in my main CoNFacilities java file:

 

 

package net.clash_of_nations.forge.confacilities;

import net.clash_of_nations.forge.confacilities.ObjReg;
import net.clash_of_nations.forge.confacilities.blocks.BlockLoader;

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.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.relauncher.Side;



@Mod(modid = CoNFacilities.MODID)
public class CoNFacilities {

public static final String MODID = "CoNFacilities";

@Instance
public static CoNFacilities instance = new CoNFacilities();

@EventHandler
public void preInit(FMLPreInitializationEvent e) {
	System.out.println("[PreInit] Loading Configuration.");
	ObjReg.objLoaderInit();
        if (e.getSide() == Side.CLIENT){
        ObjReg.objClientPreInit();
        }
}


@EventHandler
public void init(FMLInitializationEvent e){
	System.out.println("[ModInit] Loading Mod.");
	BlockLoader.loadBlocks();


}

@EventHandler
public void postInit(FMLPostInitializationEvent e){
	System.out.println("[PostInit] Loading connections between Mods.");
}

}

 

 

 

I did this because I think it makes it easier for me to keep everything in sight and makes my main file less messy.

 

I also placed all obj models in the package:

assets.confacilities.models.obj

 

all textures in the package:

assets.confacilities.textures.objs

 

all .json (blockstates) in the package:

assets.confacilities.blockstates

 

I updated all references for textures and models in the .json files.

 

So, when I try to start this whole thing, the game starts, but without loading my OBJ's. It is loading my simple Block that I created which is loaded here:

...	
@EventHandler
public void init(FMLInitializationEvent e){
	System.out.println("[ModInit] Loading Mod.");
	BlockLoader.loadBlocks();


}
...

 

BlockLoader.loadBlocks(); is the important line.

 

When I take a look to the console, it smashes out one error:

EDIT: I solved this problem. Was an unimportant mcmod.info error. I don't get any errors.

 

Did I do something wrong?

 

Please let me know if you need something else to see the error.

 

I'm glad for everyone who helps and thank you guys!

Posted

Nevermind, brought it to work!

 

There were just simple logic problems in the classes, because i seperatet them. Everything works fine now!

 

Thanks to everyone helping me trough this. If you have also questions, you can ask me too now :).

 

Have a nice day everyone!

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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