Jump to content

Recommended Posts

Posted

Custom render for my item is not rendering.

 

 

 

package me.ryancp.zeldamod.client;

import org.lwjgl.opengl.GL11;

import cpw.mods.fml.common.FMLCommonHandler;
import me.ryancp.zeldamod.ZeldaMod;
import me.ryancp.zeldamod.models.Bomb;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.client.IItemRenderer;



public class Render3DItem implements IItemRenderer {

protected Bomb bombModel;

public Render3DItem() {
	bombModel = new Bomb();
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,
		ItemRendererHelper helper) {

	return false;
}

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
	switch(type) {
		case EQUIPPED:
		{
			GL11.glPushMatrix();

			Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("zeldamod", "/textures/models/bombModel.png"));

			bombModel.render((Entity)data[1], 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F);

			GL11.glPopMatrix();
		}

	default:
		break;
	}
}

public Item setUnlocalizedName(String string) {
	return null;
}

@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
	switch(type) {
	case EQUIPPED: return true;
	default: return false;
	}
}
}

 

package me.ryancp.zeldamod.client;

import me.ryancp.zeldamod.CommonProxy;
import me.ryancp.zeldamod.KeyHandler;
import me.ryancp.zeldamod.ZeldaMod;
import me.ryancp.zeldamod.entities.EntityFireRodProjectile;
import me.ryancp.zeldamod.entities.EntityIceRodProjectile;
import me.ryancp.zeldamod.entities.RenderFireRodProjectile;
import me.ryancp.zeldamod.entities.RenderIceRodProjectile;
import me.ryancp.zeldamod.gui.GuiEvents;
import me.ryancp.zeldamod.gui.ZeldaInvGui;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.registry.EntityRegistry;

public class ClientProxy extends CommonProxy{

@Override
public void registerItemRenders() {
	MinecraftForgeClient.registerItemRenderer(ZeldaMod.bombs,(IItemRenderer)new Render3DItem());
}

@Override
public void registerRenders() {
	super.registerRenders();
	EntityRegistry.registerGlobalEntityID(EntityIceRodProjectile.class, "IceProjectile", 1000);
	RenderingRegistry.registerEntityRenderingHandler(EntityIceRodProjectile.class, new RenderIceRodProjectile());

	EntityRegistry.registerGlobalEntityID(EntityFireRodProjectile.class, "FireProjectile", 1001);
	RenderingRegistry.registerEntityRenderingHandler(EntityFireRodProjectile.class, new RenderFireRodProjectile());
}


@Override
public void registerHandlers() {}

@Override
public void registerMessage() { }

@Override
public void registerKeyBindings() {
	keyHandler = new KeyHandler();
	FMLCommonHandler.instance().bus().register(keyHandler);
	MinecraftForge.EVENT_BUS.register(new GuiEvents());
}

@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
	if (world instanceof WorldClient) {
		switch (ID) {
			case ZeldaMod.GUI: return new ZeldaInvGui(player);
		}
	}
	return null;
}

@Override
public World getClientWorld() {
	return FMLClientHandler.instance().getClient().theWorld;
}

}

 

package me.ryancp.zeldamod.models;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

