Jump to content

[SOLVED] Customized Render Class Never Being Called


Selacstellap

Recommended Posts

(Updated 2013/7/25) Solved

 

I use EntityRegistry.registerModEntity(params) instead of EntityRegistry.registerGlobalEntityID(params) and it works!

Thanks to the OP of http://www.minecraftforge.net/forum/index.php/topic,10285.msg52206.html#msg52206 whose post inspires me.

 

Thank you guys who replied me.

Feel free to lock this thread.

---

Hi everyone. I'm designing a shooter shooting healing ball and the ball is nothing but a snowball with a different texture (original snowball.png painted yellow). Then I copy-paste the renderer and entity code for snowball and customize it. Of course I have registered the item, the entity and the renderer and bind them together, but it just doesn't work: the rendering methods inside the customized class are never called.

 

As the following code shows, I add some console output into the methods. When my shooter shoots a EntitySnowball, the message is displayed, but when it shoots EntityHealingBall, console shows nothing related. However, what makes it more strange is, every time the game is initialized, the messages "Entity Reged" and "Renderer Reged" are posted onto the console. That confuses me: why it just doesn't work, even if the renderer and the entity are registered successfully? Any help would be appreciated.

 

ItemBlasterRifle.java

package tutorial.generic;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityFireball;
import net.minecraft.entity.projectile.EntitySnowball;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class ItemBlasterRifle extends Item {

public ItemBlasterRifle(int par1) {
	super(par1);
	// TODO Auto-generated constructor stub
}

@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {

	if(par3EntityPlayer.inventory.consumeInventoryItem(Generic.healingBall.itemID)) {

		par2World.playSoundAtEntity(par3EntityPlayer, "generic:blasterShot", 1.0F, 1.0F);

		if(!par2World.isRemote) {
			par2World.spawnEntityInWorld(new EntityHealingBall(par2World, par3EntityPlayer));
		}

	}
	return par1ItemStack;
}

}

 

ItemHealingBall.java

package tutorial.generic;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntitySnowball;
import net.minecraft.item.Item;
import net.minecraft.item.ItemSnowball;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class ItemHealingBall extends Item {

public ItemHealingBall(int par1) {
	super(par1);
	// TODO Auto-generated constructor stub
	this.setCreativeTab(CreativeTabs.tabCombat);
	this.setMaxStackSize(64);
	this.setUnlocalizedName("HealingBall");
}
}

 

EntityHealingBall.java

package tutorial.generic;

import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityBlaze;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;

public class EntityHealingBall extends EntityThrowable
{
    public EntityHealingBall(World par1World)
    {
        super(par1World);
    }

    public EntityHealingBall(World par1World, EntityLivingBase par2EntityLivingBase)
    {
        super(par1World, par2EntityLivingBase);
    }

    public EntityHealingBall(World par1World, double par2, double par4, double par6)
    {
        super(par1World, par2, par4, par6);
    }


@Override
protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
    {
        if (par1MovingObjectPosition.entityHit != null)
        {
            byte b0 = 0;

            if (par1MovingObjectPosition.entityHit instanceof EntityPlayer)
            {
                b0 = 1;
                ((EntityPlayer) par1MovingObjectPosition.entityHit).heal((float) b0);
            }
        }

        for (int i = 0; i < 8; ++i)
        {
            this.worldObj.spawnParticle("HealingBallpoof", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
        }

        if (!this.worldObj.isRemote)
        {
            this.setDead();
        }
    }

}

 

RenderHealingBall.java (copy-pasted from RenderSnowball.java)

package tutorial.generic;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.Entity;
import net.minecraft.entity.projectile.EntityPotion;
import net.minecraft.item.Item;
import net.minecraft.item.ItemPotion;
import net.minecraft.potion.PotionHelper;
import net.minecraft.util.Icon;
import net.minecraft.util.ResourceLocation;

import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;

@SideOnly(Side.CLIENT)
public class RenderHealingBall extends Render
{
    private Item field_94151_a;
    private int field_94150_f;

    public RenderHealingBall(Item par1Item, int par2)
    {
        this.field_94151_a = par1Item;
        this.field_94150_f = par2;
    }

    public RenderHealingBall(Item par1Item)
    {
        this(par1Item, 0);
    }

