Jump to content

Adding a New Entity - Invisible? Texture Error?


Recommended Posts

So, I'm basically trying to [for starters] make a mod to add a Ball of Yarn that cats will play with. I haven't added any code for the cats to actually play with it, mostly because I can't figure out how to get it to render at all. In fact, I can't even get the icon for the item used to spawn it to render; it returns to the default iron helmet icon. Any help would be much appreciated.




package CatAdditions.common;

import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
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.registry.EntityRegistry;

import net.minecraft.src.Block;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.EntityList;
import net.minecraft.src.EntityEggInfo;

@Mod(modid="CatAdditions", name="CatAdditions", version="Cat Additions rev 1 for MC ver 1.4.2")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class ModCatAdditions
//public static final Block exampleBlock = new BlockExampleBlock(250, 0);
public static final Item yarnBall = new ItemYarnBall(6240);

public static ModCatAdditions instance;

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

public void preInit(FMLPreInitializationEvent event)

public void load(FMLInitializationEvent event)

	//Adding (Item)yarnBall
	LanguageRegistry.addName(yarnBall, "Ball of Yarn");

	//Adding (Entity)yarnBall
	EntityRegistry.registerModEntity(EntityYarnBall.class, "Ball of Yarn", 1, this, 80, 3, true);
	EntityList.IDtoClassMapping.put(300, EntityYarnBall.class);
	EntityList.entityEggs.put(300, new EntityEggInfo(300, 657930, 3394560));
	LanguageRegistry.instance().addStringLocalization("entity.CatAdditions.EntityYarnBall.name", "en_US", "Ball of Yarn");

	//Adding recipes
	ItemStack silkStacked = new ItemStack(Item.silk);
	GameRegistry.addRecipe(new ItemStack(yarnBall, 1),
		" A ", "AAA", " A ",
		'A', silkStacked);

public void postInit(FMLPostInitializationEvent event)





package CatAdditions.common;

import net.minecraft.src.Item;
import net.minecraft.src.CreativeTabs;
import net.minecraft.src.ItemStack;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.World;

public class ItemYarnBall extends Item
public int yarnBallColor = 0;

public ItemYarnBall(int id)

public ItemYarnBall(int par1, int par2)
	yarnBallColor = par2;

public int getColorFromItemStack(ItemStack par1ItemStack, int par2)
	switch (yarnBallColor)
		default: return 16777215;
		case 0: return 2631720;
		case 1: return 12464176;
		case 2: return 4877080;
		case 3: return 9001014;
		case 4: return 5931746;
		case 5: return 10769358;
		case 6: return 3968688;
		case 7: return 13158600;
		case 8: return 8684676;
		case 9: return 14388148;
		case 10: return 7783952;
		case 11: return 14538023;
		case 12: return 9419252;
		case 13: return 13330885;
		case 14: return 15113780;
		case 15: return 16777215;

public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
		par3World.spawnEntityInWorld(new EntityYarnBall(par3World, par4, par5, par6));
		return true;
		return false;

public String getTextureFiles()
	return CommonProxy.ITEMS_PNG;





package CatAdditions.common;

import java.util.ArrayList;

import net.minecraft.src.Entity;
import net.minecraft.src.World;
import net.minecraft.src.AxisAlignedBB;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.DamageSource;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.ItemStack;

public class EntityYarnBall extends Entity
protected String texture = "/CatAdditions/common/images/ModelYarnBall.png";

public EntityYarnBall(World par1World)
	this.preventEntitySpawning = true;
	this.setSize(0.25F, 0.25F);
	this.yOffset = this.height / 2.0F;

public EntityYarnBall(World par1World, double par2, double par3, double par4)
	this.setPosition(par2, (double)(par3 + this.yOffset), par4);
	this.motionX = 0.0D;
	this.motionY = 0.0D;
	this.motionZ = 0.0D;
	this.prevPosX = par2;
	this.prevPosY = par3;
	this.prevPosZ = par4;

public String getTexture()
	return texture;

public boolean canBePushed()
	return true;

public boolean canBeCollidedWith()
	return !this.isDead;

public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)
	if (!this.isDead && !this.worldObj.isRemote)
		EntityPlayer entityPlayer = null;

		if (par1DamageSource.getEntity() instanceof EntityPlayer)
			entityPlayer = (EntityPlayer)par1DamageSource.getEntity();

		if (entityPlayer != null && entityPlayer.capabilities.isCreativeMode)
			return true;


	return true;