public class Bomb extends ModelBase
{
//fields
public ModelRenderer BombBlock1;
public ModelRenderer BombBlock2;
public ModelRenderer BombBlock3;
public ModelRenderer BombBlock4;
public ModelRenderer BombBlock5;
public ModelRenderer BombTop;
public ModelRenderer BombBase;
public ModelRenderer Shape1;

public Bomb()
{
	textureWidth = 64;
	textureHeight = 32;

	BombBlock1 = new ModelRenderer(this, 0, 20);
	BombBlock1.addBox(0F, 0F, 0F, 6, 6, 6);
	BombBlock1.setRotationPoint(-2F, 0F, -2F);
	BombBlock1.setTextureSize(64, 32);
	BombBlock1.mirror = true;
	setRotation(BombBlock1, 0F, 0F, 0F);
	BombBlock2 = new ModelRenderer(this, 52, 10);
	BombBlock2.addBox(0F, 0F, 0F, 1, 4, 4);
	BombBlock2.setRotationPoint(-3F, 1F, -1F);
	BombBlock2.setTextureSize(64, 32);
	BombBlock2.mirror = true;
	setRotation(BombBlock2, 0F, 0F, 0F);
	BombBlock3 = new ModelRenderer(this, 52, 0);
	BombBlock3.addBox(0F, 0F, 0F, 1, 4, 4);
	BombBlock3.setRotationPoint(4F, 1F, -1F);
	BombBlock3.setTextureSize(64, 32);
	BombBlock3.mirror = true;
	setRotation(BombBlock3, 0F, 0F, 0F);
	BombBlock4 = new ModelRenderer(this, 40, 0);
	BombBlock4.addBox(0F, 0F, 0F, 1, 4, 4);
	BombBlock4.setRotationPoint(-1F, 1F, -2F);
	BombBlock4.setTextureSize(64, 32);
	BombBlock4.mirror = true;
	setRotation(BombBlock4, 0F, 1.570796F, 0F);
	BombBlock4 = new ModelRenderer(this, 40, 10);
	BombBlock4.addBox(0F, 0F, 0F, 1, 4, 4);
	BombBlock4.setRotationPoint(-1F, 1F, 5F);
	BombBlock4.setTextureSize(64, 32);
	BombBlock4.mirror = true;
	setRotation(BombBlock4, 0F, 1.570796F, 0F);
	BombTop = new ModelRenderer(this, 52, 20);
	BombTop.addBox(0F, 0F, 0F, 1, 4, 4);
	BombTop.setRotationPoint(3F, 6F, -1F);
	BombTop.setTextureSize(64, 32);
	BombTop.mirror = true;
	setRotation(BombTop, 0F, 0F, 1.570796F);
	BombBase = new ModelRenderer(this, 40, 20);
	BombBase.addBox(0F, 0F, 0F, 1, 4, 4);
	BombBase.setRotationPoint(3F, -1F, -1F);
	BombBase.setTextureSize(64, 32);
	BombBase.mirror = true;
	setRotation(BombBase, 0F, 0F, 1.570796F);
	Shape1 = new ModelRenderer(this, 19, 5);
	Shape1.addBox(0F, 0F, 0F, 1, 3, 1);
	Shape1.setRotationPoint(0F, -4F, 1F);
	Shape1.setTextureSize(64, 32);
	Shape1.mirror = true;
	setRotation(Shape1, 0F, 0F, 0F);
}

public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
{
	super.render(entity, f, f1, f2, f3, f4, f5);
	setRotationAngles(f, f1, f2, f3, f4, f5, entity);
	BombBlock1.render(f5);
	BombBlock2.render(f5);
	BombBlock3.render(f5);
	BombBlock4.render(f5);
	BombBlock4.render(f5);
	BombTop.render(f5);
	BombBase.render(f5);
	Shape1.render(f5);
}

private void setRotation(ModelRenderer model, float x, float y, float z)
{
	model.rotateAngleX = x;
	model.rotateAngleY = y;
	model.rotateAngleZ = z;
}

public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity)
{
	super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
}

}

 

 

 

There's 10 types of people in this world; Those that understand binary and those that don't.

Posted

You should be rendering it more than just EQUIPPED. The render type you want probably isn't being called.

-Mitchellbrine

 

Minecraft can do ANYTHING, it's coded in Java and you got the full power of Java behind you when you code. So nothing is impossible.

It may be freaking fucking hard though, but still possible ;)

 

If you create a topic on Modder Support, live by this motto:

I don't want your charity, I want your information
Posted

Trying to render it in the player's hand only right now, is the case correct, or is it a different type for it?

There's 10 types of people in this world; Those that understand binary and those that don't.

Posted

yeah there is quite a lot more involved mate you have just made it render for 3rd person, theres inventory rendering first person item frame (entity item on the ground also gets covered by this) etc ill give you my render class to peek at and see where the rest comes in to play

 

 


@SideOnly(Side.CLIENT)
public class ItemRenderMace implements IItemRenderer
{




@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
	switch (type) {
	case ENTITY:
		return true;
	case EQUIPPED:
		return true;
	case EQUIPPED_FIRST_PERSON:
		return true;
	case INVENTORY:
		return true;
	default:
		return false;
}
}

