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
  On 7/21/2017 at 3:22 PM, Big_Bad_E said:

Is there a place I can go for 1.7.10 help?

Expand  

 

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Ignore shrimple, it doesn't work with Oculus. Also, enableShaders was alr true when it said that towards the end of the log. If you could also figure out why my tags are messed up that'd be cool too, but that's a later issue. https://drive.google.com/drive/folders/1ovEKDZECUCl7zZxGfpyQcS4s5PZPQyfa?usp=drive_link
    • accidental duplicate mesage cuz lag
    • https://gnomebot.dev/paste/231527759279685634/1372324909073563730/1372324908629102716 https://gnomebot.dev/paste/231527759279685634/1372320454861262908/1372320454299090996 seems like theres a registry sync error, not sure what that means though, however in an old pack i played on, i actually had a registry sync error happen whenever the world tried too save and it would suddenly stop loading chunks, is there a mod fix for this or some way too bypass registry syncing? is this a server problem? i have no issues with the pack on pc, only on my server.
    • i think the problem is the player animator library but i need it for one of my main mods is there any way i can fix this? The game crashed: rendering overlay Error: java.lang.IllegalArgumentException: Failed to create player model for default heres the crash report: https://pastebin.com/U5Wp8ysb
    • I have been an enthusiastic investor in crypt0currencies for several years, and my digital assets have been integral to my financial strategy. A few months ago, I encountered a distressing predicament when I lost access to my primary cryptocurrency walleet after clicking on an airdrop link that inadvertently connected to my walleet. The dread of potentially losing all my hard-earned funds was overwhelming, leaving me uncertain about where to seek assistance. In my pursuit of solutions, I stumbled upon ChainDigger Retrievers. From our initial consultation to the triumphant recovery of my assets, the team exhibited exceptional expertise. They provided comprehensive explanations of the recovery process, ensuring I was informed at every stage and offering reassurance during this tumultuous time. Their approach was not only meticulous but also compassionate, which significantly alleviated my anxiety. ChainDigger Retrievers unwavering commitment to resolving my issue was evident throughout the process. Leveraging their profound understanding of crypt0currency technology and digital forensics, they initiated an exhaustive investigation to trace the transactions linked to my compromised wallet. Their meticulous analysis and relentless determination were apparent as they left no stone unturned in their quest to recover my funds. After several days of diligent investigation, the team successfully recovered everything I had lost. They uncovered that the link I had clicked contained malware, which scammeers had used to infiltrate my walleet. This revelation was both alarming and enlightening, underscoring the inherent risks associated with crypt0currency transactions when proper precautions are not taken.Thanks to ChainDigger Retrievers, I not only regained everything but also acquired invaluable knowledge about safeguarding my investments. Their expertise and steadfast support transformed a daunting situation into a manageable one, and I am profoundly grateful for their assistance. I can now continue my investment journey with renewed confidence, knowing that I have a trustworthy ally in ChainDigger Retrievers. Their client satisfaction is truly commendable, and I wholeheartedly recommend their services to anyone facing similar challenges in the crypt0currency realm. With their help, I was able to turn a distressing time into a positive outcome, and I will forever be grateful for their support.  
  • Topics

×
×
  • Create New...

Important Information

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