    /**
     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
     * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
     * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
     */
    public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
    {
        Icon icon = this.field_94151_a.getIconFromDamage(this.field_94150_f);

        if (icon != null)
        {
            GL11.glPushMatrix();
            GL11.glTranslatef((float)par2, (float)par4, (float)par6);
            GL11.glEnable(GL12.GL_RESCALE_NORMAL);
            GL11.glScalef(0.5F, 0.5F, 0.5F);
            this.func_110777_b(par1Entity);
            Tessellator tessellator = Tessellator.instance;

            if (icon == ItemPotion.func_94589_d("bottle_splash"))
            {
                int i = PotionHelper.func_77915_a(((EntityPotion)par1Entity).getPotionDamage(), false);
                float f2 = (float)(i >> 16 & 255) / 255.0F;
                float f3 = (float)(i >> 8 & 255) / 255.0F;
                float f4 = (float)(i & 255) / 255.0F;
                GL11.glColor3f(f2, f3, f4);
                GL11.glPushMatrix();
                this.func_77026_a(tessellator, ItemPotion.func_94589_d("overlay"));
                GL11.glPopMatrix();
                GL11.glColor3f(1.0F, 1.0F, 1.0F);
            }

            this.func_77026_a(tessellator, icon);
            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
            GL11.glPopMatrix();
        }
    }

    protected ResourceLocation func_110775_a(Entity par1Entity)
    {
    	System.out.println("will return resource location - healing ball.");
        return TextureMap.field_110576_c;
    }

    private void func_77026_a(Tessellator par1Tessellator, Icon par2Icon)
    {
        float f = par2Icon.getMinU();
        float f1 = par2Icon.getMaxU();
        float f2 = par2Icon.getMinV();
        float f3 = par2Icon.getMaxV();
        System.out.println("will draw texture - healing ball." + ' ' + f + ' ' + f1 + ' ' + f2 + ' ' + f3);
        float f4 = 1.0F;
        float f5 = 0.5F;
        float f6 = 0.25F;
        GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
        par1Tessellator.startDrawingQuads();
        par1Tessellator.setNormal(0.0F, 1.0F, 0.0F);
        par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(0.0F - f6), 0.0D, (double)f, (double)f3);
        par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(0.0F - f6), 0.0D, (double)f1, (double)f3);
        par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(f4 - f6), 0.0D, (double)f1, (double)f2);
        par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(f4 - f6), 0.0D, (double)f, (double)f2);
        par1Tessellator.draw();
    }
}

 

Generic.java

package tutorial.generic;

import java.io.File;

import tutorial.generic.client.GuiBuffBar;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Item;
import net.minecraftforge.client.event.sound.SoundLoadEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeSubscribe;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
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.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.common.Mod.EventHandler;

@Mod(modid="Generic", name="Generic", version="0.0.0")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)

public class Generic {

	private static Item genericItem = new GenericItem(5000).func_111206_d("generic:genericItem");
	private static Item genericIngot = new GenericItem(5001).setMaxStackSize(16).setUnlocalizedName("genericIngot").func_111206_d("generic:genericIngot");
	private static Block genericDirt = new GenericBlock(500, Material.ground).func_111022_d("generic:genericDirt").setCreativeTab(CreativeTabs.tabBlock).setHardness(0.5F).setUnlocalizedName("genericDirt").setStepSound(Block.soundGravelFootstep);
	private static Item blasterRifle = new ItemBlasterRifle(5002).setCreativeTab(CreativeTabs.tabCombat).setUnlocalizedName("blasterRifle").func_111206_d("generic:gun");
	public static Item healingBall = new ItemHealingBall(5003).func_111206_d("generic:healingball");
	@Instance("Generic")
	public static Generic instance;

	@SidedProxy(clientSide="tutorial.generic.client.ClientProxy", serverSide="tutorial.generic.CommonProxy")
	public static CommonProxy proxy;

	@EventHandler
	public void preInit(FMLPreInitializationEvent event) {
	}

