Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.10] Entity Texture Not Rendering
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 1
averysumner

[1.10] Entity Texture Not Rendering

By averysumner, July 2, 2016 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

averysumner    0

averysumner

averysumner    0

  • Tree Puncher
  • averysumner
  • Members
  • 0
  • 33 posts
Posted July 2, 2016

My Slimeball Entity's texture isn't loading, heres the code:

EntitySlimeball.class:

package com.averysumner.randomstuff;

import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityBlaze;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.datafix.DataFixer;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;

public class EntitySlimeball extends EntityThrowable
{
    public EntitySlimeball(World worldIn)
    {
        super(worldIn);
    }

    public EntitySlimeball(World worldIn, EntityLivingBase throwerIn)
    {
        super(worldIn, throwerIn);
    }

    public EntitySlimeball(World worldIn, double x, double y, double z)
    {
        super(worldIn, x, y, z);
    }

    public static void func_189662_a(DataFixer p_189662_0_)
    {
        EntityThrowable.func_189661_a(p_189662_0_, "Slimeball");
    }

    /**
     * Called when this EntityThrowable hits a block or entity.
     */
    protected void onImpact(RayTraceResult result)
    {
        if (result.entityHit != null)
        {
            int i = 0;

            if (result.entityHit instanceof EntityBlaze)
            {
                i = 3;
            }

            result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)i);
        }

        for (int j = 0; j < 8; ++j)
        {
            this.worldObj.spawnParticle(EnumParticleTypes.SLIME, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, new int[0]);
        }

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

ModEntities(Rendering and Entity register):

package com.averysumner.randomstuff;

import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.projectile.EntitySnowball;
import net.minecraft.init.Biomes;
import net.minecraft.init.Items;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.registry.EntityRegistry;

public class ModEntities {

public static int id = 0;
public static int index;

public static Entity brownbear;
public static Entity slimeball;

public static void registerEntities()
{
	registerModEntity(EntityBrownBear.class, "brownbear", 0x228717, 0xE2F048);
	registerModProjectile(EntitySlimeball.class, "slimeball");

}

public static void registerRenders() {
	RenderingRegistry.registerEntityRenderingHandler(EntitySlimeball.class, new ProjectileRenderFactory());
}

@SuppressWarnings({ "rawtypes", "unchecked" })
public static void registerModEntity(Class entityClass, String name, int primaryColor, int secondaryColor)
{
        EntityRegistry.registerModEntity(entityClass, name, ++id, RandomStuff.instance, 80, 3, false);
        EntityRegistry.registerEgg(entityClass, primaryColor, secondaryColor);
        EntityRegistry.addSpawn(entityClass, 6, 1, 5, EnumCreatureType.CREATURE, Biomes.FOREST);
        EntityRegistry.addSpawn(entityClass, 6, 1, 5, EnumCreatureType.CREATURE, Biomes.BIRCH_FOREST);
        EntityRegistry.addSpawn(entityClass, 6, 1, 5, EnumCreatureType.CREATURE, Biomes.BIRCH_FOREST_HILLS);
        EntityRegistry.addSpawn(entityClass, 6, 1, 5, EnumCreatureType.CREATURE, Biomes.EXTREME_HILLS);
        EntityRegistry.addSpawn(entityClass, 6, 1, 5, EnumCreatureType.CREATURE, Biomes.EXTREME_HILLS_EDGE);
        EntityRegistry.addSpawn(entityClass, 6, 1, 5, EnumCreatureType.CREATURE, Biomes.EXTREME_HILLS_WITH_TREES);
        EntityRegistry.addSpawn(entityClass, 6, 1, 5, EnumCreatureType.CREATURE, Biomes.FOREST_HILLS);
        EntityRegistry.addSpawn(entityClass, 6, 1, 5, EnumCreatureType.CREATURE, Biomes.MUTATED_BIRCH_FOREST);
        EntityRegistry.addSpawn(entityClass, 6, 1, 5, EnumCreatureType.CREATURE, Biomes.MUTATED_BIRCH_FOREST_HILLS);
        EntityRegistry.addSpawn(entityClass, 6, 1, 5, EnumCreatureType.CREATURE, Biomes.MUTATED_EXTREME_HILLS);
        EntityRegistry.addSpawn(entityClass, 6, 1, 5, EnumCreatureType.CREATURE, Biomes.MUTATED_EXTREME_HILLS_WITH_TREES);
        EntityRegistry.addSpawn(entityClass, 6, 1, 5, EnumCreatureType.CREATURE, Biomes.MUTATED_FOREST);
        EntityRegistry.addSpawn(entityClass, 6, 1, 5, EnumCreatureType.CREATURE, Biomes.MUTATED_PLAINS);
        EntityRegistry.addSpawn(entityClass, 6, 1, 5, EnumCreatureType.CREATURE, Biomes.MUTATED_REDWOOD_TAIGA);
        EntityRegistry.addSpawn(entityClass, 6, 1, 5, EnumCreatureType.CREATURE, Biomes.MUTATED_REDWOOD_TAIGA_HILLS);
        EntityRegistry.addSpawn(entityClass, 6, 1, 5, EnumCreatureType.CREATURE, Biomes.MUTATED_FOREST);
        EntityRegistry.addSpawn(entityClass, 6, 1, 5, EnumCreatureType.CREATURE, Biomes.PLAINS);
        EntityRegistry.addSpawn(entityClass, 6, 1, 5, EnumCreatureType.CREATURE, Biomes.REDWOOD_TAIGA);
        EntityRegistry.addSpawn(entityClass, 6, 1, 5, EnumCreatureType.CREATURE, Biomes.REDWOOD_TAIGA_HILLS);
        EntityRegistry.addSpawn(entityClass, 6, 1, 5, EnumCreatureType.CREATURE, Biomes.ROOFED_FOREST);
        System.out.println("Registering Entity " + name + " with ID " + id);
}

@SuppressWarnings({ "rawtypes", "unchecked"})
public static void registerModProjectile(Class entityClass, String name){
	EntityRegistry.registerModEntity(entityClass, name, id, RandomStuff.instance, 64, 10, true);
        System.out.println("Registering Projectile " + name + " with ID " + id);
}
}

