Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I'm trying to make a laptop in minecraft. I created an obj in blender, I created an texture atlas(.png), I can't figure out the rendering in minecraft. It is my first mod:

Mod name "JavaProgrammingMod"(It adds java in minecraft)

JavaProgrammingMod.java:

package com.mikeyjy.JavaProgramming;

import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

@Mod(modid = "jp", name = "JavaProgramming", version = "0.27b")
public class JavaProgrammingMod {

	public static Block blockPC;
	public static Item itemJavaSoft;
	
	@EventHandler
	public void preInit(FMLPreInitializationEvent event) {
		blockPC = new BlockPC(Material.anvil).setBlockName("BlockPC").setCreativeTab(tabJavaProgrammingMod);
		GameRegistry.registerBlock(blockPC, blockPC.getUnlocalizedName().substring(5));
		itemJavaSoft = new ItemJavaSoft().setUnlocalizedName("ItemJavaSoft").setTextureName("jp:itemjavasoft").setCreativeTab(tabJavaProgrammingMod);
		GameRegistry.registerItem(itemJavaSoft, itemJavaSoft.getUnlocalizedName().substring(5));
		GameRegistry.registerTileEntity(TileEntityBlockPC.class, "tileBlockPC");
        ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBlockPC.class, new RenderTileEntityBlockPC());
	}
	
	@EventHandler
	public void preInit(FMLInitializationEvent event) {
		
	}
	
	@EventHandler
	public void preInit(FMLPostInitializationEvent event) {
		
	}
	
	public static CreativeTabs tabJavaProgrammingMod = new CreativeTabs("tabJavaProgrammingMod") {
		@Override
		public Item getTabIconItem() {
			return new ItemStack(blockPC).getItem();
		}
	};
}

BlockPC.java:

package com.mikeyjy.JavaProgramming;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

public class BlockPC extends BlockContainer{

    public BlockPC(Material material) {
        super(material);

        this.setBlockName("Computer");
    }

    @Override
    public boolean renderAsNormalBlock(){
        return false;
    }

    @Override
    public int getRenderType(){
        return -1;
    }

    @Override
    public boolean isOpaqueCube(){
        return false;
    }

    @Override
    public TileEntity createNewTileEntity(World world, int par2) {
        return new TileEntityBlockPC();
    }
}

RenderTileEntityBlockPC:

package com.mikeyjy.JavaProgramming;

import org.lwjgl.opengl.GL11;

import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;

public class RenderTileEntityBlockPC extends TileEntitySpecialRenderer {

	ResourceLocation texture;
	ResourceLocation objModelLocation;
	IModelCustom model;
	public RenderTileEntityBlockPC(){
        texture = new ResourceLocation("jp", "models/BlockPCTexture.png");
        objModelLocation = new ResourceLocation("jp", "models/BlockPC.obj");
        model = AdvancedModelLoader.loadModel(objModelLocation);
	}
	@Override
    public void renderTileEntityAt(TileEntity te, double posX, double posY, double posZ, float timeSinceLastTick) {
		TileEntityBlockPC te2 = (TileEntityBlockPC) te;
		bindTexture(texture);

		GL11.glPushMatrix();
		GL11.glTranslated(posX + 0.5, posY + 0.5, posZ + 0.5);
	
		GL11.glPushMatrix();
	
		model.renderAll();
		GL11.glPopMatrix();
		GL11.glPopMatrix();
	}
}

I have these errors:

BlockPC.java line 34: TileEntityBlockPC cannot be resolved to a type

RenderTileEntityBlockPC line 23: TileEntityBlockPC cannot be resolved to a type

JavaProgrammingMod line 28: The method registerTileEntity(Class<? extends TileEntity>, String) in the type GameRegistry is not applicable for the arguments (Class<TileEntityBlockPC>, String)

JavaProgrammingMod line 29: The method bindTileEntitySpecialRenderer(Class<? extends TileEntity>, TileEntitySpecialRenderer) in the type ClientRegistry is not applicable for the arguments (Class<TileEntityBlockPC>, RenderTileEntityBlockPC)

 

I followed this tutorial: https://forums.minecraftforge.net/topic/29600-1710-rendering-obj-models-as-blocks/

 

Please help

Guest
This topic is now closed to further replies.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.