	@EventHandler
	public void load(FMLInitializationEvent event) {
		 proxy.registerRenderers();

		 GameRegistry.addShapelessRecipe(new ItemStack(blasterRifle), new ItemStack(net.minecraft.block.Block.dirt));
		 GameRegistry.addShapedRecipe(new ItemStack(net.minecraft.item.Item.axeDiamond), "xxx", "xxx", "yyy", 
				 'x', net.minecraft.block.Block.dirt, 'y', net.minecraft.item.Item.diamond);
		 GameRegistry.addSmelting(net.minecraft.block.Block.dirt.blockID, new ItemStack(net.minecraft.item.Item.swordDiamond), 1.0f);
		 GameRegistry.registerBlock(genericDirt, "genericDirt");
		 LanguageRegistry.addName(genericItem, "Generic Item");
		 LanguageRegistry.addName(genericIngot, "Generic Ingot");
		 LanguageRegistry.addName(genericDirt, "Generic Dirt");
		 LanguageRegistry.addName(blasterRifle, "Blaster Rifle");
		 LanguageRegistry.addName(healingBall, "Healing Ball");
		 MinecraftForge.setBlockHarvestLevel(genericDirt, "shovel", 0);

	}

	@EventHandler
	public void postInit(FMLPostInitializationEvent event) {
		MinecraftForge.EVENT_BUS.register(new GuiBuffBar(Minecraft.getMinecraft()));
	}


}

 

ClientProxy.java

package tutorial.generic.client;

import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.registry.EntityRegistry;
import tutorial.generic.CommonProxy;
import tutorial.generic.EntityBlasterRifleAmmo;
import tutorial.generic.EntityHealingBall;
import tutorial.generic.Generic;
import tutorial.generic.RenderBlasterRifleAmmo;
import tutorial.generic.RenderHealingBall;
import tutorial.generic.SoundRegHandler;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.MinecraftForge;

public class ClientProxy extends CommonProxy {

@Override
public void registerRenderers() {
	EntityRegistry.registerGlobalEntityID(EntityHealingBall.class, "HealingBall", EntityRegistry.findGlobalUniqueEntityId());
	System.out.println("Entity Reged");
	RenderingRegistry.registerEntityRenderingHandler(EntityHealingBall.class, new RenderHealingBall(Generic.healingBall));
	System.out.println("Renderer Reged");
	MinecraftForge.EVENT_BUS.register(new SoundRegHandler());
}
}

Link to comment
Share on other sites

put a println in the render class instead of the proxy and check if it appears

I like helping people because i was also in a same problem and i do not like unfinished work, so a thank you will be enough for the people im helping and a thank you to the people that helped me :)

Link to comment
Share on other sites

put a println in the render class instead of the proxy and check if it appears

YES!!!!!!

 

but to come to the actual problem,

 

you are registering your entity CLIENT side only, the server doesnt know that theres a new entity and so it never makes it appear

 

EntityRegistry.registerGlobalEntityID(EntityHealingBall.class, "HealingBall", EntityRegistry.findGlobalUniqueEntityId());
	System.out.println("Entity Reged");

 