RenderProjectile:

package com.averysumner.randomstuff;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderItem;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.Entity;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class RenderProjectile extends Render {

    private final RenderItem ri;

    public RenderProjectile(RenderManager rm) {
        super(rm);
        this.ri = Minecraft.getMinecraft().getRenderItem();
    }

    @Override
    protected ResourceLocation getEntityTexture(Entity entity) {
        return new ResourceLocation("minecraft:items/slimeball");
    }

    @Override
    public void doRender(Entity entity, double x, double y, double z, float f, float partialTicks) {
        GlStateManager.pushMatrix();
        GlStateManager.translate((float) x, (float) y, (float) z);
        GlStateManager.enableRescaleNormal();
        GlStateManager.scale(0.5F, 0.5F, 0.5F);//TODO: Possibly change scale
        GlStateManager.rotate(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
        GlStateManager.rotate(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
        this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
        this.ri.renderItem(new ItemStack(Items.SLIME_BALL), ItemCameraTransforms.TransformType.GROUND);
        GlStateManager.disableRescaleNormal();
        GlStateManager.popMatrix();
        super.doRender(entity, x, y, z, f, partialTicks);
    }

ProjectileRenderFactory:

package com.averysumner.randomstuff;

import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.client.registry.IRenderFactory;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class ProjectileRenderFactory implements IRenderFactory<EntitySlimeball> {
    @Override
    public Render<? super EntitySlimeball> createRenderFor(RenderManager manager) {
        return new RenderProjectile(manager);
    }
}

ThrowableSlimeball (What spawns the entity):

package com.averysumner.randomstuff;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntitySnowball;
import net.minecraft.init.Items;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.world.World;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class ThrowableSlimeball extends Item {

@SubscribeEvent
public void playerRightClickSlime(PlayerInteractEvent.RightClickItem e){
	if (e.getEntityPlayer().getHeldItemMainhand().getItem() == Items.SLIME_BALL) {
        ItemStack playerHeld = e.getEntityPlayer().getHeldItemMainhand();
        
		System.out.println("Slime right clicked!");
		if (!e.getEntityPlayer().capabilities.isCreativeMode)
        {
            --e.getEntityPlayer().getHeldItemMainhand().stackSize;
        }
        
		if (e.getEntityPlayer().getHeldItemMainhand().stackSize == 0) {
			playerHeld = null;
			ForgeEventFactory.onPlayerDestroyItem(e.getEntityPlayer(), e.getEntityPlayer().getHeldItemMainhand(), e.getEntityPlayer().getActiveHand());
		}

		e.getWorld().playSound((EntityPlayer)null, e.getEntityPlayer().posX, e.getEntityPlayer().posY, e.getEntityPlayer().posZ, SoundEvents.ENTITY_SLIME_SQUISH, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!e.getWorld().isRemote)
        {
            EntitySlimeball entityslimeball = new EntitySlimeball(e.getWorld(), e.getEntityPlayer());
            entityslimeball.setHeadingFromThrower(e.getEntityPlayer(), e.getEntityPlayer().rotationPitch, e.getEntityPlayer().rotationYaw, 0.0F, 1.5F, 1.0F);
            e.getWorld().spawnEntityInWorld(entityslimeball);
        }
        e.setCanceled(true);
	}

}
}

  • Quote

There are 10 types of people in this world. Those who know binary and those who don't.

Share this post


Link to post
Share on other sites

The_Fireplace    11

The_Fireplace

The_Fireplace    11

  • Creeper Killer
  • The_Fireplace
  • Forge Modder
  • 11
  • 241 posts
Posted July 2, 2016

When is registerRenders() being called?

It sounds to me like it is being called during FMLInitializationEvent; it needs to be called in FMLPreInitializationEvent.

  • Quote

If I helped please press the Thank You button.

 

Check out my mods at http://www.curse.com/users/The_Fireplace/projects

Share this post


Link to post
Share on other sites

averysumner    0

averysumner

averysumner    0

  • Tree Puncher
  • averysumner
  • Members
  • 0
  • 33 posts
Posted July 2, 2016

It is called in PreInit:

package com.averysumner.randomstuff;

import net.minecraft.util.datafix.DataFixer;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

public class ClientProxy extends CommonProxy {

    @Override
    public void preInit(FMLPreInitializationEvent e) {
        super.preInit(e);
        ModItems.init();
        ModEntities.registerEntities();
        ModEntities.registerRenders();
    }

    @Override
    public void init(FMLInitializationEvent e) {
    	super.init(e);
    }

    @Override
    public void postInit(FMLPostInitializationEvent e) {
        super.postInit(e);
    }
}

  • Quote

There are 10 types of people in this world. Those who know binary and those who don't.

Share this post


Link to post
Share on other sites

The_Fireplace    11

The_Fireplace

The_Fireplace    11

  • Creeper Killer
  • The_Fireplace
  • Forge Modder
  • 11
  • 241 posts
Posted July 2, 2016

Well, I'm out of ideas; I don't see any reason for this to not work. Are there any errors that show up in the log related to texture loading?

  • Quote

If I helped please press the Thank You button.

 

Check out my mods at http://www.curse.com/users/The_Fireplace/projects

Share this post


Link to post
Share on other sites

Abastro    123

Abastro

Abastro    123

  • World Shaper
  • Abastro
  • Forge Modder
  • 123
  • 1075 posts
Posted July 2, 2016

What do you mean by 'not loading'?

If it is simply not rendered, then it is obviously problem with your rendering.

Or do you mean you got the MISSING_TEXTURE? Then it gets interesting.

  • Quote

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • cadbane86140
      Minecraft: Cereal UHC Season 2 Episode 5- THE FINALE!

      By cadbane86140 · Posted 2 hours ago

      Hello There! A bit of a late upload due to technical issues but ITS UP! So after a week of Cereal UHC we have finally reached the end of it! I am so thankful to be apart of this series and I can't wait for the next season! There are so many hilarious moments especially during the final battle! I hope you all enjoyed this series and if you did don't forget to like and sub for more!  
    • samjviana
      [1.16.5] How to make EnchantedBook go to Custom ItemGroup

      By samjviana · Posted 2 hours ago

      But how can i do that for an enchantment book, for normal items i was able to do that by calling the function "group" as you said, but with the enchantment seems to be different.
    • poopoodice
      [1.16.5] How to make EnchantedBook go to Custom ItemGroup

      By poopoodice · Posted 3 hours ago

      Just create an instance of ItemGroup, and set the group of the item in the item property builder.
    • poopoodice
      Trying to make a crop have an "X" shape model

      By poopoodice · Posted 3 hours ago

      Check the parent of their block model.
    • LexManos
      Forge says this file does not have an app associated with it.

      By LexManos · Posted 4 hours ago

      Some zip managers like to take control of the .jar file extension away from Java. Make sure you have Java installed and try running Jarfix once, then try the installer again.
  • Topics

    • cadbane86140
      0
      Minecraft: Cereal UHC Season 2 Episode 5- THE FINALE!

      By cadbane86140
      Started 2 hours ago

    • samjviana
      2
      [1.16.5] How to make EnchantedBook go to Custom ItemGroup

      By samjviana
      Started 6 hours ago

    • TheMajorN
      1
      Trying to make a crop have an "X" shape model

      By TheMajorN
      Started 5 hours ago

    • ESCCarp
      3
      Forge says this file does not have an app associated with it.

      By ESCCarp
      Started 8 hours ago

    • hammy3502
      0
      [1.16.4] Fluid Flowing Very Oddly

      By hammy3502
      Started 4 hours ago

  • Who's Online (See full list)

    • brok4d
    • hammy3502
    • Swordstriker113
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.10] Entity Texture Not Rendering
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community