Jump to content

1.7.10 Throwable Entity is not rendering upon being thrown


Recommended Posts

Posted

Entity Class

 

 

package com.kitsu.medievalcraft.entity;

 

import com.kitsu.medievalcraft.item.ModItems;

 

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.entity.Entity;

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.entity.item.EntityItem;

import net.minecraft.entity.monster.EntityBlaze;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.entity.projectile.EntityThrowable;

import net.minecraft.item.ItemStack;

import net.minecraft.potion.Potion;

import net.minecraft.potion.PotionEffect;

import net.minecraft.util.DamageSource;

import net.minecraft.util.MovingObjectPosition;

import net.minecraft.world.World;

 

public class EntityShit extends EntityThrowable {

 

 

 

public EntityShit(World world)

    {

        super(world);

    }

 

    public EntityShit(World world, EntityLivingBase entity)

    {

        super(world, entity);

    }

   

    @SideOnly(Side.CLIENT)

    public EntityShit(World world, double x, double y, double z)

    {

        super(world, x, y, z);

    }

 

 

   

@Override

protected void onImpact(MovingObjectPosition object) {

 

if (object.entityHit != null) {

 

float impactDamage = 1.0F;

 

 

 

object.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), impactDamage);

}

 

 

        if (!this.worldObj.isRemote)

        {

            this.setDead();

            this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, new ItemStack(ModItems.itemShit)));

        }

 

}

 

@Override

    public void onUpdate()

    {

        super.onUpdate();

    }

 

}

 

 

 

Item Class

 

package com.kitsu.medievalcraft.item;

 

import com.kitsu.medievalcraft.CustomTab;

import com.kitsu.medievalcraft.Main;

import com.kitsu.medievalcraft.entity.EntityShit;

 

import cpw.mods.fml.common.registry.GameRegistry;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.entity.projectile.EntitySnowball;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.world.World;

 

public class ItemShit extends Item {

 

private String name = "itemShit";

 

public ItemShit() {

 

setUnlocalizedName("itemShit");

setCreativeTab(CustomTab.MedievalCraftTab);

setTextureName(Main.MODID + ":itemShit");

GameRegistry.registerItem(this, name);

 

}

 

  public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)

    {

 

            --stack.stackSize;

 

 

      world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

 

        if (!world.isRemote)

        {

            world.spawnEntityInWorld(new EntityShit(world, player));

        }

 

        return stack;

    }

 

}

 

 

 

Entity Registry in Main

 

 

        public void preInit(FMLPreInitializationEvent e) {

                this.proxy.preInit(e);

                CustomTab.MedievalTab();

                EntityRegistry.registerModEntity(EntityShit.class, "itemShit", 1, this, 64, 10, true);

        ModItems.init();

        ModBlocks.init();

        ModCrafting.init();

               

        }

 

 

Everything about the Item works except i get a white cube while the item is being thrown. While in the players inventory and while on the ground it renders as the item.

 

Thanks in advance

Posted

You'll need a Renderer for your Entity.

 

I have this in my Common Proxy class as well

 

public class CommonProxy {

 

    public void registerRenderer() {

    RenderingRegistry.registerEntityRenderingHandler(EntityShit.class, new RenderSnowball(ModItems.itemShit));

    }

 

not sure if thats right.  Are you saying I need a rendering class?

Posted

Post your entire main class. It doesn't look like you are registering the renderer.

 

You were right, I uncommented the register renderer and added this.proxy.registerRenderer(); to my main and now its working.

 

Thank You all very much =)

Posted

Also you should register Renderers in the ClientProxy...

If you don't have this, your mod will crash on a Dedicated Server...

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

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.