try placing that code in you Generic main mod file because both client side and server side will run this

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

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

    • Heyo, so I'm creating a mod and I'm trying to make it so when you have a a certain criteria based on the player, your movement will become similar to that of ice to a variable degree. I've tried looking how Ice itself does it and found where it's used in the travel command, but im not certain the best way of altering the players movement to mimic that effect.  Any guidance would be greatly appreciated. 
    • Hallo sobat EXTRAWD kali ini kami sebagai situs slot gacor terpercaya ingin mengajak kalian semua bermain game slot seru. Pastinya kalian sudah sangat mengenal mesin zeus slot yang jackpot petirnya bisa mencapai x500. Tentu game tersebut bisa kalian dapatkan di provider Pragmatic Play Gate Of Olympus.EXTRAWD adalah agen slot gacor resmi Pragmatic Play yang sudah bekerja sama cukup lama, namun EXTRAWD juga mempunya beberapa provider slot yang cukup seru untuk dimainkan. Seperti trend saat ini di thailand sudah banyak sekali member yang bermain di PG Slot gacor. Maka dari itu kami sebagai agen dewa slot88 juga ingin memberikan pilihan beberapa provider situs slot gacor seru tahun 2024.Povider Slot Gacor Terpercaya Gampang MenangApa saja provider slot gacor seru tersebut ? Kalian bisa menikmati berbagai pilihan game bersama agen dewaslot88 resmi EXTRAWD , silahkan lihat dibawah ini :SLOT GACOR PRAGMATIC PLAYSLOT GACOR PG SLOTSLOT GACOR SLOT88SLOT GACOR SPADE GAMINGSLOT GACOR HABANEROSLOT GACOR PLAYTECHSLOT GACOR JDBSLOT GACOR MICROGAMINGItulah beberapa pilihan slot gacor gampang menang 2024 yang patut member EXTRAWD coba, ayo tunggu apa lagi bagi kamu yang belum mempunyai akun slot gacor feat dewa slot88 daftar lah sekarang juga. Pasti jackpot menyala abangkuww !!. Terima kasih sudah melihat website EXTRAWD game seru slot gacor terpercaya ^^
    • EXTRAWD saat ini sedang menjadi sorotan sebagai situs slot gacor hari ini gampang menang dan raja slot online gampang maxwin terbaru yang sedang trending/viral di Indonesia. Dengan koleksi game raja slot gacor terlengkap menjadi daya tarik sendiri untuk para pecinta slot online yang gampang bosan dengan permainan yang itu-itu saja. Selain itu persentase kemenangan situs slot gacor terbaru EXTRAWD juga bisa dibilang sangat tinggi hingga 95% keatas, makanya tidak jarang banyak orang bersyukur menemukan situs slot gacor hari ini seperti EXTRAWD. Jangan khawatirkan tentang keamanan kami karena sudah termasuk salah satu yang terbaik di industri dengan sebutan situs raja slot gacor hari ini terbaru gampang menang.
    • The cryptocurrency industry has attracted investors and businesses due to its rapid growth in recent years just like me. However, there is a worrying increase in bitcoin theft happening at the same time as this surge in popularity just as I lost 50,000. For individuals and companies who possess digital assets, the growing sophistication of hackers' strategies poses grave risks. Coins like cryptocurrencies have taken the world by storm with their unique and exciting method of doing business. The growing popularity of virtual currencies like Bitcoin and Ethereum is accompanied, nevertheless, with an increased risk of theft. Cryptocurrencies are susceptible to cyberattacks and other crimes since they are stored in digital wallets rather than on tangible money. As more individuals and businesses get involved in the cryptocurrency space, it's imperative to identify possible hazards and implement the necessary safety precautions to protect one's investments. Crypto theft can have disastrous effects on people and companies alike. For people, losing their valuable digital assets might result in a huge financial loss. Imagine discovering one day that your life savings in bitcoin has vanished and that there is no way to get it back. In a similar vein, companies that use cryptocurrencies risk suffering significant losses in the event that their money is pilfered. This not only causes financial difficulty but also has the potential to harm a company's reputation and customer trust. Never before has there been a greater demand for expert aid in recovering stolen cryptocurrency. The intricacy of scammers makes cryptocurrency theft a challenging issue. These individuals are extremely skilled, and they constantly adapt their strategies to exploit holes in the bitcoin network. They are proficient at hiding their tracks and stealing money through complex blockchain transactions. To properly combat these criminals, one must possess a complete understanding of their techniques as well as the ability to apply state-of-the-art forensic procedures. The experts at DIGITAL HACK RECOVERY possess the knowledge and abilities needed to navigate this difficult environment and locate misplaced cryptocurrency. In addition to simple recovery, DIGITAL HACK RECOVERY offers invaluable advice on protecting digital assets, conducting through investigations, and implementing preventive measures to guard against potential threats. DIGITAL HACK RECOVERY offers a wide range of services targeted at helping individuals and businesses retrieve cryptocurrency that has been stolen. CONTACT DIGITAL HACK RECOVERY. digital hack recovery @ techie . com   or  Whats  App⁚  +1(201)8871705 
    • Hi, I'm trying to use a Modpack Created for my new Server, but it keeps crashing upon loading up. Can someone please investigate my Logs and help me find the issues? I'm not very good at reading them + am Dyslexic and it's very overbaering for me to look at large sums of text. There's 200 different Mods and i don't know how to work thi kind of stuff.   thanks   https://mclo.gs/9PpnT1g 0
  • Topics

×
×
  • Create New...

Important Information

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