Hello. I need some help with rendering my EntityThrowable. I have tried my best, but with no luck :(. I have searched for countless posts, followed them, but still no render. I do know that it is spawning in the correct place, it just isn't rendering the texture.
/**
* Called when this EntityThrowable hits a block or entity.
*/
@Override
protected void onImpact(MovingObjectPosition dirt_ball)
{
if (dirt_ball.entityHit != null)
{
byte b0 = 3;
for (int i = 0; i < 8; ++i)
{
this.worldObj.spawnParticle(EnumParticleTypes.BLOCK_DUST, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, new int[0]);
}
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
if (!playerIn.capabilities.isCreativeMode)
{
--itemStackIn.stackSize;
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) {
tooltip.add("A ball of dirt. Can be used to hurt things.");
}
You could use the RenderSnowball class. This will render your entity like the snowball renderer does. If you want a model, you should do this with tesselator and lwjgl.
You could use the RenderSnowball class. This will render your entity like the snowball renderer does. If you want a model, you sould do this with tesselator and lwjgl.
Tesselator can cause performance issues if you don't know know what you are doing, So i would recommend sticking with vanilla box model class for rendering.
Thanks for the help! It's rendering now. Well... as a white cube. But i'll fix that later, no big problem! Spyeedy's suggestion fixed it. Thanks for the help, everyone!
Hello. I need some help with rendering my EntityThrowable. I have tried my best, but with no luck :(. I have searched for countless posts, followed them, but still no render. I do know that it is spawning in the correct place, it just isn't rendering the texture.
Main:
package com.TheRobloxDevYT.HardMod;
import java.util.Random;
import com.TheRobloxDevYT.HardMod.Recipes.RecipeRemover;
import com.TheRobloxDevYT.HardMod.init.MyBlocks;
import com.TheRobloxDevYT.HardMod.init.MyItems;
import com.TheRobloxDevYT.HardMod.init.entity.EntityDirtball;
import com.TheRobloxDevYT.HardMod.init.entity.RenderDirtball;
import com.TheRobloxDevYT.HardMod.init.generators.FlintGenerator;
import com.TheRobloxDevYT.HardMod.proxy.CommonProxy;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.OreDictionary;
@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION)
public class Main {
@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
public static CommonProxy proxy;
public static final HardModeTab tabHardMode = new HardModeTab("tabHardMode");
@EventHandler
public void preInit(FMLPreInitializationEvent event){
MyItems.init();
MyItems.register();
MyBlocks.init();
MyBlocks.register();
}
@EventHandler
public void Init(FMLInitializationEvent event){
Random ranFlint = new Random(4);
proxy.registerRenders();
RecipeRemover.removeRecipe(Blocks.crafting_table);
RecipeRemover.removeRecipe(Blocks.planks);
GameRegistry.addRecipe(new ItemStack(Blocks.crafting_table), new Object[]{"XF ", "FF ", " ", 'X', Blocks.planks, 'F', Items.flint});
GameRegistry.addRecipe(new ItemStack(MyItems.hay_bundle), new Object[]{"FF ", "FF ", " ",'F', MyItems.hay});
GameRegistry.addRecipe(new ItemStack(MyItems.bush_stick), new Object[]{"F ", "F ", " ",'F', MyItems.hay});
GameRegistry.addRecipe(new ItemStack(Blocks.hay_block), new Object[]{"FFF", "FFF", "FFF",'F', MyItems.hay_bundle});
GameRegistry.addRecipe(new ItemStack(MyItems.plank), new Object[]{"FL ", "FF ", " ", 'F', MyItems.bush_stick, 'L', MyItems.hay});
GameRegistry.addRecipe(new ItemStack(MyItems.flint_axe), new Object[]{"FH ", "S ", " ", 'F', Items.flint, 'H', MyItems.hay, 'S', MyItems.bush_stick});
GameRegistry.addRecipe(new ItemStack(MyItems.flint_saw), new Object[]{"SF ", "H ", " ", 'F', Items.flint, 'H', MyItems.hay, 'S', MyItems.bush_stick});
GameRegistry.addRecipe(new ItemStack(MyItems.flint_saw), new Object[]{"DDD", "DDD", "DDD", 'F', Items.flint, 'D', Item.getItemFromBlock(Blocks.dirt)});
GameRegistry.addShapelessRecipe(new ItemStack(MyItems.stone, 9), new ItemStack(Items.flint), new ItemStack(Blocks.cobblestone));
GameRegistry.addShapelessRecipe(new ItemStack(Item.getItemFromBlock(Blocks.planks), 2, OreDictionary.WILDCARD_VALUE), new ItemStack(MyItems.flint_saw), new ItemStack(Blocks.log, 1, OreDictionary.WILDCARD_VALUE));
GameRegistry.addShapelessRecipe(new ItemStack((MyItems.dirt_ball), 9), new ItemStack(Item.getItemFromBlock(Blocks.dirt)));
GameRegistry.addShapelessRecipe(new ItemStack((Items.flint), 2), new ItemStack(Item.getItemFromBlock(Blocks.gravel)));
Blocks.log.setHardness(10);
GameRegistry.registerWorldGenerator(new FlintGenerator(), 0);
EntityRegistry.registerModEntity(EntityDirtball.class, "DirtBall", 0, Reference.MOD_ID, 64, 10, true);
}
@EventHandler
public void postInit(FMLPostInitializationEvent event){
}
}
EntityDirtball:
package com.TheRobloxDevYT.HardMod.init.entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityBlaze;
import net.minecraft.entity.projectile.EntitySnowball;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public class EntityDirtball extends EntityThrowable{
public EntityDirtball(World worldIn, EntityLivingBase throwerIn) {
super(worldIn, throwerIn);
}
@Override
protected float getVelocity() {
return 2.0F;
}
/**
* Called when this EntityThrowable hits a block or entity.
*/
@Override
protected void onImpact(MovingObjectPosition dirt_ball)
{
if (dirt_ball.entityHit != null)
{
byte b0 = 3;
dirt_ball.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)b0);
}
for (int i = 0; i < 8; ++i)
{
this.worldObj.spawnParticle(EnumParticleTypes.BLOCK_DUST, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, new int[0]);
}
if (!this.worldObj.isRemote)
{
this.setDead();
}
}
}
ClientProxy:
package com.TheRobloxDevYT.HardMod.proxy;
import com.TheRobloxDevYT.HardMod.Main;
import com.TheRobloxDevYT.HardMod.init.MyBlocks;
import com.TheRobloxDevYT.HardMod.init.MyItems;
import com.TheRobloxDevYT.HardMod.init.entity.EntityDirtball;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
public class ClientProxy extends CommonProxy{
@Override
public void registerRenders() {
MyBlocks.registerRenders();
MyItems.registerRenders();
}
public void preInit() {
RenderManager manager = Minecraft.getMinecraft().getRenderManager();
RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
RenderingRegistry.registerEntityRenderingHandler(EntityDirtball.class, new RenderSnowball(manager, MyItems.dirt_ball, itemRender));
}
}
Also, by the way, I am new to creating mods. Thanks for your help.
Where is your entity's spawning code and you need to register your entity
Oh, yes.
Here is the spawning code: (The dirtball Item)
package com.TheRobloxDevYT.HardMod.init.item;
import java.util.List;
import com.TheRobloxDevYT.HardMod.init.entity.EntityDirtball;
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.stats.StatList;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemDirtBall extends Item {
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
if (!playerIn.capabilities.isCreativeMode)
{
--itemStackIn.stackSize;
}
worldIn.playSoundAtEntity(playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!worldIn.isRemote)
{
worldIn.spawnEntityInWorld(new EntityDirtball(worldIn, playerIn));
}
playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
return itemStackIn;
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) {
tooltip.add("A ball of dirt. Can be used to hurt things.");
}
}
Here is where I registered the entity.
MyEntities:
package com.TheRobloxDevYT.HardMod.init;
import com.TheRobloxDevYT.HardMod.init.entity.EntityDirtball;
import net.minecraftforge.fml.common.registry.EntityRegistry;
public class MyEntities {
public void init() {
int modEntityID = 0;
EntityRegistry.registerModEntity(EntityDirtball.class, "Dirt Ball", ++modEntityID, this, 64, 10, true);
}
public static void register() {
}
public static void registerRenders() {
}
public static void registerRender() {
}
}
Your EntityRegistry#registerModEntity should be in the preInit method not init method in your Main class
You could use the RenderSnowball class. This will render your entity like the snowball renderer does. If you want a model, you should do this with tesselator and lwjgl.
Youtube | Website | Twitter
Tesselator can cause performance issues if you don't know know what you are doing, So i would recommend sticking with vanilla box model class for rendering.
Not doing mc modding that much anymore because I am making a full blown game that does not have limitations that mc has. (rip Magiology for now)
I may come back if MC fixes it's rendering pipeline.
Thanks for the help! It's rendering now. Well... as a white cube. But i'll fix that later, no big problem! Spyeedy's suggestion fixed it. Thanks for the help, everyone!
You are welcome!
Not doing mc modding that much anymore because I am making a full blown game that does not have limitations that mc has. (rip Magiology for now)
I may come back if MC fixes it's rendering pipeline.