@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,ItemRendererHelper helper) {
	return true;
}

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
        

	MaceModel model = new MaceModel();

        GL11.glPushMatrix();
        if(type == ItemRenderType.EQUIPPED_FIRST_PERSON){
            GL11.glTranslatef((float) 0.5F, (float) 5.0F, (float) 0.5F);
        }else if(type == ItemRenderType.INVENTORY){
            GL11.glTranslatef((float) 0.5F, (float) 2.15F, (float) 0.5F);

        }else if(type == ItemRenderType.EQUIPPED){
            GL11.glTranslatef((float) 0.72F, (float) 5.3F, (float) 0.72F);
        
        }else if(type == ItemRenderType.ENTITY){
            GL11.glTranslatef((float) 0F, (float) 1.6F, (float) 0F);
        }


        Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("mcr" , "textures/models/Mace.png"));


     GL11.glPushMatrix();
        GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);


        if(type == ItemRenderType.EQUIPPED_FIRST_PERSON){
            GL11.glRotatef((1 * 120F), 0.0F, 1.0F, 0.0F);

        }else if(type == ItemRenderType.EQUIPPED){
            GL11.glRotatef(40, 0.0F, 1.0F, 0.0F);

        }else
        GL11.glRotatef(0F, 0.0F, 1.0F, 0.0F);

        if(type == ItemRenderType.EQUIPPED_FIRST_PERSON){
        	model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.2025F);

        }else  if(type == ItemRenderType.EQUIPPED){
        	model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.2025F);

        } else
        model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0855F);


        GL11.glPopMatrix();
        GL11.glPopMatrix();
}
} 

 

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Yep I did upgrade just because it showed me a new version available.  I'll redownload the mod list and make sure anything works.  Thanks!
    • The latest log was taken down by pastebin for some reason. Did you try removing the mods you added? The mods you updated, was there a specific reason you updated, or just because? It's possible the updates introduced incompatibilitie, or even need a newer build of forge. If you didn't need the updates for a specific reason, you could also try downgrading those mods.
    • Please read the FAQ, and post logs as described there. https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/
    • I am using forge 1.20.1 (version 47.3.0). My pc has an RTX 4080 super and an i9 14900 KF, I am on the latest Nvidia graphics driver, latest windows 10 software, I have java 23, forge 1.12.2 works and so does all vanilla versions but for some reason no version of forge 1.20.1 works and instead the game just crashes with the error code "-1." I have no mods in my mods fodler, I have deleted my options.txt and forge.cfg files in case my settings were causing a crash and have tried removing my forge version from the installations folder and reinstalling but no matter what I still crash with the same code and my log doesn't tell me anything: 18:34:53.924 game 2025-02-06 18:34:53,914 main WARN Advanced terminal features are not available in this environment 18:34:54.023 game [18:34:54] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher running: args [--username, mrmirchi, --version, 1.20.1-forge-47.3.0, --gameDir, C:\Users\aryam\AppData\Roaming\.minecraft, --assetsDir, C:\Users\aryam\AppData\Roaming\.minecraft\assets, --assetIndex, 5, --uuid, 2db00ea8d678420a8956109a85d90e9d, --accessToken, ????????, --clientId, ZWI3NThkNzMtNmNlZS00MGI5LTgyZTgtYmZkNzcwMTM5MGMx, --xuid, 2535436222989555, --userType, msa, --versionType, release, --quickPlayPath, C:\Users\aryam\AppData\Roaming\.minecraft\quickPlay\java\1738838092785.json, --launchTarget, forgeclient, --fml.forgeVersion, 47.3.0, --fml.mcVersion, 1.20.1, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20230612.114412] 18:34:54.027 game [18:34:54] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher 10.0.9+10.0.9+main.dcd20f30 starting: java version 17.0.8 by Microsoft; OS Windows 10 arch amd64 version 10.0 18:34:54.132 game [18:34:54] [main/INFO] [ne.mi.fm.lo.ImmediateWindowHandler/]: Loading ImmediateWindowProvider fmlearlywindow 18:34:54.191 game [18:34:54] [main/INFO] [EARLYDISPLAY/]: Trying GL version 4.6 18:34:54.303 game [18:34:54] [main/INFO] [EARLYDISPLAY/]: Requested GL version 4.6 got version 4.6 18:34:54.367 monitor Process Monitor Process crashed with exit code -1     screenshot of log: https://drive.google.com/file/d/1WdkH88H865XErvmIqAKjlg7yrmj8EYy7/view?usp=sharing
    • I am currently working on a big mod, but I'm having trouble with my tabs, I want to find a way to add tabs inside tabs, like how in mrcrayfishes furniture mod, his furniture tab has multiple other sub tabs to them, so i know it is possible but i just don't know how it is possible, any help would be appreciated, thanks
  • Topics

×
×
  • Create New...

Important Information

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