public void dropItemStack()
	this.entityDropItem(new ItemStack(ModCatAdditions.yarnBall), 0.0F);

protected void entityInit() {}
protected void readEntityFromNBT(NBTTagCompound par1) {}
protected void writeEntityToNBT(NBTTagCompound par1) {}





package CatAdditions.common;

import net.minecraft.src.Render;
import net.minecraft.src.ModelBase;
import net.minecraft.src.Entity;

public class RenderYarnBall extends Render
private ModelBase modelYarnBall;

public RenderYarnBall(ModelBase modelBase)
	this.shadowSize = 0.5F;
	modelYarnBall = modelBase;

public void doRenderYarnBall(EntityYarnBall par1EntityYarnBall, double par2, double par3, double par4, float par5, float par6)
	modelYarnBall.render(par1EntityYarnBall, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F);

public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
	doRenderYarnBall((EntityYarnBall)par1Entity, par2, par4, par6, par8, par9);





// Date: 11/6/2012 5:24:24 PM
// Template version 1.1
// Java generated by Techne
// Keep in mind that you still need to fill in some blanks
// - ZeuX
package CatAdditions.common;

import net.minecraft.src.ModelBase;
import net.minecraft.src.ModelRenderer;
import net.minecraft.src.Entity;

public class ModelYarnBall extends ModelBase
    ModelRenderer base;
    ModelRenderer front;
    ModelRenderer back;
    ModelRenderer right;
    ModelRenderer left;
    ModelRenderer top;
    ModelRenderer bottom;

public ModelYarnBall()
	textureWidth = 32;
	textureHeight = 16;

	base = new ModelRenderer(this, 0, 0);
	base.addBox(0F, 0F, 0F, 4, 4, 4);
	base.setRotationPoint(-2F, 19F, -2F);
	base.setTextureSize(32, 16);
	base.mirror = true;
	setRotation(base, 0F, 0F, 0F);
	front = new ModelRenderer(this, 16, 0);
	front.addBox(0F, 0F, 0F, 2, 2, 1);
	front.setRotationPoint(-1F, 20F, -3F);
	front.setTextureSize(32, 16);
	front.mirror = true;
	setRotation(front, 0F, 0F, 0F);
	back = new ModelRenderer(this, 16, 0);
	back.addBox(0F, 0F, 0F, 2, 2, 1);
	back.setRotationPoint(-1F, 20F, 2F);
	back.setTextureSize(32, 16);
	back.mirror = true;
	setRotation(back, 0F, 0F, 0F);
	right = new ModelRenderer(this, 16, 3);
	right.addBox(0F, 0F, 0F, 1, 2, 2);
	right.setRotationPoint(-3F, 20F, -1F);
	right.setTextureSize(32, 16);
	right.mirror = true;
	setRotation(right, 0F, 0F, 0F);
	left = new ModelRenderer(this, 16, 3);
	left.addBox(0F, 0F, 0F, 1, 2, 2);
	left.setRotationPoint(2F, 20F, -1F);
	left.setTextureSize(32, 16);
	left.mirror = true;
	setRotation(left, 0F, 0F, 0F);
	top = new ModelRenderer(this, 22, 0);
	top.addBox(0F, 0F, 0F, 2, 1, 2);
	top.setRotationPoint(-1F, 18F, -1F);
	top.setTextureSize(32, 16);
	top.mirror = true;
	setRotation(top, 0F, 0F, 0F);
	bottom = new ModelRenderer(this, 22, 0);
	bottom.addBox(0F, 0F, 0F, 2, 1, 2);
	bottom.setRotationPoint(-1F, 23F, -1F);
	bottom.setTextureSize(32, 16);
	bottom.mirror = true;
	setRotation(bottom, 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);

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);





package CatAdditions.common;

public class CommonProxy
public static String ITEMS_PNG = "/CatAdditions/common/images/items.png";
public static String BLOCK_PNG = "/CatAdditions/common/images/block.png";

public void registerRenderers()





package CatAdditions.common.client;

import net.minecraftforge.client.MinecraftForgeClient;
import cpw.mods.fml.client.registry.RenderingRegistry;

import CatAdditions.common.CommonProxy;
import CatAdditions.common.EntityYarnBall;
import CatAdditions.common.RenderYarnBall;
import CatAdditions.common.ModelYarnBall;

