Jump to content

Recommended Posts

Posted

So, I have been working on a mod that adds in a new mob. The new mob is called "Dark Knight" I have gotten the texture working, and the model renders, but I can't seem to get the item and armor to render, I have looked everywhere but nothing has helped me. I don't know where to start at all. Any help would be appriciated!

 

My mob class:

 

package DarkKnight.Entitys;

import net.minecraftforge.common.DungeonHooks;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.World;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.DamageSource;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Item;
import net.minecraft.init.Items;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIOpenDoor;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAIArrowAttack;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.IRangedAttackMob;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.Entity;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.model.ModelBase;

import java.util.Random;

import cpw.mods.fml.relauncher.SideOnly;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.client.registry.RenderingRegistry;

@SuppressWarnings("unchecked")
public class DarkKnight {
	
	public static int mobid = 0;
	public Object instance;
	
	public void load() {
	}

	public void generateNether(World world, Random random, int chunkX, int chunkZ) {
	}

	public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
	}

	public int addFuel(ItemStack fuel) {
		return 0;
	}

	@SideOnly(Side.CLIENT)
	public void registerRenderers() {
		RenderingRegistry.registerEntityRenderingHandler(DarkKnight.EntitydarkKnight.class, new RenderLiving(
				new DarkKnight.ModelDarkKnight(), 0) {
			protected ResourceLocation getEntityTexture(Entity par1Entity) {
				return new ResourceLocation("darkknights:/textures/entity/darkknight.png");
			}
		});
		RenderingRegistry.registerEntityRenderingHandler(EntityArrowCustom.class, new RenderSnowball(new ItemStack(Items.arrow).getItem()));

	}

	public void serverLoad(FMLServerStartingEvent event) {
	}

	public void preInit(FMLPreInitializationEvent event) {
		int entityID = EntityRegistry.findGlobalUniqueEntityId();
		mobid = entityID;
		EntityRegistry.registerGlobalEntityID(DarkKnight.EntitydarkKnight.class, "darkKnight", entityID);
		EntityRegistry.registerModEntity(DarkKnight.EntitydarkKnight.class, "darkKnight", entityID, instance, 64, 1, true);
		EntityList.entityEggs.put(Integer.valueOf(entityID), new EntityList.EntityEggInfo(entityID, (0 << 16) + (0 << 8) + 0, (0 << 16) + (0 << 8)
				+ 0));
		EntityRegistry.addSpawn(DarkKnight.EntitydarkKnight.class, 8, 1, 3, EnumCreatureType.monster);
		
		DungeonHooks.addDungeonMob("darkKnight", 180);

		int entityID2 = EntityRegistry.findGlobalUniqueEntityId();
		EntityRegistry.registerModEntity(EntityArrowCustom.class, "entityBulletdarkKnight", entityID2, instance, 64, 1, true);

	}

	public static class EntityArrowCustom extends EntityArrow {
		public EntityArrowCustom(World a) {
			super(a);
		}

		public EntityArrowCustom(World worldIn, EntityLivingBase shooter, float c) {
			super(worldIn, shooter, c);
		}
	}

	public static class EntitydarkKnight extends EntityMob {
		World world = null;
		private int attackTimer;

		public EntitydarkKnight(World var1) {
			super(var1);
			world = var1;
			experienceValue = 15;
			this.isImmuneToFire = false;
			this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.0D, false));
			this.tasks.addTask(0, new EntityAISwimming(this));
			this.tasks.addTask(6, new EntityAIWander(this, 1.0D));
			this.tasks.addTask(8, new EntityAILookIdle(this));
			this.tasks.addTask(1, new EntityAIWander(this, 0.8D));
			this.tasks.addTask(1, new EntityAISwimming(this));
			this.tasks.addTask(1, new EntityAIOpenDoor(this, true));
			this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 2, true));
			this.targetTasks.addTask(2, new EntityAIHurtByTarget(this, false));
			this.tasks.addTask(1, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
			this.setCurrentItemOrArmor(0, new ItemStack(Items.diamond_sword));
			this.setCurrentItemOrArmor(4, new ItemStack(Items.diamond_helmet));
			this.setCurrentItemOrArmor(3, new ItemStack(Items.diamond_chestplate));
			this.setCurrentItemOrArmor(2, new ItemStack(Items.diamond_leggings));
			this.setCurrentItemOrArmor(1, new ItemStack(Items.diamond_boots));
		}
		
		protected void applyEntityAttributes() {
			super.applyEntityAttributes();
			this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.2D);
			this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(30D);
			if (this.getEntityAttribute(SharedMonsterAttributes.attackDamage) != null)
				this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(4D);
		}
		protected void dropRareDrop(int par1) {
			this.dropItem(Items.iron_ingot, 2);
		}
		public boolean isAIEnabled() {
			return true;
		}

		@Override
		protected Item getDropItem() {
			return new ItemStack(Items.enchanted_book).getItem();
		}

		/**
		 * Returns the sound this mob makes while it's alive.
		 */
		protected String getLivingSound() {
			return "";
		}

		/**
		 * Returns the sound this mob makes when it is hurt.
		 */
		protected String getHurtSound() {
			return "";
		}

		/**
		 * Returns the sound this mob makes on death.
		 */
		protected String getDeathSound() {
			return "";
		}

		public void onStruckByLightning(EntityLightningBolt entityLightningBolt) {
			super.onStruckByLightning(entityLightningBolt);
			int i = (int) this.posX;
			int j = (int) this.posY;
			int k = (int) this.posZ;
			Entity entity = this;

		}

		protected void fall(float l) {
			super.fall(l);
			int i = (int) this.posX;
			int j = (int) this.posY;
			int k = (int) this.posZ;
			super.fall(l);
			Entity entity = this;

		}

		public void onDeath(DamageSource dsource) {
			super.onDeath(dsource);
			int i = (int) this.posX;
			int j = (int) this.posY;
			int k = (int) this.posZ;
			Entity entity = this;

		}

		public void onKillEntity(EntityLiving entityLiving) {
			super.onKillEntity(entityLiving);
			int i = (int) this.posX;
			int j = (int) this.posY;
			int k = (int) this.posZ;
			Entity entity = this;

		}

		public boolean interact(EntityPlayer entity) {
			super.interact(entity);
			int i = (int) this.posX;
			int j = (int) this.posY;
			int k = (int) this.posZ;

			return true;
		}
		
		public String getEntityName() {
			return "DarkKnight";
		}

	}

	public static class ModelDarkKnight extends ModelBase {
		// fields
		ModelRenderer head;
		ModelRenderer body;
		ModelRenderer rightarm;
		ModelRenderer leftarm;
		ModelRenderer rightleg;
		ModelRenderer leftleg;

		public ModelDarkKnight() {
			textureWidth = 64;
			textureHeight = 32;

			head = new ModelRenderer(this, 0, 0);
			head.addBox(-4F, -8F, -4F, 8, 8, 8);
			head.setRotationPoint(0F, 0F, 0F);
			head.setTextureSize(64, 32);
			head.mirror = true;
			setRotation(head, 0F, 0F, 0F);
			body = new ModelRenderer(this, 16, 16);
			body.addBox(-4F, 0F, -2F, 8, 12, 4);
			body.setRotationPoint(0F, 0F, 0F);
			body.setTextureSize(64, 32);
			body.mirror = true;
			setRotation(body, 0F, 0F, 0F);
			rightarm = new ModelRenderer(this, 40, 16);
			rightarm.addBox(-3F, -2F, -2F, 4, 12, 4);
			rightarm.setRotationPoint(-5F, 2F, 0F);
			rightarm.setTextureSize(64, 32);
			rightarm.mirror = true;
			setRotation(rightarm, 0F, 0F, 0F);
			leftarm = new ModelRenderer(this, 40, 16);
			leftarm.addBox(-1F, -2F, -2F, 4, 12, 4);
			leftarm.setRotationPoint(5F, 2F, 0F);
			leftarm.setTextureSize(64, 32);
			leftarm.mirror = true;
			setRotation(leftarm, 0F, 0F, 0F);
			rightleg = new ModelRenderer(this, 0, 16);
			rightleg.addBox(-2F, 0F, -2F, 4, 12, 4);
			rightleg.setRotationPoint(-2F, 12F, 0F);
			rightleg.setTextureSize(64, 32);
			rightleg.mirror = true;
			setRotation(rightleg, 0F, 0F, 0F);
			leftleg = new ModelRenderer(this, 0, 16);
			leftleg.addBox(-2F, 0F, -2F, 4, 12, 4);
			leftleg.setRotationPoint(2F, 12F, 0F);
			leftleg.setTextureSize(64, 32);
			leftleg.mirror = true;
			setRotation(leftleg, 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);
			head.render(f5);
			body.render(f5);
			rightarm.render(f5);
			leftarm.render(f5);
			rightleg.render(f5);
			leftleg.render(f5);
			this.head.rotateAngleX = f4 / (180F / (float)Math.PI);
			this.head.rotateAngleY = f3 / (180F / (float)Math.PI);
			this.leftleg.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1;
			this.rightleg.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 1.4F * f1;
			this.leftarm.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1;
			this.rightarm.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 1.4F * f1;
		}

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

}

 

I know I need a render class, but I have no idea what code to put in it

 

And please don't say to go look into the vanilla classes, I have and will continue to do it, and that comment is seriously useless in every way.

Posted

1.7.10 is no longer supported on this forum, update if you want help.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
1 minute ago, Big_Bad_E said:

Is there a place I can go for 1.7.10 help?

 

Some people on Minecraft Forum still provide support for 1.7.10.

 

I strongly recommend updating to a modern version of Minecraft, though.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

  • Guest locked this topic
Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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