public class ClientProxy extends CommonProxy
public void registerRenderers()
	RenderingRegistry.registerEntityRenderingHandler(EntityYarnBall.class, new RenderYarnBall(new ModelYarnBall()));











The block.png and items.png are just generic testing sheets, I shouldn't have them referenced anywhere.



↑It makes sense if you don't think about it.↑


Creepers only explode because they want to hug you, but when they reach you, they realize they have no arms, and then explode with anger.

Link to comment
Share on other sites

  • 3 weeks later...

In the item.java u add an extra 's' at the method name:


public String getTextureFiles()
  return CommonProxy.ITEMS_PNG;




public String getTextureFile()
  return CommonProxy.ITEMS_PNG;


Also you didn't call the right image files in the commonProxy.java. I'm sure this will fix the "texture not loading" problem... at least for forge 6.3.0 (mc 1.4.4).

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.

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.

  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Okay so we tried both versions and both cant run on her pc for some reason!  
    • Well. Make sure you installed a correct jdk for your forge mdk version. Make sure your JAVA_HOME and %PATH% environment-variables are setup correctly. (If you're on windows)   I downloaded an example forge mdk for my version and extracted the contents to a folder I'm working in Using Eclipse, I opened Eclipse and imported an existing gradle Project (with its root directory in the folder directory which I previously extracted my contents to). Waited for Eclipse to do its thing After it having finished, I ran genEclipseRuns, setupDecompWorkspace and setupDevWorkspace (Gradle Tasks > your mod name here > forgegradle)    If it still didn't work (and you're using Eclipse) run cleanEclipse and, in a command prompt  Also If I recall correctly, someone, somewhere said that the way you setup your workspace changes depending on your Minecraft Version. I did this in 1.8.9.
    • https://mclo.gs/ZlRMU4G Still crash, help 
    • Hi, im having problem with error: Could not resolve dependency: net.minecraftforge:forge:1.20.1:userdev   im new in modding, but i tried everything, and it is still not working. all versions are correct etc.   build gradle: plugins {     id 'eclipse'     id 'idea'     id 'maven-publish'     id 'net.minecraftforge.gradle' version '[6.0,6.2)'     id 'org.parchmentmc.librarian.forgegradle' version '1.+' } version = mod_version group = mod_group_id base {     archivesName = mod_id } // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(17) println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft {     // See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md     // Additional setup is needed to use their mappings: https://parchmentmc.org/docs/getting-started     mappings channel: mapping_channel, version: mapping_version          copyIdeResources = true          runs {         // applies to all the run configs below         configureEach {             workingDirectory project.file('run')             property 'forge.logging.markers', 'REGISTRIES'             // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels             property 'forge.logging.console.level', 'debug'             mods {                 "${mod_id}" {                     source sourceSets.main                 }             }         }         client {             // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.             property 'forge.enabledGameTestNamespaces', mod_id         }         server {             property 'forge.enabledGameTestNamespaces', mod_id             args '--nogui'         }                  gameTestServer {             property 'forge.enabledGameTestNamespaces', mod_id         }         data {             workingDirectory project.file('run-data')                          args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')         }     } } // Include resources generated by data generators. sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { } dependencies {     minecraft "net.minecraftforge:forge:1.20.1" } tasks.named('processResources', ProcessResources).configure {     var replaceProperties = [             minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,             forge_version: forge_version, forge_version_range: forge_version_range,             loader_version_range: loader_version_range,             mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,             mod_authors: mod_authors, mod_description: mod_description,     ]     inputs.properties replaceProperties     filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {         expand replaceProperties + [project: project]     } } // Example for how to get properties into the manifest for reading at runtime. tasks.named('jar', Jar).configure {     manifest {         attributes([                 'Specification-Title'     : mod_id,                 'Specification-Vendor'    : mod_authors,                 'Specification-Version'   : '1', // We are version 1 of ourselves                 'Implementation-Title'    : project.name,                 'Implementation-Version'  : project.jar.archiveVersion,                 'Implementation-Vendor'   : mod_authors,                 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")         ])     }     // This is the preferred method to reobfuscate your jar file     finalizedBy 'reobfJar' } publishing {     publications {         register('mavenJava', MavenPublication) {             artifact jar         }     }     repositories {         maven {             url "file://${project.projectDir}/mcmodsrepo"         }     } } tasks.withType(JavaCompile).configureEach {     options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation }       please help me out
    • Hi, im having same issue, but it is my time creating mode, can you help out and explain more?
  • Topics

  • Create New...

Important Information

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